aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/ProtoMessageFile.cs
blob: 2bcdac8b4b19d0aa67cc2ad24d242df8ad807921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.CodeGeneration
{
    public class ProtoMessageFile : CodeObject
    {
        public String Name { get; set; }
        public String Package { get; set; }
        public List<String> Imports { get; set; }

        public List<ProtoProperty> Properties { get; set; }

        public ProtoMessageFile()
        {
            Imports = new List<string>();
            Properties = new List<ProtoProperty>();
        }
    }
}
light .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.Media;
using System.Xml.Serialization;
using Tango.BL;
using Tango.BL.Entities;
using Tango.Core.Commands;
using Tango.SharedUI.Helpers;

namespace Tango.MachineStudio.Technician.TechItems
{
    /// <summary>
    /// Represents a Blower controller item.
    /// </summary>
    /// <seealso cref="Tango.MachineStudio.Technician.TechItems.TechItem" />
    [TechItem(16)]
    public class BlowerItem : TechItem
    {
        public event EventHandler<bool> SetCommandClicked;

        private static List<HardwareBlower> _BlowerConfigurations;
        /// <summary>
        /// Gets or sets the Blower configurations.
        /// </summary>
        public static List<HardwareBlower> BlowerConfigurations
        {
            get { return _BlowerConfigurations; }
            set { _BlowerConfigurations = value; }
        }

        static BlowerItem()
        {
            BlowerConfigurations = new List<HardwareBlower>();

            foreach (var BlowerType in ObservablesStaticCollections.Instance.HardwareBlowerTypes)
            {
                BlowerConfigurations.Add(new HardwareBlower() { HardwareBlowerType = BlowerType });
            }
        }

        private HardwareBlowerType _hardwareBlowerType;
        /// <summary>
        /// Gets or sets the type of the hardware Blower.
        /// </summary>
        [XmlIgnore]
        public HardwareBlowerType HardwareBlowerType
        {
            get { return _hardwareBlowerType; }
            set
            {
                _hardwareBlowerType = value; RaisePropertyChangedAuto(); TechName = _hardwareBlowerType != null ? _hardwareBlowerType.Description : null; ItemGuid = value != null ? value.Guid : null;

                if (_hardwareBlowerType != null)
                {
                    HardwareBlower = BlowerConfigurations.SingleOrDefault(x => x.HardwareBlowerType == _hardwareBlowerType);
                }
            }
        }

        private HardwareBlower _hardwareBlower;
        /// <summary>
        /// Gets or sets the hardware Blower.
        /// </summary>
        [XmlIgnore]
        public HardwareBlower HardwareBlower
        {
            get { return _hardwareBlower; }
            set { _hardwareBlower = value; RaisePropertyChangedAuto(); }
        }

        private bool _isActive;
        [XmlIgnore]
        public bool IsActive
        {
            get { return _isActive; }
            set { _isActive = value; RaisePropertyChangedAuto(); }
        }

        private bool _effectiveActive;
        [XmlIgnore]
        public bool EffectiveActive
        {
            get { return _effectiveActive; }
            set
            {
                _effectiveActive = value;
                RaisePropertyChangedAuto();
                IsActive = _effectiveActive;
            }
        }

        /// <summary>
        /// Gets or sets the set command.
        /// </summary>
        [XmlIgnore]
        public RelayCommand SetCommand { get; set; }

        [XmlIgnore]
        public RelayCommand ToggleActiveCommand { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="BlowerItem"/> class.
        /// </summary>
        public BlowerItem() : base()
        {
            Name = "Blower";
            Description = "Blower Controller";
            Image = ResourceHelper.GetImageFromResources("Images/blower.png");
            Color = Colors.White;
            HardwareBlower = new HardwareBlower();

            SetCommand = new RelayCommand(() => { SetCommandClicked?.Invoke(this, _isActive); });

            ToggleActiveCommand = new RelayCommand(() => 
            {
                SetCommandClicked?.Invoke(this, _isActive);
            });
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BlowerItem"/> class.
        /// </summary>
        /// <param name="BlowerType">Type of the Blower.</param>
        public BlowerItem(HardwareBlowerType BlowerType) : this()
        {
            HardwareBlowerType = BlowerType;
        }

        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns></returns>
        public override TechItem Clone()
        {
            BlowerItem cloned = base.Clone() as BlowerItem;
            cloned.HardwareBlowerType = HardwareBlowerType;
            return cloned;
        }
    }
}