//async void CopyImage()
        //{
        //    string sourece = ImagePath;
        //    string target = Models.TodoItem.ImagePath + ImageName;
        //    Windows.Storage.StorageFolder sourceFolder = await StorageFolder.GetFolderFromPathAsync(ImagePath);
        //    Windows.Storage.StorageFolder targetFolder = await StorageFolder.GetFolderFromPathAsync(Models.TodoItem.ImagePath);
        //    Windows.Storage.StorageFile file = await sourceFolder.GetFileAsync(ImageName);
        //    await file.CopyAsync(targetFolder);
        //    System.IO.File.Copy(sourece, target);
        //}

        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (Window.Current.Content != null)
            {
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame.CanGoBack)
                {
                    // Show UI in title bar if opted-in and in-app backstack is not empty.
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                        AppViewBackButtonVisibility.Visible;
                    ((App)App.Current).BackRequest += NewPageBackRequested;
                    ((App)App.Current).Suspending  += NewPageSuspending;
                }
                else
                {
                    // Remove the UI from the title bar if in-app back stack is empty.
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                        AppViewBackButtonVisibility.Collapsed;
                }
            }

            if (true)
            {
                CreateOrUpdateButton.Content = "Create";
                SelectedItem.title           = Title.Text;
                SelectedItem = new Models.TodoItem();
                await SelectedItem.LoadImageAsync();

                Image.Source = SelectedItem.image;
            }
            else
            {
                CreateOrUpdateButton.Content = "Update";
            }
        }
예제 #2
0
        private void Share_Click(object sender, RoutedEventArgs e)
        {
            dynamic d = e.OriginalSource;

            SharedItem = (Models.TodoItem)d.DataContext;
            DataTransferManager.ShowShareUI();
        }
예제 #3
0
        private void CreateButton_Clicked(object sender, RoutedEventArgs e)
        {
            Models.TodoItem TodoToCreate = new Models.TodoItem(title2.Text,
                                                               details2.Text, dueDate2.Date, image2.Source, file);

            if (TodoToCreate.TodoInfoValidator())
            {
                ViewModel.AddTodoItem(TodoToCreate);
            }
            var db = App.conn;

            try
            {
                using (var TodoItem = db.Prepare("INSERT INTO TodoItems(Title, Description, DueDate) VALUES(?, ?, ?)"))
                {
                    TodoItem.Bind(1, title2.Text);
                    TodoItem.Bind(2, details2.Text);
                    TodoItem.Bind(3, dueDate2.Date.ToString("yyyy-MM-dd HH:mm:ss"));
                    TodoItem.Step();
                }
            }
            catch (Exception ex)
            {
            }
        }
        //async void CopyImage()
        //{
        //    string sourece = ImagePath;
        //    string target = Models.TodoItem.ImagePath + ImageName;
        //    Windows.Storage.StorageFolder sourceFolder = await StorageFolder.GetFolderFromPathAsync(ImagePath);
        //    Windows.Storage.StorageFolder targetFolder = await StorageFolder.GetFolderFromPathAsync(Models.TodoItem.ImagePath);
        //    Windows.Storage.StorageFile file = await sourceFolder.GetFileAsync(ImageName);
        //    await file.CopyAsync(targetFolder);
        //    System.IO.File.Copy(sourece, target);
        //}

        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (Window.Current.Content != null)
            {
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame.CanGoBack)
                {
                    // Show UI in title bar if opted-in and in-app backstack is not empty.
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                        AppViewBackButtonVisibility.Visible;
                    ((App)App.Current).BackRequest += NewPageBackRequested;
                    ((App)App.Current).Suspending += NewPageSuspending;
                }
                else
                {
                    // Remove the UI from the title bar if in-app back stack is empty.
                    SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                        AppViewBackButtonVisibility.Collapsed;
                }
            }

            if (true)
            {
                CreateOrUpdateButton.Content = "Create";
                SelectedItem.title = Title.Text;
                SelectedItem = new Models.TodoItem();
                await SelectedItem.LoadImageAsync();
                Image.Source = SelectedItem.image;
            }
            else
                CreateOrUpdateButton.Content = "Update";
        }
