aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Synchronization/Properties/AssemblyInfo.cs
blob: 44e1dba95ac97aa6dbc65632d72d5ddbf10605be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;

[assembly: AssemblyTitle("Tango - Machine Studio Synchronization Module")]
[assembly: AssemblyVersion("2.0.9.1633")]

[assembly: ComVisible(false)]

[assembly:ThemeInfo(
    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
                             //(used if a resource is not found in the page,
                             // or application resource dictionaries)
    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
                                      //(used if a resource is not found in the page,
                                      // app, or any theme specific resource dictionaries)
)]
tick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.Logging;
using Tango.SharedUI.Controls;

namespace Tango.MachineStudio.Common.Controls
{
    /// <summary>
    /// Interaction logic for HiveComboControl.xaml
    /// </summary>
    public partial class HiveComboControl : UserControl
    {
        public event EventHandler<HexagonControl> SelectedHexagonChanged;
        public event EventHandler<int> LAxisValueChanged;
        public event EventHandler<int> ResolutionChanged;
        public event EventHandler HiveGenerated;

        public int Resolution
        {
            get { return (int)GetValue(ResolutionProperty); }
            set { SetValue(ResolutionProperty, value); }
        }
        public static readonly DependencyProperty ResolutionProperty =
            DependencyProperty.Register("Resolution", typeof(int), typeof(HiveComboControl), new PropertyMetadata(1, (d, e) => (d as HiveComboControl).OnResolutionChanged()));

        public HexagonControl SelectedHexagon
        {
            get { return (HexagonControl)GetValue(SelectedHexagonProperty); }
            set { SetValue(SelectedHexagonProperty, value); }
        }
        public static readonly DependencyProperty SelectedHexagonProperty =
            DependencyProperty.Register("SelectedHexagon", typeof(HexagonControl), typeof(HiveComboControl), new PropertyMetadata(null, (d, e) => (d as HiveComboControl).OnSelectedHexagonChanged()));

        public int LAxisValue
        {
            get { return (int)GetValue(LAxisValueProperty); }
            set { SetValue(LAxisValueProperty, value); }
        }
        public static readonly DependencyProperty LAxisValueProperty =
            DependencyProperty.Register("LAxisValue", typeof(int), typeof(HiveComboControl), new PropertyMetadata(0, (d, e) => (d as HiveComboControl).OnLAxisValueChanged()));

        public HexagonControl CenterHexagon
        {
            get { return hive.CenterHexagon; }
        }


        public HiveComboControl()
        {
            InitializeComponent();

            hive.HiveGenerated += (x, e) => HiveGenerated?.Invoke(this, new EventArgs());
        }

        private void OnLAxisValueChanged()
        {
            LAxisValueChanged?.Invoke(this, LAxisValue);
        }

        private void OnSelectedHexagonChanged()
        {
            SelectedHexagonChanged?.Invoke(this, SelectedHexagon);
        }

        private void OnResolutionChanged()
        {
            ResolutionChanged?.Invoke(this, Resolution);
        }

        public void GenerateDemoModeHiveColors(Color originalColor)
        {
            if (hive.CenterHexagon != null)
            {
                Random rnd = new Random();

                (hive.CenterHexagon.Fill as SolidColorBrush).Color = originalColor;

                int counter = 0;

                foreach (var hexagon in hive.Hexagons.Where(x => x != hive.CenterHexagon).OrderBy(x => rnd.Next()))
                {
                    (hexagon.Fill as SolidColorBrush).Color = Color.FromRgb((byte)Math.Min(originalColor.R + counter++, 255), (byte)Math.Min((originalColor.G + counter++), 255), (byte)Math.Min((originalColor.B + counter++), 255));

                    counter += (int)(4d * ((double)Resolution / 4d));
                }
            }
        }

        private void OnResolutionUpClicked(object sender, RoutedEventArgs e)
        {
            if (Resolution < 10)
            {
                Resolution++;
            }
        }

        private void OnResolutionDownClicked(object sender, RoutedEventArgs e)
        {
            if (Resolution > 1)
            {
                Resolution--;
            }
        }

        private void OnRowHiveHexagonSelected(object sender, HexagonControl hexagon)
        {
            LAxisValue = 2 - hexagon.Row;
        }

        private void OnHexagonSelected(object sender, HexagonControl e)
        {
            SelectedHexagon = e;
        }

        public void SelectHeagon(HexagonControl hexagon)
        {
            hive.SelectHexagon(hexagon);
            SelectedHexagonChanged?.Invoke(this, hexagon);
        }
    }
}