/// <summary> /// Add the task item to the task list and save the list to storage /// </summary> /// <param name="newItem"></param> public async void AddTaskItem(TaskItem newItem) { if (_taskList == null) { _taskList = new ObservableCollection<TaskItem>(); taskList = new ObservableCollection<TaskItem>(); } _taskList.Add(newItem); // save the data await writeData(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif // load the data from storage await _taskModel.loadData(); //ViewModel.taskList = new System.Collections.ObjectModel.ObservableCollection<TaskItem>(); if (_taskModel.taskList == null || _taskModel.taskList.Count == 0) { TaskItem new1 = new TaskItem(DateTime.UtcNow, "test", "first one"); _taskModel.AddTaskItem(new1); await _taskModel.writeData(); } // Get current position await _geolocator.GetGeoLocation(); Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { #if WINDOWS_PHONE_APP // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; #endif // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
private void makeTaskToggle_Unchecked(object sender, RoutedEventArgs e) { move.Y -= 100; makeTaskToggle.Content = loader.GetString("CreateTask"); normalPosition = true; // reenable the bottom menu button, for 16:9 screens... oneThingAtATime = false; // Save the text in the textbox, and then reset the textbox string taskstring = taskBox.Text; string title = titleBox.Text; titleBox.Text = ""; taskBox.Text = ""; TaskItem newItem = new TaskItem(DateTime.UtcNow, title, taskstring); if (backButtonClick == false) { if (taskstring != "") taskModel.AddTaskItem(newItem); // ********************************** Update Live Tile ********************************* //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// //////////////////////////////////////////////// /*IconicTileData tile = new IconicTileData(); tile.Title = AppResources.ApplicationTitle; // Add the number of tasks to the tile tile.Count = App.ViewModel.taskList.Count; // empty the tiles tile.WideContent1 = ""; tile.WideContent2 = ""; tile.WideContent3 = ""; // Add the images to the tile tile.IconImage = new Uri("Assets/Tiles/Iconic/202x202.png", UriKind.Relative); tile.SmallIconImage = new Uri("Assets/Tiles/Iconic/110x110.png", UriKind.Relative); // Set the wide tile content switch (tile.Count) { case 0: tile.WideContent1 = AppResources.emptyTilePrompt; break; case 1: tile.WideContent1 = App.ViewModel.taskList.ElementAt<TaskItem>(0).Details; break; case 2: { tile.WideContent1 = App.ViewModel.taskList.ElementAt<TaskItem>(0).Details; tile.WideContent2 = App.ViewModel.taskList.ElementAt<TaskItem>(1).Details; } break; case 3: { tile.WideContent1 = App.ViewModel.taskList.ElementAt<TaskItem>(0).Details; tile.WideContent2 = App.ViewModel.taskList.ElementAt<TaskItem>(1).Details; tile.WideContent3 = App.ViewModel.taskList.ElementAt<TaskItem>(App.ViewModel.taskList.Count() - 1).Details; } break; default: { tile.WideContent1 = App.ViewModel.taskList.ElementAt<TaskItem>(0).Details; tile.WideContent2 = App.ViewModel.taskList.ElementAt<TaskItem>(1).Details; tile.WideContent3 = App.ViewModel.taskList.ElementAt<TaskItem>(App.ViewModel.taskList.Count() - 1).Details; } break; } // find the tile object for the application tile that using "Iconic" contains string in it. ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("Iconic".ToString())); if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains("Iconic")) { TileToFind.Update(tile); } */ } backButtonClick = false; }
/// <summary> /// Delete the task and save the changes /// </summary> /// <param name="taskToDelete"></param> public async void DeleteTaskItem(TaskItem taskToDelete) { _taskList.Remove(taskToDelete); // save the data await writeData(); }