/// <summary> /// Return list of graphic objects. /// Used if client program needs to make its own usage of /// graphics objects, like save them in some persistent storage. /// </summary> public PropertiesGraphicsBase[] GetListOfGraphicObjects() { PropertiesGraphicsBase[] result = new PropertiesGraphicsBase[graphicsList.Count]; int i = 0; foreach (GraphicsBase g in graphicsList) { result[i++] = g.CreateSerializedObject(); } return(result); }
// Replace objects in graphicsList with objects from clone list private static void ReplaceObjects(VisualCollection graphicsList, List <PropertiesGraphicsBase> list) { for (int i = 0; i < graphicsList.Count; i++) { PropertiesGraphicsBase replacement = null; foreach (PropertiesGraphicsBase o in list) { if (o.ID == ((GraphicsBase)graphicsList[i]).Id) { replacement = o; break; } } if (replacement != null) { // Replace object with its clone graphicsList.RemoveAt(i); graphicsList.Insert(i, replacement.CreateGraphics()); } } }
// Create this command with DrawObject instance added to the list public CommandAdd(GraphicsBase newObject) : base() { // Keep copy of added object this.newObjectClone = newObject.CreateSerializedObject(); }