aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs
diff options
context:
space:
mode:
authorVictoria Plitt <Victoria.Plitt@twine-s.com>2023-06-20 16:40:58 +0300
committerVictoria Plitt <Victoria.Plitt@twine-s.com>2023-06-20 16:40:58 +0300
commita5de87ea9863c6e7053e09ed1c2eabf58285af48 (patch)
treef39ec628a4857a1e3e103cc47c91bbadaa67bcd2 /Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs
parenta495866908071d2204c8eab85dc0163308c5e53e (diff)
downloadTango-a5de87ea9863c6e7053e09ed1c2eabf58285af48.tar.gz
Tango-a5de87ea9863c6e7053e09ed1c2eabf58285af48.zip
PPC. Added Real Time Graph
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/GraphHelper.cs36
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs149
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml106
3 files changed, 291 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/GraphHelper.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/GraphHelper.cs
new file mode 100644
index 000000000..d06ed042a
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/GraphHelper.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Media;
+
+namespace Tango.PPC.UI.Graphs
+{
+ public static class GraphHelper
+ {
+ public enum GraphColor
+ {
+ White,
+ Red,
+ Yellow,
+ Green,
+ Orange
+ }
+
+ public static Color GetGraphColor(GraphColor graphColor)
+ {
+ return (Color)Application.Current.Resources[$"Tango_RealTimeGraph_{graphColor.ToString()}"];
+ }
+
+ public static Brush GetGraphBrush(GraphColor graphColor)
+ {
+ return new SolidColorBrush(GetGraphColor(graphColor));
+ }
+
+ public static Color GetGraphStrokeColor()
+ {
+ return (Color)Application.Current.Resources["Tango_RealTimeGraph_ForegroundColor"];
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs
new file mode 100644
index 000000000..303b18892
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.cs
@@ -0,0 +1,149 @@
+using RealTimeGraphX;
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace Tango.PPC.UI.Graphs
+{
+ public class RealTimeGraph : Control
+ {
+ /// <summary>
+ /// Gets or sets the graph controller.
+ /// </summary>
+ public IGraphController Controller
+ {
+ get { return (IGraphController)GetValue(ControllerProperty); }
+ set { SetValue(ControllerProperty, value); }
+ }
+ public static readonly DependencyProperty ControllerProperty =
+ DependencyProperty.Register("Controller", typeof(IGraphController), typeof(RealTimeGraph), new PropertyMetadata(null));
+
+
+ /// <summary>
+ /// Gets or sets the string format of the y-axis.
+ /// </summary>
+ public String StringFormat
+ {
+ get { return (String)GetValue(StringFormatProperty); }
+ set { SetValue(StringFormatProperty, value); }
+ }
+ public static readonly DependencyProperty StringFormatProperty =
+ DependencyProperty.Register("StringFormat", typeof(String), typeof(RealTimeGraph), new PropertyMetadata("0.0"));
+
+
+ /// <summary>
+ /// Gets or sets the display name.
+ /// </summary>
+ public String DisplayName
+ {
+ get { return (String)GetValue(DisplayNameProperty); }
+ set { SetValue(DisplayNameProperty, value); }
+ }
+ public static readonly DependencyProperty DisplayNameProperty =
+ DependencyProperty.Register("DisplayName", typeof(String), typeof(RealTimeGraph), new PropertyMetadata(null));
+
+
+ /// <summary>
+ /// Gets or sets the display units.
+ /// </summary>
+ public String DisplayUnits
+ {
+ get { return (String)GetValue(DisplayUnitsProperty); }
+ set { SetValue(DisplayUnitsProperty, value); }
+ }
+ public static readonly DependencyProperty DisplayUnitsProperty =
+ DependencyProperty.Register("DisplayUnits", typeof(String), typeof(RealTimeGraph), new PropertyMetadata(null));
+
+ /// <summary>
+ /// Gets or sets the graph label visibility.
+ /// </summary>
+ public Visibility GraphLabelVisibility
+ {
+ get { return (Visibility)GetValue(GraphLabelVisibilityProperty); }
+ set { SetValue(GraphLabelVisibilityProperty, value); }
+ }
+ public static readonly DependencyProperty GraphLabelVisibilityProperty =
+ DependencyProperty.Register("GraphLabelVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Visible));
+
+
+ /// <summary>
+ /// Gets or sets the vertical ticks.
+ /// </summary>
+ public int VerticalTicks
+ {
+ get { return (int)GetValue(VerticalTicksProperty); }
+ set { SetValue(VerticalTicksProperty, value); }
+ }
+ public static readonly DependencyProperty VerticalTicksProperty =
+ DependencyProperty.Register("VerticalTicks", typeof(int), typeof(RealTimeGraph), new PropertyMetadata(10));
+
+
+ /// <summary>
+ /// Gets or sets the horizontal ticks.
+ /// </summary>
+ public int HorizontalTicks
+ {
+ get { return (int)GetValue(HorizontalTicksProperty); }
+ set { SetValue(HorizontalTicksProperty, value); }
+ }
+ public static readonly DependencyProperty HorizontalTicksProperty =
+ DependencyProperty.Register("HorizontalTicks", typeof(int), typeof(RealTimeGraph), new PropertyMetadata(10));
+
+ public Brush GridLinesBrush
+ {
+ get { return (Brush)GetValue(GridLinesBrushProperty); }
+ set { SetValue(GridLinesBrushProperty, value); }
+ }
+ public static readonly DependencyProperty GridLinesBrushProperty =
+ DependencyProperty.Register("GridLinesBrush", typeof(Brush), typeof(RealTimeGraph), new PropertyMetadata(null));
+
+ public Visibility HorizontalAxisVisibility
+ {
+ get { return (Visibility)GetValue(HorizontalAxisVisibilityProperty); }
+ set { SetValue(HorizontalAxisVisibilityProperty, value); }
+ }
+ public static readonly DependencyProperty HorizontalAxisVisibilityProperty =
+ DependencyProperty.Register("HorizontalAxisVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Visible));
+
+ public Visibility VerticalAxisVisibility
+ {
+ get { return (Visibility)GetValue(VerticalAxisVisibilityProperty); }
+ set { SetValue(VerticalAxisVisibilityProperty, value); }
+ }
+ public static readonly DependencyProperty VerticalAxisVisibilityProperty =
+ DependencyProperty.Register("VerticalAxisVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Visible));
+
+ public Visibility CurrentValueVisibility
+ {
+ get { return (Visibility)GetValue(CurrentValueVisibilityProperty); }
+ set { SetValue(CurrentValueVisibilityProperty, value); }
+ }
+ public static readonly DependencyProperty CurrentValueVisibilityProperty =
+ DependencyProperty.Register("CurrentValueVisibility", typeof(Visibility), typeof(RealTimeGraph), new PropertyMetadata(Visibility.Collapsed));
+
+ public double CurrentValueFontSize
+ {
+ get { return (double)GetValue(CurrentValueFontSizeProperty); }
+ set { SetValue(CurrentValueFontSizeProperty, value); }
+ }
+ public static readonly DependencyProperty CurrentValueFontSizeProperty =
+ DependencyProperty.Register("CurrentValueFontSize", typeof(double), typeof(RealTimeGraph), new PropertyMetadata(25.0));
+
+ public Thickness CurrentValueMargin
+ {
+ get { return (Thickness)GetValue(CurrentValueMarginProperty); }
+ set { SetValue(CurrentValueMarginProperty, value); }
+ }
+ public static readonly DependencyProperty CurrentValueMarginProperty =
+ DependencyProperty.Register("CurrentValueMargin", typeof(Thickness), typeof(RealTimeGraph), new PropertyMetadata(new Thickness(20)));
+
+ /// <summary>
+ /// Initializes the <see cref="RealTimeGraph"/> class.
+ /// </summary>
+ static RealTimeGraph()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(RealTimeGraph), new FrameworkPropertyMetadata(typeof(RealTimeGraph)));
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml
new file mode 100644
index 000000000..8844f9627
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Graphs/RealTimeGraph.xaml
@@ -0,0 +1,106 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:realTimeGraphX="clr-namespace:RealTimeGraphX.WPF;assembly=RealTimeGraphX.WPF"
+ xmlns:local="clr-namespace:Tango.PPC.UI.Graphs">
+
+ <BitmapImage x:Key="PPC_Screw" UriSource="../Images/screw.png" />
+
+ <Style TargetType="{x:Type local:RealTimeGraph}">
+ <Setter Property="BorderThickness" Value="1"></Setter>
+ <Setter Property="BorderBrush" Value="{StaticResource Tango_RealTimeGraph_OuterBorderBrush}"></Setter>
+ <Setter Property="Padding" Value="20 20 30 20"></Setter>
+ <Setter Property="FontSize" Value="11"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource Tango_RealTimeGraph_ForegroundBrush}"></Setter>
+ <Setter Property="Background" Value="{StaticResource Tango_RealTimeGraph_BackgroundBrush}"></Setter>
+ <Setter Property="GridLinesBrush" Value="{StaticResource Tango_RealTimeGraph_GridLinesBrush}"></Setter>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type local:RealTimeGraph}">
+ <Grid>
+ <Border Background="{TemplateBinding Background}"
+ BorderBrush="{TemplateBinding BorderBrush}"
+ BorderThickness="{TemplateBinding BorderThickness}"
+ CornerRadius="5"
+ Padding="{TemplateBinding Padding}">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="1*"/>
+ </Grid.ColumnDefinitions>
+
+ <Grid Grid.Column="1">
+ <realTimeGraphX:WpfGraphGridLines Controller="{TemplateBinding Controller}" Foreground="{TemplateBinding GridLinesBrush}" />
+ <realTimeGraphX:WpfGraphSurface x:Name="surface" Controller="{TemplateBinding Controller}" BorderThickness="1 0 0 1" BorderBrush="{StaticResource Tango_RealTimeGraph_InnerBorderBrush}" />
+ </Grid>
+
+ <realTimeGraphX:WpfGraphAxisControl Width="70" Visibility="{TemplateBinding VerticalAxisVisibility}" Orientation="Vertical" Controller="{TemplateBinding Controller}" StringFormat="{TemplateBinding StringFormat}" Ticks="{TemplateBinding VerticalTicks}" />
+ <realTimeGraphX:WpfGraphAxisControl Height="35" Visibility="{TemplateBinding HorizontalAxisVisibility}" Orientation="Horizontal" Controller="{TemplateBinding Controller}" Grid.Column="1" Grid.Row="1" Ticks="{TemplateBinding HorizontalTicks}" StringFormat="hh\:mm\:ss"/>
+ </Grid>
+ </Border>
+ <Image HorizontalAlignment="Left" VerticalAlignment="Top" Margin="8" Source="{StaticResource PPC_Screw}" RenderOptions.BitmapScalingMode="Fant" Width="10" Height="10" />
+ <Image HorizontalAlignment="Right" VerticalAlignment="Top" Margin="8" Source="{StaticResource PPC_Screw}" RenderOptions.BitmapScalingMode="Fant" Width="10" Height="10" />
+
+ <Image HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="8" Source="{StaticResource PPC_Screw}" RenderOptions.BitmapScalingMode="Fant" Width="10" Height="10" />
+ <Image HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="8" Source="{StaticResource PPC_Screw}" RenderOptions.BitmapScalingMode="Fant" Width="10" Height="10" />
+ </Grid>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <Style TargetType="{x:Type local:RealTimeGraph}" x:Key="PPC_RealTimeGraph_Flat">
+ <Setter Property="BorderThickness" Value="1"></Setter>
+ <Setter Property="BorderBrush" Value="{StaticResource Tango_RealTimeGraph_OuterBorderBrush}"></Setter>
+ <Setter Property="Padding" Value="0"></Setter>
+ <Setter Property="FontSize" Value="11"></Setter>
+ <Setter Property="Foreground" Value="{StaticResource Tango_RealTimeGraph_ForegroundBrush}"></Setter>
+ <Setter Property="Background" Value="Transparent"></Setter>
+ <Setter Property="GridLinesBrush" Value="{StaticResource Tango_RealTimeGraph_GridLinesBrush}"></Setter>
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type local:RealTimeGraph}">
+ <Grid>
+ <Border Background="{TemplateBinding Background}"
+ BorderBrush="{TemplateBinding BorderBrush}"
+ BorderThickness="{TemplateBinding BorderThickness}"
+ Padding="{TemplateBinding Padding}">
+ <Grid>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="1*"/>
+ <RowDefinition Height="Auto"/>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="Auto"/>
+ <ColumnDefinition Width="1*"/>
+ </Grid.ColumnDefinitions>
+
+ <Grid Grid.Column="1" ClipToBounds="True">
+ <realTimeGraphX:WpfGraphGridLines Controller="{TemplateBinding Controller}" Foreground="{TemplateBinding GridLinesBrush}" Rows="5" Columns="0"/>
+ <realTimeGraphX:WpfGraphSurface Margin="-2 0 0 0" x:Name="surface" Controller="{TemplateBinding Controller}" BorderThickness="0 0 0 0" BorderBrush="{StaticResource Tango_RealTimeGraph_InnerBorderBrush}" />
+ </Grid>
+
+ <realTimeGraphX:WpfGraphAxisControl Width="30" Visibility="{TemplateBinding VerticalAxisVisibility}" Orientation="Vertical" Controller="{TemplateBinding Controller}" StringFormat="{TemplateBinding StringFormat}" Ticks="{TemplateBinding VerticalTicks}" />
+ <realTimeGraphX:WpfGraphAxisControl Height="38" Visibility="{TemplateBinding HorizontalAxisVisibility}" Orientation="Horizontal" Controller="{TemplateBinding Controller}" Grid.Column="1" Grid.Row="1" Ticks="{TemplateBinding HorizontalTicks}" StringFormat="hh\:mm"/>
+ </Grid>
+ </Border>
+
+ <Viewbox IsHitTestVisible="False" Stretch="Uniform" Margin="{TemplateBinding CurrentValueMargin}" Visibility="{TemplateBinding CurrentValueVisibility}">
+ <Grid Width="200" Height="200">
+ <!--<Ellipse Stroke="#38FFFFFF" StrokeThickness="20" />-->
+
+ <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+ <TextBlock Opacity="0.8" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="SemiBold" FontSize="{TemplateBinding CurrentValueFontSize}" Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=Controller.DataSeriesCollection[0].CurrentValue}"></TextBlock>
+ </StackPanel>
+ </Grid>
+ </Viewbox>
+ </Grid>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+</ResourceDictionary> \ No newline at end of file