예제 #1
0
        /// <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();
        }
예제 #2
0
        /// <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();
        }
예제 #3
0
        private void makeTaskToggle_Unchecked(object sender, RoutedEventArgs e)
        {
            move.Y -= 100;
            makeTaskToggle.Content = AppResources.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;
            taskBox.Text = "";

            TaskItem newItem = new TaskItem
            {
                dateTime = DateTime.UtcNow.ToString(),
                Details = taskstring
            };

            if (backButtonClick == false)
            {
                if (taskstring != "")
                    App.ViewModel.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;

        }
예제 #4
0
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private async void Application_Launching(object sender, LaunchingEventArgs e)
        {

            // load the data from storage
            await viewModel.loadData();
            //ViewModel.taskList = new System.Collections.ObjectModel.ObservableCollection<TaskItem>();
            if(viewModel.taskList == null || viewModel.taskList.Count == 0)
            {
                TaskItem new1 = new TaskItem
                {
                    dateTime = DateTime.UtcNow.ToString(),
                    Details = "first one"
                };
                viewModel.AddTaskItem(new1);
                viewModel.writeData();
            }
            
        }