/// <summary>
        /// User clicked on "Move" appbar button, this method will build and display a popup menu with list of Notebooks.
        /// Allowing the user target notebook.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async void btnMoveNotebookClick(object sender, RoutedEventArgs e)
        {
            PopupMenu nbMenu = new PopupMenu();
            var       nbs    = NotesDataSource.GetGroups();

            foreach (NoteBook nb in nbs)
            {
                if (!nb.UniqueId.Equals(Note.NoteBookUniqueId))
                {
                    nbMenu.Commands.Add(new UICommand(nb.Title, null, nb.UniqueId));
                }
            }

            var        rect    = Helpers.GetElementRect((FrameworkElement)sender);
            IUICommand command = await nbMenu.ShowForSelectionAsync(rect);

            if (command == null)
            {
                return;
            }


            var result = await Helpers.ShowDialog(string.Format(Consts.MoveNote, Note.NoteBook.Title, command.Label), "Move Note");

            var nbUniqueId = (string)command.Id;

            if (result)
            {
                NotesDataSource.Move(Note.UniqueId, nbUniqueId);
                DrawDefaultAppBar();
            }
        }
示例#2
0
        /// <summary>
        /// Update ToDo Note after each ToDo item update.
        /// </summary>
        void UpdateNote()
        {
            var item = NotesDataSource.GetItem(NoteUniqueId);

            TileManager.UpdateSecondaryTile(NoteUniqueId);
            DataManager.Save(item.NoteBook);
        }
        /// <summary>
        /// Place Splash Screen at the center of the page and register to the following events:
        /// DataTransferManager -> DataRequested
        /// SettingsPane -> CommandsRequested
        /// NotesDataSource -> DataCompleted
        /// </summary>
        /// <param name="splashScreen">SplashScreen from IActivatedEventArgs</param>
        public async Task Init()
        {
            if (!NotesDataSource.DataLoaded)
            {
                this.InitializeComponent();
                this.splashImageCoordinates = splash.ImageLocation;

                // Position the extended splash screen image in the same location as the splash screen image.
                this.loader.SetValue(Canvas.LeftProperty, this.splashImageCoordinates.X);
                this.loader.SetValue(Canvas.TopProperty, this.splashImageCoordinates.Y);
                this.loader.Height = this.splashImageCoordinates.Height;
                this.loader.Width  = this.splashImageCoordinates.Width;

                // LAB #8 - CONTRACTS

                Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);

                SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;

                NotesDataSource data = new NotesDataSource();
                data.Completed += Data_Completed;
                await data.Load();

                return;
            }
            else
            {
                return;
            }
        }
示例#4
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            var query = (String)navigationParameter;
            var list  = NotesDataSource.Search(query);

            this.pageTitle.Text = string.Format("Results for \"{0}\"", query);
            var nb = new NoteBook();

            foreach (NoteDataCommon note in list)
            {
                switch (note.Type)
                {
                case DataModel.NoteTypes.Food:
                    nb.FoodSection.Add(note);
                    break;

                case DataModel.NoteTypes.ToDo:
                    nb.ToDoSection.Add(note);
                    break;

                default:
                    nb.NotesSection.Add(note);
                    break;
                }
            }

            this.DefaultViewModel["Groups"] = nb.Sections;
        }
