private void setParName(TextBox nameTextBox) { int rowIndex = getRowIndex(null, nameTextBox, null, null, null); string newName = nameTextBox.Text.Trim(); nameTextBox.Text = newName; if (!string.IsNullOrEmpty(newName) && _rootNode.Pars[rowIndex].Name != newName) { UndoManager.PreSave(); Plugin.ResetPar(_rootNode, _rootNode.Pars[rowIndex], newName); _rootNode.Pars[rowIndex].Name = newName; PropertiesDock.UpdatePropertyGrids(); _rootNode.OnPropertyValueChanged(true); UndoManager.Save((Nodes.Behavior)_rootNode); UndoManager.PostSave(); BehaviorTreeView behaviorTreeView = BehaviorTreeViewDock.LastFocused.BehaviorTreeView; if (behaviorTreeView != null) { behaviorTreeView.Redraw(); } } }
internal static PropertiesDock CreateFloatDock(Nodes.BehaviorNode rootBehavior, object node) { PropertiesDock newDock = null; // Ignore the first one. for (int i = 1; i < __propertyGrids.Count; ++i) { if (__propertyGrids[i].SelectedObject == node) { newDock = __propertyGrids[i]; break; } } if (newDock == null) { newDock = new PropertiesDock(); newDock.Show(MainWindow.Instance.DockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Float); } else { newDock.Show(); } newDock._rootBehavior = rootBehavior; newDock.SelectedObject = node; return(newDock); }
private void listView_Click(object sender, EventArgs e) { // check if there is an item selected if (listView.SelectedItems.Count < 1) { return; } // check if this item has a node connected to it. The no-errors message doesn't Nodes.Node node = listView.SelectedItems[0].Tag as Nodes.Node; if (node == null) { return; } // show the behaviour and select the node. NodeViewData nvd = _behaviorTreeList.ShowNode(node); Debug.Check(nvd != null); _behaviorTreeView.SelectedNode = nvd; _behaviorTreeView.ShowNode(nvd); PropertiesDock.InspectObject(nvd.RootBehavior, nvd.Node); }
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); } } }
private void acceptButton_Click(object sender, EventArgs e) { bool themeChanged = (Settings.Default.ColorTheme != themeComboBox.SelectedIndex); bool basicDisplayNameChanged = (Settings.Default.UseBasicDisplayName != useBasicDisplayNameCheckBox.Checked); bool showVersionChanged = (Settings.Default.ShowVersionInfo != showVersionCheckBox.Checked); bool limitDisplayLengthChanged = (Settings.Default.IsDisplayLengthLimited != limitDisplayLengthCheckBox.Checked) || (Settings.Default.LimitedDisplayLength != (int)displayLengthNumericUpDown.Value); bool languageChanged = (Settings.Default.Language != languageComboBox.SelectedIndex); Settings.Default.Language = languageComboBox.SelectedIndex; Settings.Default.ColorTheme = themeComboBox.SelectedIndex; Settings.Default.ShowNodeToolTips = nodeToolTipsCheckBox.Checked; Settings.Default.ShowControlsOnStartUp = showControlsCheckBox.Checked; Settings.Default.CheckLatestVersion = checkBoxChecktheLatest.Checked; Settings.Default.DumpConnectData = dumpConnectDataCheckBox.Checked; Settings.Default.ShowVersionInfo = showVersionCheckBox.Checked; Settings.Default.UseBasicDisplayName = useBasicDisplayNameCheckBox.Checked; Settings.Default.NoResultTreatAsError = checkBoxTweatAsError.Checked; Settings.Default.IsDisplayLengthLimited = limitDisplayLengthCheckBox.Checked; Settings.Default.LimitedDisplayLength = (int)displayLengthNumericUpDown.Value; Settings.Default.ConcurrentProcessBehaviors = concurrentProcessBehaviorsCheckBox.Checked; Nodes.Node.ColorTheme = (Nodes.Node.ColorThemes)Settings.Default.ColorTheme; Behaviac.Design.Nodes.Action.NoResultTreatAsError = Settings.Default.NoResultTreatAsError; if (Settings.Default.ShowProfilingInfo != showProfileCheckBox.Checked) { Settings.Default.ShowProfilingInfo = showProfileCheckBox.Checked; Network.NetworkManager.Instance.SendProfiling(Settings.Default.ShowProfilingInfo); } Plugin.UseBasicDisplayName = Settings.Default.UseBasicDisplayName; //Plugin.ConcurrentProcessBehaviors = Settings.Default.ConcurrentProcessBehaviors; NodeViewData.ShowNodeId = Settings.Default.ShowVersionInfo; NodeViewData.IsDisplayLengthLimited = Settings.Default.IsDisplayLengthLimited; NodeViewData.LimitedDisplayLength = Settings.Default.LimitedDisplayLength; if (themeChanged || basicDisplayNameChanged || showVersionChanged || limitDisplayLengthChanged) { BehaviorTreeViewDock.RefreshAll(); PropertiesDock.UpdatePropertyGrids(); } if (languageChanged) { MessageBox.Show(Resources.LanguageChangedWarning, Resources.Warning, MessageBoxButtons.OK); //MainWindow.Instance.ReloadLayout(); } Settings.Default.FastExportFileType.Clear(); foreach (ListViewItem it in listView1.CheckedItems) { Settings.Default.FastExportFileType.Add(it.Text); } }
void editor_ValueWasChanged(object sender, DesignerPropertyInfo property) { string text = _selectedObject == null ? Resources.Properties : string.Format(Resources.PropertiesOf, _selectedObject.ToString()); Text = text; TabText = text; UndoManager.PreSave(); if (_selectedObject != null) { Nodes.Node node = null; if (_selectedObject is Nodes.Node) { node = (Nodes.Node)_selectedObject; } else if (_selectedObject is Attachments.Attachment) { node = ((Attachments.Attachment)_selectedObject).Node; } if (node != null) { if ((property.Attribute == null || !property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NotPrefabRelated)) && !string.IsNullOrEmpty(node.PrefabName)) { node.HasOwnPrefabData = true; } UndoManager.Save(this._rootBehavior); } } UndoManager.PostSave(); // if we change a DesignerNodeProperty other properties of that object might be affected if (property.Attribute is DesignerNodeProperty || uiPolicy != null && uiPolicy.ShouldUpdatePropertyGrids(property)) { PropertiesDock.UpdatePropertyGrids(); } if (BehaviorTreeViewDock.LastFocused != null && BehaviorTreeViewDock.LastFocused.BehaviorTreeView != null) { BehaviorTreeViewDock.LastFocused.BehaviorTreeView.Redraw(); } }
private void loadLayout(EditModes editMode, string layoutFile, bool bLoadWks) { preLoadLayout(editMode); __layoutFile = layoutFile; // Remove all controls and create a new dockPanel. this.Controls.Clear(); InitializeComponent(); this.RecentWorkspacesMenu = new RecentMenu(this.recentWorkspacesMenuItem, new RecentMenu.ClickedHandler(OnMenuRecentWorkspaces), "SOFTWARE\\Tencent\\Tag\\Behaviac\\MRU"); this.FormClosed -= this.MainWindow_FormClosed; this.FormClosed += this.MainWindow_FormClosed; this.KeyDown -= this.MainWindow_KeyDown; this.KeyDown += this.MainWindow_KeyDown; // Display the file version this.Text = "BehaviacDesigner " + this.ProductVersion; // Set the stored settings for the window this.WindowState = Settings.Default.MainWindowState; if (this.WindowState == FormWindowState.Normal) { this.Size = Settings.Default.MainWindowSize; this.Location = Settings.Default.MainWindowLocation; this.PerformLayout(); } // If we have no stored layout, generate a default one if (behaviorTreeListDock != null) { nodeTreeList.Dispose(); nodeTreeList = null; behaviorTreeList.Dispose(); behaviorTreeList = null; behaviorTreeListDock.Close(); behaviorTreeListDock = null; } bool layoutFileExisting = System.IO.File.Exists(layoutFile); if (layoutFileExisting) { // Add child controls for the dockPanel from the layout file. dockPanel.LoadFromXml(layoutFile, new WeifenLuo.WinFormsUI.Docking.DeserializeDockContent(GetContentFromPersistString)); if (this.behaviorTreeList == null) { //the corrupt layout file was deleted layoutFileExisting = false; } } if (!layoutFileExisting) { BehaviorTreeListDock btlDock = new BehaviorTreeListDock(); RegisterBehaviorTreeList(btlDock); btlDock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockLeft); PropertiesDock dock = new PropertiesDock(); dock.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockRight); } if (this.WindowState == FormWindowState.Maximized) { this.Hide(); this.WindowState = FormWindowState.Minimized; this.WindowState = FormWindowState.Maximized; this.Show(); if (!layoutFileExisting) { this.dockPanel.Size = new Size(this.Size.Width - 20, this.Size.Height - 68); } } postLoadLayout(editMode, bLoadWks); // Make sure the window is focused Focus(); }
internal static PropertiesDock CreateFloatDock(Nodes.BehaviorNode rootBehavior, object node) { PropertiesDock newDock = null; // Ignore the first one. for (int i = 1; i < __propertyGrids.Count; ++i) { if (__propertyGrids[i].SelectedObject == node) { newDock = __propertyGrids[i]; break; } } if (newDock == null) { newDock = new PropertiesDock(); newDock.Show(MainWindow.Instance.DockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Float); } else { newDock.Show(); } newDock._rootBehavior = rootBehavior; newDock.SelectedObject = node; return newDock; }
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; } } }
private void deleteButton_Click(object sender, EventArgs e) { List <int> referredIndexes = new List <int>(); List <int> deletedIndexes = new List <int>(); List <Node.ErrorCheck> errorResult = new List <Node.ErrorCheck>(); for (int rowIndex = _rowControls.Count - 1; rowIndex >= 0; --rowIndex) { RowControl rowControl = _rowControls[rowIndex]; if (rowControl.SelectCheckBox.Checked) { ParInfo par = _rootNode.Pars[rowIndex]; List <Node.ErrorCheck> result = new List <Node.ErrorCheck>(); Plugin.CheckPar(_rootNode, par, ref result); if (result.Count > 0) { referredIndexes.Add(rowIndex); errorResult.AddRange(result); } else { deletedIndexes.Add(rowIndex); } } } if (referredIndexes.Count > 0) { errorResult.Reverse(); referredIndexes.Reverse(); string pars = string.Empty; for (int i = 0; i < referredIndexes.Count; ++i) { int rowIndex = referredIndexes[i]; ParInfo par = _rootNode.Pars[rowIndex]; if (string.IsNullOrEmpty(pars)) { pars += par.Name; } else { pars += ", " + par.Name; } } Debug.Check(BehaviorTreeViewDock.LastFocused != null); string groupLabel = string.Format("Par(s) {0} can not be deleted, which the following nodes are using.", pars); BehaviorTreeViewDock.LastFocused.BehaviorTreeView.ShowErrorDialog("Par Delete Error", groupLabel, errorResult); } if (deletedIndexes.Count > 0) { for (int i = 0; i < deletedIndexes.Count; ++i) { int rowIndex = deletedIndexes[i]; ParInfo par = _rootNode.Pars[rowIndex]; par.ParameterSet -= parameter_ParameterSet; _rootNode.Pars.RemoveAt(rowIndex); this.Hide(); deleteRowControl(rowIndex); this.Show(); PropertiesDock.UpdatePropertyGrids(); _rootNode.OnPropertyValueChanged(true); } UndoManager.Save((Nodes.Behavior)_rootNode); } }