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