Exemple #1
0
        private void btnEditChannel_Click(object sender, EventArgs e)
        {
            if (lViewChannels.SelectedItems.Count < 1)
            {
                btnDeleteChannel.Enabled = false;
                btnEditChannel.Enabled   = false;
                return;
            }

            if (!lViewChannels.SelectedItems[0].SubItems[1].ToString().Trim().Equals(""))
            {
                int         ChannelIndex = lViewChannels.Items.IndexOf(lViewChannels.SelectedItems[0]);
                FormChannel frm          = new FormChannel(Program.ConfigMgr.Config.Channels[ChannelIndex]);
                //frm.Channel = Program.ConfigMgr.Config.Channels[ChannelIndex];

                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    Program.ConfigMgr.Config.Channels[ChannelIndex].Enable      = frm.Channel.Enable;
                    Program.ConfigMgr.Config.Channels[ChannelIndex].Name        = frm.Channel.Name;
                    Program.ConfigMgr.Config.Channels[ChannelIndex].DeviceName  = frm.Channel.DeviceName;
                    Program.ConfigMgr.Config.Channels[ChannelIndex].Description = frm.Channel.Description;
                    Program.ConfigMgr.Config.Channels[ChannelIndex].Setting     = frm.Channel.Setting;

                    lViewChannels.Items[ChannelIndex].SubItems[1].Text = frm.Channel.Name;
                    lViewChannels.Items[ChannelIndex].SubItems[2].Text = frm.Channel.DeviceName;
                    lViewChannels.Items[ChannelIndex].SubItems[3].Text = frm.Channel.Description;
                    lViewChannels.Items[ChannelIndex].SubItems[4].Text = frm.Channel.Enable.ToString();
                }
            }
        }
Exemple #2
0
        private void btnAddChannel_Click(object sender, EventArgs e)
        {
            ChannelInstance chi = new ChannelInstance();

            chi.Name        = "";
            chi.Description = "";
            chi.DeviceName  = "";
            chi.Setting     = "";

            FormChannel frm = new FormChannel(chi);

            //frm.Channel = chi;
            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                Program.ConfigMgr.Config.Channels.Add(frm.Channel);

                ListViewItem lvi = new ListViewItem((lViewChannels.Items.Count + 1).ToString());
                lvi.SubItems.Add(frm.Channel.Name);
                lvi.SubItems.Add(frm.Channel.DeviceName);
                lvi.SubItems.Add(frm.Channel.Description);
                lvi.SubItems.Add(frm.Channel.Enable.ToString());
                lViewChannels.Items.Add(lvi);
            }
        }