diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-10-10 16:55:44 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-10-10 16:55:44 +0300 |
| commit | 79eb19cbd10785a7dbc972bc0b26817932237419 (patch) | |
| tree | e36176fc94ce6f26efc89b006d7e6faf7e4398cb /Software/Visual_Studio/SideChains/RealTimeGraphX.WPF/Components/GraphAxisPanel.cs | |
| parent | df9197240ba5a643ce1599f36b7e3dd34aad6a60 (diff) | |
| download | Tango-79eb19cbd10785a7dbc972bc0b26817932237419.tar.gz Tango-79eb19cbd10785a7dbc972bc0b26817932237419.zip | |
Sign-out works !
Fixed issue where color conversion was busy while not in research module but research module in job view.
Added new RealTimeGraphX !
Diffstat (limited to 'Software/Visual_Studio/SideChains/RealTimeGraphX.WPF/Components/GraphAxisPanel.cs')
| -rw-r--r-- | Software/Visual_Studio/SideChains/RealTimeGraphX.WPF/Components/GraphAxisPanel.cs | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/Software/Visual_Studio/SideChains/RealTimeGraphX.WPF/Components/GraphAxisPanel.cs b/Software/Visual_Studio/SideChains/RealTimeGraphX.WPF/Components/GraphAxisPanel.cs new file mode 100644 index 000000000..55edfa314 --- /dev/null +++ b/Software/Visual_Studio/SideChains/RealTimeGraphX.WPF/Components/GraphAxisPanel.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace RealTimeGraphX.WPF.Components +{ + /// <summary> + /// Represents a panel that will align its children in an axis like arrangement. + /// </summary> + /// <seealso cref="System.Windows.Controls.Grid" /> + public class GraphAxisPanel : Grid + { + /// <summary> + /// Gets or sets the panel orientation. + /// </summary> + public Orientation Orientation + { + get { return (Orientation)GetValue(OrientationProperty); } + set { SetValue(OrientationProperty, value); } + } + public static readonly DependencyProperty OrientationProperty = + DependencyProperty.Register("Orientation", typeof(Orientation), typeof(GraphAxisPanel), new PropertyMetadata(Orientation.Vertical)); + + /// <summary> + /// Initializes a new instance of the <see cref="GraphAxisPanel"/> class. + /// </summary> + public GraphAxisPanel() + { + Loaded += VerticalAxisPanel_Loaded; + } + + /// <summary> + /// Handles the Loaded event of the VerticalAxisGrid 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 VerticalAxisPanel_Loaded(object sender, RoutedEventArgs e) + { + UpdatePanel(); + } + + /// <summary> + /// Updates the panel. + /// </summary> + private void UpdatePanel() + { + RowDefinitions.Clear(); + ColumnDefinitions.Clear(); + + + if (Orientation == Orientation.Vertical) + { + for (int i = 0; i < InternalChildren.Count; i++) + { + FrameworkElement element = InternalChildren[i] as FrameworkElement; + + if (i < InternalChildren.Count - 1) + { + RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Star) }); + Grid.SetRow(element, i); + element.VerticalAlignment = VerticalAlignment.Top; + + element.SizeChanged += (_, __) => + { + element.Margin = new Thickness(0, (element.ActualHeight / 2) * -1, 0, 0); + }; + } + else + { + Grid.SetRow(element, i); + element.VerticalAlignment = VerticalAlignment.Bottom; + + element.SizeChanged += (_, __) => + { + element.Margin = new Thickness(0, 0, 0, (element.ActualHeight / 2) * -1); + }; + } + } + } + else + { + for (int i = 0; i < InternalChildren.Count; i++) + { + FrameworkElement element = InternalChildren[i] as FrameworkElement; + + if (i < InternalChildren.Count - 1) + { + ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); + Grid.SetColumn(element, i); + element.HorizontalAlignment = HorizontalAlignment.Left; + + element.SizeChanged += (_, __) => + { + element.Margin = new Thickness((element.ActualWidth / 2) * -1, 0, 0, 0); + }; + } + else + { + Grid.SetColumn(element, i); + element.HorizontalAlignment = HorizontalAlignment.Right; + + element.SizeChanged += (_, __) => + { + element.Margin = new Thickness(0, 0, (element.ActualWidth / 2) * -1, 0); + }; + } + } + } + } + } +} |
