Пример #1
0
        public VariableEditor(AutoSplitEnv env, Type varType, Variable source)
        {
            InitializeComponent();

            _env           = env;
            EditedVariable = source?.Clone(env);

            var typeName = varType.Name.IndexOf("`") != -1
                                ? varType.Name.Remove(varType.Name.IndexOf("`"))
                                : varType.Name;

            Text = typeName + " Editor";

            _editor          = (VariableControl)Activator.CreateInstance(_env.GetEditor(varType), env, source);
            _editor.Dock     = DockStyle.Fill;
            _editor.Margin   = new Padding(_editor.Margin.Left, _editor.Margin.Top, _editor.Margin.Right, 0);
            _editor.TabIndex = 0;
            tlpMain.Controls.Add(_editor);
            tlpMain.SetRow(_editor, 0);
            tlpMain.SetColumn(_editor, 0);
        }
Пример #2
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);
            }
        }