public ItemsChangeObservableCollection<Project> LoadProjects() { ItemsChangeObservableCollection<Project> loadedProjects = new ItemsChangeObservableCollection<Project>(); //Read from file try { using (Stream stream = new FileStream("NerdyTimer_Savings.txt", FileMode.Open, FileAccess.Read, FileShare.Read, 4096, true)) { SaveableProjectsContainer SaveableProjectsContainer = (SaveableProjectsContainer)BinaryFormatter.Deserialize(stream); //Load mechanism foreach (SaveableProject SavedProject in SaveableProjectsContainer.Projects) { loadedProjects.Add(new Project(SavedProject.Name)); foreach (SaveableTask SavedTask in SavedProject.Tasks) { loadedProjects.Last().AddTask(new ProjectTask(SavedTask.Name, SavedTask.Time)); } } } } catch (Exception e) { //Do nothing, NerdyTimer_Savings.txt isn't created yet which is fine } return loadedProjects; }
private void ItemConnections_ChildElementPropertyChanged(ItemsChangeObservableCollection <NameValue> .ChildElementPropertyChangedEventArgs e) { OnPropertyChanged(new PropertyChangedEventArgs(nameof(InitLamps))); OnPropertyChanged(new PropertyChangedEventArgs(nameof(InitSignals))); RaisePropertyChanged(nameof(NetworkParTScript)); }
/// <summary> /// /// </summary> public BrowserWidgetViewModel() : base(Window.Current) { this.CurrentTabUiItems = new ItemsChangeObservableCollection <TabUiItem>(); this.RegisterEvents(); this.CheckTabItemsEmptyTabs(); }
public MapViewModel(INavigationService navigationService) : base(navigationService) { this._uiFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext()); _travel = new MapTravelBindingModel(); _places = new ObservableCollection<MapPlaceBindingModel>(); _categories = new ItemsChangeObservableCollection<CategoryVisibilityModel>(); BindCommands(); LocationEllipse = new LocationEllipseParams() { Fill = new SolidColorBrush(Color.FromArgb(255, 83, 83, 83)), Stroke = new SolidColorBrush(Color.FromArgb(255, 195, 195, 195)), Width = 20, Height = 20, }; CompassPath = new CompassPathParams() { CompassMode = false, Fill = new SolidColorBrush(Colors.Gray) }; }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { AddNewCommand = new RelayCommand(AddNew); CopyToClipboardCommand = new RelayCommand(CopyToClipboard); DataValues = new ItemsChangeObservableCollection <EncryptedKeyPair>(new List <EncryptedKeyPair>()); DataValues.CollectionChanged += DataValues_CollectionChanged; }
public TreeWindowViewModel() { ManagerModel = new Manager(); EmployeeModel = new Employee(); _managers = new ItemsChangeObservableCollection <Manager>(); LoadData(); }
/// <summary> /// Default constructor. /// </summary> /// <param name="Lines">Lines collection to whom to add the new person.</param> public AddPersonViewModel(ItemsChangeObservableCollection <Line> lines) { AddPersonCommand = new CommandHandler <IDialog>(AddPerson, AddPersonCanExecute); CancelCommand = new CommandHandler <IDialog>(Cancel, () => true); Lines = lines; }
/// <summary> /// Default constructor. /// </summary> /// <param name="lines">List of lines to add a person.</param> public AddPersonWindow(ItemsChangeObservableCollection <Line> lines) { // Instanciate the view model and set it as the data context. ViewModel = new AddPersonViewModel(lines); this.DataContext = ViewModel; InitializeComponent(); }
public BoardGameViewModel() { _boardGameContainer = new ItemsChangeObservableCollection<BoardGame>(); _boardGameContainer.Add(new BoardGame("Monopoly", "EA Games", "1st", 500, 0, 0)); _boardGameContainer.Add(new BoardGame("Twister", "Games", "2nd", 300, 0, 0)); _newGame = new BoardGame(); _increment = new CommandHandler(IncrementCommand); _decrement = new CommandHandler(DecrementCommand); }
public InvoiceListViewModel(IUnitOfWork context,IFrameNavigationService navigationService) { _context = context; _navigationService = navigationService; InvoiceList = new ItemsChangeObservableCollection<BasicInvoiceInformation>(); HandleNavigationParameter(_navigationService.Parameter); }
private async void GetItems() { var registerItems = await RestClient.GetRegisterItems(); RegisterItemViewModels = new ItemsChangeObservableCollection<RegisterItemViewModel>(); foreach (var registerItem in registerItems) { RegisterItemViewModels.Add(new RegisterItemViewModel(registerItem)); } ItemPanorama.DataContext = RegisterItemViewModels; }
/// <summary> /// Constructs a line and initialises the maximum penalties a person can have. /// </summary> /// <param name="croissantsSlots">Number of croissant slots to set to the line.</param> public Line(int croissantsSlots) { this._CroissantsSlots = croissantsSlots; Croissants = new ItemsChangeObservableCollection <Croissant>(); for (int i = 0; i < CroissantsSlots; i++) { Croissants.Add(new Croissant()); } PenaltiesAdded = new ObservableCollection <DateTime>(); }
public ItemsChangeObservableCollection<CategoryVisibilityModel> GetCategoryVisibilityCollection(List<MapPlaceBindingModel> places) { IEnumerable<string> categories = places.Select(x => x.CategoryName).Distinct(); ItemsChangeObservableCollection<CategoryVisibilityModel> result = new ItemsChangeObservableCollection<CategoryVisibilityModel>(); foreach (var category in categories) { result.Add(new CategoryVisibilityModel() { Visibile = true, Name = category }); } return result; }
public CardMenuVM(IEventAggregator eventAggregator, ICardService cardService, ISetService setService) { _eventAggregator = eventAggregator; _cardService = cardService; _setService = setService; SideOptions = new ObservableCollection <string> { "Corp", "Runner" }; Sets = new ItemsChangeObservableCollection <SetWrapper>(_setService.Sets); Sets.CollectionChanged += Sets_CollectionChanged; _side = "Corp"; StartCardListCommand = new DelegateCommand(OnStartCardList, OnStartCardListCanExecute); }
public ProjectViewModel() { FileHandler = new FileHandler(); Projects = new ItemsChangeObservableCollection<Project>(); Task.Run(() => { Projects = FileHandler.LoadProjects(); }); TaskTimer = new TaskTimer(); BtnCommandAddProject = new RelayCommand(new Action<object>(AddProject)); BtnCommandAddTask = new RelayCommand(new Action<object>(AddTask)); BtnCommandStartTimer = new RelayCommand(new Action<object>(StartTimer)); BtnCommandStopTimer = new RelayCommand(new Action<object>(StopTimer)); }
public void TestBubbleSortExplicitAscending() { bool result = false; var sortedCollection = new ItemsChangeObservableCollection <Croissant>(unorderedCollection); sortedCollection.BubbleSort(SortDirection.Ascending); result = (sortedCollection[0].Date == croissant7.Date && sortedCollection[1].Date == croissant6.Date && sortedCollection[2].Date == croissant3.Date && sortedCollection[3].Date == croissant1.Date && sortedCollection[4].Date == croissant4.Date && sortedCollection[5].Date == null && sortedCollection[6].Date == null); Assert.IsTrue(result); }
public PaymentViewModel(IUnitOfWork context, IMessageBoxService messageBoxService, IFrameNavigationService navigationService) { NavigationService = navigationService; MessageBoxService = messageBoxService; Context = context; BuyerList = new List<Buyer>(); SaleDate = DateTime.Now; _paymentDetailList = new ItemsChangeObservableCollection<PaymentDetail>(); _paymentDetailList.CollectionChanged+= PaymentDetailList_CollectionChanged; PaymentDetailViewModel = new PaymentDetailViewModel(); RegisterMessages(); }
public void TestBubbleSortDefault() { bool result = false; var sortedCollection = new ItemsChangeObservableCollection <Croissant>(unorderedCollection); sortedCollection.BubbleSort(); // Default behavior: ascending sort result = (sortedCollection[0].Date == croissant7.Date && sortedCollection[1].Date == croissant6.Date && sortedCollection[2].Date == croissant3.Date && sortedCollection[3].Date == croissant1.Date && sortedCollection[4].Date == croissant4.Date && sortedCollection[5].Date == null && sortedCollection[6].Date == null); Assert.IsTrue(result); }
public void TestInit() { unorderedCollection = new ItemsChangeObservableCollection <Croissant>(); croissant1 = new Croissant(new DateTime(2017, 09, 05)); croissant2 = new Croissant(); croissant3 = new Croissant(new DateTime(2017, 09, 03)); croissant4 = new Croissant(new DateTime(2017, 09, 10)); croissant5 = new Croissant(); croissant6 = new Croissant(new DateTime(2017, 09, 02)); croissant7 = new Croissant(new DateTime(2017, 09, 01)); unorderedCollection.Add(croissant1); unorderedCollection.Add(croissant2); unorderedCollection.Add(croissant3); unorderedCollection.Add(croissant4); unorderedCollection.Add(croissant5); unorderedCollection.Add(croissant6); unorderedCollection.Add(croissant7); }
public DraftMenuVM(IEventAggregator eventAggregator, ICardService cardService, ISetService setService, ICubeService cubeService) { _eventAggregator = eventAggregator; _cardService = cardService; _setService = setService; _cubeService = cubeService; NumberOfPlayersOptions = new ObservableCollection <int> { 2, 3, 4, 5, 6 }; SideOptions = new ObservableCollection <string> { "Corp", "Runner" }; Sets = new ItemsChangeObservableCollection <SetWrapper>(_setService.Sets); Cubes = new ObservableCollection <CubeWrapper>(_cubeService.GetCubes()); Sets.CollectionChanged += Sets_CollectionChanged; _numberOfPlayers = 2; _side = "Corp"; StartDraftCommand = new DelegateCommand(OnStartDraft, OnStartDraftCanExecute); UseCubeCommand = new DelegateCommand(OnUseCube, OnUseCubeCanExecute); }
public MainViewModel() { //TilmeldteHuse hus = new TilmeldteHuse(); TilmeldteHuse hus1 = new TilmeldteHuse(18, 2, 3, 1, "Hjælper"); TilmeldteHuse hus2 = new TilmeldteHuse(19, 2, 2, 0, "Oprydder"); TilmeldteHuse hus3 = new TilmeldteHuse(20, 1, 1, 1, "Chefkok"); TilmeldteHuse hus4 = new TilmeldteHuse(21, 4, 0, 0, "Ingen"); Alletilmeldtehuse = new ItemsChangeObservableCollection <TilmeldteHuse>(); Alletilmeldtehuse.Add(hus1); Alletilmeldtehuse.Add(hus2); Alletilmeldtehuse.Add(hus3); Alletilmeldtehuse.Add(hus4); OpretUgeCommand = new RelayCommand(LavNyUge); FjernEtHus = new RelayCommand(FjernHusFraDag); IndtastUdgiftCommand = new RelayCommand(Beregn); OpretEtHus = new RelayCommand(AddNewHus); NewHus = new TilmeldteHuse(); NyUge = new Uge(); GW = new GridView(); Ugenspris = new Dictionary <int, double>(); RetListen = new RetListe(); _selectedret = new Retter(); LavNyUge(); VisRandomMenuMandag(); VisRandomMenuTirsdag(); VisRandomMenuOnsdag(); VisRandomMenuTorsdag(); }
public Project(string name) { _name = name; Tasks = new ItemsChangeObservableCollection<ProjectTask>(); }
public InvoiceViewModel(IUnitOfWork context, IMessageBoxService messageBoxService, IFrameNavigationService navigationService) : base(context, messageBoxService,navigationService) { IssueDate = DateTime.Now; InvoiceModel = new Invoice(); PaymentPeriod = 1; PaymentMethodValues = new Dictionary<PaymentMethod, string> { {PaymentMethod.Cash,"Gotówka"}, {PaymentMethod.Transfer,"Przelew"} }; SelectedPaymentMethod = PaymentMethod.Transfer; HandleNavigationParameter(navigationService.Parameter); RegisterMessages(); ConfigureValidationRules(); #region DesignMode if (IsInDesignMode) { BuyerList = new Collection<Buyer> { new Buyer { FirstName = "Michał", LastName = "Pełcik", CompanyName = "sdfsf" } }; SaleDate = new DateTime(2015, 05, 05); PaymentDetailList = new ItemsChangeObservableCollection<PaymentDetail> { new PaymentDetail { Description = "sdfsdf", MeasureUnit = "szt.", PricePerUnit = 234, Quantity = 3, Amount = 702 } }; } #endregion }
/// <summary> /// Load the lines from the file. /// </summary> private void Load() { Lines = new ItemsChangeObservableCollection <Line>(PetitsPainsStore.ReadCroissantsLines()); }
/// <summary> /// Constructor. /// </summary> /// <param name="date">Date at which the report was created.</param> /// <param name="lines">Collection of lines.</param> public EmailTemplate(DateTime date, ItemsChangeObservableCollection <Line> lines) { this.date = date; this.lines = lines; }
/// <summary> /// Handler for item change in observationCollection /// </summary> /// <param name="e"></param> private void ItemConnections_ChildElementPropertyChanged(ItemsChangeObservableCollection <Connection> .ChildElementPropertyChangedEventArgs e) { OnPropertyChanged(new PropertyChangedEventArgs(nameof(this.Connections))); OnPropertyChanged(new PropertyChangedEventArgs(nameof(this.ConnectTestScript))); }
private TracklistProvider() { Tracks = new ItemsChangeObservableCollection <TrackVM>(); Tracks.CollectionChanged += TracklistProvider_CollectionChanged; SetCurrentIndex(NO_TRACK_SELECTED_INDEX); }
private void ItemConnections_ChildElementPropertyChanged(ItemsChangeObservableCollection <NameValue> .ChildElementPropertyChangedEventArgs e) { OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("InitLamps")); OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs("InitSignals")); RaisePropertyChanged("NetworkParTScript"); }
private void Parameter_ChildElementChanged(ItemsChangeObservableCollection <CANTxParameter> .ChildElementPropertyChangedEventArgs e) { OnPropertyChanged(new PropertyChangedEventArgs(nameof(this.Parameterized))); OnPropertyChanged(new PropertyChangedEventArgs(nameof(this.TestScript))); }