コード例 #1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            ParInfo par = new ParInfo(_rootNode);

            using (ParSettingsDialog parSettingsDialog = new ParSettingsDialog())
            {
                parSettingsDialog.SetPar(par, _rootNode, true);

                if (DialogResult.OK == parSettingsDialog.ShowDialog())
                {
                    par.ParameterSet -= parameter_ParameterSet;
                    par.ParameterSet += parameter_ParameterSet;

                    par.Copy(parSettingsDialog.GetPar());
                    _rootNode.Pars.Add(par);

                    _isParReady = false;
                    {
                        this.Hide();
                        addRowControl(par);
                        this.Show();
                    }
                    _isParReady = true;

                    PropertiesDock.UpdatePropertyGrids();
                    _rootNode.OnPropertyValueChanged(true);

                    UndoManager.Save((Nodes.Behavior)_rootNode);
                }
            }
        }
コード例 #2
0
        private void editSelectedPar(int rowIndex)
        {
            if (rowIndex < 0 || _rootNode == null)
            {
                return;
            }

            ParInfo par = _rootNode.Pars[rowIndex];

            List <Node.ErrorCheck> result = new List <Node.ErrorCheck>();

            Plugin.CheckPar(_rootNode, par, ref result);

            using (ParSettingsDialog parSettingsDialog = new ParSettingsDialog())
            {
                par.ParameterSet -= parameter_ParameterSet;
                parSettingsDialog.SetPar(par, _rootNode, false);

                Type   preType = par.Type;
                string preName = par.Name;

                if (DialogResult.OK == parSettingsDialog.ShowDialog())
                {
                    UndoManager.PreSave();

                    ParInfo curPar  = parSettingsDialog.GetPar();
                    Type    curType = curPar.Type;
                    string  curName = curPar.Name;

                    if (preType != curType)
                    {
                        // If this par is used by others
                        if (result.Count > 0)
                        {
                            string info = string.Format("Par {0} is used in some nodes. Are you sure change its type?", preName);
                            if (DialogResult.Cancel == MessageBox.Show(info, "Warning", MessageBoxButtons.OKCancel))
                            {
                                par.ParameterSet += parameter_ParameterSet;
                                return;
                            }
                        }

                        Plugin.ResetPar(_rootNode, par, string.Empty);
                    }
                    else if (preName != curName)
                    {
                        Plugin.ResetPar(_rootNode, par, curName);
                    }

                    par.Copy(curPar);

                    if (preType != curType)
                    {
                        RowControl rowControl = _rowControls[rowIndex];
                        rowControl.DefaultValueEditor = createValueEditor(rowIndex, curType);
                    }

                    par.ParameterSet += parameter_ParameterSet;
                    par.OnValueChanged();

                    PropertiesDock.UpdatePropertyGrids();
                    _rootNode.OnPropertyValueChanged(true);

                    UndoManager.Save((Nodes.Behavior)_rootNode);

                    UndoManager.PostSave();

                    BehaviorTreeView behaviorTreeView = BehaviorTreeViewDock.LastFocused.BehaviorTreeView;
                    if (behaviorTreeView != null)
                    {
                        behaviorTreeView.Redraw();
                    }
                }
                else
                {
                    par.ParameterSet += parameter_ParameterSet;
                }
            }
        }