Subversion Repositories group.NITPanels

Rev

Blame | Last modification | View Log | RSS feed

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Windows.Forms;

namespace NITNavComm {
    public static class NITPanelsForms {
        public static int ReAssignDevice(NITDevice device) {
            Form form = new Form();
            form.Width = 280;
            form.Height = 160;
            form.AutoSize = false;
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.StartPosition = FormStartPosition.CenterParent;
            form.MaximizeBox = false;
            form.MinimizeBox = false;            

            form.Text = "Re-Assign Device";
            string text = "Set new assignment for " + device.type + "-" + device.id;
            Label label1 = new Label() { Left = 16, Top = 20, Width = 260, Text = text };

            ComboBox assign = new ComboBox() { Left = 16, Top = 45, Width = 40, TabIndex = 0, TabStop = true };
            assign.Items.Add("1");
            assign.Items.Add("2");
            assign.SelectedIndex = assign.FindString(device.assigned.ToString());
            assign.DropDownStyle = ComboBoxStyle.DropDownList;

            Button cmdOk = new Button() { Text = "Ok", Left = 16, Width = 60, Top = 80, TabIndex = 1, TabStop = true };
            cmdOk.Click += (sender, e) => { form.Close(); };
            form.Controls.Add(label1);
            form.Controls.Add(assign);
            form.Controls.Add(cmdOk);
            form.AcceptButton = cmdOk;
            form.ShowDialog();
            return int.Parse(assign.SelectedItem.ToString());
        }
    }
}