Exemplo n.º 1
0
 public Scene(ScenesSet scenesSet, ShapeTemplatesSet shapeTemplatesSet, ISceneView sceneView)
 {
   m_ScenesSet = scenesSet;
   m_ShapeTemplatesSet = shapeTemplatesSet;
   m_SceneView = sceneView;
   m_Size = Settings.DefaultSceneSize;
   m_Shapes = new List<Shape>();
   
   this.UserPropertiesFilepath = "SceneProperties.xml";
 }
Exemplo n.º 2
0
 public static void SaveScenes(ScenesSet scenes,
   string filepath, string templatesFilepath)
 {
   Document document = new Document("root");
   DataElement templatesEl = document.RootElement.CreateChild("templates");
   templatesEl.CreateAttribute("filepath", templatesFilepath);
   DataElement scenesContainer = document.RootElement.CreateChild("scenes");
   foreach(Scene scene in scenes)
   {
     DataElement sceneElement = scenesContainer.CreateChild("scene");
     sceneElement.CreateAttribute("name", scene.Name);
     SaveScene(sceneElement, scene);
   }
   
   document.Save(filepath);
 }
Exemplo n.º 3
0
 public static ScenesSet OpenScenes(ISceneView sceneView,
   string filepath, out string templatesFilepath)
 {
   Document document = Document.CreateFromFile(filepath);
   DataElement templatesEl = document.RootElement.GetChild("templates");
   templatesFilepath = templatesEl.GetAttribValue("filepath");
   while(!File.Exists(templatesFilepath))
   {
     DialogResult dialogResult = MessageBox.Show("Would you like to select correct one?",
       "No template descriptor", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
     if(dialogResult == DialogResult.Yes)
     {
       OpenFileDialog openFileDialog = new OpenFileDialog();
       openFileDialog.DefaultExt = "template";
       openFileDialog.Filter = "Template (*.Template)|*.Template";
       openFileDialog.RestoreDirectory = true;
       if(openFileDialog.ShowDialog() == DialogResult.OK)
       {
         templatesFilepath = openFileDialog.FileName;
       }
     }
     else
     {
       return null; /* canceled by user */
     }
   }
   
   ShapeTemplatesSet templates = new ShapeTemplatesSet();
   OpenTemplates(templates, templatesFilepath);
   ScenesSet scenes = new ScenesSet(templates, sceneView);
   DataElement scenesContainer = document.RootElement.GetChild("scenes");
   foreach(DataElement sceneElement in scenesContainer.CollectChildren("scene"))
   {
     string name = sceneElement.GetAttribValue("name");
     Scene scene = scenes.CreateScene(name);
     LoadScene(sceneElement, scene, templates);
   }
   
   return scenes;
 }
Exemplo n.º 4
0
 private void OnSceneRemoved(ScenesSet sender, Scene.Scene scene)
 {
   RemoveScene(scene);
   TreeNodeEx node = this.ProjectNode.Nodes.FindFirstByText(scene.Name);
   node.Remove();
 }
Exemplo n.º 5
0
 private void OnSceneAdded(ScenesSet sender, Scene.Scene scene)
 {
   TreeNodeEx node = this.ProjectNode.Nodes.Add(scene.Name, scene);
   RebuildSceneNode(node);
   AddScene(scene);
   node.Select();
 }
Exemplo n.º 6
0
 private void NotifyNewScenes(ScenesSet previous)
 {
   if(this.NewScenes != null)
   {
     this.NewScenes(this, previous);
   }
 }
Exemplo n.º 7
0
 private void OnSceneRemoved(ScenesSet sender, Scene.Scene scene)
 {
   if(this.SelectedScene == scene)
   {
     this.SelectedScene = null;
   }
 }
Exemplo n.º 8
0
 private void OnNewScenes(Solution sender, ScenesSet previous)
 {
   if(previous != null)
   {
     previous.SceneRemoved -= this.OnSceneRemoved;
   }
   
   m_ProjectExplorer.Scenes = sender.Scenes;
   m_TemplatesExplorer.Scenes = sender.Scenes;
   if(sender.Scenes != null)
   {
     sender.Scenes.SceneRemoved += this.OnSceneRemoved;
   }
 }