Пример #1
0
 public static Variable ShowEditor(AutoSplitEnv env, Type type, Variable source = null)
 {
     using (var form = new VariableEditor(env, type, source))
     {
         if (form.ShowDialog() != DialogResult.Cancel)
         {
             return(form.EditedVariable);
         }
     }
     return(source);
 }
        void btnOK_Click(object sender, EventArgs e)
        {
            if (cbVarTypes.SelectedIndex == -1)
            {
                return;
            }

            Visible        = false;
            EditedVariable = VariableEditor.ShowEditor(_env, (Type)cbVarTypes.SelectedValue);
            if (EditedVariable != null)
            {
                DialogResult = DialogResult.OK;
            }
            else
            {
                Show();
            }
        }
Пример #3
0
        void lstVariables_DoubleClick(object sender, EventArgs e)
        {
            if (lstVariables.SelectedIndex == -1)
            {
                return;
            }

            var splitIndex  = lstVariables.SelectedIndex;
            var selectedVar = (Variable)lstVariables.SelectedItem;

            if (_env.GetEditor(selectedVar.GetType()) != null)
            {
                var varList = ((BindingList <Variable>)lstVariables.DataSource);
                var events  = (selectedVar is Action) == false
                                        ? varList.GetRestrictedEvents()
                                        : varList.Where(v => (v is Action) == false).GetRestrictedEvents();

                var env = _env.Clone();
                env.Events = events ?? _env.Events;

                var newVariable = VariableEditor.ShowEditor(env, selectedVar);
                if (varList.Where(v => v != selectedVar).AreCompatible(newVariable))
                {
                    varList[splitIndex] = newVariable;
                    RefreshEvents();
                }
                else
                {
                    MessageBox.Show($"The condition could not be edited because one or more existing conditions are incompatible with it. Changes were reverted.",
                                    "Condition could not be edited",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("No editor found for this condition type.", "AutoSplit Editor", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }