示例#1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method is used to copy/paste a new item.</summary>
        ///
        /// <param name="copyItem">The item to copy/paste.</param>
        /// <param name="savePaste">Flag to determine whether to save the results of the paste.</param>
        ///--------------------------------------------------------------------------------
        public DiagramViewModel PasteDiagram(DiagramViewModel copyItem, bool savePaste = true)
        {
            Diagram newItem = new Diagram();

            newItem.ReverseInstance = new Diagram();
            newItem.TransformDataFromObject(copyItem.Diagram, null, false);
            newItem.DiagramID     = Guid.NewGuid();
            newItem.IsAutoUpdated = false;

            newItem.Solution = Solution;
            newItem.Solution = Solution;
            DiagramViewModel newView = new DiagramViewModel(newItem, Solution);

            newView.ResetModified(true);
            AddDiagram(newView);

            // paste children
            foreach (DiagramEntityViewModel childView in copyItem.DiagramEntities)
            {
                newView.PasteDiagramEntity(childView, savePaste);
            }
            if (savePaste == true)
            {
                Solution.DiagramList.Add(newItem);
                newView.OnUpdated(this, null);
                Solution.ResetModified(true);
            }
            return(newView);
        }