protected override void OnLeaveState() { // Unregister events DualityEditorApp.SelectionChanged -= this.DualityEditorApp_SelectionChanged; DualityEditorApp.ObjectPropertyChanged -= this.DualityEditorApp_ObjectPropertyChanged; this.View.SuspendLayout(); toolstrip.SuspendLayout(); toolstrip.Items.Clear(); this.View.Controls.Remove(toolstrip); toolstrip.Dispose(); toolstrip.ResumeLayout(true); this.View.ResumeLayout(true); base.OnLeaveState(); this.View.SetToolbarCamSettingsEnabled(true); this.CameraObj.Active = true; if (selectedBody != null) { selectedBody.IsSelected = false; selectedBody = null; } }
private void DualityEditorApp_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (selectedBody != null) { selectedBody.IsSelected = false; } if (e.Current != null) { GameObject gameObj = e.Current.GameObjects.Where(x => x.GetComponent <Core.ComplexBody>() != null).FirstOrDefault(); if (gameObj != null) { selectedBody = gameObj.GetComponent <Core.ComplexBody>(); selectedBody.IsSelected = true; } } this.View.Refresh(); this.View.Focus(); }
protected override void OnEnterState() { base.OnEnterState(); // Init the custom tile editing toolbar { this.View.SuspendLayout(); toolstrip = new ToolStrip(); toolstrip.SuspendLayout(); toolstrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; toolstrip.Name = "toolstrip"; toolstrip.Text = "ComplexBody Editor Tools"; toolstrip.Renderer = new Duality.Editor.Controls.ToolStrip.DualitorToolStripProfessionalRenderer(); ToolStripButton btnInvHor = new ToolStripButton() { Tag = "Invert Horizontal", Text = "Invert Horizontal", DisplayStyle = ToolStripItemDisplayStyle.Text, AutoToolTip = true }; ToolStripButton btnInvVert = new ToolStripButton() { Tag = "Invert Vertical", Text = "Invert Vertical", DisplayStyle = ToolStripItemDisplayStyle.Text, AutoToolTip = true }; ToolStripButton btnCenterInObj = new ToolStripButton() { Tag = "Center in Object", Text = "Center in Object", DisplayStyle = ToolStripItemDisplayStyle.Text, AutoToolTip = true }; btnInvHor.Click += BtnInvHor_Click; btnInvVert.Click += BtnInvVert_Click; btnCenterInObj.Click += BtnCenterInObj_Click; toolstrip.Items.Add(btnInvHor); toolstrip.Items.Add(btnInvVert); toolstrip.Items.Add(btnCenterInObj); this.View.Controls.Add(toolstrip); this.View.Controls.SetChildIndex(toolstrip, this.View.Controls.IndexOf(this.View.ToolbarCamera)); toolstrip.ResumeLayout(true); this.View.ResumeLayout(true); } this.View.SetToolbarCamSettingsEnabled(false); this.CameraObj.Active = false; // Register events DualityEditorApp.SelectionChanged += this.DualityEditorApp_SelectionChanged; DualityEditorApp.ObjectPropertyChanged += this.DualityEditorApp_ObjectPropertyChanged; GameObject gameObj = DualityEditorApp.Selection.GameObjects.Where(x => x.GetComponent <Core.ComplexBody>() != null).FirstOrDefault(); if (gameObj != null) { selectedBody = gameObj.GetComponent <Core.ComplexBody>(); selectedBody.IsSelected = true; } this.View.Refresh(); this.View.Focus(); }