Ejemplo n.º 1
0
 private void DeepCopy(Note source, Note destination)
 {
     //use properties where possible, to raise PropertyChanged events.
     destination.StartTime = source.StartTime;
     destination.StartTrackNumber = source.StartTrackNumber;
     destination.EndTime = source.EndTime;
     destination.EndTrackNumber = source.EndTrackNumber;
     destination.Title = source.Title;
     destination.Body = source.Body;
     destination.Rating = source.Rating;
     destination.Tags = new ObservableCollection<Tag>(source.Tags);
 }
Ejemplo n.º 2
0
 //
 // Summary:
 //     Pushes changes since the last System.ComponentModel.IEditableObject.BeginEdit()
 //     or System.ComponentModel.IBindingList.AddNew() call into the underlying object.
 public virtual void EndEdit()
 {
     //JDW: DataGrid control calls CancelEdit twice. this is known datagrid behaviour. ref: http://stackoverflow.com/questions/4450878/wpf-datagrid-calls-beginedit-on-an-ieditableobject-two-times
     if (IsDirty)
     {
         //ensure we clear the 'IsDirty' flag first, so we can correctly detect whether the note needs saving.
         this.IsDirty = false;
         if (null != ChangeCommitted)
         {
             ChangeCommitted(this, new EventArgs());
         }
         _versionBeforeEdit = null;
     }
 }
Ejemplo n.º 3
0
        public virtual void CancelEdit()
        {
            //JDW: DataGrid control calls CancelEdit twice. this is known datagrid behaviour. ref: http://stackoverflow.com/questions/4450878/wpf-datagrid-calls-beginedit-on-an-ieditableobject-two-times
            if (IsDirty)
            {
                //revert all changes. use the tracked properties where possible, to raise PropertyChanged events.
                //NOTE: for reference members, this will always send out PropertyChanged events (since we cloned them, they're difference objects)
                DeepCopy(_versionBeforeEdit, this);

                _versionBeforeEdit = null;
                this.IsDirty = false;
            }
        }
Ejemplo n.º 4
0
 public virtual object Clone()
 {
     Note clone = new Note();
     DeepCopy(this, clone);
     return clone;
 }
Ejemplo n.º 5
0
 // Summary:
 //     Begins an edit on an object.
 public virtual void BeginEdit()
 {
     //JDW: DataGrid control calls BeginEdit twice. this is known datagrid behaviour. ref: http://stackoverflow.com/questions/4450878/wpf-datagrid-calls-beginedit-on-an-ieditableobject-two-times
     if (false == IsDirty)
     {
         IsDirty = true;
         _versionBeforeEdit = (Note)this.Clone();
     }
 }