示例#1
0
        /// <summary>
        /// Create a new blank page.
        /// </summary>
        public void AddPage()
        {
            if (!HasLoaded)
            {
                _createOnLoad = true;
                return;
            }

            if (SelectedNotebook == null)
            {
                AddNotebook();
                return;
            }

            if (SelectedSection == null)
            {
                AddSection();
                return;
            }

            NotebookPage p = new NotebookPage();

            p.SectionID = SelectedSection.ID;
            p.Title     = "Untitled Page";
            p.Created   = p.LastModified = DateTime.UtcNow;

            NoteDatabase.Add(p);
            AddPage(p, true);
        }
示例#2
0
        private void PageDelete_Click(object sender, RoutedEventArgs e)
        {
            NotebookPage selectedPage = SelectedPage;

            NoteDatabase.Delete(selectedPage);
            SelectedPage = null;

            foreach (FrameworkElement each in pageTabs.Items)
            {
                if (each.Tag == selectedPage)
                {
                    int index = pageTabs.Items.IndexOf(each);
                    pageTabs.Items.Remove(each);

                    if (pageTabs.HasItems)
                    {
                        if (index > 0)
                        {
                            ((ToggleButton)pageTabs.Items[index - 1]).IsChecked = true;
                        }
                        else
                        {
                            ((ToggleButton)pageTabs.Items[0]).IsChecked = true;
                        }
                    }
                    else
                    {
                        SelectedPage = null;
                        ShowEmptySectionMessage();
                    }

                    break;
                }
            }
        }
示例#3
0
        private async void pageTabs_SelectionChanged(object sender, RoutedEventArgs e)
        {
            if (_ignorePageTabsChanged)
            {
                _ignorePageTabsChanged = false;
                return;
            }

            NotebookPage    selectedPage     = SelectedPage;
            NotebookSection selectedSection  = SelectedSection;
            Notebook        selectedNotebook = SelectedNotebook;
            FlowDocument    doc = document.HasContentChanged ? document.Document.Copy() : null;

            FrameworkElement _sender = (FrameworkElement)sender;
            NotebookPage     page    = (NotebookPage)_sender.Tag;

            // If the Notes app bar is open to this note, close it.
            if (NotesAppBar.LastUsedNotesAppBar != null && NotesAppBar.LastUsedNotesAppBar.SelectedPage.ID == page.ID)
            {
                NotesAppBar.LastUsedNotesAppBar.Close();
            }

            SelectedPage = page;

            document.Document.Blocks.Clear();
            document.Document = await page.GetDetailsDocumentAsync();

            pageTabsScroller.UpdateLayout();
            pageTabsScroller.ScrollToVerticalPixel(_sender.TranslatePoint(new Point(0, 0), pageTabs).Y);

            await Save(selectedPage, selectedSection, selectedNotebook, doc);
        }
示例#4
0
        /// <summary>
        /// Add a new page.
        /// </summary>
        /// <param name="page">the page to add</param>
        public static XmlElement Add(NotebookPage page)
        {
            if (!PageExists(page))
            {
                //
                // <p />
                //
                XmlElement nt = db.Doc.CreateElement(PageTag);

                nt.SetAttribute(XmlDatabase.IdAttribute, page.ID);
                nt.SetAttribute(TitleAttribute, page.Title);
                nt.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(page.ReadOnly));
                nt.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(page.Private));
                nt.SetAttribute(CreatedAttribute, FormatHelpers.DateTimeToString(page.Created));
                nt.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(page.LastModified));

                // If section has been deleted, ignore requests to add page.
                XmlElement section = db.Doc.GetElementById(page.SectionID);

                if (section != null)
                {
                    section.AppendChild(nt);
                }

                return(nt);
            }

            return(null);
        }
