/// <summary>
        /// Initializes a new instance of the <see cref="AMLInsertCopyFromSourceCommand"/> class. 
        /// A deep copy of the defined source will be created. The Copy is used in the <see cref="Execute"/> Method
        /// where the Copy is added to the Childs of the Target.
        /// </summary>
        /// <param name="target">The target for the Insertion Command.</param>
        /// <param name="source">The source for the Copy Operation.</param>
        public AMLInsertCopyFromSourceCommand(AMLNodeViewModel target, AMLNodeViewModel source)
        {
            _Target = target;
            _node = source.CAEXNode.CloneNode(true);

            DisplayName = "Insert Node";
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Handler for the SelectedElements collection changed event which will propagate the selection event to every PlugIn.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="System.Collections.Specialized.NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 private void SelectedElementsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace)
     {
         AMLNodeViewModel node = e.NewItems.OfType <AMLNodeViewModel>().FirstOrDefault();
         if (node != null)
         {
             PropagateSelectionEventToPlugins(node.CAEXObject);
             CurrentSelectedObject = node.CAEXObject as CAEXBasicObject;
         }
     }
 }
 /// <summary>
 /// Creates and Excutes an <see cref="AMLInsertCopyFromSourceCommand"/> and if the execute Method returns true, the
 /// Command is stored in the defined AMLUndoRedo-Manager for an undo-Action.
 /// </summary>
 /// <param name="manager">The AMLUndoRedo-Manager used to manage the created command.</param>
 /// <param name="target">The target for the Insertion. </param>
 /// <param name="source">The source which is used to create a Copy which than is inserted as a new child in the target.</param>
 /// <returns><c>true</c> if Command is executed and stored for undo, <c>false</c> otherwise.</returns>
 public static bool ExcuteAndInsertCommand(AMLUndoRedoManager manager, AMLNodeViewModel target, AMLNodeViewModel source)
 {
     IAMLCommand cmd = new AMLInsertCopyFromSourceCommand(target, source);
     return manager.ExcuteAndInsertCommand(cmd);
 }