aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Visuals/YAxisTicks
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2018-02-09 13:41:58 +0200
committerRoy <roy.mail.net@gmail.com>2018-02-09 13:41:58 +0200
commitc8c9606e545f49aae3d9f0524775436adbdf27e9 (patch)
tree83d9fe870f652058af96f32b7159186f5b80f491 /Software/Visual_Studio/Tango.Visuals/YAxisTicks
parentbfcefc0cf95f3b8d5243908753129c79bad8dc8b (diff)
downloadTango-c8c9606e545f49aae3d9f0524775436adbdf27e9.tar.gz
Tango-c8c9606e545f49aae3d9f0524775436adbdf27e9.zip
Added my Controls Library !
Implemented Tech VU Item.
Diffstat (limited to 'Software/Visual_Studio/Tango.Visuals/YAxisTicks')
-rw-r--r--Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml11
-rw-r--r--Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs197
2 files changed, 208 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml b/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml
new file mode 100644
index 000000000..68eca47c0
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml
@@ -0,0 +1,11 @@
+<UserControl x:Class="Tango.Visuals.YAxisTicks"
+ 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"
+ mc:Ignorable="d"
+ d:DesignHeight="300" d:DesignWidth="20">
+ <Grid x:Name="grid">
+
+ </Grid>
+</UserControl>
diff --git a/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs b/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs
new file mode 100644
index 000000000..6aa713d16
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Visuals/YAxisTicks/YAxisTicks.xaml.cs
@@ -0,0 +1,197 @@
+using System;
+using System.Collections.Generic;
+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;
+
+namespace Tango.Visuals
+{
+ /// <summary>
+ /// Interaction logic for TicksAxis.xaml
+ /// </summary>
+ public partial class YAxisTicks : UserControl
+ {
+ #region Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="YAxisTicks"/> class.
+ /// </summary>
+ public YAxisTicks()
+ {
+ InitializeComponent();
+ this.FocusVisualStyle = null;
+ this.Focusable = false;
+ this.Loaded += TicksAxis_Loaded;
+ }
+
+ #endregion
+
+ #region Event Handlers
+
+ /// <summary>
+ /// Handles the Loaded event of the TicksAxis control.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
+ private void TicksAxis_Loaded(object sender, RoutedEventArgs e)
+ {
+ DrawTicks();
+ }
+
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Gets or sets the ticks.
+ /// </summary>
+ public int Ticks
+ {
+ get { return (int)GetValue(TicksProperty); }
+ set { SetValue(TicksProperty, value); }
+ }
+ public static readonly DependencyProperty TicksProperty =
+ DependencyProperty.Register("Ticks", typeof(int), typeof(YAxisTicks), new PropertyMetadata(11, (d, e) => (d as YAxisTicks).DrawTicks()));
+
+ /// <summary>
+ /// Gets or sets the tick template.
+ /// </summary>
+ public DataTemplate TickTemplate
+ {
+ get { return (DataTemplate)GetValue(TickTemplateProperty); }
+ set { SetValue(TickTemplateProperty, value); }
+ }
+ public static readonly DependencyProperty TickTemplateProperty =
+ DependencyProperty.Register("TickTemplate", typeof(DataTemplate), typeof(YAxisTicks), new PropertyMetadata(null, (d, e) => (d as YAxisTicks).DrawTicks()));
+
+ /// <summary>
+ /// Gets or sets the big tick interval.
+ /// </summary>
+ public int? BigTickInterval
+ {
+ get { return (int?)GetValue(BigTickIntervalProperty); }
+ set { SetValue(BigTickIntervalProperty, value); }
+ }
+ public static readonly DependencyProperty BigTickIntervalProperty =
+ DependencyProperty.Register("BigTickInterval", typeof(int?), typeof(YAxisTicks), new PropertyMetadata(null, (d, e) => (d as YAxisTicks).DrawTicks()));
+
+ /// <summary>
+ /// Gets or sets the big tick template.
+ /// </summary>
+ public DataTemplate BigTickTemplate
+ {
+ get { return (DataTemplate)GetValue(BigTickTemplateProperty); }
+ set { SetValue(BigTickTemplateProperty, value); }
+ }
+ public static readonly DependencyProperty BigTickTemplateProperty =
+ DependencyProperty.Register("BigTickTemplate", typeof(DataTemplate), typeof(YAxisTicks), new PropertyMetadata(null));
+
+ #endregion
+
+ #region Methods
+
+ /// <summary>
+ /// Draws the ticks.
+ /// </summary>
+ private void DrawTicks()
+ {
+ grid.Children.Clear();
+ grid.RowDefinitions.Clear();
+
+ for (int i = 0; i < Ticks; i++)
+ {
+ if (i == Ticks - 1)
+ {
+ ContentControl tick = null;
+
+ if (BigTickInterval != null && BigTickTemplate != null)
+ {
+ tick = AddBigTick(i, i);
+ }
+ else
+ {
+ tick = AddTick(i, i);
+ }
+ tick.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
+ grid.Children.Add(tick);
+ }
+ else
+ {
+ ContentControl tick = null;
+
+ RowDefinition row = new RowDefinition();
+ row.Height = new GridLength(1, GridUnitType.Star);
+ grid.RowDefinitions.Add(row);
+
+
+ if (BigTickInterval != null && (double)i % (double)BigTickInterval == 0 && BigTickTemplate != null)
+ {
+ tick = AddBigTick(i, i);
+ }
+ else
+ {
+ tick = AddTick(i, i);
+ }
+
+ grid.Children.Add(tick);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Adds the tick.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <param name="index">The index.</param>
+ /// <returns></returns>
+ private ContentControl AddTick(double value, int index)
+ {
+ ContentControl tick = new ContentControl();
+ tick.Focusable = false;
+ tick.VerticalAlignment = System.Windows.VerticalAlignment.Top;
+ tick.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
+ Grid.SetRow(tick, index);
+
+ if (TickTemplate != null)
+ {
+ tick.ContentTemplate = TickTemplate;
+ }
+
+ return tick;
+ }
+
+ /// <summary>
+ /// Adds big tick.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <param name="index">The index.</param>
+ /// <returns></returns>
+ private ContentControl AddBigTick(double value, int index)
+ {
+ ContentControl tick = new ContentControl();
+ tick.Focusable = false;
+ tick.VerticalAlignment = System.Windows.VerticalAlignment.Top;
+ tick.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
+ Grid.SetRow(tick, index);
+
+ if (BigTickTemplate != null)
+ {
+ tick.ContentTemplate = BigTickTemplate;
+ }
+
+ return tick;
+ }
+
+ #endregion
+
+ }
+}