aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.SharedUI/Controls
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-03-06 18:28:51 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-03-06 18:28:51 +0200
commit4e48c569f1cae820ffade8a786354b2ba79b50b4 (patch)
tree1bfbdf19f8c86cc1f1a1d8b900756b0cc2781d66 /Software/Visual_Studio/Tango.SharedUI/Controls
parent7e6c673cc8b04086fa3c78cd1bf5e31085fd8cc8 (diff)
downloadTango-4e48c569f1cae820ffade8a786354b2ba79b50b4.tar.gz
Tango-4e48c569f1cae820ffade8a786354b2ba79b50b4.zip
Some improvements on hive.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls')
-rw-r--r--Software/Visual_Studio/Tango.SharedUI/Controls/HiveControl.xaml.cs35
1 files changed, 31 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/HiveControl.xaml.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/HiveControl.xaml.cs
index 81fc1250d..5fba6eaa0 100644
--- a/Software/Visual_Studio/Tango.SharedUI/Controls/HiveControl.xaml.cs
+++ b/Software/Visual_Studio/Tango.SharedUI/Controls/HiveControl.xaml.cs
@@ -25,6 +25,8 @@ namespace Tango.SharedUI.Controls
{
public event EventHandler<HexagonControl> HexagonSelected;
+ public event EventHandler HiveGenerated;
+
public ObservableCollection<HexagonControl> Hexagons
{
get { return (ObservableCollection<HexagonControl>)GetValue(HexagonsProperty); }
@@ -65,6 +67,21 @@ namespace Tango.SharedUI.Controls
public static readonly DependencyProperty CenterHexagonProperty =
DependencyProperty.Register("CenterHexagon", typeof(HexagonControl), typeof(HiveControl), new PropertyMetadata(null));
+ public int HiveWidth
+ {
+ get { return (int)GetValue(HiveWidthProperty); }
+ set { SetValue(HiveWidthProperty, value); }
+ }
+ public static readonly DependencyProperty HiveWidthProperty =
+ DependencyProperty.Register("HiveWidth", typeof(int), typeof(HiveControl), new PropertyMetadata(5));
+
+ public int HiveHeight
+ {
+ get { return (int)GetValue(HiveHeightProperty); }
+ set { SetValue(HiveHeightProperty, value); }
+ }
+ public static readonly DependencyProperty HiveHeightProperty =
+ DependencyProperty.Register("HiveHeight", typeof(int), typeof(HiveControl), new PropertyMetadata(5));
public HiveControl()
{
@@ -78,13 +95,10 @@ namespace Tango.SharedUI.Controls
this.Loaded += HiveControl_Loaded;
}
- public int HiveHeight { get; set; }
-
- public int HiveWidth { get; set; }
-
private void HiveControl_Loaded(object sender, RoutedEventArgs e)
{
GenerateHive();
+ HiveGenerated?.Invoke(this,new EventArgs());
}
private void GenerateHive()
@@ -155,7 +169,20 @@ namespace Tango.SharedUI.Controls
private void Hexagon_MouseUp(object sender, MouseButtonEventArgs e)
{
HexagonControl hexagon = sender as HexagonControl;
+ ToggleHexagonSelection(hexagon);
+ }
+ public void SelectHexagon(HexagonControl hexagon)
+ {
+ SelectedHexagons.Clear();
+ SelectedHexagons.Add(hexagon);
+ Hexagons.ToList().ForEach(x => x.IsSelected = false);
+ hexagon.IsSelected = true;
+ HexagonSelected?.Invoke(this, hexagon);
+ }
+
+ private void ToggleHexagonSelection(HexagonControl hexagon)
+ {
bool selected = !hexagon.IsSelected;
if (MaxSelections > Hexagons.Where(x => x.IsSelected).Count())