aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Scripting/Tango.Scripting.IDE/Images/algorithm.png
blob: ab6b4c30f60bb38b1c9b5744b91cb9afa1366aca (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 20 00 00 00 20 08 06 00 00 00 73 7a 7a .PNG........IHDR.............szz
0020 f4 00 00 00 04 73 42 49 54 08 08 08 08 7c 08 64 88 00 00 00 09 70 48 59 73 00 00 00 b2 00 00 00 .....sBIT....|.d.....pHYs.......
0040 b2 01 6b 94 68 e0 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 65 00 77 77 77 2e 69 6e 6b 73 63 ..k.h.....tEXtSoftware.www.inksc
0060 61 70 65 2e 6f 72 67 9b ee 3c 1a 00 00 05 fd 49 44 41 54 58 85 b5 57 59 6c 54 55 18 fe ce b9 77 ape.org..<.....IDATX..WYlTU....w
0080 66 ee ec 7b 4b 3b 95 ee 20 d0 86 a2 2d 2d 50 b4 40 b5 c0 60 0c 9b 0a a8 10 0d 04 97 98 98 20 6e f..{K;......--P.@..`...........n
00a0 2f f0 80 b8 10 13 c5 28 a8 10 1f ac 16 44 50 a4 96 b2 56 21 80 94 87 52 4a 13 a0 74 a3 05 4a db /......(.....DP...V!...RJ..t..J.
00c0 e9 32 ed cc ed cc dc 7b 7c d0 5b 09 99 a5 ad f0 bf dd fb fd e7 fb be 7b ce c9 b9 df 21 88 50 c5 .2.....{|.[............{....!.P.
00e0 13 56 14 06 05 cd 02 aa d7 69 89 5e af 95 ef f4 6c a9 aa fd b6 4d c1 e7 19 17 db 75 79 ae 5f 19 .V.......i.^....l....M.....uy._.
0100 63 41 e9 62 e3 d3 15 9e 8a 7e 05 9b 9b b0 24 59 72 18 5e 26 6a 95 9a c4 39 9c e4 96 67 d7 89 9a cA.b.....~....$Yr.^&j...9...g...
0120 6f ce 84 d3 e1 23 19 18 74 1a b7 df 9c 97 91 93 98 3d 13 82 de 02 f2 79 69 36 6a 51 38 2c 3e 3d o....#..t........=.....yi6jQ8,>=
0140 e9 b0 f6 ad 39 b9 76 67 02 ba b7 55 d6 2f a8 c4 64 c5 44 30 d1 fc 59 eb c2 87 9f b6 a7 4e 81 39 ....9.vg...U./..d.D0..Y......N.9
0160 31 15 f2 ae 9f 17 a0 06 89 e1 74 68 24 03 4c cd 51 49 e0 01 93 11 cc a4 07 e3 a9 a0 60 da 5c 57 1.........th$.L.QI..........`.\W
0180 a9 f6 ad 39 b9 d6 f1 49 b0 a5 3d 84 b4 ad 2b 5d 06 77 c1 89 e1 c1 1c a7 92 b4 2a 30 a3 0e cc a0 ...9...I..=...+].w........*0....
01a0 03 34 aa 88 1f 1a d1 40 b4 62 fe 50 9d d4 ec f1 f9 7d 83 90 99 8c 81 ba 56 06 71 e8 fc 58 b8 22 .4.....@.b.P.....}......V.q..X."
01c0 3a d3 f4 8a 77 1c 17 da 5b b8 9b 7f 58 89 5a 10 48 30 70 49 c1 ca cf ed d8 e0 96 d6 9a 00 ac 6a :...w...[...X.Z.H0pI...........j
01e0 a9 69 43 e0 b7 cb 07 f6 fd fa e1 ab 0a 4e fd a1 eb ce ea b6 16 4d 63 d0 c0 6c cd 46 e2 e9 6f 8f .iC..........N.......Mc..l.F..o.
0200 a4 43 22 01 9b b0 89 56 9b ab cd 32 2f bc 0d e6 fb e0 ee 4d a6 94 3b 6b f5 97 84 72 03 87 6a 77 .C"....V...2/......M..;k...r..jw
0220 6f bc 17 2b b6 2e 37 ab a8 fc 2e 0d 89 1f 95 f7 95 f7 02 60 a3 32 a0 d4 42 db e2 8f 19 a5 0d 61 o..+..7............`.2..B......a
0240 41 26 4f 06 a8 08 82 c6 f0 38 4b ae e8 de ff 7e 34 fe 88 4b a0 d4 74 cf d4 77 aa cd d5 e6 b0 fc A&O......8K....~4..K..t..w......
0260 9c 30 97 81 78 69 c8 5f 1d 0e ff f7 cb a3 56 cc 19 b8 b7 9e 4c 7f 61 ae 68 e4 df 08 d9 f5 19 9c .0..xi._......V.....L.a.h.......
0280 3d 6e 1c a7 d5 09 08 06 45 f4 f4 35 aa db 3a 37 1c b9 b4 eb cf d1 f0 8d d8 40 91 73 b9 81 25 18 =n......E..5..:7.........@.s..%.
02a0 4a 3d 53 c7 cd 26 4f 14 5a ad 29 13 41 28 f7 5f 83 2c 83 1e 3f 27 b3 b3 35 67 d9 d5 ce e2 aa e6 J=S..&O.Z.).A(._.,..?'..5g......
02c0 ef c4 fb 66 a0 c8 b9 dc 20 25 19 4f dc 58 f4 70 9e e3 91 59 30 38 c3 9e 29 ff 10 76 f7 01 5f ed ...f.....%.O.X.p...Y08..)..v.._.
02e0 69 12 1a 6a 26 55 34 54 0c c5 e2 1e d1 39 20 8f d3 97 dd 70 4f cc b3 4c ce 89 2a 0e 00 cc 6e 06 i..j&U4T.....9.....pO..L..*...n.
0300 d6 3f 9b 2a a6 4e 39 32 12 ee 98 06 8a 33 56 96 74 3f 92 38 8b d8 2d 30 3f 94 31 12 4e 30 87 19 .?.*.N92.....3V.t?.8..-0?.1.N0..
0320 24 7f 6a e1 fc ec 17 67 c4 ea e5 01 60 51 ce 4b 6b 89 45 5b 42 65 d6 c9 ea db 36 1e ec 3a e8 55 $.j....g....`Q.Kk.E[Be....6..:.U
0340 1a 86 0c c2 eb 7d 13 ec 16 47 62 3a c8 28 f6 ac fc c4 0c 3a 54 5d b7 0d 97 30 4b 79 e7 36 bb ad .....}...Gb:.(.....:T]...0Ky.6..
0360 98 e8 da 42 75 aa 38 95 8a 1e dd 7f 74 fb 4e 7e 51 fe ba 8f 35 2f e4 be 6a 28 c8 d4 c7 9b e2 d1 ...Bu.8.....t.N~Q...5/..j(......
0380 b4 79 ef 53 45 a5 fd 29 55 a8 0a 01 40 c0 a2 49 05 21 d0 59 9d 23 16 07 00 70 1c 98 d3 92 a9 3c .y.SE..)U...@..I.!.Y.#...p.....<
03a0 16 a5 ac 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
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.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.BL.Entities;
using Tango.DragAndDrop;
using Tango.MachineStudio.MachineDesigner.ViewModels;

namespace Tango.MachineStudio.MachineDesigner.Views
{
    /// <summary>
    /// Interaction logic for MainView.xaml
    /// </summary>
    public partial class ConfigurationView : UserControl
    {
        private MainViewVM _vm;
        private Rectangle _highlightRect;
        private bool _highlightShown;
        private DoubleAnimation _highlightAnimation;

        public ColumnDefinition PanelColumnDefinition { get; set; }

        public ConfigurationView()
        {
            InitializeComponent();

            PanelColumnDefinition = panelColumnDefinition;

            DraggingSurface = dragSufrace;
            this.Loaded += (x, y) =>
            {
                _vm = DataContext as MainViewVM;
            };

            DragAndDropService.DragStarted += DragAndDropService_DragStarted;
            DragAndDropService.DragEnded += DragAndDropService_DragEnded;

            _highlightRect = new Rectangle();
            _highlightRect.IsHitTestVisible = false;
            _highlightRect.Stroke = Application.Current.Resources["AccentColorBrush"] as Brush;
            _highlightRect.StrokeThickness = 2;
            _highlightRect.StrokeDashArray = new DoubleCollection(new double[] { 3, 3, 3, 3 });
        }

        private void DragAndDropService_DragEnded(object sender, FrameworkElement e)
        {
            canvas.Children.Remove(_highlightRect);
            _highlightShown = false;
            _highlightRect.BeginAnimation(Rectangle.OpacityProperty, null);
        }

        private void DragAndDropService_DragStarted(object sender, FrameworkElement e)
        {
            if (e.DataContext is HardwareVersion)
            {
                SetHighlightRegion(hardwareGrid);
            }
            else if (e.DataContext is ApplicationOsVersion || e.DataContext is ApplicationDisplayPanelVersion || e.DataContext is ApplicationFirmwareVersion)
            {
                SetHighlightRegion(gridTablet);
            }
            else if (e.DataContext is EmbeddedFirmwareVersion)
            {
                SetHighlightRegion(gridEmbedded);
            }
            else if (e.DataContext is DispenserType || e.DataContext is CartridgeType || e.DataContext is LiquidType || e.DataContext is MidTankType || e.DataContext is IdsPackFormula)
            {
                SetHighlightRegion(gridIds);
            }
        }

        public DraggingSurface DraggingSurface
        {
            get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); }
            set { SetValue(DraggingSurfaceProperty, value); }
        }
        public static readonly DependencyProperty DraggingSurfaceProperty =
            DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null));

        private void OnDropOnIdsPack(object sender, DropEventArgs e)
        {
            if (e.Draggable.DataContext is Dispenser)
            {
                _vm.DropDispenser(e.Draggable.DataContext as Dispenser, e.Droppable.DataContext as IdsPack);
            }
            else if (e.Draggable.DataContext is LiquidType)
            {
                _vm.DropLiquidType(e.Draggable.DataContext as LiquidType, e.Droppable.DataContext as IdsPack);
            }
            else if (e.Draggable.DataContext is CartridgeType)
            {
                _vm.DropCartridgeType(e.Draggable.DataContext as CartridgeType, e.Droppable.DataContext as IdsPack);
            }
            else if (e.Draggable.DataContext is MidTankType)
            {
                _vm.DropMidTankType(e.Draggable.DataContext as MidTankType, e.Droppable.DataContext as IdsPack);
            }
            else if (e.Draggable.DataContext is IdsPackFormula)
            {
                _vm.DropIdsFormula(e.Draggable.DataContext as IdsPackFormula, e.Droppable.DataContext as IdsPack);
            }
            else if (e.Draggable.DataContext is IdsPack)
            {
                _vm.DropIdsPack(e.Draggable.DataContext as IdsPack, e.Droppable.DataContext as IdsPack);
            }
        }

        private void OnTabletDrop(object sender, DropEventArgs e)
        {
            if (e.Draggable.DataContext is ApplicationDisplayPanelVersion)
            {
                _vm.DropTouchPanel(e.Draggable.DataContext as ApplicationDisplayPanelVersion);
            }
            else if (e.Draggable.DataContext is ApplicationOsVersion)
            {
                _vm.DropApplicationOsVersion(e.Draggable.DataContext as ApplicationOsVersion);
            }
            else if (e.Draggable.DataContext is ApplicationFirmwareVersion)
            {
                _vm.DropApplicationFirmwareVersion(e.Draggable.DataContext as ApplicationFirmwareVersion);
            }
        }

        private void OnEmbeddedDrop(object sender, DropEventArgs e)
        {
            if (e.Draggable.DataContext is EmbeddedFirmwareVersion)
            {
                _vm.DropEmbeddedFirmware(e.Draggable.DataContext as EmbeddedFirmwareVersion);
            }
        }

        private void MachineDrop(object sender, DropEventArgs e)
        {
            if (e.Draggable.DataContext is HardwareVersion)
            {
                _vm.DropHardwareVersion(e.Draggable.DataContext as HardwareVersion);
            }
        }

        private void SetHighlightRegion(FrameworkElement element)
        {
            if (!_highlightShown)
            {
                _highlightRect.Width = element.Width;
                _highlightRect.Height = element.Height;
                Canvas.SetLeft(_highlightRect, Canvas.GetLeft(element));
                Canvas.SetTop(_highlightRect, Canvas.GetTop(element));
                canvas.Children.Add(_highlightRect);
                _highlightShown = true;
                _highlightAnimation = new DoubleAnimation();
                _highlightAnimation.From = 0;
                _highlightAnimation.To = 1;
                _highlightAnimation.Duration = TimeSpan.FromSeconds(0.2);
                _highlightAnimation.AutoReverse = true;
                _highlightAnimation.RepeatBehavior = RepeatBehavior.Forever;
                _highlightRect.BeginAnimation(Rectangle.OpacityProperty, _highlightAnimation);
            }
        }
    }
}