Пример #1
0
        private void AddBookmarkView()
        {
            bool NeedToAdd = false;

            if (null == bookMarkView)
            {
                bookMarkView = new NoteNavigation(this);
                NeedToAdd    = true;
            }


            bookMarkView.Location = new Point(richBox.Location.X, richBox.Location.Y);

            bookMarkView.Height = richBox.Height;
            bookMarkView.Width  = ((int)richBox.Width / 2);
            if (bookMarkView.Width > bookMarkView.MAX_NAVIGATION_WIDTH)
            {
                bookMarkView.Width = bookMarkView.MAX_NAVIGATION_WIDTH;
            }

            bookMarkView.Dock = DockStyle.Left;
            if (NeedToAdd || bookMarkView.Parent == null)
            {
                ParentNotePanel.Controls.Add(bookMarkView);
            }
            if (true == bookMarkView.Visible)
            {
                bookMarkView.UpdateListOfBookmarks();
            }
        }
Пример #2
0
        protected override void DoBuildChildren(LayoutPanelBase Layout)
        {
            base.DoBuildChildren(Layout);
            CaptionLabel.Dock        = DockStyle.Top;
            richBox                  = new RichTextExtended();
            richBox.ContextMenuStrip = Layout.GetLayoutTextEditContextStrip();
            richBox.Enter           += HandleRichBoxEnter;
            richBox.Parent           = ParentNotePanel;
            richBox.Dock             = DockStyle.Fill;
            richBox.BringToFront();
            richBox.Rtf = this.Data1;
            richBox.SelectionChanged += HandleRichTextSelectionChanged;
            richBox.TextChanged      += HandleTextChanged;
            richBox.ReadOnly          = this.ReadOnly;
            richBox.HideSelection     = false;         // must be able to see focus form other controls
            captionLabel.MouseDown   += HandleMouseDownOnCaptionLabel;
            //CaptionLabel.MouseHover += HandleCaptionMouseHover;
            MarkupCombo             = new ToolStripComboBox();
            MarkupCombo.ToolTipText = Loc.Instance.GetString("AddIns allow text notes to format text. A global option controls the default markup to use on notes but this may be overridden here.");
            //	LayoutDetails.Instance.BuildMarkupComboBox (MarkupCombo);

            BuildDropDownList();

            properties.DropDownItems.Add(new ToolStripSeparator());

            ToolStripButton fullScreen = new ToolStripButton();

            fullScreen.Text   = Loc.GetStr("Fullscreen");
            fullScreen.Click += HandleFullScreenClick;
            properties.DropDown.Items.Add(fullScreen);

            properties.DropDownItems.Add(MarkupCombo);
            MarkupCombo.SelectedIndexChanged += HandleSelectedIndexChanged;
            MarkupCombo.DropDownStyle         = ComboBoxStyle.DropDownList;
            MarkupCombo.DropDown             += HandleDropDown;
            loadingcombo = true;
            // just show default if we have not overridden this
            if (Markuplanguage == defaultmarkup)
            {
                MarkupCombo.Text = defaultmarkup;
            }
            else
            if (SelectedMarkup != null)
            {
                for (int i = 0; i < MarkupCombo.Items.Count; i++)
                {
                    if (MarkupCombo.Items [i].GetType() == SelectedMarkup.GetType())
                    {
                        MarkupCombo.SelectedIndex = i;
                        break;
                    }
                }
                richBox.MarkupOverride = (iMarkupLanguage)MarkupCombo.SelectedItem;
            }


            extraItemsToShow = new ToolStripComboBox();
            extraItemsToShow.Items.AddRange(Enum.GetNames(typeof(ExtraItemsToShow)));
            extraItemsToShow.DropDownStyle = ComboBoxStyle.DropDownList;
            properties.DropDownItems.Add(extraItemsToShow);

            extraItemsToShow.SelectedIndex         = (int)extraItemsToShow_value;
            extraItemsToShow.ToolTipText           = Loc.Instance.GetString("Reselect this to refresh after editing text.");
            extraItemsToShow.SelectedIndexChanged += (object sender, EventArgs e) => {
                extraItemsToShow_value = (ExtraItemsToShow)extraItemsToShow.SelectedIndex;
                SetSaveRequired(true);
                UpdateExtraView();
            };

            // we use markup tag to indicate whether the data on the markup combo has changed to avoid slowness in save
            MarkupCombo.Tag = false;
            loadingcombo    = false;

            tabView         = new TabNavigation(richBox);
            tabView.Visible = false;
            tabView.Parent  = ParentNotePanel;
            tabView.Dock    = DockStyle.Top;
            //tabView.SendToBack();
            tabView.BringToFront();

            if (null == bookMarkView)
            {
                bookMarkView = new NoteNavigation(this);
            }
            bookMarkView.Visible = false;
            AddBookmarkView();

            UpdateExtraView();
            richBox.BringToFront();
            //CaptionLabel.BringToFront();
        }
        private void AddBookmarkView()
        {
            bool NeedToAdd = false;
            if (null == bookMarkView) {
                bookMarkView = new NoteNavigation (this);
                NeedToAdd = true;
            }

            bookMarkView.Location = new Point (richBox.Location.X, richBox.Location.Y);

            bookMarkView.Height = richBox.Height;
            bookMarkView.Width = ((int)richBox.Width / 2);
            if (bookMarkView.Width > bookMarkView.MAX_NAVIGATION_WIDTH)
                bookMarkView.Width = bookMarkView.MAX_NAVIGATION_WIDTH;

            bookMarkView.Dock = DockStyle.Left;
            if (NeedToAdd || bookMarkView.Parent == null) {
                ParentNotePanel.Controls.Add (bookMarkView);
            }
            if (true == bookMarkView.Visible) {
                bookMarkView.UpdateListOfBookmarks ();
            }
        }
        protected override void DoBuildChildren(LayoutPanelBase Layout)
        {
            base.DoBuildChildren (Layout);
            CaptionLabel.Dock = DockStyle.Top;
            richBox = new RichTextExtended ();
            richBox.ContextMenuStrip = Layout.GetLayoutTextEditContextStrip ();
            richBox.Enter += HandleRichBoxEnter;
            richBox.Parent = ParentNotePanel;
            richBox.Dock = DockStyle.Fill;
            richBox.BringToFront ();
            richBox.Rtf = this.Data1;
            richBox.SelectionChanged += HandleRichTextSelectionChanged;
            richBox.TextChanged += HandleTextChanged;
            richBox.ReadOnly = this.ReadOnly;
            richBox.HideSelection = false; // must be able to see focus form other controls
            captionLabel.MouseDown += HandleMouseDownOnCaptionLabel;
            //CaptionLabel.MouseHover += HandleCaptionMouseHover;
            MarkupCombo = new ToolStripComboBox ();
            MarkupCombo.ToolTipText = Loc.Instance.GetString ("AddIns allow text notes to format text. A global option controls the default markup to use on notes but this may be overridden here.");
            //	LayoutDetails.Instance.BuildMarkupComboBox (MarkupCombo);

            BuildDropDownList ();

            properties.DropDownItems.Add (new ToolStripSeparator());

            ToolStripButton fullScreen = new ToolStripButton();
            fullScreen.Text = Loc.GetStr("Fullscreen");
            fullScreen.Click+= HandleFullScreenClick;
            properties.DropDown.Items.Add (fullScreen);

            properties.DropDownItems.Add (MarkupCombo);
            MarkupCombo.SelectedIndexChanged += HandleSelectedIndexChanged;
            MarkupCombo.DropDownStyle = ComboBoxStyle.DropDownList;
            MarkupCombo.DropDown += HandleDropDown;
            loadingcombo = true;
            // just show default if we have not overridden this
            if (Markuplanguage == defaultmarkup) {
                MarkupCombo.Text = defaultmarkup;
            } else
            if (SelectedMarkup != null) {
                for (int i = 0; i < MarkupCombo.Items.Count; i++) {
                    if (MarkupCombo.Items [i].GetType () == SelectedMarkup.GetType ()) {
                        MarkupCombo.SelectedIndex = i;
                        break;
                    }
                }
                richBox.MarkupOverride = (iMarkupLanguage)MarkupCombo.SelectedItem;
            }

            extraItemsToShow = new ToolStripComboBox ();
            extraItemsToShow.Items.AddRange (Enum.GetNames (typeof(ExtraItemsToShow)));
            extraItemsToShow.DropDownStyle = ComboBoxStyle.DropDownList;
            properties.DropDownItems.Add (extraItemsToShow);

            extraItemsToShow.SelectedIndex = (int)extraItemsToShow_value;
            extraItemsToShow.ToolTipText = Loc.Instance.GetString ("Reselect this to refresh after editing text.");
            extraItemsToShow.SelectedIndexChanged += (object sender, EventArgs e) => {
                extraItemsToShow_value = (ExtraItemsToShow)extraItemsToShow.SelectedIndex;
                SetSaveRequired (true);
                UpdateExtraView ();
            };

            // we use markup tag to indicate whether the data on the markup combo has changed to avoid slowness in save
            MarkupCombo.Tag = false;
            loadingcombo = false;

            tabView = new TabNavigation (richBox);
            tabView.Visible = false;
            tabView.Parent = ParentNotePanel;
            tabView.Dock = DockStyle.Top;
            //tabView.SendToBack();
            tabView.BringToFront ();

            if (null == bookMarkView) {
                bookMarkView = new NoteNavigation (this);
            }
            bookMarkView.Visible = false;
            AddBookmarkView ();

            UpdateExtraView();
            richBox.BringToFront();
            //CaptionLabel.BringToFront();
        }
        public FullScreenEditor(NoteDataXML_RichText theNote)
        {
            this.KeyPreview    = true;
            this.StartPosition = FormStartPosition.Manual;
            var screen = Screen.FromPoint(Cursor.Position);

            this.Location    = screen.Bounds.Location;
            this.WindowState = FormWindowState.Maximized;
            //this.DesktopBounds = MyWind

            if (null == theNote)
            {
                throw new Exception("theNote was invalid in FullSCreenEditor");
            }
            originalNote = theNote;

            RichTextBox      = new RichTextExtended();
            RichTextBox.Dock = DockStyle.Fill;
            this.Controls.Add(RichTextBox);
//			Panel tempToHideRTFBorder = new Panel();
//			this.Controls.Add (tempToHideRTFBorder);
//			tempToHideRTFBorder.Controls.Add (RichTextBox);
//			tempToHideRTFBorder.Dock = DockStyle.Fill;
//			tempToHideRTFBorder.BorderStyle = BorderStyle.Fixed3D;

            RichTextBox.Rtf         = theNote.Data1;
            RichTextBox.BorderStyle = BorderStyle.None;
            RichTextBox.BackColor   = theNote.GetRichTextBox().BackColor;


            // pretty up
            this.ControlBox = false;
            this.Text       = string.Empty;
            this.BackColor  = RichTextBox.BackColor;
            // this works but you see richTextBorder
            this.Padding = new System.Windows.Forms.Padding(15);
            //RichTextBox.Margin= new System.Windows.Forms.Padding(10);

            hud = new Panel();
            this.Controls.Add(hud);
            hud.Dock      = DockStyle.Bottom;
            hud.Height    = this.Height / 5;
            hud.BackColor = System.Drawing.Color.White;
            hud.ForeColor = System.Drawing.Color.Black;
            hud.BringToFront();

            Button closeButton = new Button();

            closeButton.Text = Loc.GetStr("Close");

            closeButton.Dock   = DockStyle.Bottom;
            closeButton.Click += (object sender, EventArgs e) => {
                Close();
            };
            closeButton.ForeColor = this.ForeColor;

            Button outlinerButton = new Button();

            hud.Controls.Add(outlinerButton);
            outlinerButton.Text   = Loc.GetStr("Outline");
            outlinerButton.Dock   = DockStyle.Bottom;
            outlinerButton.Click += (object sender, EventArgs e) => {
                bookMarkView.Visible = !bookMarkView.Visible;
                if (bookMarkView.Visible)
                {
                    AddBookmarkView();
                }
            };



            wordLabel      = new Label();
            startingWords  = LayoutDetails.Instance.WordSystemInUse.CountWords(RichTextBox.Text);
            wordLabel.Text = Loc.Instance.GetStringFmt("{0} words", startingWords);
            //wordLabel.BackColor = this.BackColor;
            //wordLabel.ForeColor = RichTextBox.ForeColor;
            hud.Visible = false;
            hud.Controls.Add(closeButton);
            hud.Controls.Add(wordLabel);



            // outliner

            bookMarkView = new NoteNavigation(originalNote);
            this.Controls.Add(bookMarkView);
            bookMarkView.Dock    = DockStyle.Left;
            bookMarkView.Visible = false;

            RichTextBox.BringToFront();
        }
        public void TestNavigationNote()
        {
            NoteDataXML_RichText texter = new NoteDataXML_RichText(100, 100);

            System.Windows.Forms .Form form = new System.Windows.Forms.Form ();
            _TestSingleTon.Instance._SetupForLayoutPanelTests ();

            FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false);
            form.Controls.Add (panel);
            form.Show ();

            //NOTE: For now remember that htis ADDS 1 Extra notes
            panel.NewLayout ("mynewpanel", true, null);

            panel.AddNote(texter);

            texter.GetRichTextBox().Text = "";

            NoteNavigation bookMarkView = new NoteNavigation (texter);

            // Test 1: Tests that no crash happens when we don't have a proper markup assigned
            bookMarkView.UpdateListOfBookmarks();

            LayoutDetails.Instance.SetCurrentMarkup(new iMarkupYourOtherMind());
            // Test 2: Same test. No crash still.
            bookMarkView.UpdateListOfBookmarks();
            string TestText = @"7 minutes
            Bus crash over cliff in Ecuador
            Lost style flash leading to salvation
            ddd[[f]]
            =Dog=

            =Dog 2=
            The |whatis|this|
            ===error===
            The |firstssafdfsf|day of the ghoose|
            The |linkfdfgdfgdfg|dfdgdfgedfgdnded|";
                texter.GetRichTextBox().Text = TestText;
            // test 3: some text
            bookMarkView.UpdateListOfBookmarks();

            // Main Level Node +1
            // Dog +1
            // Dog 2 + 1
            // <Make Up Node to insert between Dog 2 and Error> +1
            // Error + 1
            // Current Position (Automated Node) + 1
            // = 6
            Assert.AreEqual (6, bookMarkView.NumberOfNodes());

            texter.GetRichTextBox().Text = "[[~scene]]";
            bookMarkView.UpdateListOfBookmarks();
            Assert.AreEqual (3, bookMarkView.NumberOfNodes());
            texter.GetRichTextBox().Text = @"Hello.
            =h1=
            =h2=
            =h3=
            =h4=
            =h1=
            ";
            bookMarkView.UpdateListOfBookmarks();
            Assert.AreEqual (7, bookMarkView.NumberOfNodes());
        }