示例#5
0
        internal void RemovePage(object sender, EventArgs e)
        {
            IComponentChangeService iccs       = (IComponentChangeService)GetService(typeof(IComponentChangeService));
            IDesignerHost           designHost = (IDesignerHost)GetService(typeof(IDesignerHost));

            DesignerTransaction designerTransaction = null;

            try
            {
                designerTransaction = designHost.CreateTransaction("Remove Notebook Page");

                NotebookPage tabPage = MyNotebook.SelectedPage;

                if (tabPage == null)
                {
                    return;
                }

                MyNotebook.Controls.Remove(tabPage);

                iccs.OnComponentChanged(Component, null, null, null);

                designerTransaction.Commit();

                EnableRemove();
            }
            finally
            {
                (designerTransaction as IDisposable).Dispose();
            }
        }
示例#6
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (mOverCloseBox != -1)
            {
                if (ParentDesign == false)
                {
                    mClickCloseBox      = true;
                    mClickCloseBoxIndex = mOverCloseBox;
                }
            }
            else
            {
                int clickIndex = TabIndexFromPoint(e.Location);

                if (0 <= clickIndex && clickIndex < visiblePages.Count)
                {
                    SelectedIndex = clickIndex;

                    if (navProperties.AllowTabReorder)
                    {
                        mDraggingPage = true;
                        mPageClickIn  = visiblePages[clickIndex];
                    }
                }
            }

            base.OnMouseDown(e);
        }
示例#7
0
        private static void ExecutedNewNoteCommand(object sender, ExecutedRoutedEventArgs e)
        {
            NotesView notesView = (NotesView)sender;

            NotebookPage    page     = (NotebookPage)e.Parameter;
            NotebookSection section  = NoteDatabase.GetSection(page.SectionID);
            Notebook        notebook = NoteDatabase.GetNotebook(section.NotebookID);

            if (notesView.SelectedNotebook == null)
            {
                notesView.AddNotebook(notebook, true);
                return;
            }

            if (notesView.SelectedSection == null)
            {
                notesView.AddSection(section, true);
                return;
            }

            if (notesView.SelectedPage == null)
            {
                notesView.AddPage(page, true);
            }
            else
            {
                notesView.AddPage(page);
            }
        }
示例#8
0
        private async Task Save(NotebookPage page, NotebookSection section, Notebook notebook, FlowDocument document)
        {
            if (page != null)
            {
                if (document != null)
                {
                    await page.SetDetailsDocumentAsync(document);
                }

                await Task.Factory.StartNew(() =>
                {
                    page.LastModified = DateTime.UtcNow;
                    NoteDatabase.UpdatePage(page);

                    section.LastSelectedPageID = page.ID;
                    section.LastModified       = DateTime.UtcNow;
                    NoteDatabase.UpdateSection(section);

                    notebook.LastSelectedSectionID = section.ID;
                    notebook.LastModified          = DateTime.UtcNow;
                    NoteDatabase.UpdateNotebook(notebook);

                    Settings.LastOpenedNotebook = notebook.ID;
                });
            }
            else
            {
                await Task.Factory.StartNew(() =>
                {
                    if (section != null)
                    {
                        section.LastSelectedPageID = "";
                        section.LastModified       = DateTime.UtcNow;
                        NoteDatabase.UpdateSection(section);
                    }

                    if (notebook != null)
                    {
                        if (section != null)
                        {
                            notebook.LastSelectedSectionID = section.ID;
                        }
                        else
                        {
                            notebook.LastSelectedSectionID = "";
                        }

                        notebook.LastModified = DateTime.UtcNow;
                        NoteDatabase.UpdateNotebook(notebook);

                        Settings.LastOpenedNotebook = notebook.ID;
                    }
                    else
                    {
                        Settings.LastOpenedNotebook = "";
                    }
                });
            }
        }
示例#9
0
 protected override void OnSwitchPage(NotebookPage page, uint n)
 {
     base.OnSwitchPage(page, n);
     if (!loadedPages.Contains(Page))
     {
         OnPageLoadRequired();
     }
 }
