public void ColumnsFromConverterWithManipulation() { var vm = new SingleVM <List <string> > { Item = new List <string> { "Name", "Logo", "Win", "Test" } }; var dg = new DataGrid(); dg.SetBinding(DataGrid.ColumnsProperty, new Binding("Item", source: vm, converter: new ColumnConverter())); Assert.IsTrue(dg.Columns.Count == vm.Item.Count); for (int i = 0; i < vm.Item.Count; i++) { Assert.IsTrue(dg.Columns[i].Title == vm.Item[i]); } vm.Item = new List <string> { "Col1", "Col2" }; Assert.IsTrue(dg.Columns.Count == 2); Assert.IsTrue(dg.Columns[0].Title == "Col1" && dg.Columns[1].Title == "Col2"); }
public void SortedColumnIndexWithUnsortableDGWithBinding() { var vm = new SingleVM <List <Team> > { Item = Util.GetTeams(), }; var scVm = new SingleVM <int> { Item = 1, }; var dg = new DataGrid { IsSortable = false, Columns = new ColumnCollection { new DataGridColumn { Title = "Name", PropertyName = "Name" }, new DataGridColumn { Title = "Logo", PropertyName = "Logo" } } }; dg.SetBinding(DataGrid.ItemsSourceProperty, new Binding("Item", source: vm)); Assert.ThrowsException <InvalidOperationException>(() => dg.SetBinding(DataGrid.SortedColumnIndexProperty, new Binding("Item", source: scVm)) ); }
public void SortedColumnIndexColumnBinding() { var columns = new ColumnCollection { new DataGridColumn { Title = "C1", PropertyName = "c1" }, new DataGridColumn { Title = "C2", PropertyName = "c2" }, new DataGridColumn { Title = "C3", PropertyName = "c3" }, }; var vm = new SingleVM <SortData> { Item = 1 }; var dg = new DataGrid { IsSortable = true }; dg.SetBinding(DataGrid.SortedColumnIndexProperty, new Binding("Item", source: vm)); dg.SetBinding(DataGrid.ColumnsProperty, new Binding(".", source: columns)); Assert.IsTrue(dg.SortedColumnIndex == vm.Item); }
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 void SortedColumnIndexBindintToInt() { var vm = new SingleVM <List <Team> > { Item = Util.GetTeams(), }; var scVM = new SingleVM <int> { Item = 2 }; var dg = new DataGrid { Columns = new ColumnCollection { new DataGridColumn { Title = "C1", PropertyName = "c1" }, new DataGridColumn { Title = "C2", PropertyName = "c2" }, new DataGridColumn { Title = "C3", PropertyName = "c3" }, } }; dg.SetBinding(DataGrid.ItemsSourceProperty, new Binding("Item", source: vm)); dg.SetBinding(DataGrid.SortedColumnIndexProperty, new Binding("Item", source: scVM)); Assert.IsTrue(dg.SortedColumnIndex.Index == 2 && dg.SortedColumnIndex.Order == SortingOrder.Ascendant); }
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 void SortedColumnIndexMoreThanColumnCountWithBindingToInt() { var vm = new SingleVM <List <Team> > { Item = Util.GetTeams(), }; var scVm = new SingleVM <int> { Item = 1, }; var dg = new DataGrid { Columns = new ColumnCollection { new DataGridColumn { Title = "Name", PropertyName = "Name" }, new DataGridColumn { Title = "Logo", PropertyName = "Logo" } } }; dg.SetBinding(DataGrid.ItemsSourceProperty, new Binding("Item", source: vm)); dg.SetBinding(DataGrid.SortedColumnIndexProperty, new Binding("Item", source: scVm)); Assert.ThrowsException <ArgumentException>(() => scVm.Item = 4); }
public void SortedColumnIndexTwoWayBindingToInt() { var vm = new SingleVM <List <Team> > { Item = Util.GetTeams(), }; var sVm = new SingleVM <SortData> { Item = 2, }; var dg = new DataGrid { Columns = new ColumnCollection { new DataGridColumn { Title = "C1", PropertyName = "c1" }, new DataGridColumn { Title = "C2", PropertyName = "c2" }, new DataGridColumn { Title = "C3", PropertyName = "c3" }, } }; dg.SetBinding(DataGrid.ItemsSourceProperty, new Binding("Item", source: vm)); dg.SetBinding(DataGrid.SortedColumnIndexProperty, new Binding("Item", mode: BindingMode.TwoWay, source: sVm)); Assert.IsTrue(dg.SortedColumnIndex.Index == 2 && dg.SortedColumnIndex.Order == SortingOrder.Ascendant); dg.SortedColumnIndex = 1; Assert.IsTrue(sVm.Item.Index == 1); sVm.Item = 0; Assert.IsTrue(dg.SortedColumnIndex.Index == 0); }
public void ColumnsWithBindingAndManipulated() { var vm = new SingleVM <ColumnCollection> { Item = new ColumnCollection { new DataGridColumn { Title = "C1", PropertyName = "c1" }, new DataGridColumn { Title = "C2", PropertyName = "c2" }, new DataGridColumn { Title = "C3", PropertyName = "c3" }, } }; var dg = new DataGrid(); dg.SetBinding(DataGrid.ColumnsProperty, new Binding("Item", source: vm)); Assert.IsTrue(dg.Columns.Count == 3); vm.Item = new ColumnCollection { new DataGridColumn { Title = "C1", PropertyName = "c1" }, new DataGridColumn { Title = "C2", PropertyName = "c2" }, }; Assert.IsTrue(dg.Columns.Count == 2); }
public void ItemsSourceBindingSortAndAddNew() { var vm = new SingleVM <ObservableCollection <Team> > { Item = new ObservableCollection <Team>(Util.GetTeams()) }; var dg = new DataGrid(); dg.SetBinding(DataGrid.ItemsSourceProperty, new Binding("Item", source: vm)); vm.Item = new ObservableCollection <Team>(vm.Item.OrderBy(x => x.Name)); vm.Item.Add(new Team { Name = "test team" }); var dgSource = dg.ItemsSource.Cast <Team>(); Assert.IsTrue(dgSource.Count() == 16); Assert.IsTrue(dgSource.ElementAt(15).Name == "test team"); for (int i = 0; i < 15; i++) { Assert.IsTrue(vm.Item.ElementAt(i) == dgSource.ElementAt(i)); } }
public ActionResult Single(int id) { var model = new SingleVM { Product = unitOfWork.Products.FirstOrDefault(x => x.Id == id), ProductPictures = unitOfWork.ProductPictures.Find(x => x.ProductId == id), OtherProducts = unitOfWork.Products.Random(3) }; return(View(model)); }
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 async Task <IActionResult> Single(int?id) { SingleVM bnm = new SingleVM(); bnm.teacearSingle = await context.Teacherrs.FindAsync(id); if (id != null) { return(View(bnm)); } return(RedirectToAction("Index", "Home")); }
public void ActiveRowColorBinding() { var vm = new SingleVM <Color> { Item = Color.Orange }; var dg = new DataGrid(); dg.SetBinding(DataGrid.ActiveRowColorProperty, new Binding("Item", source: vm)); Assert.IsTrue(dg.ActiveRowColor == vm.Item); }
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 void SelectedItemBindingWithoutSelectionEnabled() { var teams = Util.GetTeams(); var sVm = new SingleVM <Team> { Item = teams.First() }; var dg = new DataGrid { SelectionEnabled = false, }; Assert.ThrowsException <InvalidOperationException>(() => dg.SetBinding(DataGrid.SelectedItemProperty, new Binding("Item", source: sVm))); }
public void BorderThicknessFromBinding() { var vm = new SingleVM <Thickness> { Item = new Thickness(3) }; var dg = new DataGrid(); dg.SetBinding(DataGrid.BorderThicknessProperty, new Binding("Item", source: vm)); Assert.IsTrue(dg.BorderThickness == 3); vm.Item = 5; Assert.IsTrue(dg.BorderThickness == 5); }
public void FontFamilyFromBinding() { var vm = new SingleVM <string> { Item = "Arial", }; var dg = new DataGrid(); dg.SetBinding(DataGrid.FontFamilyProperty, new Binding("Item", source: vm)); Assert.IsTrue(dg.FontFamily == "Arial"); vm.Item = "Tahoma"; Assert.IsTrue(dg.FontFamily == "Tahoma"); }
public void SelectionEnabledFromBinding() { var vm = new SingleVM <bool> { Item = false }; var dg = new DataGrid(); dg.SetBinding(DataGrid.SelectionEnabledProperty, new Binding("Item", source: vm)); Assert.IsFalse(dg.SelectionEnabled); vm.Item = true; Assert.IsTrue(dg.SelectionEnabled); }
public void BorderColorWithBinding() { var vm = new SingleVM <Color> { Item = Color.Gray }; var dg = new DataGrid(); dg.SetBinding(DataGrid.BorderColorProperty, new Binding("Item", source: vm)); Assert.IsTrue(dg.BorderColor == Color.Gray); vm.Item = Color.Black; Assert.IsTrue(dg.BorderColor == Color.Black); }
public void FontSizeFromBinding() { var vm = new SingleVM <double> { Item = 14.0 }; var dg = new DataGrid(); dg.SetBinding(DataGrid.FontSizeProperty, new Binding("Item", source: vm)); Assert.IsTrue(dg.FontSize == 14); vm.Item = 15; Assert.IsTrue(dg.FontSize == 15); }
public void HeaderBackgroundColorWithBinding() { var vm = new SingleVM <Color> { Item = Color.Orange }; var dg = new DataGrid(); dg.SetBinding(DataGrid.HeaderBackgroundProperty, new Binding("Item", source: vm)); Assert.IsTrue(dg.HeaderBackground == Color.Orange); vm.Item = Color.Red; Assert.IsTrue(dg.HeaderBackground == Color.Red); }
public void IsSortableFromBinding() { var vm = new SingleVM <bool> { Item = false }; var dg = new DataGrid(); dg.SetBinding(DataGrid.IsSortableProperty, new Binding("Item", source: vm)); Assert.IsFalse(dg.IsSortable); vm.Item = true; Assert.IsTrue(dg.IsSortable); }
public void HeaderHeightFromBinding() { var vm = new SingleVM <int> { Item = 44 }; var dg = new DataGrid(); dg.SetBinding(DataGrid.HeaderHeightProperty, new Binding("Item", source: vm)); Assert.IsTrue(dg.HeaderHeight == 44); vm.Item = 42; Assert.IsTrue(dg.HeaderHeight == 42); }
public void SingleVM() { var vm = new SingleVM(); vm.EditValueProvider.String = "2"; Assert.AreEqual(2.0, vm.Value); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("de-DE"); vm.EditValueProvider.String = "2,4"; Assert.AreEqual((float)2.4, vm.Value); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); vm.EditValueProvider.String = "2.4"; Assert.AreEqual((float)2.4, vm.Value); }
public async Task <IActionResult> Index(int?id) { SingleVM bnm = new SingleVM(); bnm.clasrom = await context.Classroomms.FindAsync(id); bnm.agess = await context.Ages.ToListAsync(); bnm.teacherr = await context.Teacherrs.ToListAsync(); bnm.clasr = await context.Classroomms.ToListAsync(); if (id != null) { return(View(bnm)); } return(RedirectToAction("Index", "Home")); }
public void ItemsSourceBindingSort() { var vm = new SingleVM <List <Team> >() { Item = Util.GetTeams() }; var dg = new DataGrid(); dg.SetBinding(DataGrid.ItemsSourceProperty, new Binding("Item", source: vm)); vm.Item = vm.Item.OrderBy(x => x.Name).ToList(); var dgSource = dg.ItemsSource.Cast <Team>(); for (int i = 0; i < 15; i++) { Assert.IsTrue(vm.Item.ElementAt(i) == dgSource.ElementAt(i)); } }
public void SelectedItemBinding() { var teams = Util.GetTeams(); var vm = new SingleVM <List <Team> > { Item = teams, }; var sVm = new SingleVM <Team> { Item = teams.First() }; var dg = new DataGrid(); dg.SetBinding(DataGrid.ItemsSourceProperty, new Binding("Item", source: vm)); dg.SetBinding(DataGrid.SelectedItemProperty, new Binding("Item", source: sVm)); Assert.IsTrue(dg.ItemsSource == teams); Assert.IsTrue(dg.SelectedItem == teams.First()); }
public void BorderColorFromStyleWithBinding() { var vm = new SingleVM <Color> { Item = Color.Gray }; var style = new Style(typeof(DataGrid)); style.Setters.Add(new Setter { Property = DataGrid.BorderColorProperty, Value = new Binding("Item", source: vm) }); var dg = new DataGrid { Style = style }; Assert.IsTrue(dg.BorderColor == Color.Gray); vm.Item = Color.Black; Assert.IsTrue(dg.BorderColor == Color.Black); }
public void IsSortableFromStyleWithBinding() { var vm = new SingleVM <bool> { Item = false }; var style = new Style(typeof(DataGrid)); style.Setters.Add(new Setter { Property = DataGrid.IsSortableProperty, Value = new Binding("Item", source: vm) }); var dg = new DataGrid { Style = style }; Assert.IsFalse(dg.IsSortable); vm.Item = true; Assert.IsTrue(dg.IsSortable); }
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 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 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 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(); }