Exemple #1
0
 private static void SaveShapeCircle(DataElement node, ShapeCircle shapeCircle)
 {
   node.CreateAttribute("position", shapeCircle.Position.ToString());
   node.CreateAttribute("radius", shapeCircle.Radius.ToString());
   node.CreateAttribute("angle", shapeCircle.Angle.ToString());
 }
Exemple #2
0
    private static void SaveShape(DataElement node, Shape shape)
    {
      node.CreateAttribute("template_name", shape.Template.Name);
      node.CreateAttribute("z_order", shape.ZOrder.ToString());
      if(shape.EditableColor)
      {
        node.CreateAttribute("color", shape.Color.ToArgb().ToString());
      }

      DataElement circlesEl = node.CreateChild("circles");
      foreach(ShapeCircle circle in shape.Circles)
      {
        SaveShapeCircle(circlesEl.CreateChild("circle"), circle);
      }
      
      DataElement propertiesEl = node.CreateChild("user_properties");
      SaveUserProperties(propertiesEl, shape);
    }
Exemple #3
0
    private static void LoadShape(DataElement node, Shape shape, ShapeTemplatesSet templates)
    {
      string templateName = node.GetAttribValue("template_name");
      ShapeTemplate template = templates.FindTemplate(templateName);
      shape.Template = template;
      shape.ZOrder = float.Parse(node.GetAttribValue("z_order"));

      string colorStr = node.GetAttribValue("color");
      if(colorStr != null)
      {
        shape.Color = Color.FromArgb(int.Parse(colorStr));
      }

      if(shape.EditableColor)
      {
        node.CreateAttribute("color", shape.Color.ToArgb().ToString());
      }

      DataElement circlesEl = node.GetChild("circles");
      IList<DataElement> circleElList = circlesEl.CollectChildren("circle");
      IList<ShapeCircle> circles = shape.Circles;
      for(int index = 0; index < circleElList.Count; ++index)
      {
        DataElement circleEl = circleElList[index];
        ShapeCircle circle = circles[index];
        LoadShapeCircle(circleEl, circle);
      }
      
      DataElement userPropertiesEl = node.GetChild("user_properties");
      LoadUserProperties(userPropertiesEl, shape);
    }
Exemple #4
0
 private static void SaveScene(DataElement sceneElement, Scene scene)
 {
   sceneElement.CreateAttribute("size", scene.Size.ToString());
   DataElement sceneObjectContainer = sceneElement.CreateChild("shapes");
   foreach(Shape shape in scene.Shapes)
   {
     DataElement shapeEl = sceneObjectContainer.CreateChild("shape");
     shapeEl.CreateAttribute("name", shape.Name);
     SaveShape(shapeEl, shape);
   }
   
   DataElement propertiesContainer = sceneElement.CreateChild("properties");
   SaveUserProperties(propertiesContainer, scene);
 }
Exemple #5
0
 private static void SaveRectTemplate(DataElement node, string folder, RectTemplate template)
 {
   SaveBaseTemplate(node, folder, template);
   node.CreateAttribute("normalized", template.Normalized.ToString());
 }
Exemple #6
0
 private static void SaveBaseTemplate(DataElement node, string folder, ShapeTemplate template)
 {
   node.CreateAttribute("name", template.Name);
   node.CreateAttribute("color", template.Color.ToArgb().ToString());
   node.CreateAttribute("editable_color", template.EditableColor.ToString());
   node.CreateAttribute("background", template.Backgroud.ToString());
   DataElement circlesEl = node.CreateChild("circles");
   foreach(ShapeCircle circle in template.RootCircle.AllCircles)
   {
     DataElement circleEl = circlesEl.CreateChild("circle");
     circleEl.CreateAttribute("position", circle.Position.ToString());
     circleEl.CreateAttribute("radius", circle.Radius.ToString());
     circleEl.CreateAttribute("angle", circle.Angle.ToString());
   }
   
   DataElement circlesSettingsEl = node.CreateChild("circles_settings");
   foreach(ShapeTemplate.ShapeCircleSettings settings in template.PerCircleSettings)
   {
     DataElement circleSettingsEl = circlesSettingsEl.CreateChild("settings");
     circleSettingsEl.CreateAttribute("enable_offset", settings.EnableOffset.ToString());
     circleSettingsEl.CreateAttribute("enable_rotate", settings.EnableRotate.ToString());
   }
   
   if(!string.IsNullOrEmpty(template.PropertiesFilepath))
   {
     string relPropertiesFilepath = DirMethods.EvaluateRelativePath(folder, template.PropertiesFilepath);
     node.CreateAttribute("rel_properties_filepath", relPropertiesFilepath);
   }
 }
Exemple #7
0
 private static void SaveTemplate(DataElement node, string folder, ImageTemplate template)
 {
   SaveRectTemplate(node, folder, template);
   string relDiffuseFilepath = DirMethods.EvaluateRelativePath(folder, template.DiffuseFilepath);
   node.CreateAttribute("rel_diffuse_filepath", relDiffuseFilepath);
 }
Exemple #8
0
 private static void SaveTemplate(DataElement node, string folder, CircleTemplate template)
 {
   SaveBaseTemplate(node, folder, template);
   node.CreateAttribute("solid", template.Solid.ToString());
 }