示例#5
0
        /// <summary>
        /// Create new Note, if there is no notebooks available the show error massage.
        /// Create new Note from GroupedItemsPage (no selected notebook) then create note under the first Notebook.
        /// Create new Note from GroupDetailPage then create note under the notebook presented in GroupDetailPage.
        /// Create new Note from ItemDetailPage then create note under the current Note Notebook.
        /// </summary>
        /// <param name="item">New Note To Create</param>
        public void CreateNew(NoteDataCommon item)
        {
            if (NotesDataSource.GetGroups().Count == 0)
            {
                Helpers.ShowMessageAsync("You first need to create a notebook.", "Create Notebook");
                return;
            }

            if (this.GetType() == typeof(GroupDetailPage))
            {
                item.NoteBook = this.DefaultViewModel["Group"] as NoteBook;
                NotesDataSource.Add(item, item.NoteBookUniqueId);
            }
            else if (this.GetType() == typeof(ItemDetailPage))
            {
                item.NoteBook = (this.DefaultViewModel["Item"] as NoteDataCommon).NoteBook;
                NotesDataSource.Add(item, item.NoteBookUniqueId);
            }
            else
            {
                item.NoteBook = NotesDataSource.GetGroups()[0] as NoteBook;
                NotesDataSource.Add(item, item.NoteBookUniqueId);
            }

            this.Frame.Navigate(typeof(ItemDetailPage), item.UniqueId);
        }
        /// <summary>
        /// Remove all unused images from local storage
        /// </summary>
        /// <returns></returns>
        private async static Task RunCleanOperationAsync()
        {
            try
            {
                var storage = Windows.Storage.ApplicationData.Current.LocalFolder;
                var folder  = await storage.CreateFolderAsync(FolderNames.Images.ToString(), Windows.Storage.CreationCollisionOption.OpenIfExists);

                if (folder == null)
                {
                    return;
                }

                var notebooks = NotesDataSource.GetGroups().Cast <NoteBook>().ToList();

                var files = await folder.GetFilesAsync();

                var allImages = notebooks.SelectMany(n => n.Items).SelectMany(imgs => imgs.Images);
                foreach (var file in files)
                {
                    if (!allImages.Any(img => img.Contains(file.Name)))
                    {
                        await file.DeleteAsync();
                    }
                }
            }
            catch (Exception)
            {
                //Helpers.ShowErrorMessage("Clean", ex);
            }
        }
        /// <summary>
        /// Load all notebooks and for each note load all images under one collection.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var nbs    = NotesDataSource.GetGroups();
            var images = nbs.SelectMany(n => ((NoteBook)n).Items).SelectMany(i => i.Images).ToList();

            imagesGrid.ItemsSource = images;
        }
        /// <summary>
        /// Place Splash Screen at the center of the page and register to the following events:
        /// DataTransferManager -> DataRequested
        /// SearchPane -> SuggestionsRequested, SearchPaneQuerySubmitted
        /// SettingsPane -> CommandsRequested
        /// NotesDataSource -> DataCompleted
        /// </summary>
        /// <param name="splashScreen">SplashScreen from IActivatedEventArgs</param>
        async private void Init(SplashScreen splashScreen)
        {
            if (!NotesDataSource.DataLoaded)
            {
                this.InitializeComponent();
                this.splashImageCoordinates = splashScreen.ImageLocation;
                this.splash = splashScreen;

                // Position the extended splash screen image in the same location as the splash screen image.
                this.loader.SetValue(Canvas.LeftProperty, this.splashImageCoordinates.X);
                this.loader.SetValue(Canvas.TopProperty, this.splashImageCoordinates.Y);
                this.loader.Height = this.splashImageCoordinates.Height;
                this.loader.Width  = this.splashImageCoordinates.Width;

                DataTransferManager datatransferManager;
                datatransferManager = DataTransferManager.GetForCurrentView();
                datatransferManager.DataRequested += new TypedEventHandler <DataTransferManager, DataRequestedEventArgs>(this.DataRequested);

                Window.Current.SizeChanged += new WindowSizeChangedEventHandler(ExtendedSplash_OnResize);
                SearchPane.GetForCurrentView().SuggestionsRequested += SearchPaneSuggestionsRequested;
                SearchPane.GetForCurrentView().QuerySubmitted       += SearchPaneQuerySubmitted;

                SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;

                NotesDataSource data = new NotesDataSource();
                data.Completed += Data_Completed;
                await data.Load();
            }
            else
            {
                Data_Completed(this, null);
            }
        }
        /// <summary>
        /// User has choose a search suggestion.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void SearchPaneQuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
        {
            Frame frame;

            if (Window.Current.Content == null)
            {
                frame = new Frame();
            }
            else
            {
                frame = Window.Current.Content as Frame;
            }

            if (args.QueryText.Contains(Consts.SearchSplitter))
            {
                var notebookName = args.QueryText.Substring(0, args.QueryText.IndexOf(Consts.SearchSplitter));
                var noteName     = args.QueryText.Substring(args.QueryText.IndexOf(Consts.SearchSplitter) + Consts.SearchSplitter.Length);
                var notebook     = NotesDataSource.SearchNotebook(notebookName);
                if (notebook == null)
                {
                    return;
                }
                var note = NotesDataSource.SearchNote(notebook.UniqueId, noteName);
                if (note == null)
                {
                    return;
                }

                frame.Navigate(typeof(ItemDetailPage), note.UniqueId);
            }
            else
            {
                frame.Navigate(typeof(SearchResults), args.QueryText);
            }
        }
        /// <summary>
        /// Build navigation popup menu when clicking on Notebook title.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (navigationMenu != null)
            {
                return;
            }

            navigationMenu = new MenuFlyout();
            var navigationNotebooks = NotesDataSource.GetGroups();

            for (int i = 0; i < navigationNotebooks.Count; i++)
            {
                MenuFlyoutItem command = new MenuFlyoutItem();
                command.Text   = navigationNotebooks[i].Title;
                command.Name   = navigationNotebooks[i].UniqueId;
                command.Click += (s, args) => Navigate(command.Name);
                navigationMenu.Items.Add(command);
            }
            MenuFlyoutSeparator separator = new MenuFlyoutSeparator();

            navigationMenu.Items.Add(separator);

            MenuFlyoutItem cmd = new MenuFlyoutItem();

            cmd.Text   = "Home";
            cmd.Click += (s, args) => Navigate(null);
            navigationMenu.Items.Add(cmd);

            navigationMenu.ShowAt((FrameworkElement)pageTitle);
            navigationMenu = null;
        }
        /// <summary>
        /// Load local notebooks
        /// </summary>
        /// <returns></returns>
        static async public Task LoadAsync()
        {
            var storage = Windows.Storage.ApplicationData.Current.LocalFolder;
            var folder  = await storage.CreateFolderAsync(FolderNames.Notebooks.ToString(), CreationCollisionOption.OpenIfExists);

            var         notebooks = new ObservableCollection <NoteDataCommon>();
            List <Type> types     = new List <Type>();

            types.Add(typeof(FoodDataItem));
            types.Add(typeof(NoteDataItem));
            types.Add(typeof(ToDoDataItem));
            types.Add(typeof(NoteBook));

            NotesDataSource.Unload();
            DataContractJsonSerializer des = new DataContractJsonSerializer(typeof(NoteDataCommon), types);

            var files = await folder.GetFilesAsync();

            foreach (var file in files)
            {
                try
                {
                    using (var stream = await file.OpenReadAsync())
                    {
                        var noteB = (NoteDataCommon)des.ReadObject(stream.AsStreamForRead());
                        NotesDataSource.AddNoteBook(noteB);
                    }
                }
                catch
                {
                    Helpers.ShowErrorMessageAsync("Load Notebooks", "The application found data corruption.");
                }
            }
        }
        /// <summary>
        /// Return Search results based on search value
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args">SearchPaneSuggestionsRequestedEventArgs contains QueryText of the search value</param>
        void SearchPaneSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            var items = NotesDataSource.Search(args.QueryText);

            foreach (NoteDataCommon item in items)
            {
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion(string.Format("{0}{1}{2}", item.NoteBook.Title, Consts.SearchSplitter, item.Title));
            }
        }
