aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2018-01-07 09:27:42 +0200
committerRoy <roy.mail.net@gmail.com>2018-01-07 09:27:42 +0200
commitdd18ae0c096a34048477297ba848a089a99eece1 (patch)
treebf036a7fac1b0d1f0439fb0e039e15c491e3881a /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs
parent6900c4dea48adb484efc9648e081b7b3f75bd60c (diff)
downloadTango-dd18ae0c096a34048477297ba848a089a99eece1.tar.gz
Tango-dd18ae0c096a34048477297ba848a089a99eece1.zip
Progress on machine designer...
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs74
1 files changed, 73 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs
index ebf45624d..7c2a38401 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MainView.xaml.cs
@@ -10,6 +10,7 @@ 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;
@@ -25,15 +26,54 @@ namespace Tango.MachineStudio.MachineDesigner.Views
public partial class MainView : UserControl
{
private MainViewVM _vm;
+ private Rectangle _highlightRect;
+ private bool _highlightShown;
+ private DoubleAnimation _highlightAnimation;
public MainView()
{
InitializeComponent();
DraggingSurface = dragSufrace;
- this.Loaded += (x, y) =>
+ 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 ApplicationVersion || e.DataContext is ApplicationOsVersion || e.DataContext is ApplicationDisplayPanelVersion)
+ {
+ SetHighlightRegion(gridTablet);
+ }
+ else if (e.DataContext is EmbeddedFirmwareVersion || e.DataContext is EmbeddedSoftwareVersion)
+ {
+ SetHighlightRegion(gridEmbedded);
+ }
+ else if (e.DataContext is Dispenser || e.DataContext is Cartridge || e.DataContext is LiquidType || e.DataContext is MidTankType)
+ {
+ SetHighlightRegion(gridIds);
+ }
}
public DraggingSurface DraggingSurface
@@ -74,6 +114,10 @@ namespace Tango.MachineStudio.MachineDesigner.Views
{
_vm.DropApplicationVersion(e.Draggable.DataContext as ApplicationVersion);
}
+ else if (e.Draggable.DataContext is ApplicationOsVersion)
+ {
+ _vm.DropApplicationOsVersion(e.Draggable.DataContext as ApplicationOsVersion);
+ }
}
private void OnEmbeddedDrop(object sender, DropEventArgs e)
@@ -87,5 +131,33 @@ namespace Tango.MachineStudio.MachineDesigner.Views
_vm.DropEmbeddedSoftware(e.Draggable.DataContext as EmbeddedSoftwareVersion);
}
}
+
+ 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);
+ }
+ }
}
}