コード例 #1
0
 private Task <ObservableDiagram> RenderChordAsync(IChordFinderResult result)
 {
     return(Task <ObservableDiagram> .Factory.StartNew(() =>
     {
         ObservableDiagram od = null;
         AppVM.AppView.DoOnUIThread(() =>
         {
             try
             {
                 od = new ObservableDiagram(result.ToDiagram(Style), name: Strings.FinderResultDiagramName);
                 od.PostEditCallback = (changed) =>
                 {
                     if (changed)
                     {
                         od.Refresh();
                     }
                 };
             }
             catch (Exception ex)
             {
                 ExceptionUtils.HandleException(ex);
             }
         });
         return od;
     }));
 }
コード例 #2
0
        private Action <bool> GetDiagramPostEditCallback(ObservableDiagram od)
        {
            ObservableDiagram originalObservableDiagram = od;
            Diagram           originalDiagram           = od.Diagram;

            return((changed) =>
            {
                if (changed)
                {
                    if (Collection.Contains(originalDiagram))
                    {
                        // We edited an existing diagram, so we need to replace the pre-edited Diagram still in the library
                        // with the newly minted Diagram from the editor
                        Collection.Replace(originalDiagram, originalObservableDiagram.Diagram);
                    }
                    else
                    {
                        // This was a new diagram, so we need to add it to the library collection
                        Collection.Add(originalObservableDiagram.Diagram);
                        // Then add it to the list of visible diagrams
                        Diagrams.Add(originalObservableDiagram);
                    }

                    // Now we need to refresh the individual image
                    originalObservableDiagram.Refresh();

                    // Now that the internal Diagram has changed, we need to rebuild the callback so that the new Diagram is
                    // cached correctly for any future calls to edit this od
                    originalObservableDiagram.PostEditCallback = GetDiagramPostEditCallback(originalObservableDiagram);
                }
            });
        }
コード例 #3
0
        private ObservableDiagram CreateObservableDiagram(Diagram diagram)
        {
            ObservableDiagram od = new ObservableDiagram(diagram);

            od.PostEditCallback = GetDiagramPostEditCallback(od);
            return(od);
        }
コード例 #4
0
 void ObservableDiagram_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (!ObservableDiagram.IsCursorProperty(e.PropertyName))
     {
         Dirty = true;
         if (e.PropertyName == nameof(Style))
         {
             RaisePropertyChanged(nameof(Style));
         }
     }
 }
コード例 #5
0
        public DiagramEditorViewModel(ObservableDiagram diagram, bool isNew)
        {
            OriginalObservableDiagram = diagram ?? throw new ArgumentNullException(nameof(diagram));

            ObservableDiagram = new ObservableDiagram(diagram.Diagram.Clone())
            {
                IsEditMode = true
            };

            if (isNew)
            {
                _dirty = true;
            }

            ObservableDiagram.PropertyChanged       += ObservableDiagram_PropertyChanged;
            ObservableDiagram.Style.PropertyChanged += Style_PropertyChanged;
        }
コード例 #6
0
 public ShowDiagramEditorMessage(ObservableDiagram diagram, bool isNew, Action <bool> callback = null) : base()
 {
     Diagram  = diagram;
     IsNew    = isNew;
     Callback = callback;
 }