Server/FormEditAction.cs
author StephaneLenclud
Sun, 24 Jul 2016 20:46:34 +0200
changeset 215 5de8f8eaaa54
parent 212 1a0791daa243
child 219 99c407831232
permissions -rw-r--r--
Removing obsolete CEC options.
StephaneLenclud@211
     1
using System;
StephaneLenclud@211
     2
using System.Collections.Generic;
StephaneLenclud@211
     3
using System.ComponentModel;
StephaneLenclud@211
     4
using System.Data;
StephaneLenclud@211
     5
using System.Drawing;
StephaneLenclud@211
     6
using System.Linq;
StephaneLenclud@211
     7
using System.Text;
StephaneLenclud@211
     8
using System.Threading.Tasks;
StephaneLenclud@211
     9
using System.Windows.Forms;
StephaneLenclud@211
    10
using SharpLib.Ear;
StephaneLenclud@211
    11
StephaneLenclud@211
    12
namespace SharpDisplayManager
StephaneLenclud@211
    13
{
StephaneLenclud@214
    14
    /// <summary>
StephaneLenclud@214
    15
    /// Used to populate our action type combobox with friendly names
StephaneLenclud@214
    16
    /// </summary>
StephaneLenclud@214
    17
    class ItemActionType
StephaneLenclud@214
    18
    {
StephaneLenclud@214
    19
        public Type Type;
StephaneLenclud@214
    20
StephaneLenclud@214
    21
        public ItemActionType(Type type)
StephaneLenclud@214
    22
        {
StephaneLenclud@214
    23
            this.Type = type;
StephaneLenclud@214
    24
        }
StephaneLenclud@214
    25
StephaneLenclud@214
    26
        public override string ToString()
StephaneLenclud@214
    27
        {
StephaneLenclud@214
    28
            //Get friendly action name from action attribute.
StephaneLenclud@214
    29
            //That we then show up in our combobox
StephaneLenclud@214
    30
            return SharpLib.Utils.Reflection.GetAttribute<AttributeAction>(Type).Name;
StephaneLenclud@214
    31
        }
StephaneLenclud@214
    32
    }
StephaneLenclud@214
    33
StephaneLenclud@214
    34
StephaneLenclud@214
    35
StephaneLenclud@214
    36
    /// <summary>
StephaneLenclud@214
    37
    /// Action edit dialog form.
StephaneLenclud@214
    38
    /// </summary>
StephaneLenclud@211
    39
    public partial class FormEditAction : Form
StephaneLenclud@211
    40
    {
StephaneLenclud@211
    41
        public SharpLib.Ear.Action Action = null;
StephaneLenclud@211
    42
StephaneLenclud@211
    43
        public FormEditAction()
StephaneLenclud@211
    44
        {
StephaneLenclud@211
    45
            InitializeComponent();
StephaneLenclud@211
    46
        }
StephaneLenclud@211
    47
StephaneLenclud@211
    48
        private void FormEditAction_Load(object sender, EventArgs e)
StephaneLenclud@211
    49
        {
StephaneLenclud@211
    50
            //Populate registered actions
Stephane@212
    51
            foreach (string key in ManagerEventAction.Current.ActionTypes.Keys)
StephaneLenclud@211
    52
            {
StephaneLenclud@214
    53
                ItemActionType item = new ItemActionType(ManagerEventAction.Current.ActionTypes[key]);
StephaneLenclud@214
    54
                comboBoxActionType.Items.Add(item);
StephaneLenclud@211
    55
            }
StephaneLenclud@211
    56
StephaneLenclud@211
    57
            comboBoxActionType.SelectedIndex = 0;
StephaneLenclud@211
    58
        }
StephaneLenclud@211
    59
StephaneLenclud@211
    60
        private void buttonOk_Click(object sender, EventArgs e)
StephaneLenclud@211
    61
        {
StephaneLenclud@214
    62
            Action = (SharpLib.Ear.Action)Activator.CreateInstance(((ItemActionType)comboBoxActionType.SelectedItem).Type);
StephaneLenclud@211
    63
        }
StephaneLenclud@211
    64
StephaneLenclud@211
    65
        private void FormEditAction_Validating(object sender, CancelEventArgs e)
StephaneLenclud@211
    66
        {
StephaneLenclud@211
    67
StephaneLenclud@211
    68
        }
StephaneLenclud@211
    69
    }
StephaneLenclud@211
    70
}