-
Notifications
You must be signed in to change notification settings - Fork 0
/
PhenoPrompt.cs
90 lines (84 loc) · 2.98 KB
/
PhenoPrompt.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Coding4Fun.Phone.Controls;
namespace G7Phenology
{
public class PhenoPrompt : ToastPrompt
{
public PhenoPrompt()
{
MillisecondsUntilHidden = 1500;
VerticalAlignment = VerticalAlignment.Bottom;
VerticalContentAlignment = VerticalAlignment.Center;
Background = new SolidColorBrush
{
Color = Colors.Black,
Opacity = 0.9
};
}
public static StackPanel phenoPanel(int[] phenology)
{
StackPanel phenoPanel = new StackPanel
{
Height = 80,
Orientation = Orientation.Horizontal,
HorizontalAlignment = HorizontalAlignment.Center
};
for (int phase = 0; phase < 6; phase++)
{
int intensity = phenology[phase];
while (intensity-- > 0)
{
phenoPanel.Children.Add(PhenoTile.createIcon(phase));
}
}
if (phenoPanel.Children.Count == 0)
{
phenoPanel.Children.Add(new TextBlock
{
Text = "Não encontrado.",
FontWeight = FontWeights.Bold
});
}
return phenoPanel;
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
Grid panel = (((GetTemplateChild("ToastImage") as Image).Parent as Panel).Parent as Panel).Parent as Grid;
panel.Children.Clear();
panel.Children.Add(new TextBlock
{
Text = Title,
FontWeight = FontWeights.Bold,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left,
Margin = new Thickness(10, 10, 10, 10)
});
panel.Children.Add(new Image
{
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Left,
Stretch = Stretch.None,
Source = new BitmapImage(new Uri("Toolkit.Content/ApplicationBar.Check.png", UriKind.RelativeOrAbsolute))
});
panel.Children.Add(phenoPanel(Phenology));
}
public int[] Phenology
{
get { return (int[])GetValue(PhenologyProperty); }
set { SetValue(PhenologyProperty, value); }
}
public static readonly DependencyProperty PhenologyProperty =
DependencyProperty.Register("Phenology", typeof(int[]), typeof(PhenoPrompt), new PropertyMetadata(new int[] { 0, 0, 0, 0, 0, 0 }));
}
}