示例#10
0
        public void Load()
        {
            IEnumerable <Notebook> notebooks = NoteDatabase.GetNotebooks();

            if (notebooks.GetEnumerator().MoveNext())
            {
                foreach (Notebook each in notebooks)
                {
                    AddNotebook(each);
                }

                string lastOpened = Settings.LastOpenedNotebook;

                bool found = false;

                if (lastOpened != "")
                {
                    foreach (ToggleButton each in notebookTabs.Items)
                    {
                        if (((DatabaseObject)each.Tag).ID == lastOpened)
                        {
                            each.IsChecked = true;
                            found          = true;
                            break;
                        }
                    }
                }

                if (!found)
                {
                    ((ToggleButton)notebookTabs.Items[0]).IsChecked = true;
                }
            }
            else
            {
                SelectedNotebook = null;
                SelectedSection  = null;
                SelectedPage     = null;
                ShowEmptyWorkspaceMessage();
            }

            HasLoaded         = true;
            LastUsedNotesView = this;

            if (_createOnLoad)
            {
                AddPage();
                _createOnLoad = false;
            }

            if (_scrollToNoteId != null)
            {
                ScrollToNote(_scrollToNoteId);
            }
        }
示例#11
0
        private void TabMetrics(NotebookPage notebookPage, out Size tabSize, out Size imageSize, out Size textSize)
        {
            string text = notebookPage.Text;

            if (mBoldFont == null ||
                mBoldFont.FontFamily != Font.FontFamily ||
                mBoldFont.SizeInPoints != Font.SizeInPoints)
            {
                mBoldFont = new Font(Font, FontStyle.Bold);
            }

            Font thisFont = Font;

            if (notebookPage == owner.SelectedPage)
            {
                thisFont = mBoldFont;
            }

            textSize = TextRenderer.MeasureText(text, thisFont);

            textSize.Height = TabHeight;

            Image image = notebookPage.Image;

            // see if we have an image
            if (image != null)
            {
                imageSize = image.Size;

                if (image.Height > textSize.Height)
                {
                    float ratio = textSize.Height / (float)image.Height;

                    imageSize.Width  = (int)(image.Width * ratio);
                    imageSize.Height = (int)(image.Height * ratio);
                }
            }
            else
            {
                imageSize = Size.Empty;
            }

            // add close box size
            int closeBox = 0;

            if (navProperties.AllowClose)
            {
                closeBox = imageMargin + Properties.Resources.Close.Width;
            }

            tabSize = new Size(tabMargin + imageSize.Width + imageMargin * 2 + textSize.Width + closeBox + tabMargin,
                               TabHeight);
        }
示例#12
0
        private async void notebookTabs_SelectionChanged(object sender, RoutedEventArgs e)
        {
            NotebookPage    selectedPage     = SelectedPage;
            NotebookSection selectedSection  = SelectedSection;
            Notebook        selectedNotebook = SelectedNotebook;
            FlowDocument    doc = document.HasContentChanged ? document.Document.Copy() : null;

            _selectedNotebookTab = sender;

            LoadNotebook((Notebook)((FrameworkElement)sender).Tag);

            await Save(selectedPage, selectedSection, selectedNotebook, doc);
        }
示例#13
0
        private void NewNote(Notebook nb = null, NotebookSection ns = null, NotebookPage page = null)
        {
            if (page == null)
            {
                page         = new NotebookPage();
                page.Created = page.LastModified = DateTime.UtcNow;
            }

            if (nb == null)
            {
                string nbID = Settings.LastOpenedNotebook;

                if (nbID != null)
                {
                    nb = NoteDatabase.GetNotebook(nbID);
                }

                if (nb == null)
                {
                    nb = NoteDatabase.FirstNotebook();
                }
            }

            if (nb == null)
            {
                nb       = new Notebook();
                nb.Title = "My Notebook";
                nb.Color = NotesFunctions.GenerateNotebookColor();
                NoteDatabase.Add(nb);
            }

            if (ns == null)
            {
                ns = NoteDatabase.GetSection(nb.LastSelectedSectionID);
            }

            if (ns == null)
            {
                ns            = new NotebookSection();
                ns.Title      = "Quick Notes";
                ns.NotebookID = nb.ID;
                ns.Color      = NotesFunctions.GenerateSectionColor();
                NoteDatabase.Add(ns);
            }

            page.SectionID = ns.ID;

            SelectedPage     = page;
            SelectedSection  = ns;
            SelectedNotebook = nb;
        }
