Пример #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                ApplicationData.Current.LocalSettings.Values.Remove("NavigationPage");
            }
            else
            {
                if (ApplicationData.Current.LocalSettings.Values.ContainsKey("NavigationPage"))
                {
                    // Read data
                    var composite = ApplicationData.Current.LocalSettings.Values["NavigationPage"] as ApplicationDataCompositeValue;
                    myTitle.Text          = (string)composite["myTitle"];
                    myDetail.Text         = (string)composite["myDetail"];
                    myDate.Date           = (DateTimeOffset)composite["myDate"];
                    RightPad.Visibility   = ((bool)composite["RightPad"]) ? Visibility.Visible : Visibility.Collapsed;
                    readAndLoad(fileToken = (string)composite["myImg"]);
                    isCreating            = (bool)composite["isCreating"];
                    if ((int)composite["Selected"] >= 0)
                    {
                        memo  = ViewModel.Memos.ElementAt((int)composite["Selected"]);
                        bytes = memo.Bytes;
                    }
                    DeletePage.Visibility = isCreating ? Visibility.Collapsed : Visibility.Visible;

                    // Clean data
                    ApplicationData.Current.LocalSettings.Values.Remove("NavigationPage");
                }
            }
            base.OnNavigatedTo(e);
        }
        public void Loadmemos(string token = "")
        {
            App.ViewModel.Memos.Clear();
            string sql = "SELECT * FROM StorageMemo";

            if (token != "")
            {
                sql += " WHERE Detail LIKE '%" + token;
                sql += "%' OR Title LIKE '%" + token;
                sql += "%' OR Time LIKE '%" + token + "%'";
            }
            var memos = db.Query <StorageMemo>(sql);

            foreach (var memo in memos)
            {
                BitmapImage bitmap = (memo.Image == null) ? new BitmapImage(new Uri("ms-appx:///Assets/Square150x150Logo.scale-200.png")) : BytesToBitmapImage(memo.Image);
                Memorandum  toAdd  = new Memorandum(memo.Id)
                {
                    MemoDate   = DateTime.ParseExact(memo.Time, pattern, null, System.Globalization.DateTimeStyles.None),
                    MemoDetail = memo.Detail,
                    MemoTitle  = memo.Title,
                    Bytes      = memo.Image,
                    MemoImg    = bitmap,
                    IsDone     = memo.state
                };
                App.ViewModel.Memos.Add(toAdd);
            }
        }
Пример #3
0
 private void DeletePage_Click(object sender, RoutedEventArgs e)
 {
     App.databaseManager.DeleteMemo(memo.Id);
     memo      = null;
     fileToken = null;
     bytes     = null;
     ViewModel.Memos.RemoveAt(MainPage.PresentItem);
     PageList.SelectedIndex = -1;
     (new Windows.UI.Popups.MessageDialog("删除成功", "提示信息")).ShowAsync();
     RightPad.Visibility = Visibility.Collapsed;
     App.tileController.Update();
 }
 public void InsertMemo(Memorandum toAdd)
 {
     db.Insert(new StorageMemo()
     {
         Id     = toAdd.Id,
         Detail = toAdd.MemoDetail,
         Title  = toAdd.MemoTitle,
         Time   = toAdd.MemoDate.ToString(pattern),
         Image  = toAdd.Bytes,
         state  = toAdd.IsDone
     });
 }
Пример #5
0
 private void PageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     MainPage.PresentItem = PageList.SelectedIndex;
     if (MainPage.PresentItem == -1)
     {
         return;
     }
     memo = ViewModel.Memos.ElementAt(MainPage.PresentItem);
     if (Window.Current.Bounds.Width > 880)
     {
         RightPad.Visibility = Visibility.Visible;
         if (!isCreating)
         {
             myTitle.Text  = memo.MemoTitle;
             myDetail.Text = memo.MemoDetail;
             myDate.Date   = memo.MemoDate.Date;
             myImg.Source  = memo.MemoImg;
             bytes         = memo.Bytes;
             fileToken     = null;
         }
         else
         {
             isCreating            = false;
             DeletePage.Visibility = Visibility.Visible;
         }
     }
     else
     {
         if (!isCreating)
         {
             NewPage.Current.myTitle.Text  = memo.MemoTitle;
             NewPage.Current.myDetail.Text = memo.MemoDetail;
             NewPage.Current.myDate.Date   = memo.MemoDate.Date;
             NewPage.Current.myImg.Source  = memo.MemoImg;
         }
         else
         {
             isCreating = false;
             NewPage.Current.DeletePage.Visibility = Visibility.Visible;
         }
     }
 }