Example #1
0
        // Add a to-do item to the database and collections.
        public void AddToDoItem(ToDoItem newToDoItem)
        {
            // Add a to-do item to the data context.
            toDoDB.Items.InsertOnSubmit(newToDoItem);

            // Save changes to the database.
            toDoDB.SubmitChanges();

            // Add a to-do item to the "all" observable collection.
            AllToDoItems.Add(newToDoItem);

            // Add a to-do item to the appropriate filtered collection.
            switch (newToDoItem.Category.Name)
            {
                case "Home":
                    HomeToDoItems.Add(newToDoItem);
                    break;
                case "Work":
                    WorkToDoItems.Add(newToDoItem);
                    break;
                case "Hobbies":
                    HobbiesToDoItems.Add(newToDoItem);
                    break;
                default:
                    break;
            }
        }
Example #2
0
        // Remove a to-do task item from the database and collections.
        public void DeleteToDoItem(ToDoItem toDoForDelete)
        {
            // Remove the to-do item from the "all" observable collection.
            AllToDoItems.Remove(toDoForDelete);

            // Remove the to-do item from the data context.
            toDoDB.Items.DeleteOnSubmit(toDoForDelete);

            // Remove the to-do item from the appropriate category.
            switch (toDoForDelete.Category.Name)
            {
                case "Home":
                    HomeToDoItems.Remove(toDoForDelete);
                    break;
                case "Work":
                    WorkToDoItems.Remove(toDoForDelete);
                    break;
                case "Hobbies":
                    HobbiesToDoItems.Remove(toDoForDelete);
                    break;
                default:
                    break;
            }

            // Save changes to the database.
            toDoDB.SubmitChanges();
        }
Example #3
0
        // Load the existing item when navigating from main page
        public void loadItemPage()
        {
            PageTitle.Text = LoadedItemInfo;
            newEntryNameTextBox.Text = LoadedItemInfo;

            // Get the list of fields from the load item method. And then fill in the text boxes with
            // the information of the fields.

            LoadedItem = App.ViewModel.GetItem(LoadedItemInfo);

            List<ToDoField> itemFields = App.ViewModel.LoadItem(LoadedItemInfo);
            UpdateFieldDictionary.Add("username", newUserNameTextBox);
            UpdateFieldDictionary.Add("password", newPasswordTextBox);
            UpdateFieldDictionary.Add("note", newNoteTextBox);
            foreach (ToDoField field in itemFields)
            {
                switch (field.FieldName)
                {
                    case "username":
                        newUserNameTextBox.Text = field.FieldValue;

                        break;
                    case "password":
                        newPasswordTextBox.Text = field.FieldValue;
                        LoginPassword.Password = newPasswordTextBox.Text;
                        break;
                    case "note":
                        newNoteTextBox.Text = field.FieldValue;
                        break;
                    default:
                        addFieldBox(field);
                        break;
                }
            }
        }
Example #4
0
        private void appBarOkButton_Click(object sender, EventArgs e)
        {
            // Confirm there is some text in the text box.
            if (newTaskNameTextBox.Text.Length > 0)
            {
                // Create a new to-do item.
                ToDoItem newToDoItem = new ToDoItem
                {
                    ItemName = newTaskNameTextBox.Text,
                    Category = (ToDoCategory)categoriesListPicker.SelectedItem
                };

                // Add the item to the ViewModel.
                App.ViewModel.AddToDoItem(newToDoItem);

                // Return to the main page.
                if (NavigationService.CanGoBack)
                {
                    NavigationService.GoBack();
                }
            }
        }
Example #5
0
 // Called during an add operation
 private void attach_ToDo(ToDoItem toDo)
 {
     NotifyPropertyChanging("ToDoItem");
     toDo.Category = this;
 }
 // Called during a remove operation
 private void detach_ToDo(ToDoItem toDo)
 {
     NotifyPropertyChanging("ToDoItem");
     toDo.Category = null;
 }
 // Called during an add operation
 private void attach_ToDo(ToDoItem toDo)
 {
     NotifyPropertyChanging("ToDoItem");
     toDo.Category = this;
 }
Example #8
0
 //rename
 public void RenameToDoItem(ToDoItem toDoForRename,String newName)
 {
     toDoForRename.ItemName = newName;
 }
Example #9
0
        // Remove a to-do task item from the database and collections.
        public void DeleteToDoItem(ToDoItem toDoForDelete)
        {
            // Remove the to-do item from the "all" observable collection.
            AllToDoItems.Remove(toDoForDelete);

            // Remove the to-do item from the data context.
            toDoDB.Items.DeleteOnSubmit(toDoForDelete);

            // Remove the to-do item from the appropriate category.

            if (toDoForDelete.Category.Id == 1)
            {

                HomeToDoItems.Remove(toDoForDelete);
            }
            else if (toDoForDelete.Category.Id == 2)
            {
                WorkToDoItems.Remove(toDoForDelete);
            }
            else
            {
                HobbiesToDoItems.Remove(toDoForDelete);
            }

            // Save changes to the database.
            toDoDB.SubmitChanges();
        }