예제 #5
0
        private void UpdateButton_Clicked(object sender, RoutedEventArgs e)
        {
            var db = App.conn;

            using (var statement = db.Prepare("UPDATE TodoItems SET Title = ?, Description = ?, DueDate = ? WHERE Title = ? AND Description = ? AND DueDate = ?"))
            {
                statement.Bind(1, title.Text);
                statement.Bind(2, details.Text);
                statement.Bind(3, dueDate.Date.ToString("yyyy-MM-dd HH:mm:ss"));

                statement.Bind(4, ViewModel.SelectedItem.title);
                statement.Bind(5, ViewModel.SelectedItem.description);
                statement.Bind(6, ViewModel.SelectedItem.DueDate.ToString("yyyy-MM-dd HH:mm:ss"));
                statement.Step();
            }
            using (var statement = db.Prepare("DELETE FROM TodoItems WHERE Title = ? AND Description = ? AND DueDate = ?"))
            {
                statement.Bind(1, title.Text);
                statement.Bind(2, details.Text);
                statement.Bind(3, dueDate.Date.ToString("yyyy-MM-dd HH:mm:ss"));
                statement.Step();
            }
            if (ViewModel.SelectedItem != null)
            {
                StorageFile     strFile      = ViewModel.SelectedItem.shareFile;
                Models.TodoItem TodoToUpdate = new Models.TodoItem(title.Text, details.Text, dueDate.Date, image.Source, strFile);
                TodoToUpdate.id = ViewModel.SelectedItem.id;
                if (TodoToUpdate.TodoInfoValidator())
                {
                    ViewModel.UpdateTodoItem(ViewModel.SelectedItem, TodoToUpdate);
                    Frame.Navigate(typeof(MainPage), ViewModel);
                }
            }
        }
