Skip to content

Commit

Permalink
First version comes in!
Browse files Browse the repository at this point in the history
  • Loading branch information
10Develops committed Dec 30, 2021
1 parent cb45c2f commit e523452
Show file tree
Hide file tree
Showing 47 changed files with 3,432 additions and 6,716 deletions.
5 changes: 2 additions & 3 deletions TextEditor.sln → CS Tabbed Text Editor.sln
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextEditor", "TextEditor\TextEditor.csproj", "{1A9B7179-78AD-46AA-A6E6-D8F17F1F23DC}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CS Tabbed Text Editor", "CS Tabbed Text Editor\CS Tabbed Text Editor.csproj", "{1A9B7179-78AD-46AA-A6E6-D8F17F1F23DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
42 changes: 42 additions & 0 deletions CS Tabbed Text Editor/App.config
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>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,27 @@
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{1A9B7179-78AD-46AA-A6E6-D8F17F1F23DC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>TextEditor</RootNamespace>
<AssemblyName>TextEditor</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<RootNamespace>CS_Tabbed_Text_Editor</RootNamespace>
<AssemblyName>CS Tabbed Text Editor</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -32,33 +48,44 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>TextEditor.ico</ApplicationIcon>
<ApplicationIcon>TabbedTextEditor.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup />
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Windows\AboutWindow.cs">
<SubType>Form</SubType>
<Compile Include="Classes\RichTextBoxTabControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Classes\RichTextBoxTabPage.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Classes\RichTextBoxCore.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Windows\AboutWindow.Designer.cs">
<DependentUpon>AboutWindow.cs</DependentUpon>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Windows\HelpWindow.cs">
<Compile Include="Windows\AboutForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Windows\HelpWindow.Designer.cs">
<DependentUpon>HelpWindow.cs</DependentUpon>
<Compile Include="Windows\AboutForm.designer.cs">
<DependentUpon>AboutForm.cs</DependentUpon>
</Compile>
<Compile Include="Windows\MainWindow.cs">
<SubType>Form</SubType>
Expand All @@ -68,24 +95,35 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Windows\AboutWindow.resx">
<DependentUpon>AboutWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Windows\HelpWindow.resx">
<DependentUpon>HelpWindow.cs</DependentUpon>
<Compile Include="Windows\OptionsDialogue.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Windows\OptionsDialogue.designer.cs">
<DependentUpon>OptionsDialogue.cs</DependentUpon>
</Compile>
<Compile Include="Windows\UpdatesForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Windows\UpdatesForm.designer.cs">
<DependentUpon>UpdatesForm.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Windows\AboutForm.resx">
<DependentUpon>AboutForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Windows\MainWindow.resx">
<DependentUpon>MainWindow.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Windows\OptionsDialogue.resx">
<DependentUpon>OptionsDialogue.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Windows\UpdatesForm.resx">
<DependentUpon>UpdatesForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
Expand All @@ -100,7 +138,20 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="TextEditor.ico" />
<None Include="Resources\hamburgerMenuItem.Image.png" />
<None Include="Resources\newTabMenuItem.Image.png" />
<None Include="Resources\closeTabMenuItem.Image.png" />
<Content Include="Resources\openFileMenuItem.Image.png" />
<None Include="Resources\printMenuItem.Image.png" />
<Content Include="Resources\saveFileMenuItem.Image.png" />
<Content Include="TabbedTextEditor.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
55 changes: 55 additions & 0 deletions CS Tabbed Text Editor/Classes/RichTextBoxCore.cs
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);
}
}
}
121 changes: 121 additions & 0 deletions CS Tabbed Text Editor/Classes/RichTextBoxTabControl.cs
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();

}
}
}
Loading

0 comments on commit e523452

Please sign in to comment.