示例#13
0
        /// <summary>
        /// Set all notebooks as NotebooksGridView itemsSource.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (!NotesDataSource.DataLoaded)
            {
                await DataManager.LoadAsync();
            }

            NotebooksGridView.ItemsSource = NotesDataSource.GetGroups();
        }
示例#14
0
 /// <summary>
 /// Populates the page with content passed during navigation.  Any saved state is also
 /// provided when recreating a page from a prior session.
 /// </summary>
 /// <param name="navigationParameter">The parameter value passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
 /// </param>
 /// <param name="pageState">A dictionary of state preserved by this page during an earlier
 /// session.  This will be null the first time a page is visited.</param>
 protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
 {
     if (navigationParameter != null)
     {
         InitializeFirstTimeData();
     }
     else
     {
         NotesDataSource.Unload();
     }
 }
        /// <summary>
        /// Gets all used tags from all notebooks.
        /// </summary>
        /// <returns>List of all Tags</returns>
        private Dictionary <string, bool> BuildTagList()
        {
            var allTags = NotesDataSource.GetGroups().SelectMany(nb => ((NoteBook)nb).Items).SelectMany(t => t.Tags).Distinct();
            var tags    = new Dictionary <string, bool>();

            foreach (var tag in allTags)
            {
                tags.Add(tag, this.Note.Tags.Contains(tag));
            }
            return(tags);
        }
