private void comboBoxCustomEditProg_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxCustomEditProg.Enabled)
            {
                string progname = comboBoxCustomEditProg.Text.Replace(" (Ext)", "");     // remove the EXT marker

                ActionProgram p = null;
                if (!progname.Equals("New"))
                {
                    p = actionfile.ProgramList.Get(progname);
                }

                if (p != null && p.StoredInSubFile != null)
                {
                    p.EditInEditor(p.StoredInSubFile);         // Edit in the editor..
                }
                else
                {
                    ActionProgramEditForm apf = new ActionProgramEditForm();
                    apf.EditProgram += EditProgram;

                    apf.Init(this.Icon, actioncorecontroller, applicationfolder,
                             AdditionalNames(null),           // no event associated, so just return the globals in effect
                             actionfile.Name, p,
                             actionfile.ProgramList.GetActionProgramList(), "", ModifierKeys.HasFlag(Keys.Shift));

                    DialogResult res = apf.ShowDialog(this);

                    if (res == DialogResult.OK)
                    {
                        ActionProgram np = apf.GetProgram();
                        actionfile.ProgramList.AddOrChange(np);                // replaces or adds (if its a new name) same as rename
                        Usercontrol_RefreshEvent();
                    }
                    else if (res == DialogResult.Abort)   // delete
                    {
                        ActionProgram np2 = apf.GetProgram();
                        actionfile.ProgramList.Delete(np2.Name);
                        Usercontrol_RefreshEvent();
                    }
                }
            }
        }
