private void treeControl_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { TreeViewItem treeItem = e.NewValue as TreeViewItem; if (treeItem == null) { return; } IconTextItem item = treeItem.Header as IconTextItem; if (item == null) { return; } string name = item.Name; MogitorsRoot mogRoot = MogitorsRoot.Instance; BaseEditor curEdit = mogRoot.FindObject(name, 0); if (curEdit != mogRoot.Selected) { if (mogRoot.Selected != null) { mogRoot.Selected.IsSelected = false; } if (curEdit != null) { curEdit.IsSelected = true; } } }
private void SetupMogre(string pluginFileName, string configFileName, string logFileName) { // Create the main mogre object this.mogreRoot = new Mogre.Root(pluginFileName); Mogre.LogManager.Singleton.SetLogDetail(Mogre.LoggingLevel.LL_BOREME); SetupMogreResources(); SetupDirectX(); // Initialize without creating window this.mogreRoot.Initialise(false); // don't create a window this.mogitorsRoot = MogitorsRoot.Instance; }
private void treeControl_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { TreeViewItem treeItem = e.NewValue as TreeViewItem; if (treeItem == null) { return; } if (treeItem.Parent == null) { if (MogitorsRoot.Instance.Selected != null) { MogitorsRoot.Instance.Selected.IsSelected = false; } MogitorsRoot.Instance.RootEditor.IsSelected = true; return; } IconTextItem item = treeItem.Header as IconTextItem; if (item == null) { e.Handled = true; return; } int id = (treeItem.Tag != null) ? (int)treeItem.Tag : 0; int level = 0; while (treeItem.Tag != null) { treeItem = treeItem.Parent as TreeViewItem; item = treeItem.Header as IconTextItem; ++level; } string name = item.Name; MogitorsRoot mogRoot = MogitorsRoot.Instance; if (this.materialEditor == null || name != this.materialEditor.Name || level != this.materialEditor.PropertyLevel || id != this.materialEditor.PropertyId) { if (mogRoot.Selected != null) { mogRoot.Selected.IsSelected = false; } if (this.materialEditor != null) { this.materialEditor.Destroy(false); } BaseEditor parentEd = null; Mogre.NameValuePairList parameters = new Mogre.NameValuePairList(); parameters["Name"] = name; this.materialEditor = MaterialEditor.Factory.CreateObject(ref parentEd, parameters) as MaterialEditor; if (this.materialEditor != null && this.materialEditor.Load()) { this.materialEditor.TreeItemHandle = treeItem; this.materialEditor.SetPropertiesLevel(level, id); this.materialEditor.IsSelected = true; } } }
private void CommandBinding_NewCmdExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { MogitorsRoot mogRoot = MogitorsRoot.Instance; if (!(mogRoot.TerminateScene())) { return; } ProjectOptions opt = mogRoot.ProjectOptions; opt.IsNewProject = true; opt.ProjectName = ""; opt.ProjectDir = MogitorsSystem.Instance.ProjectsDirectory; opt.SceneManagerName = "OctreeSceneManager"; opt.TerrainDirectory = "Terrain"; opt.ResourceDirectories.Clear(); opt.Cameras.Clear(); opt.SelectionBBColourForSerializer = Color.FromRgb(255, 255, 255); opt.HighlightBBColourForSerializer = Color.FromRgb(232, 48, 48); SettingsDialog dlg = new SettingsDialog(opt); if (dlg.ShowDialog() == true) { string fileName = MogitorsSystem.Instance.CombinePath(mogRoot.ProjectOptions.ProjectDir, mogRoot.ProjectOptions.ProjectName + ".mogscene"); fileName = MogitorsSystem.Instance.GetFullPath(fileName); XmlTextWriter textWriter = new XmlTextWriter(fileName, System.Text.Encoding.Unicode); textWriter.Formatting = Formatting.Indented; textWriter.WriteStartDocument(); // XML Root textWriter.WriteStartElement("MogitorScene"); // Write project options mogRoot.WriteProjectOptions(textWriter, true); // Write new scene definition textWriter.WriteStartElement("Object"); textWriter.WriteStartAttribute("Type"); textWriter.WriteValue(mogRoot.ProjectOptions.SceneManagerName); textWriter.WriteEndAttribute(); textWriter.WriteStartAttribute("SceneManagerType"); textWriter.WriteValue(mogRoot.ProjectOptions.SceneManagerName); textWriter.WriteEndAttribute(); textWriter.WriteStartAttribute("Name"); textWriter.WriteValue("SceneManager"); textWriter.WriteEndAttribute(); textWriter.WriteStartAttribute("Ambient"); textWriter.WriteValue("1.000 1.000 1.000"); textWriter.WriteEndAttribute(); textWriter.WriteEndElement(); textWriter.WriteEndElement(); textWriter.WriteEndDocument(); textWriter.Close(); mogRoot.LoadScene(fileName); } this.statusString.Text = "New scene created"; }