Example #10
0
        // Add a to-do item to the database and collections.
        public void AddToDoItem(ToDoItem newToDoItem)
        {
            // Add a to-do item to the data context.
            toDoDB.Items.InsertOnSubmit(newToDoItem);

            // Save changes to the database.

            // Add a to-do item to the "all" observable collection.
            //AllToDoItems.Add(newToDoItem);

            // Add a to-do item to the appropriate filtered collection.

            if (newToDoItem.Category.Id == 1)
            {

                HomeToDoItems.Add(newToDoItem);
            }
            else if (newToDoItem.Category.Id == 2)
            {
                WorkToDoItems.Add(newToDoItem);
            }
            else if (newToDoItem.Category.Id == 3)
            {
                HobbiesToDoItems.Add(newToDoItem);
            }

            toDoDB.SubmitChanges();
        }
Example #11
0
 // Called during a remove operation
 private void detach_ToDo(ToDoItem toDo)
 {
     NotifyPropertyChanging("ToDoItem");
     toDo.Category = null;
 }
Example #12
0
        private void Save()
        {
            String itemname = fileNameInput.Text;
            int count = App.ViewModel.displayItemCount(fileNameInput.Text);
               // ToDoItem toSave = App.ViewModel.displayItem(fileNameInput.Text);
            if (AddHeader.Text == txtnote.Resources.StringLibrary.addtxt)
            {
                // Picker.Visibility = System.Windows.Visibility.Collapsed;

                if (count > 0)
                {
                    itemname = fileNameInput.Text + "_" + count.ToString() ;
                }
                //不同difference
                // Create a new to-do item.
                ToDoItem newToDoItem = new ToDoItem
                {
                    ItemName = itemname+".txt",
                    Category = (ToDoCategory)IEcategoriesListPicker.SelectedItem,
                    CreatTime = DateTime.Now,
                    EditTime = DateTime.Now,
                    TxtFile = editTextBox.Text.ToString()

                };
                App.ViewModel.AddToDoItem(newToDoItem);
                initialAddPano();//重置添加页面
                MainPano.DefaultItem = ViewPano;

               CleanCheckBox();
                //navigationback();
            }
            else
            {
                //如果该txt还存在,则保存编辑
                if (count != 0)
                {
                    if (App.ViewModel.forShare == null)
                    {
                        App.ViewModel.forShare = App.ViewModel.displayItem(fileNameInput.Text);
                    }

                    App.ViewModel.forShare.EditTime = DateTime.Now;
                    App.ViewModel.forShare.ItemName = fileNameInput.Text;
                    App.ViewModel.forShare.Category = (ToDoCategory)IEcategoriesListPicker.SelectedItem;
                    App.ViewModel.forShare.TxtFile = editTextBox.Text;
                    App.ViewModel.SaveChangesToDB();
                    initialAddPano();
                    MainPano.DefaultItem = ViewPano;
                    CleanCheckBox();
                    // navigationback();
                }
                else
                {
                    AddHeader.Text = txtnote.Resources.StringLibrary.addtxt;
                    Save();
                }
            }
        }
Example #13
0
        private void appBarOkButton_Click(object sender, EventArgs e)
        {
            Microsoft.Devices.VibrateController.Default.Start(
                               TimeSpan.FromSeconds(0.1));
            var bitmap = new System.Windows.Media.Imaging.WriteableBitmap(
                            this.personcanvas, null);
            var stream = new System.IO.MemoryStream();
            System.Windows.Media.Imaging.Extensions.SaveJpeg(bitmap, stream,
                               bitmap.PixelWidth, bitmap.PixelHeight, 0, 100);
            stream.Position = 0;
            var mediaLib = new Microsoft.Xna.Framework.Media.MediaLibrary();
            var datetime = System.DateTime.Now;
            var filestring = datetime.Year % 100 + datetime.Month + datetime.Day +
                        datetime.Hour + datetime.Minute + datetime.Second;
            var filename =
                System.String.Format("historyperson" + filestring,
                        datetime.Year % 100, datetime.Month, datetime.Day,
                        datetime.Hour, datetime.Minute, datetime.Second);
            mediaLib.SavePicture(filename, stream);
            string historyperson = "historyperson" + filestring + ".jpg";

            IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
            using (Stream stream1 = storage.OpenFile(historyperson, FileMode.Create))
            {
                Extensions.SaveJpeg(bitmap, stream1, 300, 300, 0, 100);
            }

            // Create a new to-do item.
            ToDoItem newToDoItem = new ToDoItem
            {
                ItemName = @"historyperson" + filestring + ".jpg",
                //ItemName = img,
                Category = (ToDoCategory)categoriesListPicker.SelectedItem
            };

            // Add the item to the ViewModel.
            App.ViewModel.AddToDoItem(newToDoItem);
        }