示例#14
0
        private async void sectionTabs_SelectionChanged(object sender, RoutedEventArgs e)
        {
            NotebookPage    selectedPage     = SelectedPage;
            NotebookSection selectedSection  = SelectedSection;
            Notebook        selectedNotebook = SelectedNotebook;
            FlowDocument    doc = document.HasContentChanged ? document.Document.Copy() : null;

            _selectedSectionTab = sender;

            NotebookSection section = (NotebookSection)((FrameworkElement)sender).Tag;

            SelectedSection = section;

            pageTabs.Items.Clear();

            IEnumerable <NotebookPage> pages = section.Pages;

            if (pages.GetEnumerator().MoveNext())
            {
                _ignorePageTabsChanged = false;

                string selectedID = section.LastSelectedPageID;
                bool   found      = false;

                foreach (NotebookPage page in pages)
                {
                    if (page.ID != selectedID)
                    {
                        AddPage(page);
                    }
                    else
                    {
                        AddPage(page, _createOnLoad ? false : true);
                        found = true;
                    }
                }

                if (!found)
                {
                    ((ToggleButton)pageTabs.Items[0]).IsChecked = true;
                }
            }
            else
            {
                SelectedPage = null;
                ShowEmptySectionMessage();
            }

            await Save(selectedPage, selectedSection, selectedNotebook, doc);
        }
示例#15
0
        /// <summary>
        /// Delete existing page
        /// </summary>
        /// <param name="page">The page to delete.</param>
        public static void Delete(NotebookPage page)
        {
            if (page != null)
            {
                // Delete details file, if it exists.
                string file = NotesAppData + "\\" + page.ID;

                if (File.Exists(file))
                {
                    File.Delete(file);
                }

                Delete(page.ID);
            }
        }
示例#16
0
        private void lstBox_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            int fontHeight = Font.Height;

            int imageHeight = 0;

            NotebookPage p = Items[e.Index] as NotebookPage;

            if (p.Image != null)
            {
                imageHeight = p.Image.Height;
            }

            e.ItemHeight = Math.Max(fontHeight, imageHeight) + 2;
            e.ItemWidth  = Width;
        }
示例#17
0
        private void NotebookDelete_Click(object sender, RoutedEventArgs e)
        {
            Notebook selectedNotebook = SelectedNotebook;

            NoteDatabase.Delete(selectedNotebook);
            SelectedNotebook = null;
            SelectedSection  = null;
            SelectedPage     = null;

            foreach (FrameworkElement each in notebookTabs.Items)
            {
                if (each.Tag == selectedNotebook)
                {
                    int index = notebookTabs.Items.IndexOf(each);
                    notebookTabs.Items.Remove(each);

                    if (notebookTabs.HasItems)
                    {
                        if (index > 0)
                        {
                            ((ToggleButton)notebookTabs.Items[index - 1]).IsChecked = true;
                        }
                        else
                        {
                            ((ToggleButton)notebookTabs.Items[0]).IsChecked = true;
                        }
                    }
                    else
                    {
                        SelectedNotebook = null;
                        SelectedSection  = null;
                        SelectedPage     = null;
                        ShowEmptyWorkspaceMessage();
                    }

                    break;
                }
            }

            if (NotesAppBar.LastUsedNotesAppBar != null && NotesAppBar.LastUsedNotesAppBar.SelectedNotebook.ID == selectedNotebook.ID)
            {
                NotesAppBar.LastUsedNotesAppBar.SelectedNotebook = null;
                NotesAppBar.LastUsedNotesAppBar.SelectedSection  = null;
                NotesAppBar.LastUsedNotesAppBar.SelectedPage     = null;
                NotesAppBar.LastUsedNotesAppBar.Close();
            }
        }