示例#16
0
        /// <summary>
        /// Delete Notebook
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            var result = await Helpers.ShowDialog("Are you sure you want to delete this NoteBook?", "Delete NoteBook");

            if (result)
            {
                await NotesDataSource.DeleteAsync(notebook);

                var frame = new Frame();
                frame.Navigate(typeof(GroupedItemsPage));
                Window.Current.Content = frame;
            }
        }
示例#17
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            if (pageState != null && pageState.ContainsKey("ID"))
            {
                navigationParameter = pageState["ID"];
            }

            notebook = NotesDataSource.GetNotebook((String)navigationParameter) as NoteBook;
            this.DefaultViewModel["Sections"] = notebook.Sections;
            this.DefaultViewModel["Group"]    = notebook;
            notebook.PropertyChanged         -= notebook_PropertyChanged;
            notebook.PropertyChanged         += notebook_PropertyChanged;
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var sampleDataGroups = NotesDataSource.GetGroups();

            this.DefaultViewModel["Groups"] = sampleDataGroups;
            this.groupGridView.ItemsSource  = this.groupedItemsViewSource.View.CollectionGroups;

            if (sampleDataGroups.Count == 0)
            {
                EmptyCollectionGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
            }
        }
示例#19
0
        private List <ListViewItem> BuildTagList()
        {
            var allTags = NotesDataSource.GetGroups().SelectMany(nb => ((NoteBook)nb).Items).SelectMany(t => t.Tags).Distinct();

            List <ListViewItem> tags = new List <ListViewItem>();

            foreach (var tag in allTags)
            {
                var viewItem = new ListViewItem();
                viewItem.Content    = tag;
                viewItem.Style      = Application.Current.Resources["TagSuggestionItemTemplate"] as Style;
                viewItem.IsSelected = this.Tags.Contains(tag);
                tags.Add(viewItem);
            }
            return(tags);
        }
        // LAB #9 TILES

        #endregion

        /// <summary>
        /// Show confirmation message for deleting Note, if the user choose Yes then delete note and return to GroupDetailPage based on deleted note Notebook.
        /// </summary>
        /// <param name="command"></param>
        async void DeleteAsync(object command)
        {
            var result = await Helpers.ShowDialog("Are you sure you want to delete this Note?", "Delete Note");

            if (result)
            {
                _printer.UnregisterForPrinting();
                await NotesDataSource.DeleteAsync(Note);

                // LAB #9 TILES
                var frame = new Frame();
                frame.Navigate(typeof(GroupedItemsPage));
                frame.Navigate(typeof(GroupDetailPage), Note.NoteBook.UniqueId);
                Window.Current.Content = frame;
            }
        }
示例#21
0
        private void SecondaryTileNavigation(string args)
        {
            var unqiueId = args.Substring(args.IndexOf("=") + 1);
            var item     = NotesDataSource.Find(unqiueId.ToString());
            var frame    = Window.Current.Content as Frame;

            if (item == null)
            {
                frame.Navigate(typeof(GroupedItemsPage));
            }
            else if (item.GetType() == typeof(NoteBook))
            {
                frame.Navigate(typeof(GroupDetailPage), item.UniqueId);
            }
            else
            {
                frame.Navigate(typeof(ItemDetailPage), item.UniqueId);
            }
        }
