Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
 public SashTypeViewModel(SashType sashType)
 {
     Original = sashType;
     Restore();
 }