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; }
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(); } } }
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; }
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; }
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); }
public ShapeColorProperty(Shape owner) { m_Owner = owner; this.Value = m_Owner.Color; }
private void HandleAngleChanged(Shape sender) { this.Value = this.Degrees; }
private void HandlePositionChanged(Shape sender) { this.Value = m_Owner.Position; }
public NameProperty(Shape owner) { m_Owner = owner; m_Owner.NameChanged += this.OnOwnerRenamed; this.Value = owner.Name; }
private void AddShape(Shape shape) { m_Shapes.Add(shape); if(this.ShapeAdded != null) { this.ShapeAdded(this, shape); } m_SceneView.Invalidate(); }
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; } }
public abstract void Render(Shape shape, Renderer renderer, bool selected);
public abstract List<SpatialManip> GetManips(Shape shape);
public abstract bool TryTouch(Shape shape, Vector2f position, bool selected);
public void Render(Renderer renderer, Vector2f position) { Shape shape = new Shape(null); shape.Template = this; shape.Position = position; Render(shape, renderer, false); }
public bool CheckContains(Shape shape) { return m_Shapes.Contains(shape); }
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(); }
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; }
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; }
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; } } }
public PositionProperty(Shape owner) { m_Owner = owner; this.Value = m_Owner.Position; m_Owner.PositionChanged += this.HandlePositionChanged; }
private void OnShapeAdded(Scene.Scene sender, Shape shape) { TreeNodeEx sceneNode = this.ProjectNode.Nodes.FindFirstByTag(sender); sceneNode.Nodes.Add(shape.Name, shape); sceneNode.Expand(); }
public AngleProperty(Shape owner) { m_Owner = owner; this.Value = this.Degrees; m_Owner.AngleChanged += this.HandleAngleChanged; }
private void OnShapeRemoved(Scene.Scene sender, Shape shape) { TreeNodeEx sceneNode = this.ProjectNode.Nodes.FindFirstByTag(sender); TreeNodeEx shapeNode = sceneNode.Nodes.FindFirstByTag(shape); shapeNode.Remove(); }
public ZOrderProperty(Shape owner) { m_Owner = owner; this.Value = m_Owner.ZOrder; }
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; }
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; } } }
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); }
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; }