public DiagramMarkEditorViewModel(DiagramMark diagramMark, bool isNew)
        {
            DiagramMark = diagramMark ?? throw new ArgumentNullException(nameof(diagramMark));

            // Save properties
            _text = diagramMark.Text;

            // Save original
            _originalStyle = new ObservableDiagramStyle(diagramMark.Style, diagramMark.MarkStyle);

            // Create editable clone
            DiagramStyle clone = _originalStyle.Style.Clone();

            if (_originalStyle.Style.ReadOnly)
            {
                clone.MarkAsReadOnly();
            }

            Style = new ObservableDiagramStyle(clone);
            Style.MarkStyle.MarkType = DiagramMark.Type;
            Style.PropertyChanged   += ObservableDiagramStyle_PropertyChanged;

            if (isNew)
            {
                _dirty = true;
            }
        }
        public DiagramBarreEditorViewModel(DiagramBarre diagramBarre, bool isNew)
        {
            if (null == diagramBarre)
            {
                throw new ArgumentNullException("diagramBarre");
            }

            DiagramBarre = diagramBarre;

            // Save original
            _originalStyle = new ObservableDiagramStyle(diagramBarre.Style);

            // Create editable clone
            DiagramStyle clone = _originalStyle.Style.Clone();

            if (_originalStyle.Style.ReadOnly)
            {
                clone.MarkAsReadOnly();
            }

            Style = new ObservableDiagramStyle(clone);
            Style.PropertyChanged += ObservableDiagramStyle_PropertyChanged;

            if (isNew)
            {
                _dirty = true;
            }
        }
        public DiagramFretLabelEditorViewModel(DiagramFretLabel diagramFretLabel, bool isNew)
        {
            if (null == diagramFretLabel)
            {
                throw new ArgumentNullException("diagramFretLabel");
            }

            DiagramFretLabel = diagramFretLabel;

            // Save properties
            _text = diagramFretLabel.Text;

            // Save original
            _originalStyle = new ObservableDiagramStyle(diagramFretLabel.Style);

            // Create editable clone
            DiagramStyle clone = _originalStyle.Style.Clone();

            if (_originalStyle.Style.ReadOnly)
            {
                clone.MarkAsReadOnly();
            }

            Style = new ObservableDiagramStyle(clone);
            Style.PropertyChanged += ObservableDiagramStyle_PropertyChanged;

            if (isNew)
            {
                _dirty = true;
            }
        }
Ejemplo n.º 4
0
 public void MarkAsReadOnly()
 {
     ReadOnly = true;
     ChordiousSettings.MarkAsReadOnly();
     DiagramStyle.MarkAsReadOnly();
     Instruments.MarkAsReadOnly();
     ChordQualities.MarkAsReadOnly();
     Scales.MarkAsReadOnly();
 }
        public DiagramStyleEditorViewModel(ObservableDiagramStyle diagramStyle)
        {
            if (null == diagramStyle)
            {
                throw new ArgumentNullException(nameof(diagramStyle));
            }

            // Add original
            _originalStyles = new ObservableCollection <ObservableDiagramStyle>
            {
                diagramStyle
            };

            // Recursively parents up the tree
            DiagramStyle style = diagramStyle.Style.Parent;

            while (null != style)
            {
                ObservableDiagramStyle parentStyle = new ObservableDiagramStyle(style);
                _originalStyles.Insert(0, parentStyle);
                style = style.Parent;
            }

            // Add editable clones
            Styles = new ObservableCollection <ObservableDiagramStyle>();

            foreach (ObservableDiagramStyle originalStyle in _originalStyles)
            {
                DiagramStyle clone = originalStyle.Style.Clone();
                if (originalStyle.Style.ReadOnly)
                {
                    clone.MarkAsReadOnly();
                }

                ObservableDiagramStyle editableStyle = new ObservableDiagramStyle(clone);
                editableStyle.PropertyChanged += ObservableDiagramStyle_PropertyChanged;
                Styles.Add(editableStyle);
            }

            _selectedStyleIndex = Styles.Count - 1;
        }