Example #1
0
 public static bool CanCopySelection(SceneViewModel viewModel)
 {
     if (viewModel.DesignerContext.ActiveView.EventRouter.IsEditingText)
     {
         if (viewModel.TextSelectionSet.IsActive)
         {
             return(viewModel.TextSelectionSet.CanCopy);
         }
         return(false);
     }
     if (viewModel.ElementSelectionSet.IsEmpty && viewModel.KeyFrameSelectionSet.IsEmpty && (viewModel.ChildPropertySelectionSet.IsEmpty && viewModel.BehaviorSelectionSet.IsEmpty) && viewModel.AnnotationSelectionSet.IsEmpty)
     {
         return(false);
     }
     if (viewModel.ChildPropertySelectionSet.Selection.Count == 1)
     {
         return(true);
     }
     if (viewModel.ChildPropertySelectionSet.Selection.Count > 1)
     {
         return(false);
     }
     if (!viewModel.BehaviorSelectionSet.IsEmpty || !viewModel.AnnotationSelectionSet.IsEmpty)
     {
         return(true);
     }
     if (viewModel.KeyFrameSelectionSet.IsEmpty)
     {
         if (!CopyCommand.ElementsHaveSameParent((ICollection <SceneElement>)viewModel.ElementSelectionSet.Selection))
         {
             return(false);
         }
         foreach (SceneElement sceneElement in viewModel.ElementSelectionSet.Selection)
         {
             if (sceneElement is CameraElement)
             {
                 return(false);
             }
         }
     }
     else
     {
         IEnumerator <KeyFrameSceneNode> enumerator = viewModel.KeyFrameSelectionSet.Selection.GetEnumerator();
         enumerator.MoveNext();
         SceneNode targetElement = enumerator.Current.TargetElement;
         while (enumerator.MoveNext())
         {
             if (enumerator.Current.TargetElement != targetElement)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Example #2
0
        public static void CopyElements(SceneViewModel viewModel, List <SceneElement> elements)
        {
            if (elements.Count == 0 || !CopyCommand.ElementsHaveSameParent((ICollection <SceneElement>)elements))
            {
                return;
            }
            PerformanceUtility.StartPerformanceSequence(PerformanceEvent.CopyElements);
            SceneNode    parent       = elements[0].Parent;
            PastePackage pastePackage = new PastePackage(viewModel);

            using (viewModel.ForceBaseValue())
                pastePackage.AddElements(elements, true);
            pastePackage.SendToClipboard();
            PerformanceUtility.EndPerformanceSequence(PerformanceEvent.CopyElements);
        }