Esempio n. 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;
            }
        }
Esempio n. 2
0
        public static void Load()
        {
            SQLiteConnection   conn   = new SQLiteConnection(DB);
            string             GETALL = "SELECT * FROM " + TABLE;
            ListItemViewModels all    = VM.Vm;

            using (var statement = conn.Prepare(GETALL))
            {
                while (SQLiteResult.ROW == statement.Step())
                {
                    int            id          = Convert.ToInt32((Int64)statement[0]);
                    string         title       = statement[1] as string;
                    string         description = statement[2] as string;
                    DateTimeOffset duedate     = DateTimeOffset.Parse(statement[3] as string);
                    byte[]         pixels      = statement[4] as byte[];
                    bool?          completed   = Convert.ToBoolean(statement[5]);

                    ListItem item = new ListItem(id, title, description, duedate, pixels, completed);
                    all.Items.Add(item);
                    ListItemViewModels.count = id;
                }
                ++ListItemViewModels.count;
                TileService.Reset();
            }
        }
Esempio n. 3
0
        public MainPage()
        {
            NavigationCacheMode = NavigationCacheMode.Enabled;
            this.InitializeComponent();

            listItemViewModels = ListItemViewModels.get_instance();
        }
Esempio n. 4
0
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     ViewModel        = new ListItemViewModels();
     TileUpdateManager.CreateTileUpdaterForApplication().Clear();
     TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
 }
Esempio n. 5
0
        }  //创建item

        private async void CreateDialog(int mode)
        {
            ListItemViewModels myViewModels = ListItemViewModels.GetInstance();
            ImageSource        source       = image.Source;

            if (mode == 0)
            {
                ListItem item = new ListItem(textBox.Text, textBox1.Text, source, datepicker.Date, CurrentPic);
                myViewModels.allItems.Add(item);
                UpdateTile(textBox.Text, textBox1.Text, datepicker.Date);
                byte[] picbyte = await ByteArrayBitmapExtensions.AsByteArray(CurrentPic == null?DefaultPic : CurrentPic);

                string res = Convert.ToBase64String(picbyte);
                DataAccess.AddData(item.GetId(), item.title, item.description, item.date.ToString("d"), (item.completed ? 1 : 0), res);
                CurrentPic = DefaultPic;
            }
            else if (mode == 1)
            {
                myViewModels.UpdateTodoItem(id, textBox.Text, textBox1.Text, source, datepicker.Date, CurrentPic);
                byte[] picbyte = await ByteArrayBitmapExtensions.AsByteArray(CurrentPic == null?DefaultPic : CurrentPic);

                string res = Convert.ToBase64String(picbyte);
                DataAccess.UpdateData(id, textBox.Text, textBox1.Text, datepicker.Date.ToString("d"), 0, res);
                CurrentPic = DefaultPic;
            }
            else
            {
                myViewModels.RemoveTodoItem(id);
                DataAccess.DeleteData(id);
            }
            var dialog = new ContentDialog()
            {
                Title             = "成功",
                PrimaryButtonText = "确定",
                FullSizeDesired   = false,
            };
            await dialog.ShowAsync();

            this.id        = null;
            button.Content = "Create";
            if (mode == 1 || mode == 2)
            {
                button.Click -= Update;
                button.Click += Create;
            }
            textBox.Text          = "";
            textBox1.Text         = "";
            datepicker.Date       = DateTime.Now;
            image.Source          = new BitmapImage(new Uri("ms-appx:///Assets/IMG_0245.JPG"));
            DeleteItem.Visibility = Visibility.Collapsed;
            list.SelectedItem     = null;
            mode = 0;
        }  //管理创建更新删除
Esempio n. 6
0
 public NewPage()
 {
     Items = VM.Vm;
     this.InitializeComponent();
     changeBg.Click += CustomSetting.ChangeBg;
     if (Items.SelectedItem != null)
     {
         ListItem temp = Items.SelectedItem;
         editor.SetInfo(temp.Title, temp.Description,
                        temp.Duedate, temp.Pixels);
     }
 }
