aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-24 18:30:53 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-24 18:30:53 +0200
commit11e64f69d00d84974bb09bef6f921c7eeab7c47e (patch)
tree4981a4e079bb4d4c669901ffad6387fcfc9ed1ff /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls
parente82bd25172095f1a521a95179b35cb01db7e8a62 (diff)
downloadTango-11e64f69d00d84974bb09bef6f921c7eeab7c47e.tar.gz
Tango-11e64f69d00d84974bb09bef6f921c7eeab7c47e.zip
Added Graphs Drag & Drop to Developer Module.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml90
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs94
2 files changed, 184 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml
new file mode 100644
index 000000000..687bc6030
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml
@@ -0,0 +1,90 @@
+<UserControl x:Class="Tango.MachineStudio.Common.Controls.RealTimeGraphControl"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+ xmlns:graphEx="clr-namespace:RealTimeGraphEx.FastGraphs;assembly=RealTimeGraphEx"
+ xmlns:components="clr-namespace:RealTimeGraphEx.Components;assembly=RealTimeGraphEx"
+ xmlns:converters="clr-namespace:Tango.MachineStudio.Common.Converters"
+ xmlns:local="clr-namespace:Tango.MachineStudio.Common.Controls"
+ mc:Ignorable="d"
+ d:DesignHeight="150" d:DesignWidth="300">
+
+ <UserControl.Resources>
+ <ResourceDictionary>
+ <ResourceDictionary.MergedDictionaries>
+ <!--RealTimeGraphEx-->
+ <ResourceDictionary Source="pack://application:,,,/RealTimeGraphEx;component/Resources/Resources.xaml"></ResourceDictionary>
+ <ResourceDictionary Source="../Resources/MaterialDesign.xaml"></ResourceDictionary>
+
+ <ResourceDictionary>
+ <Style TargetType="ContentControl" x:Key="graphContent">
+ <Style.Setters>
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <Grid MouseEnter="Graph_MouseEnter" MouseLeave="Graph_MouseLeave" ClipToBounds="True">
+ <ContentControl Content="{Binding}"></ContentControl>
+ <Grid Opacity="0.8" HorizontalAlignment="Stretch" VerticalAlignment="Top" ClipToBounds="True" Height="35" Margin="0 -35 0 0">
+ <StackPanel Orientation="Horizontal" Margin="5" HorizontalAlignment="Right" VerticalAlignment="Top">
+ <Button Margin="0 0 5 0" Click="OnGraphFullScreen" ToolTip="Full Screen" Width="24" Height="24" BorderBrush="Transparent" Background="{StaticResource AccentColorBrush}" Style="{StaticResource MaterialDesignFloatingActionAccentButton}" >
+ <materialDesign:PackIcon Kind="Fullscreen" HorizontalAlignment="Right" Width="20" Height="20" Foreground="{StaticResource WhiteBrush}" />
+ </Button>
+ <Button Click="OnGraphRemove" ToolTip="Remove" Width="24" Height="24" BorderBrush="Transparent" Background="#FF7777" Style="{StaticResource MaterialDesignFloatingActionAccentButton}" >
+ <materialDesign:PackIcon Kind="CloseCircle" HorizontalAlignment="Right" Width="20" Height="20" Foreground="{StaticResource WhiteBrush}" />
+ </Button>
+ </StackPanel>
+ </Grid>
+ </Grid>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style.Setters>
+ </Style>
+ </ResourceDictionary>
+
+ <ResourceDictionary>
+ <converters:SecondsToGraphPointsConverter x:Key="secondsToPoints"></converters:SecondsToGraphPointsConverter>
+ </ResourceDictionary>
+ </ResourceDictionary.MergedDictionaries>
+ </ResourceDictionary>
+ </UserControl.Resources>
+
+ <Grid>
+ <!--Temperature-->
+ <ContentControl Style="{StaticResource graphContent}" Margin="0 0 5 5" MinHeight="5">
+ <Grid>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="40"/>
+ <ColumnDefinition Width="438*"/>
+ </Grid.ColumnDefinitions>
+
+ <Border BorderBrush="{StaticResource AccentColorBrush}" BorderThickness="1 1 0 1">
+ <StackPanel Orientation="Horizontal">
+ <components:YAxisScroll Interval="6" Graph="{Binding ElementName=Graph}" Width="35" Foreground="{StaticResource MaterialDesignLightForeground}" VerticalOffset="-5" FontSize="8" StringFormat="#0.0"></components:YAxisScroll>
+ <components:YAxisTicks SmallTickTemplate="{StaticResource graphTicksTemplate}" Width="5" SmallTicks="6" Foreground="{StaticResource MaterialDesignLightForeground}" BigTicks="10" Graph="{Binding ElementName=Graph}"></components:YAxisTicks>
+ </StackPanel>
+ </Border>
+ <Border Grid.Column="1" BorderThickness="1" BorderBrush="{StaticResource borderBrush}" Background="{DynamicResource graphBackground}" Margin="5 0 0 0">
+ <graphEx:RealTimeGraphExLineErase x:Name="Graph" x:FieldModifier="public" Antialiased="True" RefreshRate="30" MarkerColor="{StaticResource graphsMarkerColor}" FillGraph="False" Stroke="DodgerBlue">
+ <graphEx:RealTimeGraphExLineErase.Components>
+ <components:MouseValueToolTip ToolTipTemplate="{StaticResource graphTooltipTemplate}" />
+ <components:GridLines Rows="4" Columns="6" GridBrush="{DynamicResource graphGridLinesBrush}"></components:GridLines>
+ </graphEx:RealTimeGraphExLineErase.Components>
+ <graphEx:RealTimeGraphExLineErase.InnerContent>
+ <Grid>
+ <Label Style="{StaticResource graphLabel}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl,AncestorLevel=2},Path=SensorName,FallbackValue='Dispenser Motor'}"></TextBlock>
+ <TextBlock Foreground="Gray" Margin="10 0 0 0" FontFamily="Sylfaen Regular" VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl,AncestorLevel=2},Path=SensorUnits,FallbackValue='(hz)'}"></TextBlock>
+ </StackPanel>
+ </Label>
+ </Grid>
+ </graphEx:RealTimeGraphExLineErase.InnerContent>
+ </graphEx:RealTimeGraphExLineErase>
+ </Border>
+ </Grid>
+ </ContentControl>
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs
new file mode 100644
index 000000000..6396ab91a
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Controls/RealTimeGraphControl.xaml.cs
@@ -0,0 +1,94 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+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.Animation;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.MachineStudio.Common.Controls
+{
+ /// <summary>
+ /// Interaction logic for RealTimeGraphControl.xaml
+ /// </summary>
+ public partial class RealTimeGraphControl : UserControl
+ {
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets the name of the sensor.
+ /// </summary>
+ public String SensorName
+ {
+ get { return (String)GetValue(SensorNameProperty); }
+ set { SetValue(SensorNameProperty, value); }
+ }
+ public static readonly DependencyProperty SensorNameProperty =
+ DependencyProperty.Register("SensorName", typeof(String), typeof(RealTimeGraphControl), new PropertyMetadata(null));
+
+ /// <summary>
+ /// Gets or sets the sensor units.
+ /// </summary>
+ public String SensorUnits
+ {
+ get { return (String)GetValue(SensorUnitsProperty); }
+ set { SetValue(SensorUnitsProperty, value); }
+ }
+ public static readonly DependencyProperty SensorUnitsProperty =
+ DependencyProperty.Register("SensorUnits", typeof(String), typeof(RealTimeGraphControl), new PropertyMetadata(null));
+
+
+ #endregion
+
+ #region Events
+
+ public event EventHandler GraphRemoveButtonPressed;
+ public event EventHandler GraphFullScreenButtonPressed;
+
+ #endregion
+
+ public RealTimeGraphControl()
+ {
+ InitializeComponent();
+ }
+
+ private void OnGraphFullScreen(object sender, RoutedEventArgs e)
+ {
+ GraphFullScreenButtonPressed?.Invoke(this, new EventArgs());
+ }
+
+ private void Graph_MouseEnter(object sender, MouseEventArgs e)
+ {
+ Grid mainGrid = sender as Grid;
+ var headerGrid = mainGrid.Children.OfType<Grid>().ToList().First();
+ ThicknessAnimation ani = new ThicknessAnimation();
+ ani.To = new Thickness(0, 0, 0, 0);
+ ani.Duration = TimeSpan.FromSeconds(0.2);
+ headerGrid.BeginAnimation(Grid.MarginProperty, ani);
+ }
+
+ private void Graph_MouseLeave(object sender, MouseEventArgs e)
+ {
+ Grid mainGrid = sender as Grid;
+ var headerGrid = mainGrid.Children.OfType<Grid>().ToList().First();
+ ThicknessAnimation ani = new ThicknessAnimation();
+ ani.To = new Thickness(0, -35, 0, 0);
+ ani.Duration = TimeSpan.FromSeconds(0.2);
+ headerGrid.BeginAnimation(Grid.MarginProperty, ani);
+ }
+
+ private void OnGraphRemove(object sender, RoutedEventArgs e)
+ {
+ GraphRemoveButtonPressed?.Invoke(this, new EventArgs());
+ }
+ }
+}