Skip to content

Commit

Permalink
Register Text Editor as a file type hander for .txt files
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary-Rude committed Dec 21, 2021
1 parent bdb3b00 commit b8d23c4
Show file tree
Hide file tree
Showing 25 changed files with 93 additions and 237 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
181 changes: 0 additions & 181 deletions Text Editor Setup/Text Editor Setup.aip

This file was deleted.

45 changes: 0 additions & 45 deletions Text Editor Setup/Text Editor Setup.aiproj

This file was deleted.

8 changes: 0 additions & 8 deletions Text Editor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 15.0.28307.1622
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Text Editor", "Text Editor\Text Editor.csproj", "{8A82FA64-B600-4A9A-8BA9-7790026E09E8}"
EndProject
Project("{840C416C-B8F3-42BC-B0DD-F6BB14C9F8CB}") = "Text Editor Setup", "Text Editor Setup\Text Editor Setup.aiproj", "{9ADA466B-06B1-4AD2-A7C8-545BE09B9688}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
All|Any CPU = All|Any CPU
Expand All @@ -20,12 +18,6 @@ Global
{8A82FA64-B600-4A9A-8BA9-7790026E09E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A82FA64-B600-4A9A-8BA9-7790026E09E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A82FA64-B600-4A9A-8BA9-7790026E09E8}.Release|Any CPU.Build.0 = Release|Any CPU
{9ADA466B-06B1-4AD2-A7C8-545BE09B9688}.All|Any CPU.ActiveCfg = DefaultBuild
{9ADA466B-06B1-4AD2-A7C8-545BE09B9688}.All|Any CPU.Build.0 = DefaultBuild
{9ADA466B-06B1-4AD2-A7C8-545BE09B9688}.Debug|Any CPU.ActiveCfg = DefaultBuild
{9ADA466B-06B1-4AD2-A7C8-545BE09B9688}.Debug|Any CPU.Build.0 = DefaultBuild
{9ADA466B-06B1-4AD2-A7C8-545BE09B9688}.Release|Any CPU.ActiveCfg = DefaultBuild
{9ADA466B-06B1-4AD2-A7C8-545BE09B9688}.Release|Any CPU.Build.0 = DefaultBuild
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion Text Editor/AboutForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions Text Editor/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,33 @@ public Form1()
mainEditor.WordWrap = Properties.Settings.Default.EnableWordWrap;
}

public Form1(string fileName) : this()
{
if (fileName == null)
return;

if (!File.Exists(fileName))
{
MessageBox.Show("Invalid file name.", "Cannot open file", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
this.Text = Path.GetFileName(fileName) + " - Text Editor";
using (StreamReader sr = new StreamReader(fileName))
{
path = fileName;
Task<string> text = sr.ReadToEndAsync();
mainEditor.Text = text.Result;
this.Text = this.Text.Replace("*", "");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Cannot open file", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

public static void QuickReplace(RichTextBox rtb, String word, String word2)
{
rtb.Text = rtb.Text.Replace(word, word2);
Expand Down
Binary file added Text Editor/Inno/Text_Editor_1_1_2_Setup.exe
Binary file not shown.
Binary file added Text Editor/Inno/Text_Editor_1_1_2_Setup.exe.exe
Binary file not shown.
56 changes: 56 additions & 0 deletions Text Editor/Inno/installer.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Text Editor"
#define MyAppVersion "1.1.2"
#define MyAppPublisher "Zach, Inc."
#define MyAppExeName "Text Editor.exe"
#define MyAppAssocName "Text File"
#define MyAppAssocExt ".txt"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{AEAF16D2-ED3B-417F-ABB6-B8A032C7CE2F}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName=C:\Program Files (x86)\{#MyAppName}
ChangesAssociations=yes
DisableProgramGroupPage=yes
LicenseFile=C:\Users\zacha\Documents\License Agreement.rtf
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir=C:\Users\zacha\source\repos\Text Editor\Text Editor\Inno
OutputBaseFilename=Text_Editor_1_1_2_Setup
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Users\zacha\source\repos\Text Editor\Text Editor\bin\Debug\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\zacha\source\repos\Text Editor\Text Editor\bin\Debug\textedit-help.chm"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Registry]
Root: HKCR; Subkey: "{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKCR; Subkey: "{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "C:\Windows\System32\imageres.dll,246"
Root: HKCR; Subkey: "{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""
Root: HKCR; Subkey: "Applications\{#MyAppExeName}\SupportedTypes"; ValueType: string; ValueName: ".txt"; ValueData: ""

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

8 changes: 6 additions & 2 deletions Text Editor/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ static class Program
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
string fileName = null;

if (args != null && args.Length > 0)
fileName = args[0];
Application.Run(new Form1(fileName));
}
}
}
3 changes: 3 additions & 0 deletions Text Editor/Text Editor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,8 @@
<ItemGroup>
<None Include="Resources\icon-72.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Inno\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit b8d23c4

Please sign in to comment.