public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { // Uses the IWindowsFormsEditorService to display a // drop-down UI in the Properties window. IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService) provider.GetService(typeof (IWindowsFormsEditorService)); if (edSvc != null) { // Display an angle selection control and retrieve the value. //view.DefaultExt = "ply"; this.view.Filter = "All Know Files|*.ply;*.byu;*.obj;*.off;*.noff;*.cnoff|Ply Files|*.ply|Byu Files|*.byu|Wave Obj Files|*.obj|Off Files|*.off;*.noff;*.cnoff"; if (this.view.ShowDialog() == DialogResult.OK) { TriangleModel model = context.Instance as TriangleModel; if (model != null) { model.Path = this.view.FileName; LoadingModelDialog modelDlg = new LoadingModelDialog(model); if (modelDlg.ShowDialog() == DialogResult.OK) { return this.view.FileName; } else { model = new TriangleModel(); } } } } return ""; }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { // Uses the IWindowsFormsEditorService to display a // drop-down UI in the Properties window. IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { // Display an angle selection control and retrieve the value. //view.DefaultExt = "ply"; this.view.Filter = "All Know Files|*.ply;*.byu;*.obj;*.off;*.noff;*.cnoff|Ply Files|*.ply|Byu Files|*.byu|Wave Obj Files|*.obj|Off Files|*.off;*.noff;*.cnoff"; if (this.view.ShowDialog() == DialogResult.OK) { TriangleModel model = context.Instance as TriangleModel; if (model != null) { model.Path = this.view.FileName; LoadingModelDialog modelDlg = new LoadingModelDialog(model); if (modelDlg.ShowDialog() == DialogResult.OK) { return(this.view.FileName); } else { model = new TriangleModel(); } } } } return(""); }
private void DocumentWindow_DragDrop(object sender, DragEventArgs e) { this.Activate(); ToolboxItem tItem = ((HostToolbox.HostItem)e.Data.GetData(typeof(HostToolbox.HostItem))).ToolboxItem; Assembly asm = Assembly.GetAssembly(typeof(Primitive)); Object obj = asm.CreateInstance(tItem.TypeName, false); //Object obj = Activator.CreateInstance(Type.GetType(tItem.TypeName)); if (obj == null) { return; } if (obj is Primitive) { Primitive p = (Primitive)obj; if (p is TriangleModel) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "All Know Files|*.ply;*.byu;*.obj;*.off;*.noff;*.cnoff|Ply Files|*.ply|Byu Files|*.byu|Wave Obj Files|*.obj|Off Files|*.off;*.noff;*.cnoff"; if (ofd.ShowDialog() == DialogResult.OK) { TriangleModel model = p as TriangleModel; model.Path = ofd.FileName; LoadingModelDialog modelDlg = new LoadingModelDialog(model); modelDlg.Show(); } } UnifiedScenesRepository.Scenes[this.TabText].Primitives.Add(p); } else if (obj is Scene) { DocumentWindow newForm = new DocumentWindow(); obj = newForm.Scene; newForm.Show(this.DockPanel); } else if (obj is Material) { UnifiedScenesRepository.Scenes[this.TabText].Materials.Add((Material)obj); } else if (obj is Light) { UnifiedScenesRepository.Scenes[this.TabText].Lights.Add((Light)obj); } else if (obj is Camera) { UnifiedScenesRepository.Scenes[this.TabText].Cameras.Add((Camera)obj); } PropertyWindow.Instance.PropertyGrid.SelectedObject = obj; //PropertyWindow.Instance.PropertyGrid.SelectedObject = this.Tag; //Type type = Type.GetType(tItem.TypeName,false, true); //PropertyWindow.Instance.PropertyGrid.SelectedObject = //Activator.CreateInstance(Type.GetType(tItem.TypeName), true); }
private void OpenFile(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Scene Files (*.xml, *.scn)|*.xml;*.scn"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { //System.Xml.Serialization.XmlSerializer xml = new System.Xml.Serialization.XmlSerializer(typeof(Scene)); //Scene loaded = (Scene)xml.Deserialize(File.Open(FileName, FileMode.Open)); ObjectXMLSerializer<Scene>.OnDeserialized += (scene => { IEnumerable<TriangleModel> models = from p in scene.Primitives where p is TriangleModel select p as TriangleModel; foreach (TriangleModel model in models) { LoadingModelDialog modelDlg = new LoadingModelDialog(model); modelDlg.Show(); } }); Scene loaded = Scene.Load(openFileDialog.FileName); if (UnifiedScenesRepository.Scenes.ContainsName(loaded.Name)) { DialogResult dr = MessageBox.Show( "Alredy exists an scene opened with the same name!\n Press \"Yes\" to overwrite current scene or \"No\" to rename loaded scene!", "Overwrite scene?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dr == DialogResult.Yes) { UnifiedScenesRepository.Scenes[loaded.Name] = loaded; this.SelectDocument(loaded.Name); return; } else if (dr == DialogResult.Cancel) { return; } loaded.Name = null; loaded = null; } DocumentWindow childForm = new DocumentWindow(loaded); childForm.Show(this.dockPanel); } }