示例#1
0
 public override List<SpatialManip> GetManips(Shape shape)
 {
   List<SpatialManip> manips = new List<SpatialManip>();
   ShapeCircle root = shape.RootCircle;
   ShapeCircle radiusVectorCircle = GetRadiusVectorCircle(root);
   Dictionary<ShapeCircle, ShapeCircleSettings> shapeSettings = GetCirclesSettingsMap(shape.RootCircle);
   RequestAddManip(manips, shapeSettings, shape, radiusVectorCircle);
   return manips;
 }
示例#2
0
 public override void Render(Shape shape, Renderer renderer, bool selected)
 {
   if(this.Material != null)
   {
     Quad2f imageQuad = GetShapeQuad(shape);
     renderer.DrawImage(this.Material, imageQuad);
     if(selected)
     {
       renderer.PushPen();
       renderer.Pen = SceneConstants.HighlightPen;
       renderer.DrawLine(imageQuad.Vertices, true);
       renderer.PopPen();
     }
   }
 }
示例#3
0
 public override bool TryTouch(Shape shape, Vector2f position, bool selected)
 {
   Circle circle = GetShapeCircle(shape);
   if(circle.CheckPointInside(position))
   {
     return true;
   }
   
   if(selected)
   {
     return TryTouchManip(shape, position, selected);
   }
   
   return false;
 }
示例#4
0
 public override bool TryTouch(Shape shape, Vector2f position, bool selected)
 {
   Quad2f shapeQuad = GetShapeQuad(shape);
   if(Helpers.CheckPointInside(position, shapeQuad.Vertices))
   {
     return true;
   }
   
   if(selected)
   {
     return TryTouchManip(shape, position, selected);
   }
   
   return false;
 }
示例#5
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);
    }
示例#6
0
 public ShapeColorProperty(Shape owner)
 {
   m_Owner = owner;
   this.Value = m_Owner.Color;
 }
示例#7
0
 private void HandleAngleChanged(Shape sender)
 {
   this.Value = this.Degrees;
 }
示例#8
0
 private void HandlePositionChanged(Shape sender)
 {
   this.Value = m_Owner.Position;
 }
示例#9
0
 public NameProperty(Shape owner)
 {
   m_Owner = owner;
   m_Owner.NameChanged += this.OnOwnerRenamed;
   this.Value = owner.Name;
 }
示例#10
0
 private void AddShape(Shape shape)
 {
   m_Shapes.Add(shape);
   if(this.ShapeAdded != null)
   {
     this.ShapeAdded(this, shape);
   }
   
   m_SceneView.Invalidate();
 }
示例#11
0
 public virtual SpatialManip GetSelectionManip(Shape shape)
 {
   if(shape.EditTemplateMode)
   {
     return new RefManip(shape.RootCircle, shape.SceneView);
   }
   else
   {
     PivotManip manip = new PivotManip(shape.RootCircle, shape.SceneView);
     ShapeCircleSettings shapeCircleSettings = GetCircleSettings(shape.RootCircle);
     manip.EnableRotate = shapeCircleSettings.EnableRotate;
     return manip;
   }
 }
示例#12
0
 public abstract void Render(Shape shape, Renderer renderer, bool selected);
示例#13
0
 public abstract List<SpatialManip> GetManips(Shape shape);
示例#14
0
 public abstract bool TryTouch(Shape shape, Vector2f position, bool selected);
示例#15
0
 public void Render(Renderer renderer, Vector2f position)
 {
   Shape shape = new Shape(null);
   shape.Template = this;
   shape.Position = position;
   Render(shape, renderer, false);
 }
示例#16
0
 public bool CheckContains(Shape shape)
 {
   return m_Shapes.Contains(shape);
 }
示例#17
0
 public void RemoveShape(Shape shape)
 {
   History.Change();
   if(!m_Shapes.Remove(shape))
   {
     throw new ArgumentException();
   }
   
   if(this.ShapeRemoved != null)
   {
     this.ShapeRemoved(this, shape);
   }
   
   m_SceneView.Invalidate();
 }
示例#18
0
    protected bool TryTouchManip(Shape shape, Vector2f position, bool selected)
    {
      List<SpatialManip> manips = GetManips(shape);
      manips.Add(GetSelectionManip(shape));
      foreach(SpatialManip manip in manips)
      {
        if(manip.TryTouch(position, selected))
        {
          return true;
        }
      }

      return false;
    }
示例#19
0
    public Shape CreateShape(string name)
    {
      History.Change();
      Shape result = new Shape(m_SceneView);
      if(FindShape(name) != null)
      {
        name = NameGenerator.GenerateName(name, true, CreateObjectNameChecker());
      }

      result.Name = name;
      AddShape(result);
      return result;
    }
示例#20
0
 protected void RequestAddManip(List<SpatialManip> manips,
   Dictionary<ShapeCircle, ShapeCircleSettings> shapeSettings, Shape shape, ShapeCircle circle)
 {
   ShapeCircleSettings circleSettings = shapeSettings[circle];
   if(shape.EditTemplateMode || circleSettings.EnableOffset || circleSettings.EnableRotate)
   {
     PivotManip manip = new PivotManip(circle, shape.SceneView);
     manips.Add(manip);
     if(!shape.EditTemplateMode)
     {
       manip.EnableOffset = circleSettings.EnableOffset;
       manip.EnableRotate = circleSettings.EnableRotate;
     }
   }
 }
