Exemplo n.º 1
0
        async private void DeleteAllButton_Click(object sender, RoutedEventArgs e)
        {
            ContentDialog DeleteAllConfirm = new ContentDialog
            {
                Title             = "Warning",
                Content           = "If you delete all the items, you won't be able to recover it. You sure to delete all?",
                PrimaryButtonText = "Delete",
                CloseButtonText   = "Cancel"
            };
            ContentDialogResult result = await DeleteAllConfirm.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                if (ListItemViewModel.GetViewModel().AllItems.Count == 0)
                {
                    NoneEventError();
                }
                else
                {
                    ListItemViewModel.GetViewModel().RemoveAllListItem();
                    DeleteAll_Succeed();
                    ListItemViewModel.GetViewModel().selectedItem = null;
                    title.Text       = detail.Text = "";
                    date_picker.Date = DateTime.Now;
                    create.Content   = "Create";
                    //source = null;
                    OpenFileWriteBit();
                    picture.Source = new BitmapImage(new Uri("ms-appx:/Assets/BackGroud.jpg", UriKind.RelativeOrAbsolute));
                    TileService.UpdateTiles();
                }
            }
            else
            {
            }
        }
Exemplo n.º 2
0
        private void Button_Click_Create(object sender, RoutedEventArgs e)
        {
            int year  = date_picker.Date.Year;
            int month = date_picker.Date.Month;
            int day   = date_picker.Date.Day;

            if (title.Text == "" || detail.Text == "")
            {
                Empty_Text();
            }
            else if (!Valid_Date(year, month, day))
            {
                InValid_Date_Input();
            }
            else
            {
                if ((string)create.Content == "Create")
                {
                    ListItemViewModel.GetViewModel().AddListItem(title.Text, detail.Text, new DateTime(year, month, day), source);
                    Create_Succeed();
                }
                else if ((string)create.Content == "Update")
                {
                    ListItemViewModel.GetViewModel().UpdateListItem(ListItemViewModel.GetViewModel().selectedItem.GetID(), title.Text, detail.Text, new DateTime(year, month, day), source);
                    Update_Succeed();
                }
                TileService.UpdateTiles();
                title.Text       = detail.Text = "";
                date_picker.Date = DateTime.Now;
                create.Content   = "Create";
                OpenFileWriteBit();
                picture.Source = new BitmapImage(new Uri("ms-appx:/Assets/BackGroud.jpg", UriKind.RelativeOrAbsolute));
                this.Frame.GoBack();
            }
        }
Exemplo n.º 3
0
 private void DeleteButton_Click(object sender, RoutedEventArgs e)
 {
     if (ListItemViewModel.GetViewModel().selectedItem != null)
     {
         ListItemViewModel.GetViewModel().RemoveListItem(ListItemViewModel.GetViewModel().selectedItem.GetID());
         TileService.UpdateTiles();
         Delete_Succeed();
         this.Frame.GoBack();
     }
 }
Exemplo n.º 4
0
 private void Button_Click_Cancel(object sender, RoutedEventArgs e)
 {
     title.Text       = detail.Text = "";
     date_picker.Date = DateTime.Now;
     create.Content   = "Create";
     ListItemViewModel.GetViewModel().selectedItem = null;
     OpenFileWriteBit();
     picture.Source = new BitmapImage(new Uri("ms-appx:/Assets/BackGroud.jpg", UriKind.RelativeOrAbsolute));
     this.Frame.GoBack();
 }
