public DynamoNodeButton(ModelBase model, string eventName) : this() { this.model = model; this.eventName = eventName; Click += OnDynamoNodeButtonClick; }
internal void RecordCreatedModel(ModelBase model) { if (null != model) { undoRecorder.BeginActionGroup(); undoRecorder.RecordCreationForUndo(model); undoRecorder.EndActionGroup(); } }
// See RecordModelsForModification below for more details. public void RecordModelForModification(ModelBase model) { if (null != model) { var models = new List<ModelBase> { model }; RecordModelsForModification(models); } }
public ModelModificationUndoHelper(UndoRedoRecorder recorder, ModelBase model) : this(recorder, new [] { model }) { }
public ModelEventArgs(ModelBase model) : this(model, false) { }
/// <summary> /// This is called when a model is deleted from a group /// and UNDO is clicked. /// </summary> /// <param name="model">The model.</param> /// <param name="checkOverlap"> checkoverlap determines whether the selected model is /// completely inside that group</param> internal void AddToSelectedModels(ModelBase model, bool checkOverlap = false) { var list = this.SelectedModels.ToList(); if (list.Where(x => x.GUID == model.GUID).Any()) return; if (!CheckModelIsInsideGroup(model, checkOverlap)) return; list.Add(model); this.SelectedModels = list; this.UpdateBoundaryFromSelection(); }
public void RemoveGroup(ModelBase model) { var annotation = model as AnnotationModel; RemoveAnnotation(annotation); annotation.Dispose(); }
// See RecordModelsForModification below for more details. internal static void RecordModelForModification(ModelBase model, UndoRedoRecorder recorder) { if (null != model) { var models = new List<ModelBase> { model }; RecordModelsForModification(models, recorder); } }
/// <summary> /// Updates the group boundary based on the nodes / notes selection. /// </summary> internal void UpdateBoundaryFromSelection() { var selectedModelsList = selectedModels.ToList(); if (selectedModelsList.Any()) { var groupModels = selectedModelsList.OrderBy(x => x.X).ToList(); //Shifting x by 10 and y to the height of textblock var regionX = groupModels.Min(x => x.X) - ExtendSize; //Increase the Y value by 10. This provides the extra space between // a model and textbox. Otherwise there will be some overlap var regionY = groupModels.Min(y => y.Y) - ExtendSize - (TextBlockHeight == 0.0 ? MinTextHeight : TextBlockHeight); //calculates the distance between the nodes var xDistance = groupModels.Max(x => x.X) - regionX; var yDistance = groupModels.Max(x => x.Y) - regionY; var widthandheight = CalculateWidthAndHeight(); var maxWidth = widthandheight.Item1; var maxHeight = widthandheight.Item2; // InitialTop is to store the Y value without the Textblock height this.InitialTop = groupModels.Min(y => y.Y); var region = new Rect2D { X = regionX, Y = regionY, Width = xDistance + maxWidth + ExtendSize, Height = yDistance + maxHeight + ExtendSize }; this.X = region.X; this.Y = region.Y; this.Width = region.Width; this.Height = region.Height; //Calculate the boundary if there is any overlap ModelBase overlap = null; foreach (var nodes in SelectedModels) { if (!region.Contains(nodes.Rect)) { overlap = nodes; if (overlap.Rect.Top < this.X || overlap.Rect.Bottom > region.Bottom) //Overlap in height - increase the region height { if (overlap.Rect.Bottom - region.Bottom > 0) { this.Height += overlap.Rect.Bottom - region.Bottom + ExtendSize; } region.Height = this.Height; } if (overlap.Rect.Left < this.Y || overlap.Rect.Right > region.Right) //Overlap in width - increase the region width { if (overlap.Rect.Right - region.Right > 0) { this.Width += overlap.Rect.Right - region.Right + ExtendSize; } region.Width = this.Width; } } } //Initial Height is to store the Actual height of the group. //that is the height should be the initial height without the textblock height. if (this.InitialHeight <= 0.0) { this.InitialHeight = region.Height; } } else { this.Width = 0; this.height = 0; } }
public ModelEventArgs(ModelBase model, bool transformCoordinates) { Model = model; PositionSpecified = false; TransformCoordinates = transformCoordinates; }
// See RecordModelsForModification below for more details. internal void RecordModelForModification(ModelBase model) { if (null != model) { List<ModelBase> models = new List<ModelBase>(); models.Add(model); RecordModelsForModification(models); } }
public ModelEventArgs(ModelBase model, double x, double y, bool transformCoordinates) { Model = model; X = x; Y = y; PositionSpecified = true; TransformCoordinates = transformCoordinates; }
private void UpdatePythonNodeContent(ModelBase pythonNode, string value) { var command = new DynCmd.UpdateModelValueCommand( pythonNode.GUID, "ScriptContent", value); dynSettings.Controller.DynamoViewModel.ExecuteCommand(command); }
public void ReloadModel(XmlElement modelData) { ModelBase model = GetModelForElement(modelData); model.Deserialize(modelData, SaveContext.Undo); }
private void UpdatePythonNodeContent(ModelBase pythonNode, string value) { var command = new DynCmd.UpdateModelValueCommand( System.Guid.Empty, pythonNode.GUID, "ScriptContent", value); ViewModel.ExecuteCommand(command); }
/// <summary> /// Record the given model right before it is modified. This results /// in a modification action to be recorded under the current action /// group. Undoing this action will result in the model being reverted /// to the states that it was in before the modification took place. /// </summary> /// <param name="model">The model to be recorded.</param> public void RecordModificationForUndo(ModelBase model) { RecordActionInternal(currentActionGroup, model, UserAction.Modification); redoStack.Clear(); // Wipe out the redo-stack. }
internal void RecordCreatedModel(ModelBase model) { if (null == model) return; using (undoRecorder.BeginActionGroup()) { undoRecorder.RecordCreationForUndo(model); } }
/// <summary> /// The recorder calls this method to determine if a given model has /// already been recorded in the active action group. For an example, /// if there is a connection between NodeA and NodeB, selecting both /// the nodes and deleting them will cause the connection model to be /// recorded twice (when a node is deleted, its connections are being /// recorded for undo). /// </summary> /// <param name="group">The action group to check against.</param> /// <param name="model">The model to check against.</param> /// <returns>Returns true if the model has already been recorded in the /// current action group, or false otherwise.</returns> private bool IsRecordedInActionGroup(XmlElement group, ModelBase model) { if (null == group) throw new ArgumentNullException("group"); if (null == model) throw new ArgumentNullException("model"); Guid guid = model.GUID; foreach (XmlNode childNode in group.ChildNodes) { // See if the model supports Guid identification, in unit test cases // those sample models do not support this so in such cases identity // check will not be performed. // XmlAttribute guidAttribute = childNode.Attributes["guid"]; if (null != guidAttribute && (guid == Guid.Parse(guidAttribute.Value))) return true; // This model was found to be recorded. } return false; }
/// <summary> /// Recalculate the group when a node is disposed /// </summary> /// <param name="node">The node.</param> private void model_Disposed(ModelBase model) { var modelList = this.SelectedModels.ToList(); bool remove = modelList.Remove(model); if (remove) { DeletedModelBases.Add(model); SelectedModels = modelList; UpdateBoundaryFromSelection(); } }
private void RecordActionInternal(XmlElement group, ModelBase model, UserAction action) { if (IsRecordedInActionGroup(group, model)) return; // Serialize the affected model into xml representation // and store it under the current action group. XmlNode childNode = model.Serialize(document, SaveContext.Undo); SetNodeAction(childNode, action.ToString()); group.AppendChild(childNode); }
private bool CheckModelIsInsideGroup(ModelBase model, bool checkOverlap) { if (!checkOverlap) return true; var modelRect = model.Rect; if (this.Rect.Contains(modelRect)) { return true; } return false; }
/// <summary> /// Record the given model right before it has been deleted. This /// results in a deletion action to be recorded under the current action /// group. Undoing this action will result in the model being created /// and re-inserted into the current workspace. /// </summary> /// <param name="model">The model to be recorded.</param> public void RecordDeletionForUndo(ModelBase model) { RecordActionInternal(this.currentActionGroup, model, UserAction.Deletion); this.redoStack.Clear(); // Wipe out the redo-stack. }