示例#1
0
        private void inputChannels_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo info = inputChannels.HitTest(e.X, e.Y);
            ListViewItem        item = info.Item;

            if (item != null)
            {
                FrmAlarm dialog      = new FrmAlarm(appDirs);
                int      old_channel = Convert.ToInt32(item.SubItems[0].Text);
                dialog.Channel       = old_channel;
                dialog.SoundFilePath = item.SubItems[1].Text;
                dialog.isEdit        = true;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (config.UpdateChannel(old_channel, dialog.Channel, dialog.SoundFilePath))
                    {
                        lastPath    = dialog.SoundFilePath;
                        lastChannel = dialog.Channel;
                        Modified    = true;
                        ConfigToControls();
                    }
                }
            }
        }
示例#2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!changing)
            {
                FrmAlarm dialog = new FrmAlarm(appDirs);
                dialog.isEdit        = false;
                dialog.SoundFilePath = lastPath;
                dialog.Channel       = lastChannel;
                if (config.channels.Count > 0)
                {
                    dialog.Channel += 1;
                }

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (config.channels.ContainsKey(dialog.Channel))
                    {
                        switch (MessageBox.Show(msgAlreadyExists, msgWarning, MessageBoxButtons.YesNoCancel))
                        {
                        case DialogResult.Yes:
                            config.channels.Remove(dialog.Channel);
                            break;

                        case DialogResult.No:
                            break;

                        case DialogResult.Cancel:
                            return;
                        }
                    }

                    // Сохраняем новую аварию
                    if (config.AddChannel(dialog.Channel, dialog.SoundFilePath))
                    {
                        lastPath    = dialog.SoundFilePath;
                        lastChannel = dialog.Channel;
                        Modified    = true;
                        ConfigToControls();
                    }
                }
            }
        }