Exemplo n.º 5
0
        async protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (ListItemViewModel.GetViewModel().selectedItem == null)
            {
                title.Text       = detail.Text = "";
                date_picker.Date = DateTime.Now;
                create.Content   = "Create";
                source           = null;
                picture.Source   = new BitmapImage(new Uri("ms-appx:/Assets/BackGroud.jpg", UriKind.RelativeOrAbsolute));
            }
            if (e.NavigationMode == NavigationMode.New)
            {
                ApplicationData.Current.LocalSettings.Values.Remove("mainPage");
            }
            else
            {
                if (ApplicationData.Current.LocalSettings.Values.ContainsKey("mainPage"))
                {
                    var composite = ApplicationData.Current.LocalSettings.Values["mainPage"] as ApplicationDataCompositeValue;
                    title.Text       = (string)composite["title"];
                    detail.Text      = (string)composite["detail"];
                    date_picker.Date = (DateTimeOffset)composite["date"];
                    if (ApplicationData.Current.LocalSettings.Values.ContainsKey("picture"))
                    {
                        StorageFile file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync((string)ApplicationData.Current.LocalSettings.Values["picture"]);

                        if (file != null)
                        {
                            WriteableBitmap image = await ImageTools.FileToWriteableBit(file);

                            using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                            {
                                image.SetSource(stream);
                            }
                            source         = image;
                            picture.Source = image;
                        }
                    }
                    for (int i = 0; i < ViewModel.AllItems.Count; ++i)
                    {
                        ViewModel.AllItems[i].Completed = (bool)composite["checked" + i];
                    }
                    ApplicationData.Current.LocalSettings.Values.Remove("mainPage");
                    if (ApplicationData.Current.LocalSettings.Values.ContainsKey("picture"))
                    {
                        ApplicationData.Current.LocalSettings.Values.Remove("picture");
                    }
                }
            }
            DataTransferManager.GetForCurrentView().DataRequested += OnShareDataRequested;
            base.OnNavigatedTo(e);
        }
Exemplo n.º 6
0
 private void ListView_ItemClick(object sender, ItemClickEventArgs e)
 {
     ListItemViewModel.GetViewModel().selectedItem = (ListItem)e.ClickedItem;
     if (this.ActualWidth <= 800)
     {
         this.Frame.Navigate(typeof(NewPage));
     }
     else
     {
         title.Text       = ListItemViewModel.GetViewModel().selectedItem.Title;
         detail.Text      = ListItemViewModel.GetViewModel().selectedItem.description;
         date_picker.Date = ListItemViewModel.GetViewModel().selectedItem.date;
         picture.Source   = ListItemViewModel.GetViewModel().selectedItem.ImageSource;
         source           = picture.Source as WriteableBitmap;
         create.Content   = "Update";
     }
 }
Exemplo n.º 7
0
        private void MenuFlyoutItemDelete_Click(object sender, RoutedEventArgs e)
        {
            var data = (sender as FrameworkElement).DataContext;
            var item = listView.ContainerFromItem(data) as ListViewItem;

            ViewModel.selectedItem = item.Content as Models.ListItem;
            if (ListItemViewModel.GetViewModel().selectedItem != null)
            {
                ListItemViewModel.GetViewModel().RemoveListItem(ListItemViewModel.GetViewModel().selectedItem.GetID());
                ListItemViewModel.GetViewModel().selectedItem = null;
                title.Text       = detail.Text = "";
                date_picker.Date = DateTime.Now;
                create.Content   = "Create";
                //source = null;
                OpenFileWriteBit();
                picture.Source = new BitmapImage(new Uri("ms-appx:/Assets/BackGroud.jpg", UriKind.RelativeOrAbsolute));
                Delete_Succeed();
                TileService.UpdateTiles();
            }
        }
Exemplo n.º 8
0
        private void MenuFlyoutItemEdit_Click(object sender, RoutedEventArgs e)
        {
            var data = (sender as FrameworkElement).DataContext;
            var item = listView.ContainerFromItem(data) as ListViewItem;

            ViewModel.selectedItem = item.Content as Models.ListItem;
            if (this.ActualWidth <= 800)
            {
                this.Frame.Navigate(typeof(NewPage));
            }
            else
            {
                title.Text       = ListItemViewModel.GetViewModel().selectedItem.Title;
                detail.Text      = ListItemViewModel.GetViewModel().selectedItem.description;
                date_picker.Date = ListItemViewModel.GetViewModel().selectedItem.date;
                picture.Source   = ListItemViewModel.GetViewModel().selectedItem.ImageSource;
                source           = picture.Source as WriteableBitmap;
                create.Content   = "Update";
            }
        }
