public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize) { this.origOptions = options; this.canDeserialize = canDeserialize; this.booleanVM = new BooleanVM(a => HasErrorUpdated()); this.charVM = new CharVM(a => HasErrorUpdated()); this.byteVM = new ByteVM(a => HasErrorUpdated()); this.sbyteVM = new SByteVM(a => HasErrorUpdated()); this.int16VM = new Int16VM(a => HasErrorUpdated()); this.uint16VM = new UInt16VM(a => HasErrorUpdated()); this.int32VM = new Int32VM(a => HasErrorUpdated()); this.uint32VM = new UInt32VM(a => HasErrorUpdated()); this.int64VM = new Int64VM(a => HasErrorUpdated()); this.uint64VM = new UInt64VM(a => HasErrorUpdated()); this.singleVM = new SingleVM(a => HasErrorUpdated()); this.doubleVM = new DoubleVM(a => HasErrorUpdated()); this.decimalVM = new DecimalVM(a => HasErrorUpdated()); this.dateTimeVM = new DateTimeVM(a => HasErrorUpdated()); this.timeSpanVM = new TimeSpanVM(a => HasErrorUpdated()); this.userTypeVM = new UserTypeVM(ownerModule, canDeserialize); this.resourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged()); this.UserTypeVM.PropertyChanged += (s, e) => { if (e.PropertyName == "HasError") { HasErrorUpdated(); } }; Reinitialize(); }
public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize) { origOptions = options; this.canDeserialize = canDeserialize; BooleanVM = new BooleanVM(a => HasErrorUpdated()); CharVM = new CharVM(a => HasErrorUpdated()); ByteVM = new ByteVM(a => HasErrorUpdated()); SByteVM = new SByteVM(a => HasErrorUpdated()); Int16VM = new Int16VM(a => HasErrorUpdated()); UInt16VM = new UInt16VM(a => HasErrorUpdated()); Int32VM = new Int32VM(a => HasErrorUpdated()); UInt32VM = new UInt32VM(a => HasErrorUpdated()); Int64VM = new Int64VM(a => HasErrorUpdated()); UInt64VM = new UInt64VM(a => HasErrorUpdated()); SingleVM = new SingleVM(a => HasErrorUpdated()); DoubleVM = new DoubleVM(a => HasErrorUpdated()); DecimalVM = new DecimalVM(a => HasErrorUpdated()); DateTimeVM = new DateTimeVM(a => HasErrorUpdated()); TimeSpanVM = new TimeSpanVM(a => HasErrorUpdated()); UserTypeVM = new UserTypeVM(ownerModule, canDeserialize); ResourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged()); UserTypeVM.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(UserTypeVM.HasError)) { HasErrorUpdated(); } }; Reinitialize(); }
public InstructionOperandVM() { this.@sbyte = new SByteVM(a => FieldUpdated()); this.@byte = new ByteVM(a => FieldUpdated()); this.int32 = new Int32VM(a => FieldUpdated()); this.int64 = new Int64VM(a => FieldUpdated()); this.single = new SingleVM(a => FieldUpdated()); this.@double = new DoubleVM(a => FieldUpdated()); this.@string = new StringVM(a => FieldUpdated()); this.operandListVM = new ListVM<object>((a, b) => FieldUpdated()); this.OperandListVM.DataErrorInfoDelegate = VerifyOperand; }
public InstructionOperandVM() { SByte = new SByteVM(a => FieldUpdated()); Byte = new ByteVM(a => FieldUpdated()); Int32 = new Int32VM(a => FieldUpdated()); Int64 = new Int64VM(a => FieldUpdated()); Single = new SingleVM(a => FieldUpdated()); Double = new DoubleVM(a => FieldUpdated()); String = new StringVM(a => FieldUpdated()); OperandListVM = new ListVM <object>((a, b) => FieldUpdated()); OperandListVM.DataErrorInfoDelegate = VerifyOperand; }
public InstructionOperandVM() { this.@sbyte = new SByteVM(a => FieldUpdated()); this.@byte = new ByteVM(a => FieldUpdated()); this.int32 = new Int32VM(a => FieldUpdated()); this.int64 = new Int64VM(a => FieldUpdated()); this.single = new SingleVM(a => FieldUpdated()); this.@double = new DoubleVM(a => FieldUpdated()); this.@string = new StringVM(a => FieldUpdated()); this.operandListVM = new ListVM <object>((a, b) => FieldUpdated()); this.OperandListVM.DataErrorInfoDelegate = VerifyOperand; }
public void DoubleVM() { var vm = new DoubleVM(); vm.EditValueProvider.String = "2"; Assert.AreEqual(2.0, vm.Value); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("de-DE"); vm.EditValueProvider.String = "2,4"; Assert.AreEqual(2.4, vm.Value); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); vm.EditValueProvider.String = "2.4"; Assert.AreEqual(2.4, vm.Value); }
public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize) { this.origOptions = options; this.canDeserialize = canDeserialize; this.booleanVM = new BooleanVM(a => HasErrorUpdated()); this.charVM = new CharVM(a => HasErrorUpdated()); this.byteVM = new ByteVM(a => HasErrorUpdated()); this.sbyteVM = new SByteVM(a => HasErrorUpdated()); this.int16VM = new Int16VM(a => HasErrorUpdated()); this.uint16VM = new UInt16VM(a => HasErrorUpdated()); this.int32VM = new Int32VM(a => HasErrorUpdated()); this.uint32VM = new UInt32VM(a => HasErrorUpdated()); this.int64VM = new Int64VM(a => HasErrorUpdated()); this.uint64VM = new UInt64VM(a => HasErrorUpdated()); this.singleVM = new SingleVM(a => HasErrorUpdated()); this.doubleVM = new DoubleVM(a => HasErrorUpdated()); this.decimalVM = new DecimalVM(a => HasErrorUpdated()); this.dateTimeVM = new DateTimeVM(a => HasErrorUpdated()); this.timeSpanVM = new TimeSpanVM(a => HasErrorUpdated()); this.userTypeVM = new UserTypeVM(ownerModule, canDeserialize); this.resourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged()); this.UserTypeVM.PropertyChanged += (s, e) => { if (e.PropertyName == "HasError") HasErrorUpdated(); }; Reinitialize(); }
public InstructionOperandVM() { SByte = new SByteVM(a => FieldUpdated()); Byte = new ByteVM(a => FieldUpdated()); Int32 = new Int32VM(a => FieldUpdated()); Int64 = new Int64VM(a => FieldUpdated()); Single = new SingleVM(a => FieldUpdated()); Double = new DoubleVM(a => FieldUpdated()); String = new StringVM(a => FieldUpdated()); OperandListVM = new ListVM<object>((a, b) => FieldUpdated()); OperandListVM.DataErrorInfoDelegate = VerifyOperand; }
public ConstantTypeVM(ModuleDef ownerModule, object value, ConstantType[] validConstants, bool allowNullString, bool arraysCanBeNull, TypeSigCreatorOptions options = null) { if (options == null) { IList<ConstantType> clist = validConstants; if (clist.IndexOf(ConstantType.Type) >= 0 || clist.IndexOf(ConstantType.TypeArray) >= 0 || clist.IndexOf(ConstantType.ObjectArray) >= 0) { throw new ArgumentNullException(); } } this.arraysCanBeNull = arraysCanBeNull; var list = validConstants.Select(a => typeToEnumVM[a]); this.constantTypeEnumListVM = new EnumListVM(list, (a, b) => OnConstantChanged()); this.boolean = new BooleanVM(a => FieldUpdated()); this.@char = new CharVM(a => FieldUpdated()); this.@sbyte = new SByteVM(a => FieldUpdated()); this.@byte = new ByteVM(a => FieldUpdated()); this.int16 = new Int16VM(a => FieldUpdated()); this.uint16 = new UInt16VM(a => FieldUpdated()); this.int32 = new Int32VM(a => FieldUpdated()); this.uint32 = new UInt32VM(a => FieldUpdated()); this.int64 = new Int64VM(a => FieldUpdated()); this.uint64 = new UInt64VM(a => FieldUpdated()); this.single = new SingleVM(a => FieldUpdated()); this.@double = new DoubleVM(a => FieldUpdated()); this.@string = new StringVM(a => FieldUpdated(), allowNullString); this.@enum = new EnumDataFieldVM(ownerModule, a => FieldUpdated()); this.type = new TypeSigVM(a => FieldUpdated(), options); this.objectArray = new ObjectListDataFieldVM(ownerModule, a => FieldUpdated(), options); this.booleanArray = new BooleanListDataFieldVM(a => FieldUpdated()); this.charArray = new CharListDataFieldVM(a => FieldUpdated()); this.sbyteArray = new SByteListDataFieldVM(a => FieldUpdated()); this.byteArray = new ByteListDataFieldVM(a => FieldUpdated()); this.int16Array = new Int16ListDataFieldVM(a => FieldUpdated()); this.uint16Array = new UInt16ListDataFieldVM(a => FieldUpdated()); this.int32Array = new Int32ListDataFieldVM(a => FieldUpdated()); this.uint32Array = new UInt32ListDataFieldVM(a => FieldUpdated()); this.int64Array = new Int64ListDataFieldVM(a => FieldUpdated()); this.uint64Array = new UInt64ListDataFieldVM(a => FieldUpdated()); this.singleArray = new SingleListDataFieldVM(a => FieldUpdated()); this.doubleArray = new DoubleListDataFieldVM(a => FieldUpdated()); this.stringArray = new StringListDataFieldVM(a => FieldUpdated()); this.enumArray = new EnumListDataFieldVM(ownerModule, a => FieldUpdated()); this.typeArray = new TypeSigListDataFieldVM(a => FieldUpdated(), options); this.Value = value; }
public AppSettingsPageImpl(IBackgroundImageSettingsService backgroundImageSettingsService, IPickFilename pickFilename, IPickDirectory pickDirectory, ImageSettingsInfo[] settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (settings.Length == 0) { throw new ArgumentException(); } Debug.Assert(settings.All(a => a.Lazy.Value.UserVisible)); this.backgroundImageSettingsService = backgroundImageSettingsService ?? throw new ArgumentNullException(nameof(backgroundImageSettingsService)); this.pickFilename = pickFilename ?? throw new ArgumentNullException(nameof(pickFilename)); this.pickDirectory = pickDirectory ?? throw new ArgumentNullException(nameof(pickDirectory)); Settings = new ObservableCollection <Settings>(settings.OrderBy(a => a.Lazy.Value.UIOrder).Select(a => new Settings(a))); stretchVM = new EnumListVM(EnumVM.Create(false, typeof(Stretch)), (a, b) => currentItem.RawSettings.Stretch = (Stretch)stretchVM.SelectedItem); stretchDirectionVM = new EnumListVM(stretchDirectionList, (a, b) => currentItem.RawSettings.StretchDirection = (StretchDirection)stretchDirectionVM.SelectedItem); imagePlacementVM = new EnumListVM(imagePlacementList, (a, b) => currentItem.RawSettings.ImagePlacement = (ImagePlacement)imagePlacementVM.SelectedItem); opacityVM = new DoubleVM(a => { if (!opacityVM.HasError) { currentItem.RawSettings.Opacity = FilterOpacity(opacityVM.Value); } }); horizontalOffsetVM = new DoubleVM(a => { if (!horizontalOffsetVM.HasError) { currentItem.RawSettings.HorizontalOffset = FilterOffset(horizontalOffsetVM.Value); } }); verticalOffsetVM = new DoubleVM(a => { if (!verticalOffsetVM.HasError) { currentItem.RawSettings.VerticalOffset = FilterOffset(verticalOffsetVM.Value); } }); leftMarginWidthPercentVM = new DoubleVM(a => { if (!leftMarginWidthPercentVM.HasError) { currentItem.RawSettings.LeftMarginWidthPercent = FilterMarginPercent(leftMarginWidthPercentVM.Value); } }); rightMarginWidthPercentVM = new DoubleVM(a => { if (!rightMarginWidthPercentVM.HasError) { currentItem.RawSettings.RightMarginWidthPercent = FilterMarginPercent(rightMarginWidthPercentVM.Value); } }); topMarginHeightPercentVM = new DoubleVM(a => { if (!topMarginHeightPercentVM.HasError) { currentItem.RawSettings.TopMarginHeightPercent = FilterMarginPercent(topMarginHeightPercentVM.Value); } }); bottomMarginHeightPercentVM = new DoubleVM(a => { if (!bottomMarginHeightPercentVM.HasError) { currentItem.RawSettings.BottomMarginHeightPercent = FilterMarginPercent(bottomMarginHeightPercentVM.Value); } }); maxHeightVM = new DoubleVM(a => { if (!maxHeightVM.HasError) { currentItem.RawSettings.MaxHeight = FilterLength(maxHeightVM.Value); } }); maxWidthVM = new DoubleVM(a => { if (!maxWidthVM.HasError) { currentItem.RawSettings.MaxWidth = FilterLength(maxWidthVM.Value); } }); zoomVM = new DoubleVM(a => { if (!zoomVM.HasError) { currentItem.RawSettings.Zoom = FilterZoom(zoomVM.Value); } }); intervalVM = new DefaultConverterVM <TimeSpan>(a => { if (!intervalVM.HasError) { currentItem.RawSettings.Interval = intervalVM.Value; } }); CurrentItem = Settings.FirstOrDefault(a => a.Id == backgroundImageSettingsService.LastSelectedId) ?? Settings[0]; }
public AppSettingsPageImpl(IBackgroundImageSettingsService backgroundImageSettingsService, IPickFilename pickFilename, IPickDirectory pickDirectory, ImageSettingsInfo[] settings) { if (backgroundImageSettingsService == null) throw new ArgumentNullException(nameof(backgroundImageSettingsService)); if (pickFilename == null) throw new ArgumentNullException(nameof(pickFilename)); if (pickDirectory == null) throw new ArgumentNullException(nameof(pickDirectory)); if (settings == null) throw new ArgumentNullException(nameof(settings)); if (settings.Length == 0) throw new ArgumentException(); Debug.Assert(settings.All(a => a.Lazy.Value.UserVisible)); this.backgroundImageSettingsService = backgroundImageSettingsService; this.pickFilename = pickFilename; this.pickDirectory = pickDirectory; Settings = new ObservableCollection<Settings>(settings.OrderBy(a => a.Lazy.Value.UIOrder).Select(a => new Settings(a))); stretchVM = new EnumListVM(EnumVM.Create(false, typeof(Stretch)), (a, b) => currentItem.RawSettings.Stretch = (Stretch)stretchVM.SelectedItem); stretchDirectionVM = new EnumListVM(stretchDirectionList, (a, b) => currentItem.RawSettings.StretchDirection = (StretchDirection)stretchDirectionVM.SelectedItem); imagePlacementVM = new EnumListVM(imagePlacementList, (a, b) => currentItem.RawSettings.ImagePlacement = (ImagePlacement)imagePlacementVM.SelectedItem); opacityVM = new DoubleVM(a => { if (!opacityVM.HasError) currentItem.RawSettings.Opacity = FilterOpacity(opacityVM.Value); }); horizontalOffsetVM = new DoubleVM(a => { if (!horizontalOffsetVM.HasError) currentItem.RawSettings.HorizontalOffset = FilterOffset(horizontalOffsetVM.Value); }); verticalOffsetVM = new DoubleVM(a => { if (!verticalOffsetVM.HasError) currentItem.RawSettings.VerticalOffset = FilterOffset(verticalOffsetVM.Value); }); leftMarginWidthPercentVM = new DoubleVM(a => { if (!leftMarginWidthPercentVM.HasError) currentItem.RawSettings.LeftMarginWidthPercent = FilterMarginPercent(leftMarginWidthPercentVM.Value); }); rightMarginWidthPercentVM = new DoubleVM(a => { if (!rightMarginWidthPercentVM.HasError) currentItem.RawSettings.RightMarginWidthPercent = FilterMarginPercent(rightMarginWidthPercentVM.Value); }); topMarginHeightPercentVM = new DoubleVM(a => { if (!topMarginHeightPercentVM.HasError) currentItem.RawSettings.TopMarginHeightPercent = FilterMarginPercent(topMarginHeightPercentVM.Value); }); bottomMarginHeightPercentVM = new DoubleVM(a => { if (!bottomMarginHeightPercentVM.HasError) currentItem.RawSettings.BottomMarginHeightPercent = FilterMarginPercent(bottomMarginHeightPercentVM.Value); }); maxHeightVM = new DoubleVM(a => { if (!maxHeightVM.HasError) currentItem.RawSettings.MaxHeight = FilterLength(maxHeightVM.Value); }); maxWidthVM = new DoubleVM(a => { if (!maxWidthVM.HasError) currentItem.RawSettings.MaxWidth = FilterLength(maxWidthVM.Value); }); zoomVM = new DoubleVM(a => { if (!zoomVM.HasError) currentItem.RawSettings.Zoom = FilterZoom(zoomVM.Value); }); intervalVM = new DefaultConverterVM<TimeSpan>(a => { if (!intervalVM.HasError) currentItem.RawSettings.Interval = intervalVM.Value; }); CurrentItem = Settings.FirstOrDefault(a => a.Id == backgroundImageSettingsService.LastSelectedId) ?? Settings[0]; }
public ResourceElementVM(ResourceElementOptions options, ModuleDef ownerModule, bool canDeserialize) { origOptions = options; this.canDeserialize = canDeserialize; BooleanVM = new BooleanVM(a => HasErrorUpdated()); CharVM = new CharVM(a => HasErrorUpdated()); ByteVM = new ByteVM(a => HasErrorUpdated()); SByteVM = new SByteVM(a => HasErrorUpdated()); Int16VM = new Int16VM(a => HasErrorUpdated()); UInt16VM = new UInt16VM(a => HasErrorUpdated()); Int32VM = new Int32VM(a => HasErrorUpdated()); UInt32VM = new UInt32VM(a => HasErrorUpdated()); Int64VM = new Int64VM(a => HasErrorUpdated()); UInt64VM = new UInt64VM(a => HasErrorUpdated()); SingleVM = new SingleVM(a => HasErrorUpdated()); DoubleVM = new DoubleVM(a => HasErrorUpdated()); DecimalVM = new DecimalVM(a => HasErrorUpdated()); DateTimeVM = new DateTimeVM(a => HasErrorUpdated()); TimeSpanVM = new TimeSpanVM(a => HasErrorUpdated()); UserTypeVM = new UserTypeVM(ownerModule, canDeserialize); ResourceElementTypeVM = new EnumListVM(resourceElementTypeList, (a, b) => OnResourceElementTypeChanged()); UserTypeVM.PropertyChanged += (s, e) => { if (e.PropertyName == nameof(UserTypeVM.HasError)) HasErrorUpdated(); }; Reinitialize(); }
public DoubleView(DoubleVM vm) { InitializeComponent(); DataContext = vm; }