aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.BL/Serialization/EntitySerializationFlags.cs
blob: 1993b64a09e43d2e2df7cf7b68d56f9b5937d8d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.BL.Serialization
{
    public enum EntitySerializationFlags
    {
        Default = 0,
        IgnoreGuids = 1,
        IgnoreReferenceTypes = 2,
        IgnoreCollections = 4,
        PreserveReferencesHandling = 8,
        Indented = 16,
    }
}
t .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
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);
                        };
                    }
                }
            }
        }
    }
}