Пример #1
0
        private void LoadItem(List <string> entries)
        {
            int i = 0;

            while (i < entries.Count)
            {
                ListItem item = ListItemViewModels.GetInstance().allItems.FirstOrDefault(j => j.GetId() == entries[i]);
                if (item == null)
                {
                    byte[]      picbytes = Convert.FromBase64String(entries[i + 5]);
                    BitmapImage img      = ByteArrayBitmapExtensions.AsBitmapImage(picbytes);
                    var         dateres  = DateTime.Parse(entries[i + 3]);
                    ListItemViewModels.GetInstance().AddToDoItem(entries[i + 1],
                                                                 entries[i + 2], img, dateres, null, entries[i]);
                    ListItem temp = ListItemViewModels.GetInstance().allItems.FirstOrDefault(j => j.GetId() == entries[i]);
                    temp.completed = (entries[i + 4] == "1" ? true : false);
                    UpdateTile(entries[i + 1], entries[i + 2], DateTime.Parse(entries[i + 3]));
                }
                else
                {
                    item.title        = entries[i + 1];
                    item.description  = entries[i + 2];
                    item.date         = DateTime.Parse(entries[i + 3]);
                    item.Image_Source = ByteArrayBitmapExtensions.AsBitmapImage(Convert.FromBase64String(entries[i + 5]));
                }
                i += 6;
            }
        }
Пример #2
0
        } //挂起操作

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            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;
                    for (int i = 0; i < ListItemViewModels.GetInstance().allItems.Count(); i++)
                    {
                        ListItemViewModels.GetInstance().allItems[i].completed = (bool)composite["ischecked" + i];
                    }
                    if ((int)composite["mode"] == 1)
                    {
                        button.Content        = "Update";
                        button.Click         -= Create;
                        button.Click         += Update;
                        DeleteItem.Visibility = Visibility.Visible;
                    }
                    textBox.Text    = (string)composite["title"];
                    textBox1.Text   = (string)composite["des"];
                    id              = (string)composite["id"];
                    datepicker.Date = (DateTimeOffset)composite["date"];
                    StorageFile pic = await ApplicationData.Current.LocalFolder.GetFileAsync("hangpic");

                    BitmapImage img = await ByteArrayBitmapExtensions.AsBitmapImage(pic);

                    image.Source = img;
                    ApplicationData.Current.LocalSettings.Values.Remove("newpage");
                    list.SelectedItem = ListItemViewModels.GetInstance().allItems.FirstOrDefault(j => j.GetId() == id);
                }
            }
        }
Пример #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.NavigationMode == NavigationMode.New)
            {
                if (e.Parameter != null)
                {
                    mode = 1;
                    var item = ListItemViewModels.GetInstance().allItems.FirstOrDefault(j => j.GetId() == e.Parameter as String);
                    id = e.Parameter as String;
                    List <string> data    = DataAccess.GetData();
                    byte[]        thispic = null;
                    int           i       = 0;
                    while (i < data.Count)
                    {
                        if (data[i] == id)
                        {
                            thispic = Convert.FromBase64String(data[i + 5]);
                            break;
                        }
                        i += 6;
                    }
                    StorageFile picfile = await ApplicationData.Current.LocalFolder.CreateFileAsync("tempic", CreationCollisionOption.ReplaceExisting);

                    await FileIO.WriteBytesAsync(picfile, thispic);

                    CurrentPic            = picfile;
                    button.Content        = "Update";
                    button.Click         -= Create;
                    button.Click         += Update;
                    textBox.Text          = item.title;
                    textBox1.Text         = item.description;
                    datepicker.Date       = item.date;
                    image.Source          = item.Image_Source;
                    DeleteItem.Visibility = Visibility.Visible;
                }
                else
                {
                    DeleteItem.Visibility = Visibility.Collapsed;
                    mode = 0;
                }
                base.OnNavigatedTo(e);
                ApplicationData.Current.LocalSettings.Values.Remove("newpage");
            }
            else
            {
                if (ApplicationData.Current.LocalSettings.Values.ContainsKey("newpage"))
                {
                    var composite = ApplicationData.Current.LocalSettings.Values["newpage"] as ApplicationDataCompositeValue;
                    if ((int)composite["mode"] == 1)
                    {
                        mode                  = 1;
                        button.Content        = "Update";
                        button.Click         -= Create;
                        button.Click         += Update;
                        DeleteItem.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        mode = 0;
                    }
                    textBox.Text    = (string)composite["title"];
                    textBox1.Text   = (string)composite["des"];
                    datepicker.Date = (DateTimeOffset)composite["date"];
                    id = (string)composite["id"];
                    StorageFile pic = await ApplicationData.Current.LocalFolder.GetFileAsync("hangpic");

                    CurrentPic = pic;
                    BitmapImage img = await ByteArrayBitmapExtensions.AsBitmapImage(pic);

                    image.Source = img;
                    ApplicationData.Current.LocalSettings.Values.Remove("newpage");
                }
            }
        }