示例#18
0
        private void SectionDelete_Click(object sender, RoutedEventArgs e)
        {
            NotebookSection selectedSection = SelectedSection;

            NoteDatabase.Delete(selectedSection);
            SelectedSection = null;
            SelectedPage    = null;

            foreach (object each in sectionTabs.Items)
            {
                RadioButton rb = each as RadioButton;

                if (rb != null && rb.Tag == selectedSection)
                {
                    int index = sectionTabs.Items.IndexOf(each);
                    sectionTabs.Items.Remove(each);

                    if (sectionTabs.Items.Count > 2)
                    {
                        if (index > 0)
                        {
                            ((ToggleButton)sectionTabs.Items[index - 1]).IsChecked = true;
                        }
                        else
                        {
                            ((ToggleButton)sectionTabs.Items[0]).IsChecked = true;
                        }
                    }
                    else
                    {
                        SelectedSection = null;
                        SelectedPage    = null;
                        ShowEmptyNotebookMessage();
                    }

                    break;
                }
            }

            if (NotesAppBar.LastUsedNotesAppBar != null && NotesAppBar.LastUsedNotesAppBar.SelectedSection.ID == selectedSection.ID)
            {
                NotesAppBar.LastUsedNotesAppBar.SelectedNotebook = null;
                NotesAppBar.LastUsedNotesAppBar.SelectedSection  = null;
                NotesAppBar.LastUsedNotesAppBar.SelectedPage     = null;
                NotesAppBar.LastUsedNotesAppBar.Close();
            }
        }
示例#19
0
        private static void SaveNote(Window owner, StatusStrip statusStrip, NotebookPage page, string filename)
        {
            try
            {
                switch (Path.GetExtension(filename).ToLower())
                {
                case ".rtf":
                    FlowDocument doc     = new NoteTemplate(page).GetFlowDocument();
                    TextRange    range   = new TextRange(doc.ContentStart, doc.ContentEnd);
                    FileStream   fStream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write);
                    range.Save(fStream, DataFormats.Rtf);
                    fStream.Close();

                    statusStrip.UpdateMainStatus("EXPORT SUCCESSFUL");
                    break;

                case ".txt":
                    string[] filecontents = new NoteTemplate(page).GetTextDocument();
                    File.WriteAllLines(filename, filecontents);

                    statusStrip.UpdateMainStatus("EXPORT SUCCESSFUL");
                    break;

                default:
                    statusStrip.UpdateMainStatus("ERROR: REQUESTED FILE TYPE UNAVAILABLE");

                    TaskDialog dialog = new TaskDialog(owner,
                                                       "Error Saving File", "The requested file type is not available.",
                                                       MessageType.Error);
                    dialog.ShowDialog();
                    break;
                }
            }
            catch (Exception exc)
            {
                statusStrip.UpdateMainStatus("ERROR: " + exc.Message.ToUpper());

                TaskDialog dialog = new TaskDialog(owner,
                                                   "Error Saving File", exc.Message, MessageType.Error);
                dialog.ShowDialog();

                ExportNote(owner, statusStrip, page, Path.GetDirectoryName(saveDialog.SelectedFile));
            }
        }
示例#20
0
        private void AddPage(NotebookPage page, bool openEdit = false)
        {
            RadioButton button = new RadioButton();

            Binding titleBinding = new Binding("Title");

            titleBinding.Source = page;

            button.SetBinding(ContentControl.ContentProperty, titleBinding);

            button.Tag = page;
            pageTabs.Items.Add(button);

            if (openEdit)
            {
                button.IsChecked = true;
                messageHeader.Focus();
            }
        }
