public SashModel(SerializationInfo info, StreamingContext context) : base(info, context) { code = (string)info.GetValue("Code", typeof(string)); sashType = (SashType)info.GetValue("SashType", typeof(SashType)); parent = (Surface)info.GetValue("SurfaceParent", typeof(Surface)); child = (Surface)info.GetValue("SurfaceChild", typeof(Surface)); }
public override void Restore() { SashType original = Original as SashType; if (original == null) { throw new InvalidOperationException( "View model does not have an original value."); } Id = original.Id; Name = original.Name; ProfileType = new ProfileTypeViewModel(original.ProfileType); Tolerance = original.Tolerance; Description = original.Description; }
public static SashType ToModel(this SashTypeViewModel sashTypeViewModel) { if (sashTypeViewModel == null) { throw new ArgumentNullException("sashTypeViewModel"); } SashType sashType = new SashType(); sashType.Id = sashTypeViewModel.Id; sashType.Name = sashTypeViewModel.Name; sashType.ProfileType = sashTypeViewModel.ProfileType.ToModel(); sashType.Description = sashTypeViewModel.Description; sashType.Tolerance = sashTypeViewModel.Tolerance; return(sashType); }
private void SelectedSashType_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!SashSelected) { return; } SashType sashType = SelectedSashType.SelectedItem as SashType; Sash sash = SelectionEventHandler.SelectedNode as Sash; if (sash == null) { return; } if (!sash.Model.SashType.Equals(sashType)) { sash.Model.SashType = sashType; sash.Repaint(); } }
public Sash(Surface surfaceParent, SashType sashType) : base() { if (surfaceParent.ChildrenCount > 0) { throw new ArgumentException("Invalid surface parent provided."); } this.surfaceParent = surfaceParent; Model = new SashModel(); Model.SashType = sashType; if (surfaceParent.Model.Width < MinWidth() || surfaceParent.Model.Height < MinHeight()) { throw new ArgumentException("Too small parent."); } Surface = new Surface(); Model.PropertyChanged += Model_PropertyChanged; Model.SurfaceParent = this.surfaceParent; SurfaceParent().AddChild(this); Model.SurfaceChild = Surface; Surface.Model.SashParent = this; }
public SashTypeViewModel(SashType sashType) { Original = sashType; Restore(); }