Add HistoricPage
This commit is contained in:
@@ -6,7 +6,6 @@ using Android.Runtime;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Android.OS;
|
||||
using Acr.UserDialogs;
|
||||
|
||||
namespace PlantBox.Client.Droid
|
||||
{
|
||||
@@ -21,9 +20,6 @@ namespace PlantBox.Client.Droid
|
||||
base.OnCreate(savedInstanceState);
|
||||
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
|
||||
LoadApplication(new App());
|
||||
|
||||
// Acr
|
||||
UserDialogs.Init(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,15 +53,12 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Acr.UserDialogs">
|
||||
<Version>7.0.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Xamarin.Forms" Version="3.4.0.1008975" />
|
||||
<PackageReference Include="Xamarin.Android.Support.Design" Version="27.0.2.1" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.2.1" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.2.1" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="27.0.2.1" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="27.0.2.1" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="3.6.0.344457" />
|
||||
<PackageReference Include="Xamarin.Android.Support.Design" Version="28.0.0.1" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="28.0.0.1" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v4" Version="28.0.0.1" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v7.CardView" Version="28.0.0.1" />
|
||||
<PackageReference Include="Xamarin.Android.Support.v7.MediaRouter" Version="28.0.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainActivity.cs" />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -189,11 +189,8 @@
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Acr.UserDialogs">
|
||||
<Version>7.0.4</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Xamarin.Forms" Version="3.4.0.1008975" />
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.1.5" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="3.6.0.344457" />
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.8" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\PlantBox.Client\PlantBox.Client.csproj">
|
||||
|
||||
@@ -11,5 +11,11 @@
|
||||
<Style TargetType="TableView" >
|
||||
<Setter Property="Margin" Value="{OnPlatform UWP='10, 0'}" />
|
||||
</Style>
|
||||
<Color x:Key="HumidityColor">#2196f3</Color>
|
||||
<Color x:Key="HumidityColorSecondary">#90caf9</Color>
|
||||
<Color x:Key="LuminosityColor">#ffc107</Color>
|
||||
<Color x:Key="LuminosityColorSecondary">#ffe082</Color>
|
||||
<Color x:Key="TemperatureColor">#FF5722</Color>
|
||||
<Color x:Key="TemperatureColorSecondary">#ffab91</Color>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace PlantBox.Client.Extensions
|
||||
{
|
||||
public static class ColorExtensions
|
||||
{
|
||||
public static string GetHexString(this Color color)
|
||||
{
|
||||
var red = (int)(color.R * 255);
|
||||
var green = (int)(color.G * 255);
|
||||
var blue = (int)(color.B * 255);
|
||||
var alpha = (int)(color.A * 255);
|
||||
var hex = $"#{alpha:X2}{red:X2}{green:X2}{blue:X2}";
|
||||
|
||||
return hex;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PlantBox.Client.Extensions
|
||||
{
|
||||
// Source: https://stackoverflow.com/a/14285561
|
||||
public static class TimeSpanExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Multiplies a timespan by an integer value
|
||||
/// </summary>
|
||||
public static TimeSpan Multiply(this TimeSpan multiplicand, int multiplier)
|
||||
{
|
||||
return TimeSpan.FromTicks(multiplicand.Ticks * multiplier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multiplies a timespan by a double value
|
||||
/// </summary>
|
||||
public static TimeSpan Multiply(this TimeSpan multiplicand, double multiplier)
|
||||
{
|
||||
return TimeSpan.FromTicks((long)(multiplicand.Ticks * multiplier));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:extensions="clr-namespace:PlantBox.Client.Extensions"
|
||||
xmlns:forms="clr-namespace:Microcharts.Forms;assembly=Microcharts.Forms"
|
||||
x:Class="PlantBox.Client.Forms.Plant.HistoricPage">
|
||||
<ContentPage.Content>
|
||||
<StackLayout>
|
||||
<Label Text="Welcome to Xamarin.Forms!"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
HorizontalOptions="CenterAndExpand" />
|
||||
<StackLayout Padding="5">
|
||||
<StackLayout Orientation="Horizontal">
|
||||
<Label HorizontalOptions="Start"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
Text="{extensions:Locale Interval}" />
|
||||
<Picker x:Name="Picker"
|
||||
HorizontalOptions="EndAndExpand"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
WidthRequest="200"
|
||||
SelectedItem="{Binding HistoricDuration, Mode=OneWayToSource}"
|
||||
SelectedIndexChanged="Picker_SelectedIndexChanged" />
|
||||
</StackLayout>
|
||||
<ScrollView>
|
||||
<StackLayout x:Name="layout">
|
||||
<BindableLayout.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Frame HorizontalOptions="FillAndExpand"
|
||||
HeightRequest="200"
|
||||
Padding="5">
|
||||
<StackLayout>
|
||||
<Label Text="{Binding Name}" />
|
||||
<forms:ChartView Chart="{Binding Chart}"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand" />
|
||||
</StackLayout>
|
||||
</Frame>
|
||||
</DataTemplate>
|
||||
</BindableLayout.ItemTemplate>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
</StackLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using PlantBox.Client.Models;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -7,14 +9,204 @@ using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
using Microcharts;
|
||||
using Entry = Microcharts.Entry;
|
||||
using PlantBox.Client.Extensions;
|
||||
using PlantBox.Client.ViewModels;
|
||||
|
||||
namespace PlantBox.Client.Forms.Plant
|
||||
{
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
public partial class HistoricPage : ContentPage
|
||||
{
|
||||
public HistoricPage ()
|
||||
private readonly SKColor _humidityColor;
|
||||
private readonly SKColor _humidityColorSecondary;
|
||||
private readonly SKColor _luminosityColor;
|
||||
private readonly SKColor _luminosityColorSecondary;
|
||||
private readonly SKColor _temperatureColor;
|
||||
private readonly SKColor _temperatureColorSecondary;
|
||||
|
||||
public HistoricPage(PlantViewModel viewModel)
|
||||
{
|
||||
InitializeComponent ();
|
||||
}
|
||||
}
|
||||
InitializeComponent();
|
||||
BindingContext = viewModel;
|
||||
|
||||
// Colors
|
||||
_humidityColor = SKColor.Parse(((Color)Application.Current.Resources["HumidityColor"]).GetHexString());
|
||||
_humidityColorSecondary = SKColor.Parse(((Color)Application.Current.Resources["HumidityColorSecondary"]).GetHexString());
|
||||
|
||||
_luminosityColor = SKColor.Parse(((Color)App.Current.Resources["LuminosityColor"]).GetHexString());
|
||||
_luminosityColorSecondary = SKColor.Parse(((Color)Application.Current.Resources["LuminosityColorSecondary"]).GetHexString());
|
||||
|
||||
_temperatureColor = SKColor.Parse(((Color)Application.Current.Resources["TemperatureColor"]).GetHexString());
|
||||
_temperatureColorSecondary = SKColor.Parse(((Color)Application.Current.Resources["TemperatureColorSecondary"]).GetHexString());
|
||||
|
||||
// Picker
|
||||
var durations = new List<Duration>()
|
||||
{
|
||||
new Duration(1, Interval.Hourly),
|
||||
new Duration(1, Interval.Daily),
|
||||
new Duration(2, Interval.Daily),
|
||||
new Duration(1, Interval.Weekly),
|
||||
new Duration(2, Interval.Monthly),
|
||||
new Duration(3, Interval.Monthly),
|
||||
new Duration(6, Interval.Monthly),
|
||||
new Duration(1, Interval.Yearly),
|
||||
new Duration(2, Interval.Yearly),
|
||||
new Duration(3, Interval.Yearly)
|
||||
};
|
||||
|
||||
Picker.ItemsSource = durations;
|
||||
Picker.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void Picker_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
DisplayCharts();
|
||||
}
|
||||
|
||||
private void DisplayCharts()
|
||||
{
|
||||
var charts = new NamedChart[]
|
||||
{
|
||||
new NamedChart(CreateChart(CaptorType.Humidity, _humidityColor, _humidityColorSecondary), "Humidity"),
|
||||
new NamedChart(CreateChart(CaptorType.Luminosity, _luminosityColor, _luminosityColorSecondary), "Luminosity"),
|
||||
new NamedChart(CreateChart(CaptorType.Temperature, _temperatureColor, _temperatureColorSecondary), "Temperature")
|
||||
};
|
||||
|
||||
BindableLayout.SetItemsSource(layout, charts);
|
||||
}
|
||||
|
||||
private Chart CreateChart(CaptorType captorType, SKColor begin, SKColor end)
|
||||
{
|
||||
var chart = new LineChart()
|
||||
{
|
||||
LabelTextSize = 14,
|
||||
Margin = 10,
|
||||
LineAreaAlpha = 50,
|
||||
LineMode = LineMode.Straight
|
||||
};
|
||||
var entries = CreateEntries(captorType, begin, end);
|
||||
|
||||
chart.Entries = entries;
|
||||
return chart;
|
||||
}
|
||||
|
||||
private Entry[] CreateEntries(CaptorType captorType, SKColor begin, SKColor end)
|
||||
{
|
||||
PlantViewModel viewModel = (PlantViewModel)BindingContext;
|
||||
Historic historic = viewModel.Historic;
|
||||
HistoricEntries historicEntries;
|
||||
uint multiplier = viewModel.HistoricDuration.Multiplier;
|
||||
uint count;
|
||||
float step;
|
||||
string labelFormat;
|
||||
string valueSpecifier;
|
||||
|
||||
switch (viewModel.HistoricDuration.Interval)
|
||||
{
|
||||
case Interval.Hourly:
|
||||
historicEntries = historic.MinutelyHistoric;
|
||||
count = 12;
|
||||
step = 2;
|
||||
labelFormat = "HH:mm";
|
||||
break;
|
||||
case Interval.Daily:
|
||||
historicEntries = historic.HourlyHistoric;
|
||||
count = 24;
|
||||
step = 3;
|
||||
labelFormat = "HH:mm";
|
||||
break;
|
||||
case Interval.Weekly:
|
||||
historicEntries = historic.DailyHistoric;
|
||||
count = 7;
|
||||
step = 1;
|
||||
labelFormat = "ddd";
|
||||
break;
|
||||
case Interval.Monthly:
|
||||
historicEntries = historic.DailyHistoric;
|
||||
count = 31;
|
||||
step = 4;
|
||||
labelFormat = "dd/MM";
|
||||
break;
|
||||
case Interval.Yearly:
|
||||
historicEntries = historic.MonthlyHistoric;
|
||||
count = 12;
|
||||
step = multiplier == 1 ? 1 : 1.5f;
|
||||
labelFormat = multiplier == 1 ? "MMM" : "MM/yy";
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
count *= multiplier;
|
||||
step *= multiplier;
|
||||
|
||||
HistoricEntry[] values;
|
||||
|
||||
switch (captorType)
|
||||
{
|
||||
case CaptorType.Humidity:
|
||||
values = historicEntries.Humidities;
|
||||
valueSpecifier = "%";
|
||||
break;
|
||||
case CaptorType.Luminosity:
|
||||
values = historicEntries.Luminosities;
|
||||
valueSpecifier = "lux";
|
||||
break;
|
||||
case CaptorType.Temperature:
|
||||
values = historicEntries.Temperatures;
|
||||
valueSpecifier = "°C";
|
||||
break;
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
// Take values
|
||||
values = values.Reverse().Take((int)count).ToArray();
|
||||
Entry[] entries = new Entry[values.Length / (int)step];
|
||||
SKColor[] colors = CreateGradient(begin, end, values.Length / (int)step).Reverse().ToArray();
|
||||
|
||||
int index = 0;
|
||||
for (uint i = 0; index < entries.Length; i += (uint)step)
|
||||
{
|
||||
var value = values[i];
|
||||
entries[index] = new Entry((float)value.Value)
|
||||
{
|
||||
Label = value.Date.ToString(labelFormat),
|
||||
ValueLabel = $"{value.Value} {valueSpecifier}",
|
||||
Color = colors[index]
|
||||
};
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return entries.Reverse().ToArray();
|
||||
}
|
||||
|
||||
private SKColor[] CreateGradient(SKColor begin, SKColor end, int count)
|
||||
{
|
||||
var colors = new SKColor[count];
|
||||
|
||||
byte currentRed = begin.Red;
|
||||
byte deltaRed = (byte)((end.Red - begin.Red) / count);
|
||||
|
||||
byte currentGreen = begin.Green;
|
||||
byte deltaGreen = (byte)((end.Green - begin.Green) / count);
|
||||
|
||||
byte currentBlue = begin.Blue;
|
||||
byte deltaBlue = (byte)((end.Blue - begin.Blue) / count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
colors[i] = new SKColor(currentRed, currentGreen, currentBlue);
|
||||
|
||||
currentRed += deltaRed;
|
||||
currentGreen += deltaGreen;
|
||||
currentBlue += deltaBlue;
|
||||
}
|
||||
|
||||
return colors;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,8 @@ namespace PlantBox.Client.Forms.Plant
|
||||
BindingContext = viewModel,
|
||||
Title = Locale.Informations
|
||||
});
|
||||
Children.Add(new HistoricPage()
|
||||
Children.Add(new HistoricPage(viewModel)
|
||||
{
|
||||
BindingContext = viewModel,
|
||||
Title = Locale.Historic
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Acr.UserDialogs;
|
||||
using PlantBox.Client.Resources;
|
||||
using PlantBox.Client.Resources;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
43
PlantBox.Client/PlantBox.Client/Models/Duration.cs
Normal file
43
PlantBox.Client/PlantBox.Client/Models/Duration.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using PlantBox.Client.Resources;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PlantBox.Client.Models
|
||||
{
|
||||
public class Duration
|
||||
{
|
||||
public uint Multiplier { get; }
|
||||
public Interval Interval { get; }
|
||||
|
||||
public Duration(uint multiplier, Interval interval)
|
||||
{
|
||||
Multiplier = multiplier;
|
||||
Interval = interval;
|
||||
}
|
||||
|
||||
private string IntervalToString(Interval interval)
|
||||
{
|
||||
switch (interval)
|
||||
{
|
||||
case Interval.Hourly:
|
||||
return Locale.Hour;
|
||||
case Interval.Daily:
|
||||
return Locale.Day;
|
||||
case Interval.Weekly:
|
||||
return Locale.Week;
|
||||
case Interval.Monthly:
|
||||
return Locale.Month;
|
||||
case Interval.Yearly:
|
||||
return Locale.Year;
|
||||
default:
|
||||
return "Invalid interval";
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Multiplier} {IntervalToString(Interval)}{(Multiplier > 1 && !IntervalToString(Interval).EndsWith("s") ? "s" : "")}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,16 @@ namespace PlantBox.Client.Models
|
||||
{
|
||||
public class Historic
|
||||
{
|
||||
public HistoricEntry MinutelyHistoric { get; }
|
||||
public HistoricEntry HourlyHistoric { get; }
|
||||
public HistoricEntry DailyHistoric { get; }
|
||||
public HistoricEntry WeeklyHistoric { get; }
|
||||
public HistoricEntry MonthlyHistoric { get; }
|
||||
public HistoricEntries MinutelyHistoric { get; }
|
||||
public HistoricEntries HourlyHistoric { get; }
|
||||
public HistoricEntries DailyHistoric { get; }
|
||||
public HistoricEntries WeeklyHistoric { get; }
|
||||
public HistoricEntries MonthlyHistoric { get; }
|
||||
|
||||
public Historic
|
||||
(
|
||||
HistoricEntry minutelyHistoric, HistoricEntry hourlyHistoric, HistoricEntry dailyHistoric,
|
||||
HistoricEntry weeklyHistoric, HistoricEntry monthlyHistoric
|
||||
HistoricEntries minutelyHistoric, HistoricEntries hourlyHistoric, HistoricEntries dailyHistoric,
|
||||
HistoricEntries weeklyHistoric, HistoricEntries monthlyHistoric
|
||||
)
|
||||
{
|
||||
MinutelyHistoric = minutelyHistoric;
|
||||
|
||||
43
PlantBox.Client/PlantBox.Client/Models/HistoricEntries.cs
Normal file
43
PlantBox.Client/PlantBox.Client/Models/HistoricEntries.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using PlantBox.Client.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PlantBox.Client.Models
|
||||
{
|
||||
public class HistoricEntries
|
||||
{
|
||||
public DateTime LastTime { get; }
|
||||
public TimeSpan TimeInterval { get; }
|
||||
|
||||
public HistoricEntry[] Humidities { get; }
|
||||
public HistoricEntry[] Luminosities { get; }
|
||||
public HistoricEntry[] Temperatures { get; }
|
||||
|
||||
public DateTime EndTime => LastTime - new TimeSpan(TimeInterval.Ticks * Count);
|
||||
public int Count => Humidities.Length;
|
||||
|
||||
public HistoricEntries(DateTime lastTime, TimeSpan timeInterval, double[] humidities, double[] luminosities, double[] temperatures)
|
||||
{
|
||||
LastTime = lastTime;
|
||||
TimeInterval = timeInterval;
|
||||
Humidities = ValuesToEntries(humidities);
|
||||
Luminosities = ValuesToEntries(luminosities);
|
||||
Temperatures = ValuesToEntries(temperatures);
|
||||
}
|
||||
|
||||
private HistoricEntry[] ValuesToEntries(double[] values)
|
||||
{
|
||||
HistoricEntry[] entries = new HistoricEntry[values.Length];
|
||||
var oldestDate = LastTime - TimeInterval.Multiply(values.Length - 1);
|
||||
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
entries[i] = new HistoricEntry(oldestDate + TimeInterval.Multiply(i), values[i]);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,23 +6,13 @@ namespace PlantBox.Client.Models
|
||||
{
|
||||
public class HistoricEntry
|
||||
{
|
||||
public DateTime LastTime { get; }
|
||||
public TimeSpan TimeInterval { get; }
|
||||
public DateTime Date { get; }
|
||||
public double Value { get; }
|
||||
|
||||
public double[] Humidities { get; }
|
||||
public double[] Luminosities { get; }
|
||||
public double[] Temperatures { get; }
|
||||
|
||||
public DateTime EndTime => LastTime - new TimeSpan(TimeInterval.Ticks * Count);
|
||||
public int Count => Humidities.Length;
|
||||
|
||||
public HistoricEntry(DateTime lastTime, TimeSpan timeInterval, double[] humidities, double[] luminosities, double[] temperatures)
|
||||
public HistoricEntry(DateTime date, double value)
|
||||
{
|
||||
LastTime = lastTime;
|
||||
TimeInterval = timeInterval;
|
||||
Humidities = humidities;
|
||||
Luminosities = luminosities;
|
||||
Temperatures = temperatures;
|
||||
Date = date;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
PlantBox.Client/PlantBox.Client/Models/Interval.cs
Normal file
15
PlantBox.Client/PlantBox.Client/Models/Interval.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PlantBox.Client.Models
|
||||
{
|
||||
public enum Interval
|
||||
{
|
||||
Hourly,
|
||||
Daily,
|
||||
Weekly,
|
||||
Monthly,
|
||||
Yearly
|
||||
}
|
||||
}
|
||||
19
PlantBox.Client/PlantBox.Client/Models/NamedChart.cs
Normal file
19
PlantBox.Client/PlantBox.Client/Models/NamedChart.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Microcharts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace PlantBox.Client.Models
|
||||
{
|
||||
public class NamedChart
|
||||
{
|
||||
public Chart Chart { get; }
|
||||
public string Name { get; }
|
||||
|
||||
public NamedChart(Chart chart, string name)
|
||||
{
|
||||
Chart = chart;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,9 +38,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Acr.UserDialogs" Version="7.0.4" />
|
||||
<PackageReference Include="Microcharts" Version="0.7.1" />
|
||||
<PackageReference Include="Microcharts.Forms" Version="0.7.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="3.4.0.1008975" />
|
||||
<PackageReference Include="Xamarin.Forms" Version="3.6.0.344457" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace PlantBox.Client.Resources {
|
||||
// à l'aide d'un outil, tel que ResGen ou Visual Studio.
|
||||
// Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
|
||||
// avec l'option /str ou régénérez votre projet VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Locale {
|
||||
@@ -87,6 +87,15 @@ namespace PlantBox.Client.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Day.
|
||||
/// </summary>
|
||||
internal static string Day {
|
||||
get {
|
||||
return ResourceManager.GetString("Day", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à General.
|
||||
/// </summary>
|
||||
@@ -114,6 +123,15 @@ namespace PlantBox.Client.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Hour.
|
||||
/// </summary>
|
||||
internal static string Hour {
|
||||
get {
|
||||
return ResourceManager.GetString("Hour", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Informations.
|
||||
/// </summary>
|
||||
@@ -123,6 +141,15 @@ namespace PlantBox.Client.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Interval:.
|
||||
/// </summary>
|
||||
internal static string Interval {
|
||||
get {
|
||||
return ResourceManager.GetString("Interval", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Changes will take effect at next start.
|
||||
/// </summary>
|
||||
@@ -177,6 +204,15 @@ namespace PlantBox.Client.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Month.
|
||||
/// </summary>
|
||||
internal static string Month {
|
||||
get {
|
||||
return ResourceManager.GetString("Month", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Notifications.
|
||||
/// </summary>
|
||||
@@ -230,5 +266,23 @@ namespace PlantBox.Client.Resources {
|
||||
return ResourceManager.GetString("Version", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Week.
|
||||
/// </summary>
|
||||
internal static string Week {
|
||||
get {
|
||||
return ResourceManager.GetString("Week", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recherche une chaîne localisée semblable à Year.
|
||||
/// </summary>
|
||||
internal static string Year {
|
||||
get {
|
||||
return ResourceManager.GetString("Year", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,9 @@
|
||||
<data name="Captors" xml:space="preserve">
|
||||
<value>Capteurs</value>
|
||||
</data>
|
||||
<data name="Day" xml:space="preserve">
|
||||
<value>Jour</value>
|
||||
</data>
|
||||
<data name="General" xml:space="preserve">
|
||||
<value>Général</value>
|
||||
</data>
|
||||
@@ -135,9 +138,15 @@
|
||||
<data name="HomePageTitle" xml:space="preserve">
|
||||
<value>Accueil</value>
|
||||
</data>
|
||||
<data name="Hour" xml:space="preserve">
|
||||
<value>Heure</value>
|
||||
</data>
|
||||
<data name="Informations" xml:space="preserve">
|
||||
<value>Informations</value>
|
||||
</data>
|
||||
<data name="Interval" xml:space="preserve">
|
||||
<value>Intervalle:</value>
|
||||
</data>
|
||||
<data name="LanguageChangedMessage" xml:space="preserve">
|
||||
<value>Les changements prendront effet au prochain lancement</value>
|
||||
</data>
|
||||
@@ -156,6 +165,9 @@
|
||||
<data name="Media" xml:space="preserve">
|
||||
<value>Media</value>
|
||||
</data>
|
||||
<data name="Month" xml:space="preserve">
|
||||
<value>Mois</value>
|
||||
</data>
|
||||
<data name="Notifications" xml:space="preserve">
|
||||
<value>Notifications</value>
|
||||
</data>
|
||||
@@ -174,4 +186,10 @@
|
||||
<data name="Version" xml:space="preserve">
|
||||
<value>Version</value>
|
||||
</data>
|
||||
<data name="Week" xml:space="preserve">
|
||||
<value>Semaine</value>
|
||||
</data>
|
||||
<data name="Year" xml:space="preserve">
|
||||
<value>Année</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -126,6 +126,9 @@
|
||||
<data name="Captors" xml:space="preserve">
|
||||
<value>Captors</value>
|
||||
</data>
|
||||
<data name="Day" xml:space="preserve">
|
||||
<value>Day</value>
|
||||
</data>
|
||||
<data name="General" xml:space="preserve">
|
||||
<value>General</value>
|
||||
</data>
|
||||
@@ -135,9 +138,15 @@
|
||||
<data name="HomePageTitle" xml:space="preserve">
|
||||
<value>Home</value>
|
||||
</data>
|
||||
<data name="Hour" xml:space="preserve">
|
||||
<value>Hour</value>
|
||||
</data>
|
||||
<data name="Informations" xml:space="preserve">
|
||||
<value>Informations</value>
|
||||
</data>
|
||||
<data name="Interval" xml:space="preserve">
|
||||
<value>Interval:</value>
|
||||
</data>
|
||||
<data name="LanguageChangedMessage" xml:space="preserve">
|
||||
<value>Changes will take effect at next start</value>
|
||||
</data>
|
||||
@@ -156,6 +165,9 @@
|
||||
<data name="Media" xml:space="preserve">
|
||||
<value>Media</value>
|
||||
</data>
|
||||
<data name="Month" xml:space="preserve">
|
||||
<value>Month</value>
|
||||
</data>
|
||||
<data name="Notifications" xml:space="preserve">
|
||||
<value>Notifications</value>
|
||||
</data>
|
||||
@@ -174,4 +186,10 @@
|
||||
<data name="Version" xml:space="preserve">
|
||||
<value>Version</value>
|
||||
</data>
|
||||
<data name="Week" xml:space="preserve">
|
||||
<value>Week</value>
|
||||
</data>
|
||||
<data name="Year" xml:space="preserve">
|
||||
<value>Year</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -103,6 +103,20 @@ namespace PlantBox.Client.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private Duration _historicDuration;
|
||||
public Duration HistoricDuration
|
||||
{
|
||||
get => _historicDuration;
|
||||
set
|
||||
{
|
||||
if (value != _historicDuration)
|
||||
{
|
||||
_historicDuration = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadValues()
|
||||
{
|
||||
// TODO
|
||||
@@ -113,6 +127,19 @@ namespace PlantBox.Client.ViewModels
|
||||
LuminosityCaptor = new CaptorValue(50, 1000, 375.6);
|
||||
TemperatureCaptor = new CaptorValue(20, 35, 27);
|
||||
TankValue = 78.45;
|
||||
|
||||
var humidities = new[] { 45.5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5 };
|
||||
var luminosities = new[] { 45.5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5 };
|
||||
var temperatures = new[] { 45.5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5 };
|
||||
var humidities2 = new[] { 45.5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5, 9 };
|
||||
var luminosities2 = new[] { 45.5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5, 9 };
|
||||
var temperatures2 = new[] { 45.5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5, 45, 89, 78, 42, 56, 45, 23, 14, 89, 10, 5, 9 };
|
||||
|
||||
Historic = new Historic(new HistoricEntries(DateTime.Now, TimeSpan.FromMinutes(5), humidities, luminosities, temperatures),
|
||||
new HistoricEntries(DateTime.Now, TimeSpan.FromHours(1), humidities2, luminosities2, temperatures2),
|
||||
new HistoricEntries(DateTime.Now, TimeSpan.FromDays(1), humidities2, luminosities2, temperatures2),
|
||||
new HistoricEntries(DateTime.Now, TimeSpan.FromDays(7), humidities2, luminosities2, temperatures2),
|
||||
new HistoricEntries(DateTime.Now, TimeSpan.FromDays(31), humidities2, luminosities2, temperatures2));
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
|
||||
10
PlantBox.sln
10
PlantBox.sln
@@ -1,7 +1,7 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.421
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.28803.202
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlantBox.Shared", "PlantBox.Shared\PlantBox.Shared.csproj", "{9E73B18F-8D48-43BC-974D-D1697E1085A1}"
|
||||
EndProject
|
||||
@@ -296,9 +296,9 @@ Global
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x64.Build.0 = Debug|x64
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x86.Build.0 = Debug|x86
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x86.Build.0 = Debug|x64
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Debug|x86.Deploy.0 = Debug|x64
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{33FE30F1-5344-4565-8456-24322CF17093}.Release|ARM.Build.0 = Release|ARM
|
||||
|
||||
Reference in New Issue
Block a user