public ToDoList_Service() { DirectoryCheck(); settings = new SettingsDictionary(); if (SettingsFile_Check()) { SettingsFile_Load(); } else { Initialize_Settings(); SettingsFile_Save(); } _toDoList = new ToDoListCollection(); if (DataFile_Check()) { DataFile_Load(); } else { Initialize_ToDoList(); DataFile_Save(); } }
private bool DataFile_Load() { bool result = false; try { var aList = ToDoListIO.Load(File_Path_JSON); ToDoListCollection listCollection = aList; if (listCollection != null) { ToDoList = listCollection; result = true; } } catch (Exception e) { System.Console.WriteLine("Exception: {0} \nFile Load Error", e.Message); } return(result); }
//public bool IsDateValid { get { return todoitem.dueDate < DateTime.Now; } } //public ItemList_ViewModel() //{ //} public ItemList_ViewModel(RegionManager regionManager, IToDoList_Service toDoListService) { //View discovery //this.regionManager.RegisterViewWithRegion("ContentRegion", typeof(ItemList_View)); _regionManager = regionManager; _ToDoItemListService = toDoListService; _ToDoItemList = toDoListService.GetToDoList(); //ItemSelectedCommand = new DelegateCommand<ToDoItem>(ItemSelected); _filterString = ""; //_filterString = "Search Text..."; // Initialize the CollectionView for the underlying model // and track the current selection. this.ItemsCV = CollectionViewSource.GetDefaultView(ToDoItemList); //this.ItemsCV = new ListCollectionView(ToDoItemList); this.ItemsCV.CurrentChanged += ItemSelected; //new EventHandler(this.ItemSelected); //SelectedItemChanged this.ItemsCV.Filter = SearchFilter; SelectedItem = this.ItemsCV.CurrentItem as ToDoItem; //Command to navigate to AddItem_View GoAddItemCommand = new DelegateCommand(GoAddItem, () => true); //Command to navigate to ItemDetail_View GoStatsCommand = new DelegateCommand(GoForward, CanGoForward); //GoMessage, () => true); GoSelectCommand = new DelegateCommand(GoForward, CanGoForward); GoDetailCommand = new DelegateCommand(GoItemDetails, () => true); //CanGoForward GoDeleteCommand = new DelegateCommand(GoItemDelete, () => true); GoCompleteCommand = new DelegateCommand(GoItemComplete, () => true); //CanGoForward //GoStatsCommand = new DelegateCommand(() => new IMessage("My Test Message", "A test title"), // ()=>true); //this.eventAggregator.GetEvent<PubSubEvent<int>>().Subscribe(this.ItemSelectedEvent, true); }