Example #14
0
        private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
        {
            int count = App.ViewModel.displayItemCount("example.txt");
            if (count == 0)
            {

                ToDoItem newToDoItem = new ToDoItem
                {
                    //不同difference
                    ItemName = "example.txt",
                    Category = (ToDoCategory)IEcategoriesListPicker.SelectedItem,
                    CreatTime = DateTime.Now,
                    EditTime = DateTime.Now,
                    TxtFile = txtnote.Resources.StringLibrary.shili

                };
                App.ViewModel.AddToDoItem(newToDoItem);
            }
        }
Example #15
0
        // Remove a to-do task item from the database and collections.
        public void DeleteToDoItem(ToDoItem toDoForDelete)
        {
            // Remove the to-do item from the "all" observable collection.
            AllToDoItems.Remove(toDoForDelete);

            // Remove all the fields related to the item
            List<ToDoField> itemFields = LoadItem(toDoForDelete.ItemName);
            toDoDB.Fields.DeleteAllOnSubmit(itemFields);
            // Remove the to-do item from the data context.
            toDoDB.Items.DeleteOnSubmit(toDoForDelete);

            // Remove the to-do item from the appropriate category.
            switch (toDoForDelete.Category.Name)
            {
                case "Game info":
                    AccountEntryItems.Remove(toDoForDelete);
                    break;
                case "Finance info":
                    PersonalEntryItems.Remove(toDoForDelete);
                    break;
                case "Customized info":
                    CustomEntryItems.Remove(toDoForDelete);
                    break;
                default:
                    break;
            }

            // Save changes to the database.
            toDoDB.SubmitChanges();
        }
Example #16
0
        // Add a to-do item to the database and collections.
        public void AddToDoItem(ToDoItem newToDoItem)
        {
            // Add a to-do item to the data context.
            toDoDB.Items.InsertOnSubmit(newToDoItem);

            // Save changes to the database.
            toDoDB.SubmitChanges();

            // Add a to-do item to the "all" observable collection.
            AllToDoItems.Add(newToDoItem);

            // Add a to-do item to the appropriate filtered collection.
            switch (newToDoItem.Category.Name)
            {
                case "Game info":
                    AccountEntryItems.Add(newToDoItem);
                    break;
                case "Finance info":
                    PersonalEntryItems.Add(newToDoItem);
                    break;
                case "Customized info":
                    CustomEntryItems.Add(newToDoItem);
                    break;
                default:
                    break;
            }
        }
Example #17
0
        private void downloadMerge(StreamReader reader)
        {
            while (!reader.EndOfStream)
            {
                txtfile = reader.ReadLine();
                string[] abc = txtfile.Split(new Char[] { '\t' });
                if (abc[0] != "")
                {
                    if (App.ViewModel.displayItem(abc[0]) == null)
                    {

                        ToDoItem newToDoItem = new ToDoItem
                        {
                            //txtnote需更改
                            ItemName = abc[0],
                            Category = App.ViewModel.CategoriesList.First(),
                            CreatTime = DateTime.Now,
                            EditTime = DateTime.Now,
                            TxtFile = abc[1]

                        };

                        App.ViewModel.AddToDoItem(newToDoItem);

                    }
                    else
                    {
                        ToDoItem toUpdate = App.ViewModel.displayItem(abc[0]);
                        toUpdate.TxtFile = abc[1];
                        toUpdate.EditTime = DateTime.Now;
                        App.ViewModel.SaveChangesToDB();
                    }

                }
            }
               // NavigationService.GoBack();
        }
