forked from JulianG97/TextEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb45c2f
commit e523452
Showing
47 changed files
with
3,432 additions
and
6,716 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> | ||
<section name="CS_Tabbed_Text_Editor.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> | ||
<section name="TextEditor.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/> | ||
</sectionGroup> | ||
</configSections> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> | ||
</startup> | ||
<userSettings> | ||
<CS_Tabbed_Text_Editor.Properties.Settings> | ||
<setting name="Font" serializeAs="String"> | ||
<value>Microsoft Sans Serif, 9pt</value> | ||
</setting> | ||
<setting name="ShowStatusBar" serializeAs="String"> | ||
<value>True</value> | ||
</setting> | ||
<setting name="Width" serializeAs="String"> | ||
<value>0</value> | ||
</setting> | ||
<setting name="Height" serializeAs="String"> | ||
<value>0</value> | ||
</setting> | ||
<setting name="WindowState" serializeAs="String"> | ||
<value>0</value> | ||
</setting> | ||
<setting name="EnableDynamicStatusBar" serializeAs="String"> | ||
<value>True</value> | ||
</setting> | ||
<setting name="DefaultSearchEngine" serializeAs="String"> | ||
<value>1</value> | ||
</setting> | ||
</CS_Tabbed_Text_Editor.Properties.Settings> | ||
<TextEditor.Properties.Settings> | ||
<setting name="Font" serializeAs="String"> | ||
<value>Microsoft Sans Serif, 9pt</value> | ||
</setting> | ||
</TextEditor.Properties.Settings> | ||
</userSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using System.Net; | ||
using System.IO; | ||
using System.Text.RegularExpressions; | ||
using System.Drawing; | ||
namespace CS_Tabbed_Text_Editor | ||
{ | ||
public class RichTextBoxCore : RichTextBox | ||
{ | ||
/// <summary> | ||
/// The path to the file that is currently in use. | ||
/// </summary> | ||
public string fileName; | ||
|
||
public EventHandler<EventArgs> StatusTextChanged; | ||
|
||
/// <summary> | ||
/// A value indicating whether the text of the text box has been changed or not. | ||
/// </summary> | ||
public bool textChanged; | ||
|
||
public RichTextBoxCore() | ||
{ | ||
fileName = "Untitled"; | ||
textChanged = false; | ||
} | ||
|
||
protected override void OnTextChanged(EventArgs e) | ||
{ | ||
base.OnTextChanged(e); | ||
textChanged = true; | ||
} | ||
|
||
private string _StatusText; | ||
public string StatusText | ||
{ | ||
get | ||
{ | ||
_StatusText = string.Format("length: {0} \t lines: {1} \t Sel: {2}", Text.Length, Lines.Length, SelectionLength); | ||
OnStatusTextChanged(); | ||
return _StatusText; | ||
} | ||
} | ||
|
||
protected virtual void OnStatusTextChanged() | ||
{ | ||
if (StatusTextChanged != null) StatusTextChanged(this, EventArgs.Empty); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using System.Drawing; | ||
namespace CS_Tabbed_Text_Editor | ||
{ | ||
/// <summary> | ||
/// A <b>TabControl</b> designed to display <see cref="RichTextBoxTabPage" /> objects. | ||
/// </summary> | ||
public class RichTextBoxTabControl : TabControl | ||
{ | ||
[DllImport("user32.dll")] | ||
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp); | ||
private const int TCM_SETMINTABWIDTH = 0x1300 + 49; | ||
#region Properties | ||
|
||
public RichTextBoxTabControl() | ||
{ | ||
DrawMode = TabDrawMode.Normal; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the currently selected tab page. | ||
/// </summary> | ||
/// <value> | ||
/// The <see cref="RichTextBoxTabPage" /> that is currently selected. | ||
/// </value> | ||
public RichTextBoxTabPage SelectedRichTextBoxTabPage | ||
{ | ||
get | ||
{ | ||
return (RichTextBoxTabPage)this.SelectedTab; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets the currently selected web browser. | ||
/// </summary> | ||
/// <value> | ||
/// The <b>RichTextBox</b> control on the currently selected tab page. | ||
/// </value> | ||
public RichTextBoxCore SelectedRichTextBox | ||
{ | ||
get | ||
{ | ||
return this.SelectedRichTextBoxTabPage.TextBox; | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Methods | ||
|
||
/// <summary> | ||
/// Adds a new, empty page to the tab control. | ||
/// </summary> | ||
/// <returns> | ||
/// The <see cref="RichTextBoxTabPage" /> that was added. | ||
/// </returns> | ||
public RichTextBoxTabPage AddTab() | ||
{ | ||
RichTextBoxTabPage tab = new RichTextBoxTabPage(); | ||
if (TabCount == 0) | ||
{ | ||
TabPages.Insert(TabCount, tab); | ||
} | ||
else | ||
{ | ||
TabPages.Insert(TabCount - 1, tab); | ||
} | ||
this.SelectedTab = tab; | ||
return tab; | ||
} | ||
|
||
/// <summary> | ||
/// Removes the currently selected tab from the tab control. | ||
/// </summary> | ||
/// <returns> | ||
/// <b>True</b> if the current tab was removed; otherwise, <b>False</b>. | ||
/// </returns> | ||
/// <remarks> | ||
/// There must always be at least one tab so the last tab cannot be removed. | ||
/// </remarks> | ||
public bool RemoveCurrentTab() | ||
{ | ||
bool canRemove = this.TabCount > 2; | ||
|
||
if (canRemove) | ||
{ | ||
RichTextBoxTabPage tab = this.SelectedRichTextBoxTabPage; | ||
this.TabPages.Remove(tab); | ||
tab.Dispose(); | ||
} | ||
|
||
return canRemove; | ||
} | ||
|
||
#endregion | ||
|
||
protected override void OnHandleCreated(EventArgs e) | ||
{ | ||
SendMessage(Handle, TCM_SETMINTABWIDTH, IntPtr.Zero, (IntPtr)30); | ||
base.OnHandleCreated(e); | ||
} | ||
|
||
protected override void OnDrawItem(DrawItemEventArgs e) | ||
{ | ||
base.OnDrawItem(e); | ||
|
||
//This code will render a "x" mark at the end of the Tab caption. | ||
e.Graphics.DrawString("x", e.Font, Brushes.Black, e.Bounds.Right - 10, e.Bounds.Top + 6); | ||
e.Graphics.DrawString(this.TabPages[e.Index].Text, e.Font, Brushes.Black, e.Bounds.Left, e.Bounds.Top + 6); | ||
e.DrawFocusRectangle(); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.