aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/Templates/EnumerationFile.cshtml
blob: 36154c3ec798a4aac223894d64f6c75d7e4a78cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Tango Observables Generator
// 
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. Do not modify!
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.ComponentModel;

namespace Tango.BL.Enumerations
{
    public enum @(Model.Name)
    {
        @foreach (var prop in Model.Fields)
        {
    <div>
        /// <summary>
        /// (@prop.Description)
        /// </summary>
        [Description("@(prop.Description)")]
        @(prop.Name) = @(prop.Value),

    </div>
        }
    }
}
ber.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .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;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
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.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.Touch.Controls;

namespace Tango.PPC.Maintenance.Controls
{
    public class ButtonState : DependencyObject
    {
        public Object Value
        {
            get { return (Object)GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }
        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(Object), typeof(ButtonState), new PropertyMetadata(null));

        public Object Content
        {
            get { return (Object)GetValue(ContentProperty); }
            set { SetValue(ContentProperty, value); }
        }
        public static readonly DependencyProperty ContentProperty =
            DependencyProperty.Register("Content", typeof(Object), typeof(ButtonState), new PropertyMetadata(null));
    }

    [ContentProperty(nameof(States))]
    public class StateTouchButton : TouchButton
    {
        public ObservableCollection<Object> States
        {
            get { return (ObservableCollection<Object>)GetValue(StatesProperty); }
            set { SetValue(StatesProperty, value); }
        }
        public static readonly DependencyProperty StatesProperty =
            DependencyProperty.Register("States", typeof(ObservableCollection<Object>), typeof(StateTouchButton), new PropertyMetadata(null, (d, e) => (d as StateTouchButton).OnStatesChanged()));

        public Object SelectedState
        {
            get { return (Object)GetValue(SelectedStateProperty); }
            set { SetValue(SelectedStateProperty, value); }
        }
        public static readonly DependencyProperty SelectedStateProperty =
            DependencyProperty.Register("SelectedState", typeof(Object), typeof(StateTouchButton), new PropertyMetadata(null, (d, e) => (d as StateTouchButton).OnSelectedStateChanged()));

        public StateTouchButton()
        {
            States = new ObservableCollection<object>();
        }

        private void OnStatesChanged()
        {
            if (States != null)
            {
                States.CollectionChanged -= States_CollectionChanged;
                States.CollectionChanged += States_CollectionChanged;
                OnSelectedStateChanged();
            }
        }

        private void OnSelectedStateChanged()
        {
            if (SelectedState == null)
            {
                Content = null;
                return;
            }

            if (States != null)
            {
                var converter = TypeDescriptor.GetConverter(SelectedState.GetType());
                var matchingState = States.OfType<ButtonState>().ToList().FirstOrDefault(x => x.Value != null && converter.ConvertFrom(x.Value).Equals(SelectedState));
                if (matchingState != null)
                {
                    Content = matchingState.Content;
                }
                else
                {
                    Content = null;
                }
            }
            else
            {
                Content = null;
            }
        }

        private void States_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            OnSelectedStateChanged();
        }
    }
}