示例#21
0
        /// <summary>
        /// Update the values on an existing page.
        /// </summary>
        /// <param name="page"></param>
        public static void UpdatePage(NotebookPage page)
        {
            if (page != null)
            {
                XmlElement elem = db.Doc.GetElementById(page.ID);

                if (elem != null)
                {
                    elem.SetAttribute(TitleAttribute, page.Title);
                    elem.SetAttribute(ReadOnlyAttribute, FormatHelpers.BoolToString(page.ReadOnly));
                    elem.SetAttribute(PrivateAttribute, FormatHelpers.BoolToString(page.Private));
                    elem.SetAttribute(CreatedAttribute, FormatHelpers.DateTimeToString(page.Created));
                    elem.SetAttribute(LastModifiedAttribute, FormatHelpers.DateTimeToString(page.LastModified));
                }
                else
                {
                    Add(page);
                }
            }
        }
示例#22
0
        public static NotebookPage GetPage(XmlNode node)
        {
            if (node == null)
            {
                return(null);
            }

            XmlAttributeCollection attribs = node.Attributes;

            NotebookPage page = new NotebookPage(false);

            page.ID           = attribs[XmlDatabase.IdAttribute].Value;
            page.SectionID    = node.ParentNode.Attributes[XmlDatabase.IdAttribute].Value;
            page.Title        = attribs[TitleAttribute].Value;
            page.ReadOnly     = FormatHelpers.ParseBool(attribs[ReadOnlyAttribute].Value);
            page.Private      = FormatHelpers.ParseBool(attribs[PrivateAttribute].Value);
            page.Created      = FormatHelpers.ParseDateTime(attribs[CreatedAttribute].Value);
            page.LastModified = FormatHelpers.ParseDateTime(attribs[LastModifiedAttribute].Value);

            return(page);
        }
示例#23
0
        private void LoadNotebook(Notebook notebook)
        {
            SelectedNotebook = notebook;

            sectionTabs.Items.Clear();
            sectionTabs.Items.Add(addSectionButton);
            sectionTabs.Items.Add(sectionOverflowButton);

            IEnumerable <NotebookSection> sections = notebook.Sections;

            if (sections.GetEnumerator().MoveNext())
            {
                string selectedID = notebook.LastSelectedSectionID;
                bool   found      = false;

                foreach (NotebookSection each in sections)
                {
                    if (each.ID != selectedID)
                    {
                        AddSection(each);
                    }
                    else
                    {
                        AddSection(each, true);
                        found = true;
                    }
                }

                if (!found)
                {
                    ((ToggleButton)sectionTabs.Items[0]).IsChecked = true;
                }
            }
            else
            {
                SelectedSection = null;
                SelectedPage    = null;
                ShowEmptyNotebookMessage();
            }
        }
示例#24
0
        /// <summary>
        /// Save the active note, if any, and close it, showing a message for the notebook page
        /// being opened in another window.
        /// </summary>
        public void CloseActiveNote()
        {
            //await Save();

            ShowNoteInUseMessage();
            string pageId     = SelectedPage.ID;
            string sectionId  = SelectedSection.ID;
            string notebookId = SelectedNotebook.ID;

            SelectedPage = null;

            foreach (ToggleButton each in pageTabs.Items)
            {
                each.IsChecked = false;
            }

            if (NotesAppBar.LastUsedNotesAppBar != null)
            {
                NotesAppBar.LastUsedNotesAppBar.Closed += (s, e) =>
                {
                    // If the page still exists and we don't have any other page open, re-open it.
                    if (SelectedPage == null && SelectedSection.ID == sectionId && SelectedNotebook.ID == notebookId)
                    {
                        foreach (ToggleButton each in pageTabs.Items)
                        {
                            if (((DatabaseObject)each.Tag).ID == pageId)
                            {
                                // Reload the note.
                                each.Tag = NoteDatabase.GetPage(pageId);

                                each.IsChecked = true;
                                break;
                            }
                        }
                    }
                }
            }
            ;
        }
