/// <summary> /// Add new object to draw area. /// Function is called when user left-clicks draw area, /// and one of ToolObject-derived tools is active. /// </summary> /// <param name="drawArea"></param> /// <param name="o"></param> protected void AddNewObject(DrawArea drawArea, DrawObject o) { drawArea.GraphicsList.UnselectAll(); o.Selected = true; drawArea.GraphicsList.Add(o); drawArea.Capture = true; drawArea.Refresh(); drawArea.SetDirty(); }
/// <summary> /// Replace object in specified place. /// Used for Undo. /// </summary> public void Replace(int index, DrawObject obj) { if (index >= 0 && index < graphicsList.Count) { graphicsList.RemoveAt(index); graphicsList.Insert(index, obj); } }
/// <summary> /// Insert object to specified place. /// Used for Undo. /// </summary> public void Insert(int index, DrawObject obj) { if ( index >= 0 && index < graphicsList.Count ) { graphicsList.Insert(index, obj); } }
public void Add(DrawObject obj) { // insert to the top of z-order graphicsList.Insert(0, obj); }
/// <summary> /// Copy fields from this instance to cloned instance drawObject. /// Called from Clone functions of derived classes. /// </summary> protected void FillDrawObjectFields(DrawObject drawObject) { drawObject.selected = this.selected; drawObject.color = this.color; drawObject.penWidth = this.penWidth; drawObject.ID = this.ID; }
// Create this command with DrawObject instance added to the list public CommandAdd(DrawObject drawObject) : base() { // Keep copy of added object this.drawObject = drawObject.Clone(); }