Exemplo n.º 9
0
        async protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (ListItemViewModel.GetViewModel().selectedItem != null)
            {
                title.Text              = ListItemViewModel.GetViewModel().selectedItem.Title;
                detail.Text             = ListItemViewModel.GetViewModel().selectedItem.description;
                date_picker.Date        = ListItemViewModel.GetViewModel().selectedItem.date;
                create.Content          = "Update";
                picture.Source          = ListItemViewModel.GetViewModel().selectedItem.ImageSource;
                source                  = picture.Source as WriteableBitmap;
                DeleteButton.Visibility = Visibility.Visible;
            }
            if (e.NavigationMode == NavigationMode.New)
            {
                ApplicationData.Current.LocalSettings.Values.Remove("newPage");
            }
            else
            {
                if (ApplicationData.Current.LocalSettings.Values.ContainsKey("newPage"))
                {
                    var composite = ApplicationData.Current.LocalSettings.Values["newPage"] as ApplicationDataCompositeValue;
                    title.Text       = (string)composite["title"];
                    detail.Text      = (string)composite["detail"];
                    date_picker.Date = (DateTimeOffset)composite["date"];
                    StorageFile file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync((string)ApplicationData.Current.LocalSettings.Values["picture"]);

                    WriteableBitmap image = await ImageTools.FileToWriteableBit(file);

                    using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
                    {
                        image.SetSource(stream);
                    }
                    source         = image;
                    picture.Source = image;
                    ApplicationData.Current.LocalSettings.Values.Remove("newPage");
                }
            }
            base.OnNavigatedTo(e);
        }