示例#25
0
        protected override void OnSwitchPage(NotebookPage page, uint page_num)
        {
            var previous    = (TabVBox)CurrentPageWidget;
            var previousTab = previous.Tab;

            base.OnSwitchPage(page, page_num);
            var currentTab = (this.CurrentPageWidget as TabVBox)?.Tab;

            currentTab = (currentTab as TdiSliderTab)?.ActiveDialog ?? currentTab;
            if (TabSwitched != null)
            {
                TabSwitched(this, new TabSwitchedEventArgs(currentTab));
            }
            if (previousTab.HandleSwitchOut != null)
            {
                previousTab.HandleSwitchOut(currentTab);
            }
            if (currentTab.HandleSwitchIn != null)
            {
                currentTab.HandleSwitchIn(previousTab);
            }
        }
示例#26
0
        internal void AddPage(object sender, EventArgs e)
        {
            IComponentChangeService iccs       = (IComponentChangeService)GetService(typeof(IComponentChangeService));
            IDesignerHost           designHost = (IDesignerHost)GetService(typeof(IDesignerHost));

            DesignerTransaction designerTransaction = null;

            // calculate an order value for this tab to keep them in order.
            int order = 0;

            if (MyNotebook.NotebookPages.Count > 0)
            {
                order = MyNotebook.NotebookPages[MyNotebook.NotebookPages.Count - 1].Order + 10;
            }

            try
            {
                designerTransaction = designHost.CreateTransaction("Add Notebook Page");

                NotebookPage tabPage = (NotebookPage)designHost.CreateComponent(typeof(NotebookPage));

                tabPage.Text = tabPage.Name;


                tabPage.Order = order;

                MyNotebook.Controls.Add(tabPage);
                MyNotebook.SelectedIndex = MyNotebook.PageCount - 1;

                iccs.OnComponentChanged(Component, null, null, null);

                designerTransaction.Commit();
            }
            finally
            {
                (designerTransaction as IDisposable).Dispose();
            }
        }
示例#27
0
        private void lstBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();

            if (e.Index >= 0)
            {
                NotebookPage p     = Items[e.Index] as NotebookPage;
                string       text  = p.Text;
                Image        image = p.Image;

                if (image == null)
                {
                    if (string.IsNullOrEmpty(text))
                    {
                        text = "Untitled Page";
                    }

                    e.Graphics.DrawString(text, Font, new SolidBrush(e.ForeColor), e.Bounds.Location);
                }
                else
                {
                    StringFormat format = new StringFormat(StringFormatFlags.NoWrap);
                    format.LineAlignment = StringAlignment.Center;

                    Point location = e.Bounds.Location;
                    location.Y = (e.Bounds.Height - image.Height) / 2 + e.Bounds.Y;

                    e.Graphics.DrawImage(image, new Rectangle(location, image.Size));

                    e.Graphics.DrawString(text, Font, new SolidBrush(e.ForeColor),
                                          new Rectangle(e.Bounds.Left + image.Width + 5, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height),
                                          format);
                }
            }


            e.DrawFocusRectangle();
        }
示例#28
0
        public static void ExportNote(Window owner, StatusStrip statusStrip, NotebookPage page, string rootFolder = null)
        {
            statusStrip.UpdateMainStatus("EXPORTING...");

            FileDialog save = new FileDialog(owner,
                                             rootFolder == null ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) : rootFolder,
                                             FileDialogType.Save, ListViewMode.Detail);

            save.Title        = "Export Current Note";
            save.SelectedFile = page.Title;
            save.Filter       = "Rich Text Files (*.rtf)|.rtf|Plain Text Files (*.txt)|.txt";
            save.FilterIndex  = 0;
            //save.RootFolder = rootFolder == null ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) : rootFolder;
            saveDialog = save;

            if (save.ShowDialog() == true)
            {
                SaveNote(owner, statusStrip, page, save.SelectedFile);
            }
            else
            {
                statusStrip.UpdateMainStatus("READY");
            }
        }
