private void EntityTreeview_AfterSelect(object sender, TreeViewEventArgs e) { WindWakerEntityData.BaseChunk chunk = e.Node.Tag as WindWakerEntityData.BaseChunk; if (chunk != null) { //Temp e.Node.ContextMenuStrip = contextEntityTreeRoot; contextEntityTreeRoot.Tag = chunk; //Find the Editor Type attribute. EntEditorType editorType = null; WindWakerEntityData.PlyrChunk plyr = chunk as WindWakerEntityData.PlyrChunk;; if (chunk.GetType().IsDefined(typeof(EntEditorType), true)) { Console.WriteLine("Yes!"); editorType = (EntEditorType)chunk.GetType().GetCustomAttributes(typeof(EntEditorType), false)[0]; } Type editType = null; if (editorType == null) { editType = typeof(UnsupportedEntity); } else { editType = editorType.EditorType(); } UserControl obj = Activator.CreateInstance(editType) as UserControl; obj.Dock = DockStyle.Fill; PropertiesBox.SuspendLayout(); //Dispose of the control manually right now so that they un-register their event //handler to MainForm::SelectedEntityChanged foreach (Control control in PropertiesBox.Controls) { control.Dispose(); } PropertiesBox.Controls.Clear(); PropertiesBox.Controls.Add(obj); PropertiesBox.ResumeLayout(true); if (editorType != null && MainSplitter.Panel2.Width < editorType.MinEditorWidth) { MainSplitter.SplitterDistance = MainSplitter.Width - editorType.MinEditorWidth; } if (SelectedEntityChanged != null) { SelectedEntityChanged(chunk); } } }
private void MainEditorOnSelectedEntityChanged(WindWakerEntityData.BaseChunk baseChunk) { _curChunk = baseChunk as WindWakerEntityData.PlyrChunk; UpdateEditorUiFromFile(); }