Skip to content

Commit 4094cc0

Browse files
AmbratolmAmbratolm
Ambratolm
authored and
Ambratolm
committed
Initial Commit
0 parents  commit 4094cc0

File tree

66 files changed

+5516
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+5516
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Ambratolm
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Notepad.sln

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notepad", "Notepad\Notepad.csproj", "{4F85E466-2CD8-439E-A10B-9AA21987D405}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Debug|Mixed Platforms = Debug|Mixed Platforms
10+
Debug|x86 = Debug|x86
11+
Release|Any CPU = Release|Any CPU
12+
Release|Mixed Platforms = Release|Mixed Platforms
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Debug|Any CPU.ActiveCfg = Debug|x86
17+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
18+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Debug|Mixed Platforms.Build.0 = Debug|x86
19+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Debug|x86.ActiveCfg = Debug|x86
20+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Debug|x86.Build.0 = Debug|x86
21+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Release|Any CPU.ActiveCfg = Release|x86
22+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Release|Mixed Platforms.ActiveCfg = Release|x86
23+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Release|Mixed Platforms.Build.0 = Release|x86
24+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Release|x86.ActiveCfg = Release|x86
25+
{4F85E466-2CD8-439E-A10B-9AA21987D405}.Release|x86.Build.0 = Release|x86
26+
EndGlobalSection
27+
GlobalSection(SolutionProperties) = preSolution
28+
HideSolutionNode = FALSE
29+
EndGlobalSection
30+
EndGlobal

Notepad.suo

86 KB
Binary file not shown.

Notepad/API/API.cs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Windows.Forms;
2+
3+
namespace Notepad
4+
{
5+
public static partial class API
6+
{
7+
static API()
8+
{
9+
10+
}
11+
12+
public static void ShowNotFoundMessageBox(string keyword)
13+
{
14+
MessageBox.Show(
15+
text: string.Format("Could not find \"{0}\"", keyword),
16+
caption: Application.ProductName,
17+
buttons: MessageBoxButtons.OK,
18+
icon: MessageBoxIcon.Asterisk
19+
);
20+
}
21+
}
22+
}

Notepad/API/EventArgs_Extensions.cs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Drawing;
2+
using System.Drawing.Printing;
3+
using System.Windows.Forms;
4+
5+
namespace Notepad
6+
{
7+
public static partial class API
8+
{
9+
public static void AllowText(this DragEventArgs e)
10+
{
11+
//e.Effect = e.Data.GetDataPresent(DataFormats.Text)
12+
// ? DragDropEffects.Copy : DragDropEffects.None;
13+
e.Effect = DragDropEffects.All;
14+
}
15+
16+
public static string[] GetPaths(this DragEventArgs e)
17+
{
18+
return e.Data.GetData(DataFormats.FileDrop, false) as string[];
19+
}
20+
21+
public static void DrawPage(this PrintPageEventArgs e, string text, Font font)
22+
{
23+
e.Graphics.DrawString(text, font, Brushes.Black, 100, 100);
24+
}
25+
}
26+
}

Notepad/API/RichTextBox_Extension.cs

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
using System.Windows.Forms;
2+
3+
namespace Notepad
4+
{
5+
public static partial class API
6+
{
7+
public class RichTextBoxSearchInfos
8+
{
9+
public string Keyword { get; set; }
10+
public int LatestResultStartIndex { get; set; }
11+
public int LatestResultEndIndex { get; set; }
12+
public RichTextBoxFinds Options { get; set; }
13+
public bool Ready
14+
{
15+
get
16+
{
17+
return !string.IsNullOrEmpty(this.Keyword)
18+
&& this.LatestResultStartIndex >= 0;
19+
}
20+
}
21+
public int LatestResultIndex { get; set; }
22+
23+
public RichTextBoxSearchInfos()
24+
{
25+
this.LatestResultIndex = -1;
26+
}
27+
public bool HasOption(RichTextBoxFinds option)
28+
{
29+
return this.Options.HasFlag(option);
30+
}
31+
}
32+
33+
public static void PastePlainText(this RichTextBox richTextBox)
34+
{
35+
richTextBox.Paste(new DataFormats.Format(DataFormats.Text, 1));
36+
}
37+
38+
public static void ReplaceSelection(this RichTextBox richTextBox, string text)
39+
{
40+
richTextBox.SelectedText = text;
41+
}
42+
43+
public static void DeleteSelection(this RichTextBox richTextBox)
44+
{
45+
richTextBox.SelectedText = string.Empty;
46+
}
47+
48+
public static int FindNext(this RichTextBox richTextBox, RichTextBoxSearchInfos searchInfos)
49+
{
50+
if (richTextBox.TextLength != 0 && searchInfos.Ready)
51+
{
52+
bool reverse = searchInfos.HasOption(RichTextBoxFinds.Reverse);
53+
int start = reverse ? 0 : searchInfos.LatestResultEndIndex;
54+
int end = reverse ? searchInfos.LatestResultStartIndex : richTextBox.TextLength;
55+
searchInfos.LatestResultIndex = richTextBox
56+
.Find(searchInfos.Keyword, start, end, searchInfos.Options);
57+
if (searchInfos.LatestResultIndex != -1)
58+
{
59+
searchInfos.LatestResultStartIndex = searchInfos.LatestResultIndex;
60+
searchInfos.LatestResultEndIndex = searchInfos.LatestResultIndex + searchInfos.Keyword.Length;
61+
}
62+
else
63+
{
64+
searchInfos.LatestResultStartIndex = richTextBox.SelectionStart;
65+
searchInfos.LatestResultEndIndex = richTextBox.SelectionStart;
66+
}
67+
return searchInfos.LatestResultIndex;
68+
}
69+
return -1;
70+
}
71+
72+
public static void ReplaceText(this RichTextBox richTextBox, string oldText, string newText,
73+
int startIndex = -1)
74+
{
75+
startIndex = (startIndex == -1) ? richTextBox.Text.IndexOf(oldText) : startIndex;
76+
if (oldText.Length != 0 && startIndex >= 0)
77+
{
78+
richTextBox.Text = richTextBox.Text
79+
.Remove(startIndex, oldText.Length).Insert(startIndex, newText);
80+
}
81+
}
82+
83+
public static void ReplaceTextAll(this RichTextBox richTextBox, string oldText, string newText)
84+
{
85+
if (oldText.Length != 0)
86+
{
87+
richTextBox.Text = richTextBox.Text.Replace(oldText, newText);
88+
}
89+
}
90+
91+
public static int GetSelectedLineIndex(this RichTextBox richTextBox)
92+
{
93+
return richTextBox.GetLineFromCharIndex(richTextBox.SelectionStart);
94+
}
95+
96+
public static int GetSelectedColumnIndex(this RichTextBox richTextBox)
97+
{
98+
int line = richTextBox.GetLineFromCharIndex(richTextBox.SelectionStart);
99+
return richTextBox.SelectionStart - richTextBox.GetFirstCharIndexFromLine(line);
100+
}
101+
102+
public static bool ToggleRightToLeft(this RichTextBox richTextBox)
103+
{
104+
if (richTextBox.RightToLeft == RightToLeft.No)
105+
{
106+
richTextBox.RightToLeft = RightToLeft.Yes;
107+
return true;
108+
}
109+
else
110+
{
111+
richTextBox.RightToLeft = RightToLeft.No;
112+
return false;
113+
}
114+
}
115+
}
116+
}

Notepad/GUI/Form_About.Designer.cs

+169
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)