Exemple #1
0
        private void CopyDiagrams(IEnumerable <ObservableDiagram> itemsToCopy, string destinationName)
        {
            Action <string, bool> performCopy = (name, newCollection) =>
            {
                try
                {
                    DiagramLibrary    library          = AppVM.UserConfig.DiagramLibrary;
                    DiagramCollection targetCollection = library.Get(name);

                    foreach (ObservableDiagram od in itemsToCopy)
                    {
                        Diagram clone = od.Diagram.Clone();
                        targetCollection.Add(clone);
                    }

                    Redraw(newCollection);
                }
                catch (Exception ex)
                {
                    ExceptionUtils.HandleException(ex);
                }
            };

            if (!string.IsNullOrWhiteSpace(destinationName))
            {
                // Target was specified
                performCopy(destinationName.Trim(), false);
            }
            else
            {
                // Prompt for a target
                Messenger.Default.Send(new ShowDiagramCollectionSelectorMessage(performCopy));
            }
        }
Exemple #2
0
        public ObservableDiagramLibraryNode(string path, string name, DiagramLibrary library, Action <bool> redrawCallback = null) : base()
        {
            Path = path;
            Name = name;

            Library = library ?? throw new ArgumentNullException(nameof(library));

            _redrawCallback = redrawCallback;

            _diagrams = new ObservableCollection <ObservableDiagram>();

            SelectedDiagrams = new ObservableCollection <ObservableDiagram>();
            SelectedDiagrams.CollectionChanged += SelectedDiagrams_CollectionChanged;
        }
Exemple #3
0
        private void ProcessClose()
        {
            DiagramLibrary library = AppVM.UserConfig.DiagramLibrary;

            bool newCollection = false;

            if (!library.TryGet(CollectionName, out DiagramCollection targetCollection))
            {
                targetCollection = library.Add(CollectionName);
                newCollection    = true;
            }

            Callback(CollectionName, newCollection);
        }
 public DiagramLibraryViewModel()
 {
     Library = AppVM.UserConfig.DiagramLibrary;
 }