예제 #6
0
        private void CreateButton_Clicked(object sender, RoutedEventArgs e)
        {
            if (createButton.Content.ToString() != "Update")
            {
                Models.TodoItem TodoToCreate = new Models.TodoItem(title.Text, details.Text, dueDate.Date, image.Source, ImageFile);
                if (TodoToCreate.TodoInfoValidator())
                {
                    ViewModel.AddTodoItem(TodoToCreate);
                    Frame.Navigate(typeof(MainPage), ViewModel);
                }
            }
            else
            {
                UpdateButton_Clicked(sender, e);
            }
            var db = App.conn;

            try
            {
                using (var TodoItem = db.Prepare("INSERT INTO TodoItems(Title, Description, DueDate) VALUES(?, ?, ?)"))
                {
                    TodoItem.Bind(1, title.Text);
                    TodoItem.Bind(2, details.Text);
                    TodoItem.Bind(3, dueDate.Date.ToString("yyyy-MM-dd HH:mm:ss"));
                    TodoItem.Step();
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #7
0
        private void MenuFlyoutItemShare_Click(object sender, RoutedEventArgs e)
        {
            shareItem = ((MenuFlyoutItem)sender).DataContext as Models.TodoItem;
            DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();

            dataTransferManager.DataRequested += new TypedEventHandler <DataTransferManager, DataRequestedEventArgs>(this.DataRequested);
            DataTransferManager.ShowShareUI();
        }
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     //TodoItemViewModel.Save(SelectedItem.id, Title.Text, Details.Text, Date.Date.Date);
     ((App)App.Current).BackRequest -= NewPageBackRequested;
     ((App)App.Current).Suspending  -= NewPageSuspending;
     Item         = new Models.TodoItem(SelectedItem.title, SelectedItem.description, SelectedItem.date, SelectedItem.image, SelectedItem.ImageName);
     SelectedItem = null;
     //base.OnNavigatedFrom(e);
 }
예제 #9
0
        private void Share_Click(object sender, RoutedEventArgs e)
        {
            ShareItem = (Models.TodoItem)((MenuFlyoutItem)sender).DataContext;

            DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();

            dataTransferManager.DataRequested += DataTransferManager_DataRequested;
            DataTransferManager.ShowShareUI();
        }
예제 #10
0
        private void CreateButton_Clicked(object sender, RoutedEventArgs e)
        {
            Models.TodoItem TodoToCreate = new Models.TodoItem(title2.Text,
                                                               details2.Text, dueDate2.Date, image2.Source);

            if (TodoToCreate.TodoInfoValidator())
            {
                ViewModel.AddTodoItem(TodoToCreate);
            }
        }
예제 #11
0
 private void UpdateButton_Clicked(object sender, RoutedEventArgs e)
 {
     if (ViewModel.SelectedItem != null)
     {
         Models.TodoItem TodoToUpdate = new Models.TodoItem(title.Text, details.Text, dueDate.Date, image.Source);
         TodoToUpdate.id = ViewModel.SelectedItem.id;
         if (TodoToUpdate.TodoInfoValidator())
         {
             ViewModel.UpdateTodoItem(ViewModel.SelectedItem, TodoToUpdate);
             Frame.Navigate(typeof(MainPage), ViewModel);
         }
     }
 }
예제 #12
0
        private async void deleteOneItem(object sender, RoutedEventArgs e)
        {
            var dc   = (sender as FrameworkElement).DataContext;
            var item = (ToDoListView.ContainerFromItem(dc) as ListViewItem).Content as TodoItem;

            using (var statement = conn.Prepare("DELETE FROM TodoItem WHERE Id = ?"))
            {
                statement.Bind(1, item.id);
                statement.Step();
            }

            Models.TodoItem SItem = ViewModel.getItem(item.id);
            ViewModel.AllItems.Remove(SItem);//调用Remove接口
            await new MessageDialog("Delete successfully!").ShowAsync();
            Frame.Navigate(typeof(MainPage), ViewModel);
        }
예제 #13
0
 private void CreateButton_Clicked(object sender, RoutedEventArgs e)
 {
     if (createButton.Content.ToString() != "Update")
     {
         Models.TodoItem TodoToCreate = new Models.TodoItem(title.Text, details.Text, dueDate.Date, image.Source, ImageFile);
         if (TodoToCreate.TodoInfoValidator())
         {
             ViewModel.AddTodoItem(TodoToCreate);
             Frame.Navigate(typeof(MainPage), ViewModel);
         }
     }
     else
     {
         UpdateButton_Clicked(sender, e);
     }
 }
예제 #14
0
        async void dtm_DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
        {
            /*共享文本*/
            Models.TodoItem item     = ViewModel.AllItems.ElementAt(index);
            var             deferral = e.Request.GetDeferral();
            DataPackage     dp       = e.Request.Data;

            dp.Properties.Title       = "共享文本";
            dp.Properties.Description = "共享文本详情描述";
            string str = item.title.ToString() + "\n" + item.description.ToString() + "\n" + item.date;

            dp.SetText(str);

            /*共享图片*/
            StorageFile imageFile = await Package.Current.InstalledLocation.GetFileAsync("Assets\\background.jpg");

            dp.Properties.Thumbnail = RandomAccessStreamReference.CreateFromFile(imageFile);
            dp.SetBitmap(RandomAccessStreamReference.CreateFromFile(imageFile));

            e.Request.Data = dp;
            deferral.Complete();
        }
 private void Share_Click(object sender, RoutedEventArgs e)
 {
     dynamic d = e.OriginalSource;
     SharedItem = (Models.TodoItem)d.DataContext;
     DataTransferManager.ShowShareUI();
 }
예제 #16
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     //TodoItemViewModel.Save(SelectedItem.id, Title.Text, Details.Text, Date.Date.Date);
     ((App)App.Current).BackRequest -= NewPageBackRequested;
     ((App)App.Current).Suspending -= NewPageSuspending;
     Item = new Models.TodoItem(SelectedItem.title, SelectedItem.description, SelectedItem.date, SelectedItem.image, SelectedItem.ImageName);
     SelectedItem = null;
     //base.OnNavigatedFrom(e);
 }
예제 #17
0
 private void onShare(object sender, RoutedEventArgs e)
 {
     item = (Models.TodoItem)(((MenuFlyoutItem)sender).DataContext);
     DataTransferManager.ShowShareUI();
 }