示例#22
0
        /// <summary>
        /// Create new Notebook
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnAddNBClick(object sender, RoutedEventArgs e)
        {
            var addNbPop = this.FindName("popupAddNoteBook") as Popup;
            var nbText   = this.FindName("txtNbName") as TextBox;

            if (string.IsNullOrEmpty(nbText.Text))
            {
                Helpers.ShowMessageAsync("Notebook Title can't be empty", "Create Notebook");
                return;
            }

            //Creates new Notebook with user text
            var nb = new NoteBook(nbText.Text);

            //Adding notebook to main collection
            NotesDataSource.AddNoteBook(nb);

            //Saving new notebook.
            DataManager.Save(nb);
            addNbPop.IsOpen = false;
            this.Frame.Navigate(typeof(GroupDetailPage), nb.UniqueId);
        }
        /// <summary>
        /// Defines all known Note types for DataContractJsonSerializer, each notebook will be serialized and than converted to json format, finally a file will be created under Notebooks folder
        /// with the Notebook Unique id as file name.
        /// </summary>
        private async static void RunSaveOperation()
        {
            var storage = Windows.Storage.ApplicationData.Current.LocalFolder;

            List <Type> types = new List <Type>();

            types.Add(typeof(FoodDataItem));
            types.Add(typeof(NoteDataItem));
            types.Add(typeof(ToDoDataItem));
            types.Add(typeof(NoteBook));
            var notebooks = NotesDataSource.GetGroups();

            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(NoteDataCommon), types);
            var folder = await storage.CreateFolderAsync(FolderNames.Notebooks.ToString(), Windows.Storage.CreationCollisionOption.OpenIfExists);

            foreach (var notebook in notebooks)
            {
                try
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        ser.WriteObject(ms, notebook);
                        byte[] json  = ms.ToArray();
                        var    value = Encoding.UTF8.GetString(json, 0, json.Length);

                        var file = await folder.CreateFileAsync(notebook.UniqueId,
                                                                Windows.Storage.CreationCollisionOption.ReplaceExisting);

                        await FileIO.WriteTextAsync(file, value);

                        await Task.Delay(500);
                    }
                }
                catch (Exception)
                {
                    //Helpers.ShowErrorMessage("Save Data", ex);
                }
            }
        }
示例#24
0
        async private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            shareOperation.ReportStarted();

            var notebook = comboNotebooks.SelectedItem as NoteBook;
            var noteType = (NoteTypes)comboType.SelectedItem;

            switch (noteType)
            {
            case NoteTypes.ToDo:
                var todo = new ToDoDataItem(txtTitle.Text.HttpEncode(), notebook);
                todo.Description = txtDescription.Text.HttpEncode();
                await CopyDataToLocalStorageAsync(todo);

                NotesDataSource.Add(todo, notebook.UniqueId);
                break;

            case NoteTypes.Food:
                var food = new FoodDataItem(txtTitle.Text.HttpEncode(), notebook);
                food.Description = txtDescription.Text.HttpEncode();
                await CopyDataToLocalStorageAsync(food);

                NotesDataSource.Add(food, notebook.UniqueId);
                break;

            default:
                var note = new NoteDataItem(txtTitle.Text.HttpEncode(), notebook);
                note.Description = txtDescription.Text.HttpEncode();
                await CopyDataToLocalStorageAsync(note);

                NotesDataSource.Add(note, notebook.UniqueId);
                break;
            }

            DataManager.Save();

            this.shareOperation.ReportCompleted();
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            if (pageState != null && pageState.ContainsKey("ID"))
            {
                navigationParameter = pageState["ID"];
            }

            Note = NotesDataSource.GetItem((string)navigationParameter) as NoteDataCommon;
            if (Note == null)
            {
                this.Frame.Navigate(typeof(GroupedItemsPage));
            }

            Note.PropertyChanged -= CurrentNotePropertyChanged;

            if (string.IsNullOrEmpty(Note.Title))
            {
                Note.Title = Consts.DefaultTitleText;
            }
            if (string.IsNullOrEmpty(Note.Description))
            {
                Note.Description = Consts.DefaultDescriptionText;
            }
            if (string.IsNullOrEmpty(Note.Address))
            {
                Note.Address = Consts.DefaultAddressText;
            }

            Note.PropertyChanged += CurrentNotePropertyChanged;

            this.DefaultViewModel["Item"] = Note;
            _printer = new PrinterManager(this, Note);

            // LAB #9 TILES
            //pageTitle.Focus(FocusState.Keyboard);
            DrawDefaultAppBar();
        }