Exemplo n.º 10
0
        /*public static XmlDocument CreateTiles(PrimaryTile primaryTile)
         * {
         *  XDocument xDoc = new XDocument(
         *      new XElement("tile", new XAttribute("version", 3),
         *          new XElement("visual",
         *              // Small Tile
         *              new XElement("binding", new XAttribute("branding", primaryTile.branding), new XAttribute("displayName", primaryTile.appName), new XAttribute("template", "TileSmall"),
         *                  new XElement("group",
         *                      new XElement("subgroup",
         *                          new XElement("text", primaryTile.time, new XAttribute("hint-style", "caption")),
         *                          new XElement("text", primaryTile.message, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
         *                      )
         *                  )
         *              ),
         *
         *              // Medium Tile
         *              new XElement("binding", new XAttribute("branding", primaryTile.branding), new XAttribute("displayName", primaryTile.appName), new XAttribute("template", "TileMedium"),
         *                  new XElement("group",
         *                      new XElement("subgroup",
         *                          new XElement("text", primaryTile.time, new XAttribute("hint-style", "caption")),
         *                          new XElement("text", primaryTile.message, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
         *                      )
         *                  )
         *              ),
         *
         *              // Wide Tile
         *              new XElement("binding", new XAttribute("branding", primaryTile.branding), new XAttribute("displayName", primaryTile.appName), new XAttribute("template", "TileWide"),
         *                  new XElement("group",
         *                      new XElement("subgroup",
         *                          new XElement("text", primaryTile.time, new XAttribute("hint-style", "caption")),
         *                          new XElement("text", primaryTile.message, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3)),
         *                          new XElement("text", primaryTile.message2, new XAttribute("hint-style", "captionsubtle"), new XAttribute("hint-wrap", true), new XAttribute("hint-maxLines", 3))
         *                      ),
         *                      new XElement("subgroup", new XAttribute("hint-weight", 15),
         *                          new XElement("image", new XAttribute("placement", "inline"), new XAttribute("src", "Assets/StoreLogo.png"))
         *                      )
         *                  )
         *              )
         *          )
         *      )
         *  );
         *
         *  XmlDocument xmlDoc = new XmlDocument();
         *  xmlDoc.LoadXml(xDoc.ToString());
         *  return xmlDoc;
         * }*/

        public static void UpdateTiles()
        {
            TileUpdateManager.CreateTileUpdaterForApplication().Clear();
            ListItemViewModel viewModel = ListItemViewModel.GetViewModel();
            TileContent       content;

            for (int i = 0; i < viewModel.AllItems.Count && i < 5; ++i)
            {
                content = new TileContent()
                {
                    Visual = new TileVisual()
                    {
                        Branding  = TileBranding.NameAndLogo,
                        TileSmall = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = "Assets/backgroud.jpg"
                                },

                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = viewModel.AllItems[i].Title, HintWrap = true
                                    },
                                    new AdaptiveText()
                                    {
                                        Text = viewModel.AllItems[i].description, HintStyle = AdaptiveTextStyle.CaptionSubtle, HintWrap = true
                                    }
                                }
                            }
                        },

                        TileMedium = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = "Assets/backgroud.jpg"
                                },

                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = viewModel.AllItems[i].Title, HintWrap = true
                                    },
                                    new AdaptiveText()
                                    {
                                        Text = viewModel.AllItems[i].description, HintStyle = AdaptiveTextStyle.CaptionSubtle, HintWrap = true
                                    }
                                }
                            }
                        },

                        TileWide = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = "Assets/backgroud.jpg"
                                },

                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = viewModel.AllItems[i].Title, HintWrap = true
                                    },
                                    new AdaptiveText()
                                    {
                                        Text = viewModel.AllItems[i].description, HintStyle = AdaptiveTextStyle.CaptionSubtle, HintWrap = true
                                    }
                                }
                            }
                        },

                        TileLarge = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = "Assets/backgroud.jpg"
                                },

                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = viewModel.AllItems[i].Title, HintWrap = true
                                    },
                                    new AdaptiveText()
                                    {
                                        Text = viewModel.AllItems[i].description, HintStyle = AdaptiveTextStyle.CaptionSubtle, HintWrap = true
                                    }
                                }
                            }
                        }
                    }
                };
                TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(content.GetXml()));
            }
            //如果没有item对磁贴进行初始处理
            if (viewModel.AllItems.Count == 0)
            {
                content = new TileContent()
                {
                    Visual = new TileVisual()
                    {
                        Branding  = TileBranding.NameAndLogo,
                        TileSmall = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = "Assets/backgroud.jpg"
                                },

                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = "Title", HintWrap = true
                                    },
                                    new AdaptiveText()
                                    {
                                        Text = "Detail", HintStyle = AdaptiveTextStyle.CaptionSubtle, HintWrap = true
                                    }
                                }
                            }
                        },

                        TileMedium = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = "Assets/backgroud.jpg"
                                },

                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = "This is the title", HintWrap = true
                                    },
                                    new AdaptiveText()
                                    {
                                        Text = "This is the description", HintStyle = AdaptiveTextStyle.CaptionSubtle, HintWrap = true
                                    }
                                }
                            }
                        },

                        TileWide = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = "Assets/backgroud.jpg"
                                },

                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = "This is the title", HintWrap = true
                                    },
                                    new AdaptiveText()
                                    {
                                        Text = "This is the description", HintStyle = AdaptiveTextStyle.CaptionSubtle, HintWrap = true
                                    }
                                }
                            }
                        },

                        TileLarge = new TileBinding()
                        {
                            Content = new TileBindingContentAdaptive()
                            {
                                BackgroundImage = new TileBackgroundImage()
                                {
                                    Source = "Assets/backgroud.jpg"
                                },

                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text = "This is the title", HintWrap = true
                                    },
                                    new AdaptiveText()
                                    {
                                        Text = "This is the description", HintStyle = AdaptiveTextStyle.CaptionSubtle, HintWrap = true
                                    }
                                }
                            }
                        }
                    }
                };
                var xmlDocument = content.GetXml();
                TileNotification tileNotification = new TileNotification(xmlDocument);
                TileUpdater      tileUpdater      = TileUpdateManager.CreateTileUpdaterForApplication();
                tileUpdater.Update(tileNotification);
            }
        }