Example #1
0
        private void EditAutomationButton_Click(object sender, EventArgs e)
        {
            if (edit_AutomationNameInputfield.Text.Length > 0 && edit_Message.Text.Length <= 470 && edit_Message.Text.Length > 4 && edit_Minutes.SelectedItem != null && Int32.Parse(edit_Minutes.SelectedItem.ToString()) >= 5 && autoList.SelectedItem != null)
            {
                Automation auto = autoManager.GetAutomation(autoList.SelectedItem.ToString());
                if (auto != null)
                {
                    string prevString = autoList.SelectedItem.ToString();
                    string tmpString  = edit_AutomationNameInputfield.Text;
                    if (tmpString.Length > 20)
                    {
                        tmpString = tmpString.Substring(0, 20);
                    }

                    if (autoManager.DoesNameAlreadyExist(tmpString))
                    {
                        MessageBox.Show("This name does already exist. Try again.", "Name already exist!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    auto.automationName = tmpString;
                    auto.interval       = Int32.Parse(edit_Minutes.SelectedItem.ToString());
                    auto.active         = edit_Active.Checked;
                    auto.message        = edit_Message.Text;

                    edit_AutomationNameInputfield.Text = "";
                    edit_Minutes.SelectedIndex         = -1;
                    edit_Minutes.Focus();
                    edit_Active.Checked = false;
                    edit_Message.Text   = "";

                    autoList.Items[autoList.Items.IndexOf(prevString)] = tmpString;
                }
            }
        }