示例#2
0
        public bool EditProgram(string s, string outername, ActionCoreController cp, string appfolder)
        {
            int colon = s.IndexOf(':');

            if (colon >= 0)
            {
                s = s.Substring(0, colon);
            }
            int bracket = s.IndexOf('(');

            if (bracket >= 0)
            {
                s = s.Substring(0, bracket);
            }

            ActionProgram p = Get(s);

            if (p != null)
            {
                if (p.StoredInSubFile != null)
                {
                    p.EditInEditor(p.StoredInSubFile);         // Edit in the editor..
                }
                else
                {
                    ActionProgramEditForm apf = new ActionProgramEditForm();
                    apf.EditProgram += EditProgram;

                    this.edoutername = outername;
                    this.cp          = cp;
                    this.appfolder   = appfolder;

                    List <BaseUtils.TypeHelpers.PropertyNameInfo> additionalfieldnames = new List <BaseUtils.TypeHelpers.PropertyNameInfo>(); // We don't have any names to contribute going thru this path

                    apf.Init("Action program ", cp.Icon, cp, appfolder, additionalfieldnames, outername, p, GetActionProgramList(), "");

                    System.Windows.Forms.DialogResult res = apf.ShowDialog();

                    if (res == System.Windows.Forms.DialogResult.OK)
                    {
                        ActionProgram np = apf.GetProgram();
                        AddOrChange(np);                // replaces or adds (if its a new name) same as rename
                    }

                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        private void Progedit_Click(object sender, EventArgs e)     //FULL
        {
            bool shift = ModifierKeys.HasFlag(Keys.Shift);

            ActionProgram p = null;

            if (proglist.SelectedIndex > 0)     // exclude NEW from checking for program
            {
                p = actionfile.actionprogramlist.Get(proglist.Text);
            }

            if (p != null && p.StoredInSubFile != null && shift)        // if we have a stored in sub file, but we shift hit, cancel it
            {
                if (ExtendedControls.MessageBoxTheme.Show(this, "Do you want to bring the file back into the main file", "WARNING", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    p.CancelSubFileStorage();
                    shift = false;
                }
                else
                {
                    return; // cancel, abort.
                }
            }

            if (p != null && p.StoredInSubFile != null)
            {
                p.EditInEditor(p.StoredInSubFile);         // Edit in the editor.. this also updated the program steps held internally
            }
            else
            {
                string suggestedname = null;

                if (p == null)        // if no program, create a new suggested name and clear any action data
                {
                    suggestedname = GetSuggestedName();
                    paras.Text    = "";
                }

                ActionProgramEditForm apf = new ActionProgramEditForm();
                apf.EditProgram += (s) =>
                {
                    if (!actionfile.actionprogramlist.EditProgram(s, actionfile.name, actioncorecontroller, applicationfolder))
                    {
                        ExtendedControls.MessageBoxTheme.Show(this, "Unknown program or not in this file " + s);
                    }
                };

                // we init with a variable list based on the field names of the group (normally the event field names got by SetFieldNames)
                // pass in the program if found, and its action data.

                apf.Init("Action program ", this.Icon, actioncorecontroller, applicationfolder, onAdditionalNames(), actionfile.name, p,
                         actionfile.actionprogramlist.GetActionProgramList(), suggestedname, ModifierKeys.HasFlag(Keys.Shift));

                DialogResult res = apf.ShowDialog();

                if (res == DialogResult.OK)
                {
                    ActionProgram np = apf.GetProgram();
                    UpdateProgram(np);
                }
                else if (res == DialogResult.Abort)   // delete
                {
                    ActionProgram np2 = apf.GetProgram();
                    actionfile.actionprogramlist.Delete(np2.Name);
                    cd.action = "";
                    RefreshEvent();
                }
            }
        }
示例#4
0
        private void Progedit_Click(object sender, EventArgs e)
        {
            bool shift = ModifierKeys.HasFlag(Keys.Shift);

            ActionProgram p = null;

            if (proglist.SelectedIndex > 0)     // exclude NEW from checking for program
            {
                p = actionfile.actionprogramlist.Get(proglist.Text);
            }

            if (p != null && p.StoredInSubFile != null && shift)        // if we have a stored in sub file, but we shift hit, cancel it
            {
                if (ExtendedControls.MessageBoxTheme.Show(this, "Do you want to bring the file back into the main file", "WARNING", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    p.CancelSubFileStorage();
                    shift = false;
                }
                else
                {
                    return; // cancel, abort.
                }
            }

            if (p != null && p.StoredInSubFile != null)
            {
                p.EditInEditor(p.StoredInSubFile);         // Edit in the editor.. this also updated the program steps held internally
            }
            else
            {
                string suggestedname = null;

                if (p == null)        // if no program, create a new suggested name and clear any action data
                {
                    suggestedname = eventtype.Text;
                    int n = 2;
                    while (actionfile.actionprogramlist.GetActionProgramList().Contains(suggestedname))
                    {
                        suggestedname = eventtype.Text + "_" + n.ToString(System.Globalization.CultureInfo.InvariantCulture);
                        n++;
                    }

                    paras.Text = "";
                }

                ActionProgramEditForm apf = new ActionProgramEditForm();
                apf.EditProgram += EditProgram;

                // we init with a variable list based on the field names of the group (normally the event field names got by SetFieldNames)
                // pass in the program if found, and its action data.

                apf.Init("Action program ", this.Icon, actioncorecontroller, applicationfolder, onAdditionalNames(eventtype.Text), actionfile.name, p, actionfile.actionprogramlist.GetActionProgramList(), suggestedname, ModifierKeys.HasFlag(Keys.Shift));

                DialogResult res = apf.ShowDialog();

                if (res == DialogResult.OK)
                {
                    ActionProgram np = apf.GetProgram();
                    actionfile.actionprogramlist.AddOrChange(np);                // replaces or adds (if its a new name) same as rename
                    cd.action = np.Name;
                    RefreshIt();
                    proglist.Enabled      = false;
                    proglist.SelectedItem = np.Name;
                    proglist.Enabled      = true;
                }
                else if (res == DialogResult.Abort)   // delete
                {
                    ActionProgram np2 = apf.GetProgram();
                    actionfile.actionprogramlist.Delete(np2.Name);
                    cd.action = "";
                    RefreshIt();
                }
            }
        }