Пример #1
0
        private void appbarCheck_Click(object sender, EventArgs e)
        {
            if ( newNoteTitleTextBox.Text.Length > 0 || newNoteContentTextBox.Text.Length > 0 )
            {
                // Create a new VNoteItem item.
                VNoteItem newVNoteItem = new VNoteItem
                {
                    VNoteTitle = newNoteTitleTextBox.Text,
                    VNoteText = newNoteContentTextBox.Text,
                    VNotePhoto = VNotePhotoFileName,
                    VNoteDate = DateTime.Now,
                    Category = (VNoteCategory)categoriesListPicker.SelectedItem
                };

                // Add the item to ViewModel.
                App.ViewModel.AddVNoteItem(newVNoteItem);
                ViewNote.MainPage.UpdateLiveTiles();

                // Return to previous page.
                if ( NavigationService.CanGoBack )
                {
                    NavigationService.GoBack();
                }
            }
        }
Пример #2
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            if ( e.NavigationMode == System.Windows.Navigation.NavigationMode.Back )
            {
                UseSettings();
            }

            int noteID = int.Parse(NavigationContext.QueryString["ID"]);

            foreach ( VNoteItem note in App.ViewModel.AllNotesItems )
            {
                if ( note.VNoteItemId == noteID )
                {
                    DataContext = note;
                    noteContext = note;
                    break;
                }
            }
            if ( noteContext.VNotePhoto != null )
            {
                BitmapImage imageFromStorage = new BitmapImage();
                string imageFolder = "ViewNotePhotos";
                string imageFileName = noteContext.VNotePhoto;

                using ( var isoFile = IsolatedStorageFile.GetUserStoreForApplication() )
                {
                    string filePath = System.IO.Path.Combine(imageFolder, imageFileName);
                    System.Diagnostics.Debug.WriteLine("Read filePath: {0}", filePath);
                    using ( var imageStream = isoFile.OpenFile(
                        filePath, FileMode.Open, FileAccess.Read) )
                    {
                        imageFromStorage.SetSource(imageStream);
                        System.Diagnostics.Debug.WriteLine("Reading image for pano: {0}", 0);
                    }
                }
                notePhoto.Source = imageFromStorage;
            }

            // Check if pinned
            thisPageUri = String.Format("/NotePage.xaml?ID={0}", noteID);
            ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(thisPageUri));

            if ( tile == null )
            {
                var appbarPinUnpin = ApplicationBar.Buttons[3] as ApplicationBarIconButton;
                appbarPinUnpin.Text = "Pin note to Start";
                appbarPinUnpin.IconUri = new Uri("/Images/pin.png", UriKind.Relative);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Tile: {0}", tile.ToString());
                var appbarPinUnpin = ApplicationBar.Buttons[3] as ApplicationBarIconButton;
                appbarPinUnpin.Text = "Unpin note";
                appbarPinUnpin.IconUri = new Uri("/Images/pin.remove.png", UriKind.Relative);
            }
        }
Пример #3
0
 // Remove action
 private void detach_Note(VNoteItem note)
 {
     NotifyPropertyChanging("VNoteItem");
     note.Category = null;
 }
Пример #4
0
 // Add action
 private void attach_Note(VNoteItem note)
 {
     NotifyPropertyChanging("VNoteItem");
     note.Category = this;
 }
Пример #5
0
        // Remove VNote item from the database and collections.
        public void DeleteVNoteItem(VNoteItem noteToDelete)
        {
            // Remove Vnote item from "all" observable collection.
            AllNotesItems.Remove(noteToDelete);

            // Remove VNote item from  data context.
            viewNoteDB.Items.DeleteOnSubmit(noteToDelete);

            // Remove VNote from category.
            switch ( noteToDelete.Category.Name )
            {
                case "Memo":
                    MemoNotesItems.Remove(noteToDelete);
                    break;
                case "Travel":
                    TravelNotesItems.Remove(noteToDelete);
                    break;
                case "Fun":
                    FunNotesItems.Remove(noteToDelete);
                    break;
                default:
                    break;
            }

            // Save changes to the database.
            viewNoteDB.SubmitChanges();
        }
Пример #6
0
        // Add VNote item to the database and collections.
        public void AddVNoteItem(VNoteItem newVNoteItem)
        {
            // Add VNote item to the data context.
            viewNoteDB.Items.InsertOnSubmit(newVNoteItem);

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

            // Add VNote item to the "all" observable collection.
            AllNotesItems.Add(newVNoteItem);

            // Add VNote item to the appropriate filtered collection.
            switch ( newVNoteItem.Category.Name )
            {
                case "Memo":
                    MemoNotesItems.Add(newVNoteItem);
                    break;
                case "Travel":
                    TravelNotesItems.Add(newVNoteItem);
                    break;
                case "Fun":
                    FunNotesItems.Add(newVNoteItem);
                    break;
                default:
                    break;
            }
        }