示例#29
0
        public void RefreshAllPages()
        {
            int          oldSelectedIndex = SelectedIndex;
            NotebookPage oldSelectedPage  = (NotebookPage)SelectedItem;

            Items.Clear();

            foreach (NotebookPage p in owner.NotebookPages)
            {
                if (p.ShowPage || DesignMode || owner.DesignMode)
                {
                    Items.Add(p);
                }
            }

            if (oldSelectedPage != null && Items.Contains(oldSelectedPage))
            {
                SelectedItem = oldSelectedPage;
            }
            else
            {
                SelectedIndex = Math.Min(oldSelectedIndex, Items.Count - 1);
            }
        }
示例#30
0
        public async Task Save()
        {
            NotebookPage selected = SelectedPage;

            if (selected != null)
            {
                if (document.HasContentChanged)
                {
                    await selected.SetDetailsDocumentAsync(document.Document);
                }

                selected.LastModified = DateTime.UtcNow;
                NoteDatabase.UpdatePage(selected);

                //SelectedSection.LastSelectedPageID = selected.ID;
                SelectedSection.LastModified = DateTime.UtcNow;
                NoteDatabase.UpdateSection(SelectedSection);
            }
            else if (SelectedSection != null)
            {
                //SelectedSection.LastSelectedPageID = "";
                SelectedSection.LastModified = DateTime.UtcNow;
                NoteDatabase.UpdateSection(SelectedSection);
            }

            if (SelectedNotebook != null)
            {
                //if (SelectedSection != null)
                //	SelectedNotebook.LastSelectedSectionID = SelectedSection.ID;
                //else
                //	SelectedNotebook.LastSelectedSectionID = "";

                SelectedNotebook.LastModified = DateTime.UtcNow;
                NoteDatabase.UpdateNotebook(SelectedNotebook);
            }
        }
示例#31
0
        private void LoadPage(Page page)
        {
            if (pages.ContainsKey (page.Id)) {
                Log.Warning (String.Format ("Preferences notebook already contains a page with the id `{0}'",
                    page.Id), false);
                return;
            }

            NotebookPage page_ui = new NotebookPage (page);
            page_ui.Show ();
            pages.Add (page.Id, page_ui);

            if (service.Count == 1) {
                VBox.PackStart (page_ui, false, false, 0);
            } else {
                notebook.AppendPage (page_ui, page_ui.TabWidget);
            }
        }
示例#32
0
        public NotebookPage (Page page)
        {
            this.page = page;

            BorderWidth = 5;
            Spacing = 10;

            tab_widget = new Label (page.Name);
            tab_widget.Show ();

            Widget page_widget = page.DisplayWidget as Widget;
            if (page_widget != null) {
                page_widget.Show ();
                PackStart (page_widget, true, true, 0);
            } else {
                foreach (Section section in page) {
                    AddSection (section);
                }

                if (page.ChildPages.Count > 0) {
                    Notebook notebook = new Notebook ();
                    notebook.ShowBorder = false;
                    notebook.ShowTabs = false;
                    notebook.Show ();

                    var hbox = new HBox () { Spacing = 6 };
                    // FIXME this shouldn't be hard-coded to 'Source:', but this is the only
                    // user of this code atm...
                    var page_label = new Label (Mono.Unix.Catalog.GetString ("Source:"));
                    var page_combo = new PageComboBox (page.ChildPages, notebook);
                    hbox.PackStart (page_label, false, false, 0);
                    hbox.PackStart (page_combo, true, true, 0);
                    hbox.ShowAll ();

                    PackStart (hbox, false, false, 0);

                    HSeparator sep = new HSeparator ();
                    sep.Show ();
                    PackStart (sep, false, false, 0);

                    foreach (Page child_page in page.ChildPages) {
                        NotebookPage page_ui = new NotebookPage (child_page);
                        page_ui.BorderWidth = 0;
                        page_ui.Show ();
                        notebook.AppendPage (page_ui, null);
                    }

                    PackStart (notebook, true, true, 0);
                }
            }
        }