/// <summary> /// Removes an object with the specified ID. /// </summary> /// <param name="id">ID number of object in diagram.</param> public void RemoveDiagramObject(int id) { for (int i = DiagramObjects.Count - 1; i >= 0; i--) { if (DiagramObjects[i].DiagramID == id) { // Removes object with ID match and trims list to reduce memory consumption. DiagramObjects.RemoveAt(i); DiagramObjects.TrimExcess(); break; } } }
/// <summary> /// Adds an object instance to the internal object list. /// </summary> /// <param name="obj"><code>DiagramObject</code> instance</param> public void AddDiagramObject(DiagramObject obj) { Log.LogMessageDebug($"Object placed: {obj}"); if (ErrorLogger.AllowLogging) { var parameters = obj.GetInternalParameters(); foreach (string key in parameters.Keys) { Log.LogMessageDebug($"{key}: {parameters[key]}"); } } DiagramObjects.Add(obj); }
public void Dispose() { try { for (int i = 0; i < DiagramObjects.Count; i++) { DiagramObjects[i] = null; } DiagramObjects.Clear(); DiagramObjects.TrimExcess(); _DiagramSurface.Dispose(); _DiagramSurface = null; } catch (NullReferenceException e) { Log.LogMessageError("Nullref caught.", e); } catch (Exception e) { ErrorLogger.ShowErrorMessageBox(e); } }