예제 #1
0
파일: Shape.cs 프로젝트: Paltr/SceneEditor
    public Shape Clone(Scene parentScene)
    {
      Shape clone = parentScene.CreateShape(this.Name);
      clone.Template = this.Template;
      clone.EditTemplateMode = this.EditTemplateMode;
      IList<ShapeCircle> circles = this.Circles;
      IList<ShapeCircle> cloneCircles = clone.Circles;
      for(int index = 0; index < circles.Count; ++index)
      {
        ShapeCircle circle = circles[index];
        ShapeCircle cloneCircle = cloneCircles[index];
        cloneCircle.Position = circle.Position;
        cloneCircle.Radius = circle.Radius;
        cloneCircle.Angle = circle.Angle;
      }

      Dictionary<string, IProperty> cloneProperties = clone.UserProperties;
      foreach(var kvp in this.UserProperties)
      {
        IProperty property = cloneProperties[kvp.Key];
        property.TrySetValue(kvp.Value.ToString());
      }

      clone.ZOrder = this.ZOrder;
      return clone;
    }
예제 #2
0
 private static void LoadScene(DataElement sceneElement, Scene scene, ShapeTemplatesSet templates)
 {
   scene.Size = Vector2f.Parse(sceneElement.GetAttribValue("size"));
   DataElement shapesEl = sceneElement.GetChild("shapes");
   foreach(DataElement shapeEl in shapesEl.CollectChildren("shape"))
   {
     string name = shapeEl.GetAttribValue("name");
     Shape shape = scene.CreateShape(name);
     LoadShape(shapeEl, shape, templates);
   }
   
   DataElement propertiesContainer = sceneElement.GetChild("properties");
   if(propertiesContainer != null)
   {
     LoadUserProperties(propertiesContainer, scene);
   }
 }