Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        private void exportChunksOfTypeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                FileStream   fs     = new FileStream(saveFileDialog1.FileName, FileMode.Create);
                BinaryWriter stream = new BinaryWriter(fs);

                WindWakerEntityData.BaseChunk chunk = (WindWakerEntityData.BaseChunk)contextEntityTreeRoot.Tag;
                chunk.WriteData(stream);

                fs.Flush();
                fs.Close();
            }
        }
 private void MainEditorOnSelectedEntityChanged(WindWakerEntityData.BaseChunk baseChunk)
 {
     _curChunk = baseChunk as WindWakerEntityData.TresChunk;
     UpdateEditorUiFromFile();
 }