Esempio n. 7
0
        private void trigger(object sender, SizeChangedEventArgs e)
        {
            ListItemViewModels viewmodel = ListItemViewModels.GetInstance();

            if (Frame.ActualWidth < 600)
            {
                foreach (var item in viewmodel.allItems)
                {
                    item.width = 0;
                }
            }
            else
            {
                foreach (var item in viewmodel.allItems)
                {
                    item.width = 80;
                }
            }
        } //visualstate
Esempio n. 8
0
        private async void CreateDialog(int mode)
        {
            ListItemViewModels myViewModels = ListItemViewModels.GetInstance();
            ImageSource        source       = image.Source;

            if (mode == 0)
            {
                ListItem item = new ListItem(textBox.Text, textBox1.Text, source, datepicker.Date, CurrentPic);
                myViewModels.allItems.Add(item);
                MainPage.UpdateTile(textBox.Text, textBox1.Text, datepicker.Date);
                byte[] picbyte = await ByteArrayBitmapExtensions.AsByteArray(CurrentPic == null?DefaultPic : CurrentPic);

                string res = Convert.ToBase64String(picbyte);
                DataAccess.AddData(item.GetId(), item.title, item.description, item.date.ToString("d"), (item.completed ? 1 : 0), res);
                CurrentPic = null;
            }
            else if (mode == 1)
            {
                byte[] mybytes = await ByteArrayBitmapExtensions.AsByteArray(CurrentPic);

                string res = Convert.ToBase64String(mybytes);
                DataAccess.UpdateData(id, textBox.Text, textBox1.Text, datepicker.Date.ToString("d"), res);
                myViewModels.UpdateTodoItem(id, textBox.Text, textBox1.Text, source, datepicker.Date);
            }
            else
            {
                myViewModels.RemoveTodoItem(id);
            }
            var dialog = new ContentDialog()
            {
                Title             = "成功",
                PrimaryButtonText = "确定",
                FullSizeDesired   = false,
            };
            ContentDialogResult result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                Frame rootFrame = Window.Current.Content as Frame;
                rootFrame.GoBack();
            }
        }
Esempio n. 9
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);
                }
            }
        }
Esempio n. 10
0
        protected override async void OnNavigatedFrom(NavigationEventArgs e)
        {
            bool suspending = ((App)App.Current).issuspend;

            if (suspending)
            {
                var composite = new ApplicationDataCompositeValue();
                for (int i = 0; i < ListItemViewModels.GetInstance().allItems.Count(); i++)
                {
                    var list = ListItemViewModels.GetInstance().allItems;

                    DataAccess.UpdateData(list[i].GetId(), (list[i].completed == true ? 1 : 0));
                    composite["ischecked" + i] = ListItemViewModels.GetInstance().allItems[i].completed;
                }
                composite["title"] = textBox.Text;
                composite["des"]   = textBox1.Text;
                composite["date"]  = datepicker.Date;
                composite["mode"]  = mode;
                composite["id"]    = id;
                ApplicationData.Current.LocalSettings.Values["newpage"] = composite;
                ((App)App.Current).issuspend = false;
                await CurrentPic.CopyAsync(ApplicationData.Current.LocalFolder, "hangpic", NameCollisionOption.ReplaceExisting);
            }
        } //挂起操作
Esempio n. 11
0
 public Content(string id, ListItemViewModels input)
 {
     this.id     = id;
     this.result = input;
 }
Esempio n. 12
0
 public NewPage()
 {
     this.InitializeComponent();
     listItemViewModels = ListItemViewModels.get_instance();
 }
Esempio n. 13
0
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     ViewModel        = new ListItemViewModels();
 }
Esempio n. 14
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");
                }
            }
        }
Esempio n. 15
0
 public MainPage()
 {
     Items = VM.Vm;
     this.InitializeComponent();
     changeBg.Click += CustomSetting.ChangeBg;
 }