Example #18
0
        void client_DownloadCompleted(object sender, LiveDownloadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                infoTextBlock2.Text = "Downloading...";
                try
                {
                    using (MemoryStream stream = e.Result as MemoryStream)
                    {
                        //stream = e.Result as MemoryStream;

                        using (var reader = new StreamReader(stream))
                        {

                            txtfile = reader.ReadToEnd();
                            if (App.ViewModel.displayItem(itemname) == null)
                            {

                                ToDoItem newToDoItem = new ToDoItem
                                {
                                    //txtnote需更改
                                    ItemName = itemname,
                                    Category = App.ViewModel.CategoriesList.First(),
                                    CreatTime = DateTime.Now,
                                    EditTime = DateTime.Now,
                                    TxtFile = txtfile

                                };

                                App.ViewModel.AddToDoItem(newToDoItem);

                            }
                            else
                            {
                                ToDoItem toUpdate = App.ViewModel.displayItem(itemname);
                                toUpdate.TxtFile = txtfile;
                                toUpdate.EditTime = DateTime.Now;
                                App.ViewModel.SaveChangesToDB();

                            }
                        }
                    }
                    //如果有所选中,并且选中的就是当前处理的
                    if (k != -1 && k == s_number - 1)
                    {

                        //infoTextBlock2.Text = txtnote.Resources.StringLibrary.download_2;
                        infoTextBlock2.Text = txtnote.Resources.StringLibrary.download_2;
                        // client.DownloadCompleted -= client_DownloadCompleted;
                        client.DownloadCompleted -= client_DownloadCompleted;

                    }
                    else    pickMax();
                }
                catch (Exception exc)
                {
                   // MessageBox.Show(exc.Message);
                    MessageBox.Show("Click so frequent!Now restart the Page");
                    //NavigationService.GoBack();
                    string uri = String.Format("/txtnote;component/share.xaml");
                    NavigationService.Navigate(new Uri(uri, UriKind.Relative));
                    shareManager.SelectedIndex = 1;
                }
            }
            else
            {
                MessageBox.Show("Unable to download Backup file.", "Failure", MessageBoxButton.OK);
            }
        }
        protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
        {
            base.OnNavigatingFrom(e);
            if (currentId < 0)
            {
                // Create a new to-do item.
                ToDoItem newToDoItem = new ToDoItem
                {
                    ItemName = newTaskNameTextBox.Text,
                    Foreground = this.foregroundPicker.SelectedItem.ToString(),
                    Background = this.backgroundPicker.SelectedItem.ToString(),
                    Category = (ToDoCategory)categoriesListPicker.SelectedItem
                };

                // Add the item to the ViewModel.
                App.ViewModel.AddToDoItem(newToDoItem);
            }
            else
            {
                var todo = App.ViewModel.AllToDoItems.FirstOrDefault(t => t.ToDoItemId == currentId);
                todo.ItemName = newTaskNameTextBox.Text;
                todo.Foreground = this.foregroundPicker.SelectedItem.ToString();
                todo.Background = this.backgroundPicker.SelectedItem.ToString();
                App.ViewModel.SaveChangesToDB();
            }
        }
Example #20
0
        // When ok is clicked, save the item and add to database
        // Make sure all the fields are also stored
        private void appBarOkButton_Click(object sender, EventArgs e)
        {
            // Confirm there is some text in the text box.
            if (newEntryNameTextBox.Text.Length > 0)
            {
                // Check if this is a new item or existing item
                if (LoadedItemInfo == null)
                {
                    List<ToDoField> NewFields = new List<ToDoField>();
                    // Create a new to-do item.
                    LoadedItem = new ToDoItem
                    {
                        ItemName = newEntryNameTextBox.Text,
                        Category = (ToDoCategory)categoriesListPicker.SelectedItem
                    };

                    ToDoField UsernameField = new ToDoField
                    {
                        FieldName = "username",
                        FieldValue = newUserNameTextBox.Text,
                        Item = LoadedItem
                    };

                    ToDoField PasswordField = new ToDoField
                    {
                        FieldName = "password",
                        FieldValue = newPasswordTextBox.Text,
                        Item = LoadedItem
                    };
                    ToDoField NoteField = new ToDoField
                    {
                        FieldName = "note",
                        FieldValue = newNoteTextBox.Text,
                        Item = LoadedItem
                    };

                    NewFields.Add(UsernameField);
                    NewFields.Add(PasswordField);
                    NewFields.Add(NoteField);

                    // Add the item to the ViewModel.
                    App.ViewModel.AddToDoItem(LoadedItem);
                    App.ViewModel.AddToDoField(NewFields);
                }
                else
                {
                    Dictionary<string, string> fieldValueDict = new Dictionary<string, string>();
                    foreach (KeyValuePair<string, TextBox> updateField in UpdateFieldDictionary)
                    {
                        fieldValueDict.Add(updateField.Key, updateField.Value.Text);
                    }
                    //fieldValueDict.Add("username", newUserNameTextBox.Text);
                    //fieldValueDict.Add("password", newPasswordTextBox.Text);
                    //fieldValueDict.Add("note", newNoteTextBox.Text);
                    App.ViewModel.UpdateItem(fieldValueDict, LoadedItemInfo);
                }

                List<ToDoField> NewFieldsDup = new List<ToDoField>();
                foreach (KeyValuePair<string, TextBox> newFieldInfo in NewFieldDictionary)
                {
                    ToDoField newField = new ToDoField
                    {
                        FieldName = newFieldInfo.Key,
                        FieldValue = newFieldInfo.Value.Text,
                        Item = LoadedItem
                    };
                    NewFieldsDup.Add(newField);

                }
                App.ViewModel.AddToDoField(NewFieldsDup);

                // Return to the main page.
                if (NavigationService.CanGoBack)
                {
                    NavigationService.GoBack();
                }
            }
        }