public TabNavigation(RichTextExtended box) { if (box == null) { throw new Exception(Loc.Instance.GetString("Must pass a valid RichTextBox into TabNavigation")); } textBox = box; this.Height = 25; this.Selected += (object sender, TabControlEventArgs e) => { if (this.SelectedIndex > -1) { // NewMessage.Show (this.SelectedIndex string textToFind = this.TabPages[this.SelectedIndex].Text; //NewMessage.Show (this.TabPages[this.SelectedIndex].Text); if (textToFind != Constants.BLANK) { textBox.Find("=" + textToFind + "=", 0, RichTextBoxFinds.None); textBox.SelectionLength = 0; // get rid of highlight } } }; this.VisibleChanged += (object sender, EventArgs e) => { UpdateView(); }; Parse(); }
public TabNavigation(RichTextExtended box) { if (box == null) { throw new Exception(Loc.Instance.GetString ("Must pass a valid RichTextBox into TabNavigation")); } textBox = box; this.Height = 25; this.Selected+= (object sender, TabControlEventArgs e) => { if (this.SelectedIndex > -1) { // NewMessage.Show (this.SelectedIndex string textToFind = this.TabPages[this.SelectedIndex].Text; //NewMessage.Show (this.TabPages[this.SelectedIndex].Text); if (textToFind != Constants.BLANK) { textBox.Find ("="+textToFind+"=",0, RichTextBoxFinds.None); textBox.SelectionLength = 0; // get rid of highlight } } }; this.VisibleChanged+= (object sender, EventArgs e) => { UpdateView (); }; Parse(); }
/// <summary> /// Dos the find. This is the external facing find /// </summary> /// <returns> /// <c>true</c>, if find was done, <c>false</c> otherwise. /// </returns> /// <param name='SearchText'> /// Search text. /// </param> /// <param name='Exact'> /// If set to <c>true</c> exact. /// </param> /// <param name='RichBox'> /// Rich box. /// </param> public bool DoFind(string SearchText, bool Exact, RichTextExtended RichBox, int StartingLocation) { LastRichText = RichBox; Position = -1; Searchbox.Text = SearchText; PositionsFound = DoFind_BuildListOfFoundPositions(SearchText, Exact, RichBox.Text, StartingLocation); if (PositionsFound != null && PositionsFound.Count > 0) { // UpdateSearchMatches(1, PositionsFound.Count); FindFirst(); LastSearch = SearchText; return(true); } UpdateSearchMatches(0, 0); return(false); }
public void AlLFindBarsAreTheSame() { // children panels have the same findbar as a parent _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms .Form form = new System.Windows.Forms.Form(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); form.Controls.Add (panel); // needed else DataGrid does not initialize form.Show (); //form.Visible = false; //NOTE: For now remember that htis ADDS 1 Extra notes string panelname = System.Guid.NewGuid().ToString(); panel.NewLayout (panelname,true, null); LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel"); FAKE_NoteDataXML_Panel panelA = new FAKE_NoteDataXML_Panel(); panelA.GuidForNote="panelA"; panel.AddNote(panelA); //panel.AddNote(panelA); Intentionally do not add this because it should bea failre // Won't actually add things properly because I need to override the findbar FAKE_FindBar findBar = new FAKE_FindBar(); form.Controls.Add (findBar); RichTextExtended fakeText = new RichTextExtended(); form.Controls.Add (fakeText); fakeText.Text = "We have a dog. His name is Jake." + Environment.NewLine + "We love him a lot. He is a nice dog. We all love dogs."; findBar.DoFind("dog", false,fakeText,0); Assert.AreEqual(panelA.GetPanelsLayout().GetFindbar(), panel.GetFindbar()); // Assert.AreEqual(panelB.GetPanelsLayout().GetFindbar(), panel.GetFindbar()); }
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(); }
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 void TestAsterix() { _TestSingleTon.Instance._SetupForLayoutPanelTests(); System.Windows.Forms .Form form = new System.Windows.Forms.Form(); FAKE_LayoutPanel panel = new FAKE_LayoutPanel (CoreUtilities.Constants.BLANK, false); form.Controls.Add (panel); // needed else DataGrid does not initialize form.Show (); //form.Visible = false; //NOTE: For now remember that htis ADDS 1 Extra notes string panelname = System.Guid.NewGuid().ToString(); panel.NewLayout (panelname,true, null); LayoutDetails.Instance.AddToList (typeof(FAKE_NoteDataXML_Panel), "testingpanel"); // Won't actually add things properly because I need to override the findbar FAKE_FindBar findBar = new FAKE_FindBar(); form.Controls.Add (findBar); RichTextExtended fakeText = new RichTextExtended(); form.Controls.Add (fakeText); fakeText.Text = "We have a dog. His name is Jake." + Environment.NewLine + "We love him a lot. He is a nice dog. We all love dogs."; findBar.DoFind("*dog", false,fakeText,0); Assert.AreEqual(0, findBar.PositionsFOUND(), "Found 0 *dogs"); // I removed the code that prevented typing asertixes. Do not remember why I had it. // make sure it does not crash\ }
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(); }
/// <summary> /// Dos the find. This is the external facing find /// </summary> /// <returns> /// <c>true</c>, if find was done, <c>false</c> otherwise. /// </returns> /// <param name='SearchText'> /// Search text. /// </param> /// <param name='Exact'> /// If set to <c>true</c> exact. /// </param> /// <param name='RichBox'> /// Rich box. /// </param> public bool DoFind(string SearchText, bool Exact, RichTextExtended RichBox, int StartingLocation) { LastRichText = RichBox; Position = -1; Searchbox.Text = SearchText; PositionsFound = DoFind_BuildListOfFoundPositions (SearchText, Exact, RichBox.Text, StartingLocation); if (PositionsFound != null && PositionsFound.Count > 0) { // UpdateSearchMatches(1, PositionsFound.Count); FindFirst (); LastSearch = SearchText; return true; } UpdateSearchMatches(0,0); return false; }