示例#26
0
        /// <summary>
        /// Build navigation popup menu when clicking on Notebook title.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            if (navigationMenu != null)
            {
                return;
            }

            var rect = new Rect(170, 110, 0, 0);

            navigationMenu = new PopupMenu();
            var navigationNotebooks = NotesDataSource.GetGroups();
            var count = navigationNotebooks.Count > 4 ? 4 : navigationNotebooks.Count;

            for (var i = 0; i < count; i++)
            {
                navigationMenu.Commands.Add(new UICommand(navigationNotebooks[i].Title, Navigate, navigationNotebooks[i].UniqueId));
            }
            navigationMenu.Commands.Add(new UICommandSeparator());
            navigationMenu.Commands.Add(new UICommand("Home", Navigate, null));

            await navigationMenu.ShowForSelectionAsync(rect);

            navigationMenu = null;
        }
示例#27
0
        /// <summary>
        /// Update Tile Information for Note, changing the default template of the tile to specific template based on the Note Type.
        /// </summary>
        /// <param name="UniqueId">Note Unique ID</param>
        public static void UpdateSecondaryTile(string UniqueId)
        {
            // Determine whether to pin or unpin.
            if (SecondaryTile.Exists(UniqueId))
            {
                var item = NotesDataSource.Find(UniqueId);
                if (item.Images.Count == 0)
                {
                    if (item.Type == NoteTypes.ToDo)
                    {
                        CreateTextToDoTile(item);
                    }
                    else
                    {
                        CreateTextOnlyTile(item);
                    }

                    return;
                }

                switch (item.Type)
                {
                case DataModel.NoteTypes.ToDo:
                    CreateSeconderyForToDo(item as ToDoDataItem);
                    break;

                case DataModel.NoteTypes.Notebook:
                    CreateSeconderyNoteBook(item as NoteBook);
                    break;

                default:
                    CreateSeconderyWithImage(item);
                    break;
                }
            }
        }
 public void SetDataSource(NotesDataSource notesDataSource)
 {
     _notesDataSource = notesDataSource;
 }
示例#29
0
 /// <summary>
 /// Update ToDo Note after each ToDo item update.
 /// </summary>
 void UpdateNote()
 {
     var item = NotesDataSource.GetItem(NoteUniqueId);
     // LAB #9 TILES
     // Lab #4 - Files
 }
        /// <summary>
        /// After DataManager has finished loading the data, based on the application launch type we redirect the user to the proper page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ex"></param>
        async void Data_Completed(object sender, Exception ex)
        {
            if (ex != null)
            {
                Helpers.ShowErrorMessageAsync("Loading Notebooks", "Unexpected error while loading notebooks.");
            }
            else
            {
                var rootFrame = new Frame();
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                DataManager.Clean();

                if (NotesDataSource.GetGroups().Count == 0)
                {
                    rootFrame.Navigate(typeof(RestoreWorkingPage), "Getting Started");
                    Window.Current.Content = rootFrame;
                    return;
                }

                if (RestoreLastState)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        rootFrame.Navigate(typeof(GroupedItemsPage));
                        Window.Current.Content = rootFrame;
                    }
                }
                else if (ShareTargetOperation != null)
                {
                    ShareTarget share = new ShareTarget();
                    await share.ActivateAsync(ShareTargetOperation);
                }
                else if (SearchArgs != null)
                {
                    rootFrame.Navigate(typeof(GroupedItemsPage));
                    rootFrame.Navigate(typeof(SearchResults), SearchArgs.QueryText);
                    Window.Current.Content = rootFrame;
                }
                else if (!string.IsNullOrEmpty(DirectLink))
                {
                    var note = NotesDataSource.Find(DirectLink);

                    if (note == null)
                    {
                        rootFrame.Navigate(typeof(GroupedItemsPage));
                        Window.Current.Content = rootFrame;
                        return;
                    }

                    rootFrame.Navigate(typeof(GroupedItemsPage));
                    if (note.GetType() == typeof(NoteBook))
                    {
                        rootFrame.Navigate(typeof(GroupDetailPage), note.UniqueId);
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(GroupDetailPage), note.NoteBookUniqueId);
                        rootFrame.Navigate(typeof(ItemDetailPage), note.UniqueId);
                    }

                    Window.Current.Content = rootFrame;
                }
                else
                {
                    rootFrame.Navigate(typeof(GroupedItemsPage));
                    Window.Current.Content = rootFrame;
                }
            }
        }