示例#21
0
 public PositionProperty(Shape owner)
 {
   m_Owner = owner;
   this.Value = m_Owner.Position;
   m_Owner.PositionChanged += this.HandlePositionChanged;
 }
示例#22
0
 private void OnShapeAdded(Scene.Scene sender, Shape shape)
 {
   TreeNodeEx sceneNode = this.ProjectNode.Nodes.FindFirstByTag(sender);
   sceneNode.Nodes.Add(shape.Name, shape);
   sceneNode.Expand();
 }
示例#23
0
 public AngleProperty(Shape owner)
 {
   m_Owner = owner;
   this.Value = this.Degrees;
   m_Owner.AngleChanged += this.HandleAngleChanged;
 }
示例#24
0
 private void OnShapeRemoved(Scene.Scene sender, Shape shape)
 {
   TreeNodeEx sceneNode = this.ProjectNode.Nodes.FindFirstByTag(sender);
   TreeNodeEx shapeNode = sceneNode.Nodes.FindFirstByTag(shape);
   shapeNode.Remove();
 }
示例#25
0
 public ZOrderProperty(Shape owner)
 {
   m_Owner = owner;
   this.Value = m_Owner.ZOrder;
 }
示例#26
0
 private void OnSelectedShapeChanged(IEditor sender, Shape previous)
 {
   if(previous != null)
   {
     TreeNodeEx node = this.ProjectNode.Nodes.FindFirstRecursivelyByTag(previous);
     if(node != null)
     {
       node.BackColor = node.BackDefaultColor;
     }
   }
   
   if(sender.SelectedShape != null)
   {
     TreeNodeEx node = this.ProjectNode.Nodes.FindFirstRecursivelyByTag(sender.SelectedShape);
     node.Select();
     node.BackColor = Color.Yellow;
   }
 }
 private void OnShapeSelected(IEditor sender, Shape shape)
 {
   m_Property.Value = shape;
 }
示例#28
0
 private void OnNodeClick(TreeViewEx sender, MouseClickArgs args)
 {
   switch((NodeLevel)args.Node.Level)
   {
     case NodeLevel.PROJECT:
     {
       if(args.Button == MouseButtons.Right)
       {
         LightContextMenu contextMenu = new LightContextMenu();
         ItemClickHandler addSceneHandler = delegate()
         {
           CheckValueCorrectnessDelegate checker = Solution.Instance.CreateSceneNameChecker();
           string sceneName = NameGenerator.GenerateName("Scene", checker);
           Scene.Scene scene = m_Scenes.CreateScene(sceneName);
           this.SelectedScene = scene;
         };
         contextMenu.AddItem("Add scene", addSceneHandler);
         contextMenu.Show(this, args.Location);
       }
       
       break;
     }
     
     case NodeLevel.SCENE:
     {
       Scene.Scene scene = (Scene.Scene)args.Node.Tag;
       this.SelectedScene = scene;
       if(args.Button == MouseButtons.Right)
       {
         LightContextMenu contextMenu = new LightContextMenu();
         if(Settings.SceneTranslator != null)
         {
           ItemClickHandler codeToClipboardHandler = delegate()
           {
             try
             {
               string code = Settings.SceneTranslator.Translate(m_Scenes, scene);
               System.Windows.Forms.Clipboard.SetText(code);
             }
             catch(Exception e)
             {
               MessageBox.Show("Translation error: " + e.Message, "Translation error",
                 MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
           };
           contextMenu.AddItem("Copy code to clipboard", codeToClipboardHandler);
         }
         
         ItemClickHandler cloneSceneHandler = delegate()
         {
           CheckValueCorrectnessDelegate checker = Solution.Instance.CreateSceneNameChecker();
           string cloneName = NameGenerator.GenerateName(scene.Name, checker);
           Scene.Scene clone = m_Scenes.CloneScene(scene, cloneName);
           this.SelectedScene = clone;
         };
         ItemClickHandler removeSceneHandler = delegate()
         {
           m_Scenes.RemoveScene(scene);
           this.SelectedScene = null;
         };
         contextMenu.AddItem("Clone scene", cloneSceneHandler);
         contextMenu.AddItem("Remove scene", removeSceneHandler);
         contextMenu.Show(this, args.Location);
       }
       
       break;
     }
     
     case NodeLevel.SHAPE:
     {
       Shape shape = (Shape)args.Node.Tag;
       if(shape != null && m_ShapeSelectedHandler != null)
       {
         m_ShapeSelectedHandler(this, shape);
         m_ShapeSelectedHandler = null;
       }
       else
       {
         this.SelectedShape = shape;
         if(args.Button == MouseButtons.Right)
         {
           LightContextMenu contextMenu = new LightContextMenu();
           ItemClickHandler removeObjectHandler = delegate()
           {
             this.SelectedScene.RemoveShape(shape);
             this.SelectedShape = null;
           };
           contextMenu.AddItem("Remove object", removeObjectHandler);
           contextMenu.Show(this, args.Location);
         }
       }
       
       break;
     }
   }
 }
示例#29
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);
    }
示例#30
0
    public Shape CreateShapeClone(Shape shape)
    {
      History.Change();
      Shape result = shape.Clone(this);
      if(FindShape(result.Name) != null)
      {
        result.Name = NameGenerator.GenerateName(result.Name, true, CreateObjectNameChecker());
      }

      return result;
    }