public HostedLayoutViewModel(ContentItem model) : base(model) { AddPage = new RelayCommand(OnAddPage); RemovePage = new RelayCommand(OnRemovePage, CanExecuteRemovePage); var hostedLayout = ModelAs <HostedLayout>(); var lst = new List <HostedLayoutPageViewModel>(); foreach (var x in hostedLayout.Pages) { var vm = (HostedLayoutPageViewModel)ViewModelMapper.GetViewModel(x); if (vm == null) { vm = new HostedLayoutPageViewModel(x); } vm.Parent = this; lst.Add(vm); } foreach (var x in lst) { x.RelinkBrokenPageReferences(lst); } _pages = new ViewModelCollection <HostedLayoutPageViewModel, HostedLayoutPage>(hostedLayout.Pages, lst); }
public CatalogViewModel(ICatalog catalog) : base(catalog) { Func <ICatalogProduct, ProductViewModel> viewModelFactory = CreateProductViewModel; this.Products = ViewModelCollection.Create(catalog.Products, viewModelFactory); }
public Layout() { Name = string.Empty; ActionItems = new ActionItemCollection(); Contracts = new ContractCollection(); ViewModels = new ViewModelCollection(); }
/// <summary> /// Creates a new instance of <see cref="Node"/>. /// </summary> public Node() { Terminals = new ViewModelCollection <Terminal, TerminalModel>(this, () => Model?.Terminals, Terminal.CreateTerminalViewModel); Terminals.CollectionChanged += TerminalsCollectionChanged; ExecuteWhenViewLoaded(ArrangeAllTerminals); Name ??= string.Empty; }
/// <summary> /// /// </summary> /// <param name="slave"></param> public FileManagerWindow(Slave slave) : base(slave) { InitializeComponent(); Loaded += OnNavigate; FileTransactionsList.DataContext = ViewModelCommands; FilesList.DataContext = ViewModelFiles = new ViewModelCollection <FileMeta>(); }
/// <summary> /// /// </summary> /// <param name="slave"></param> public FileManagerWindow(Slave slave) : base(slave) { InitializeComponent(); Loaded += OnNavigate; FileTransactionsList.DataContext = ViewModelCommands; FilesList.DataContext = ViewModelFiles = new ViewModelCollection<FileMeta>(); }
private void LoadSettings() { _settingsModel = _settingsService.GetSettings(); ViewModelCollection.OfType <SettingsGeneralViewModel>().FirstOrDefault()?.SetSettingsModel(_settingsModel?.GeneralSettings); ViewModelCollection.OfType <SettingsCurrencyViewModel>().FirstOrDefault()?.SetSettingsModel(_settingsModel?.CurrencySettings); ViewModelCollection.OfType <SettingsRakeBackViewModel>().FirstOrDefault()?.SetSettingsModel(_settingsModel?.RakeBackSettings); ViewModelCollection.OfType <SettingsSiteViewModel>().FirstOrDefault()?.SetSettingsModel(_settingsModel?.SiteSettings); }
public ProductViewModel(IProduct product) : base(product) { Func <IProduct, ProductViewModel> productViewModelFactory = CreateProductViewModel; Func <IRelease, ReleaseViewModel> releaseViewModelFactory = CreateReleaseViewModel; this.Products = ViewModelCollection.Create(product.Products, productViewModelFactory); this.Releases = ViewModelCollection.Create(product.Releases, releaseViewModelFactory); this.Children = ConcatCollection.Create <object>((ICollection)this.Products, (ICollection)this.Releases); }
public void SetPortfolio(int portfolioId) { this.portfolio = this.ipmModel.Portfolios.Find(portfolioId); this.accounts = new ViewModelCollection <AccountViewModel, Account>( this.portfolio.Accounts, (model, context) => new AccountViewModel { Model = model }); // ReSharper disable once ExplicitCallerInfoArgument this.OnPropertyChanged(string.Empty); }
/// <summary> /// Initializes a new instance of the /// <see cref="SelectCollaborators" /> class. /// </summary> /// <param name="collaborators">The collaborators.</param> public SelectCollaborators(IEnumerable<Collaborator> collaborators) { InitializeComponent(); TheList = new ViewModelCollection<Collab>(); foreach (var co in collaborators.Where(c => c.Status == "online")) { var collab = new Collab() { Collaborator = co }; TheList.Add(collab); } lvCollabs.ItemsSource = TheList; }
/// <summary> /// /// </summary> private void Initialize() { m_childWindows = new List <Window>(); SlavesList.DataContext = ViewModelSlaves = new ViewModelCollection <Slave>(); SlaveStatusBar.DataContext = ViewModelMonitor = new SlaveMonitorModel(); Slave.SlaveEvents.Subscribe(this); NetworkService.Instance.Start(); ViewModelMonitor.SetListeningState("Listening"); AddInfoMessage("NetworkService running..."); }
public void Add_ShouldWork() { bool isChangeTriggered = false, isAddTriggered = false, isAllTriggered = false; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); c.Bind("change", e => isChangeTriggered = true); c.Bind("add", e => isAddTriggered = true); c.Bind("all", e => isAllTriggered = true); c.Add(new SimpleModel {Id = 3}); Assert.AreEqual(c.Count, 1); Assert.AreEqual(c.ElementAt(0).Id, 3); Assert.AreEqual(isChangeTriggered, true, "change event should have been triggered"); Assert.AreEqual(isAddTriggered, true, "add event should have been triggered"); Assert.AreEqual(isAllTriggered, true, "all event should have been triggered"); }
public void ChangeEvent_OnModelInsideCollection_ShouldFireCollectionChangeEvent() { var firstModel = new SimpleModel {Id = 3}; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)) { firstModel, new SimpleModel {Id = 6}, new SimpleModel {Id = 10} }; var collectionHasChanged = false; c.Bind("change", e => collectionHasChanged = true); firstModel.Trigger("change"); Assert.IsTrue(collectionHasChanged); }
public HostedLayoutPageViewModel(HostedLayoutPage model) : base(model) { RemoveItem = new RelayCommand(OnRemoveItem, CanExecuteRemoveItem); var lst = new List <HostedLayoutItemViewModel>(); foreach (var x in model.Items) { HostedLayoutItemViewModel vm = null; vm = (ContentAreaViewModel)ViewModelMapper.GetViewModel(x); if (vm == null) { if (x is ContentArea) { vm = new ContentAreaViewModel(x); } else if (x is ToggleItem) { vm = new ToggleItemViewModel(x); } else if (x is ButtonItem) { vm = new ButtonItemViewModel(x); } else if (x is InteractableItem) { vm = new InteractableItemViewModel(x); } } if (vm == null) { continue; } vm.Parent = this; lst.Add(vm); } _items = new ViewModelCollection <HostedLayoutItemViewModel, HostedLayoutItem>(model.Items, lst); _items.CollectionChanged += items_CollectionChanged; ContentAreas = new ObservableCollection <ContentAreaViewModel>(_items.Where(x => x is ContentAreaViewModel).Cast <ContentAreaViewModel>().ToList()); }
/// <summary> /// Sets up the child collection. /// </summary> /// <param name="model">The model to sync with.</param> private void SetupChildren(CoverageNodeModel model) { Children = new ViewModelCollection <CoverageNodeModel, CoverageNodeViewModel>( model.Children, (m) => { Debug.Assert(m != null); //Debug.Assert(m.Parent == model); return(new CoverageNodeViewModel(this, m)); } ); Children.CollectionChanged += ChildrenCollectionChanged; CanExpand = (Children.Count > 0); }
public void ChangeEvent_OnModelInsideCollection_ShouldNotFireCollectionChangeEventAfterModelWasRemovedFromCollection() { var firstModel = new SimpleModel {Id = 3}; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)) { firstModel, new SimpleModel {Id = 6}, new SimpleModel {Id = 10} }; var collectionHasChanged = false; c.Bind("change", e => collectionHasChanged = true); c.Remove(firstModel, new ViewSetOptions {IsSilent = true}); Assert.IsFalse(collectionHasChanged, "Remove with silent should not trigger change"); firstModel.Trigger("change"); Assert.IsFalse(collectionHasChanged, "triggering the change event on an item that has been removed from a collection should not trigger the change event on the collection"); }
protected override void OnModelChanged(IDeck OldValue, IDeck NewValue) { base.OnModelChanged(OldValue, NewValue); if (Model == null) { Cards = null; } else { Cards = new ViewModelCollection <CardViewModel>(); foreach (Card tile in Model.Cards) { Cards.Add(new CardViewModel(tile)); } } }
private void SwitchView(object obj) { if (obj != null) { var viewModel = ViewModelCollection.FirstOrDefault(x => x == obj); if (viewModel != null) { SettingsSiteViewModel vm = viewModel as SettingsSiteViewModel; if (vm != null && _preferredSeatingFlag) { vm.SelectedSiteType = EnumPokerSites.Ignition; _preferredSeatingFlag = false; SelectedViewModel = vm; } else { SelectedViewModel = viewModel; } } } }
public RootConfigurationViewModel(RootConfiguration model) : base(model) { if (model.Sessions == null) { throw new ArgumentException("No Sessions found. Please check your json"); } var lst = new List <SessionViewModel>(); foreach (var item in model.Sessions) { var vm = new SessionViewModel(item); vm.Parent = this; lst.Add(vm); } Sessions = new ViewModelCollection <SessionViewModel, Session>(model.Sessions, lst); EnvironmentVariables = new ModelUpdatingCollection <string>(model.EnvironmentVariables, model.EnvironmentVariables); _selectedSession = Sessions[0]; }
public void SortInsertOnRightSpot() { CompositeCollection <int> collection = new CompositeCollection <int>(true); ViewModelCollection <int> a = new ViewModelCollection <int>(new List <int>()); ViewModelCollection <int> b = new ViewModelCollection <int>(new List <int>()); collection.Add(a); collection.Add(b); Random r = new Random(); for (int i = 0; i < 200; i++) { if ((i % 2) == 1) { a.Add(r.Next()); } else { b.Add(r.Next()); } } int prv = collection[0]; for (int i = 1; i < collection.Count; i++) { if (collection[i] < prv) { throw new Exception($"{i}"); } else { prv = collection[i]; } } }
public ContentItemViewModel(ContentItem model) : base(model) { MenuSelectedItemBus = EventBusManager.Instance.GetOrCreateBus(nameof(MenuSelectedItemBus)); WindowSettings = new WindowSettingsViewModel(Model.WindowSettings); var lst = new List <ContentItemViewModel>(); foreach (var item in model.Children) { var vm = CreateItem(item); vm.Parent = this; if (item.WindowSettings.InheritProperties) { vm.WindowSettings.InheritFrom(WindowSettings); } lst.Add(vm); } _children = new ViewModelCollection <ContentItemViewModel, ContentItem>(Model.Children, lst); }
public EditorLevel(int screenWidth, int screenHeight) { _environment = new EnvironmentContainer(); LevelWidth = Common.Settings.GlobalSettings.LevelWidth; LevelHeight = Common.Settings.GlobalSettings.LevelHeight; PickableObjects = new ObservableCollection <IInstancePrototype>(); ActivePrototypes = new ObservableCollection <IInstancePrototype>(); ((ObservableCollection <IInstancePrototype>)ActivePrototypes).Insert(0, ActivePrototype); ///// TODO: Replace it with special editor environment container LevelObjects = new ViewModelCollection <IInstance>(); //LevelItems = EnvironmentContainer.Items; // Add Terrain 4 test var wall1 = new StaticObjectBehavior(new DungeonStoneWall(new Point(2400, 2600), _environment)); var wall2 = new StaticObjectBehavior(new DungeonStoneWall(new Point(2900, 2900), _environment)); LevelObjects.Add(wall1); LevelObjects.Add(wall2); //Replace with invisible actor with ignoring collision resolver Player = new Player(new BrokenHeart(new Point(2700, 2700), _environment), null); ViewPort = new ViewPort(screenWidth, screenHeight, (IInstance)Player); // Load available pickable objects foreach (Type t in System.Reflection.Assembly.GetAssembly(typeof(IInstancePrototype)).GetTypes() .Where(x => x.GetInterface(typeof(IInstancePrototype).Name) != null && !x.IsInterface && !x.IsAbstract)) { ((ObservableCollection <IInstancePrototype>)PickableObjects).Insert(0, (IInstancePrototype)Activator.CreateInstance(t)); } _environment.AddInstance((IInstance)Player); _environment.Run(); }
public void AddRange_ShouldWork() { int changeTriggerCount = 0, addTriggerCount = 0, allTriggerCount = 0; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); c.Bind("change", e => changeTriggerCount++); c.Bind("add", e => addTriggerCount++); c.Bind("all", e => allTriggerCount++); c.AddRange( new [] { new SimpleModel {Id = 3}, new SimpleModel {Id = 4}, new SimpleModel {Id = 5} } ); Assert.AreEqual(c.Count, 3); Assert.AreEqual(c.ElementAt(0).Id, 3); Assert.AreEqual(c.ElementAt(1).Id, 4); Assert.AreEqual(c.ElementAt(2).Id, 5); Assert.AreEqual(changeTriggerCount, 3, "change event should have been triggered"); Assert.AreEqual(addTriggerCount, 3, "add event should have been triggered"); Assert.AreEqual(allTriggerCount, 3, "all event should have been triggered"); }
public void FactoryTest() { var provider = new AmlDocument(); var expected = new KinematicJointValue(provider) { Name = "foobar", Value = 1d, DefaultValue = 3d, Minimum = -10d, Maximum = 20d }; var ie = provider.CaexDocument.Create <InternalElementType>(); ie.Attribute.Insert((AttributeType)expected.CaexObject); Assert.Equal(1, ie.Attribute.Count); var viewModel = new InternalElementViewModel(ie, provider); var values = new ViewModelCollection <KinematicJointValue>(ie.Attribute, viewModel); Assert.Single(values); Assert.Equal(typeof(KinematicJointValue), values.First().GetType()); }
public SaveChangesCommand(ViewModelCollection <T> viewModel) : base(viewModel) { }
public void Set_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var json = new SimpleModel {Id = 3}.ToJSON(); var list = new List<JsDictionary<string, object>> {json}; c.Set(list); Assert.AreEqual(c.Count, 1); Assert.AreEqual(c.ElementAt(0).Id, 3); }
public void SetFromJSON_ShouldWork() { var c = new ViewModelCollection<BlogViewModel>(typeof(BlogViewModel)); var json = new BlogViewModel { Id = 3, Owner = new UserViewModel { Id = 33, FirstName = "John" } }.ToJSON(); var list = new List<JsDictionary<string, object>> {json}; c.SetFromJSON(list); Assert.AreEqual(c.Count, 1); Assert.AreEqual(c.ElementAt(0).Id, 3); Assert.AreEqual(c.ElementAt(0).Owner.Id, 33); }
public void Remove_WithSilent_ShouldNotTriggerChangeEvent() { bool isChangeTriggered = false, isRemoveTriggered = false, isAllTriggered = false; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var m = new SimpleModel {Id = 3}; c.Add(m); Assert.AreEqual(c.Count, 1); c.Bind("all", e => isAllTriggered = true); c.Bind("change", e => isChangeTriggered = true); c.Bind("remove", e => isRemoveTriggered = true); c.Remove(m); Assert.AreEqual(c.Count, 0); Assert.AreEqual(isChangeTriggered, true, "change event should not have been triggered"); Assert.AreEqual(isRemoveTriggered, true, "remove event should not have been triggered"); Assert.AreEqual(isAllTriggered, true, "all event should not have been triggered"); }
public SaveItemCommand(ViewModelCollection <T> viewModelCollection) : base(viewModelCollection) { }
public void Clear_ShouldWork() { bool isClearTriggered = false, isAllTriggered = false; var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var m = new SimpleModel {Id = 3}; c.Add(m); Assert.AreEqual(c.Count, 1); c.Bind("all", e => isAllTriggered = true); c.Bind("clear", e => isClearTriggered = true); c.Clear(); Assert.AreEqual(c.Count, 0); Assert.AreEqual(isClearTriggered, true, "clear event should have been triggered"); Assert.AreEqual(isAllTriggered, true, "all event should have been triggered"); }
public void EnumerableImplementation_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)) { new SimpleModel {Id = 3}, new SimpleModel {Id = 6}, new SimpleModel {Id = 10} }; var x = 0; foreach(var m in c) { x += m.Id; } Assert.AreEqual(x, 19); }
public void ElementAt_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var m = new SimpleModel {Id = 3}; c.Add(m); Assert.AreEqual(c.Count, 1); Assert.AreEqual(c.ElementAt(0).Id, m.Id); }
public void Contains_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var m = new SimpleModel {Id = 3}; c.Add(m); Assert.AreEqual(c.Count, 1); Assert.IsTrue(c.Contains(m)); }
public AddCommand(ViewModelCollection <T> viewModelCollection) : base(viewModelCollection) { }
public ViewModelRoomAvailabilityModel() { Rooms = new ViewModelCollection <Room>(new List <Room>()); }
public void EnumerableImplementation_ShouldWorkWithLinq() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)) { new SimpleModel {Id = 3}, new SimpleModel {Id = 6}, new SimpleModel {Id = 10} }; var x = (from m in c select m.Id).Sum(); Assert.AreEqual(x, 19); }
public DiscardItemCommand(ViewModelCollection <T> viewModel) : base(viewModel) { }
public void GetById_ShouldWork() { var c = new ViewModelCollection<SimpleModel>(typeof(SimpleModel)); var model = new SimpleModel {Id = 3}; c.Add(model); Assert.AreEqual(c.Count, 1); var a = c.GetById(model.Id); Assert.AreEqual(a.Id, model.Id); Assert.AreEqual(a, model); }
public RemoveCommand(ViewModelCollection <T> viewModelCollection) : base(viewModelCollection) { }
public ProjectSetRepositoryViewModel(IProjectSetRepository repository) { m_repository = repository; m_projects = ViewModelCollection <ProjectSetSummaryViewModel, ProjectSet> .Create(m_repository.ProjectSets, ps => new ProjectSetSummaryViewModel(ps)); }