diff --git a/README.md b/README.md new file mode 100644 index 0000000..46edced --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# Suzu Magnifier + +> A utility to show a magnified view of what you're working on. + +![Icon](icon/icon_64.png) + +--- + +## Features + +- Magnifies the area around your cursor +- Supports fullscreen (turn a whole monitor into a magnified viewer) +- Ad free and free-as-in-beards + +## Screenshots + +[![screenshot](wiki/screenshot-1-h240.png)](wiki/screenshot-1.png) [![screenshot](wiki/screenshot-2-h240.png)](wiki/screenshot-2.png) + +--- + +## Background + +I wanted a magnifying utility to run fullscreen on one of my monitors. +After some searching, I wasn't able to find one that I was happy with. +Some looked very outdated, others didn't support borderless fullscreen. +It seemed that the worse they were, the higher their prices. +With little choice, I decided to spend a weekend and build my own. +I hope someone finds this useful. + +--- + +## Releases & Builds + +See [Releases](/Ray/SuzuMagnifier/releases) + +## Acknowledgements + +This software uses a number of dependencies and assets from third-parties. +These developers and artists deserve due credit for their work and for their commitment to sharing their work freely. +Each product is released under their own particular license, for more information please visit their websites. + +- [Lucide](https://lucide.dev/icons/) + +## License + +This project is licensed under the least restrictive terms of its dependencies, viz. MIT License. \ No newline at end of file diff --git a/build-installer.iss b/build-installer.iss new file mode 100644 index 0000000..133f370 --- /dev/null +++ b/build-installer.iss @@ -0,0 +1,52 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "SuzuMagnifier" +#define MyAppVersion "0.1.0.227" +#define MyAppPublisher "Hi, I'm Ray" +#define MyAppURL "https://git.hiimray.co.uk/Ray/SuzuMagnifier" +#define MyAppExeName "suzumagnifier.exe" + +#define AppSourcePath "L:\gitea-hiimray\suzumagnifier\bin" +#define AppReleasePath "L:\gitea-hiimray\suzumagnifier\bin" +#define AppReleaseName "suzumagnifier-installer" + +[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={{472ED37C-C4FC-4B72-8BC3-C281A6E0D2F9} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={autopf}\{#MyAppName} +DefaultGroupName={#MyAppName} +DisableProgramGroupPage=yes +; Remove the following line to run in administrative install mode (install for all users.) +PrivilegesRequired=lowest +OutputDir={#AppReleasePath} +OutputBaseFilename={#AppReleaseName} +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: "{#AppSourcePath}\cursorguardrail.exe"; DestDir: "{app}"; Flags: ignoreversion +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" +Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + diff --git a/build.bat b/build.bat index 40e522a..9fceaf0 100644 --- a/build.bat +++ b/build.bat @@ -5,6 +5,10 @@ rmdir /s /q "source\obj\" dotnet restore SuzuMagnifier.slnx dotnet publish SuzuMagnifier.slnx -r win-x64 -c Release /p:PublishSingleFile=true /p:SelfContained=false /p:PublishReadyToRunfalse=true /p:PublishDir="..\bin\" +"C:\B\Portable Files (dev)\Inno Setup\v6.0.4-2\app\ISCC.exe" "build-installer.iss" + +"C:\B\Portable Files\7-Zip (Portable)\26.02\App\7-Zip64\7z.exe" a -t7z "bin\suzumagnifier.7z" ".\bin\suzumagnifier.exe" -mx9 + rmdir /s /q "source\bin\" rmdir /s /q "source\obj\" diff --git a/icon/icon-1.svg b/icon/icon.svg similarity index 100% rename from icon/icon-1.svg rename to icon/icon.svg diff --git a/icon/icon-128.png b/icon/icon_128.png similarity index 100% rename from icon/icon-128.png rename to icon/icon_128.png diff --git a/icon/icon-16.png b/icon/icon_16.png similarity index 100% rename from icon/icon-16.png rename to icon/icon_16.png diff --git a/icon/icon-24.png b/icon/icon_24.png similarity index 100% rename from icon/icon-24.png rename to icon/icon_24.png diff --git a/icon/icon-32.png b/icon/icon_32.png similarity index 100% rename from icon/icon-32.png rename to icon/icon_32.png diff --git a/icon/icon-48.png b/icon/icon_48.png similarity index 100% rename from icon/icon-48.png rename to icon/icon_48.png diff --git a/icon/icon-64.png b/icon/icon_64.png similarity index 100% rename from icon/icon-64.png rename to icon/icon_64.png diff --git a/source/Dtos/SavedOptions.cs b/source/Dtos/SavedOptions.cs index eaf6bd2..c4f6672 100644 --- a/source/Dtos/SavedOptions.cs +++ b/source/Dtos/SavedOptions.cs @@ -4,11 +4,16 @@ { public int Version { get; set; } = 1; + public string Format { get; set; } = "suzumagnifier"; + + public bool ReadOnly { get; set; } = false; + + public bool AutoStart { get; set; } public bool HighQuality { get; set; } - public int ZoomFactor { get; set; } + public decimal ZoomFactor { get; set; } public int UpdateFrequency { get; set; } @@ -16,7 +21,9 @@ public int CrosshairSize { get; set; } - public Color CrosshairColour { get; set; } + public string? CrosshairColour { get; set; } + + public bool ShowAlwaysOnTop { get; set; } } } diff --git a/source/Form1.Designer.cs b/source/Form1.Designer.cs index 4d8dc1b..d165d64 100644 --- a/source/Form1.Designer.cs +++ b/source/Form1.Designer.cs @@ -44,8 +44,6 @@ toolStripSeparator3 = new ToolStripSeparator(); resetToolStripMenuItem = new ToolStripMenuItem(); toolStripMenuItem9 = new ToolStripMenuItem(); - showToolStripMenuItem = new ToolStripMenuItem(); - toolStripSeparator5 = new ToolStripSeparator(); sizeToolStripMenuItem = new ToolStripMenuItem(); smallToolStripMenuItem = new ToolStripMenuItem(); mediumToolStripMenuItem = new ToolStripMenuItem(); @@ -62,7 +60,13 @@ toolStripMenuItem5 = new ToolStripMenuItem(); toolStripMenuItem3 = new ToolStripMenuItem(); toolStripSeparator1 = new ToolStripSeparator(); + toolStripMenuItem10 = new ToolStripMenuItem(); + viewHelpToolStripMenuItem = new ToolStripMenuItem(); + aboutToolStripMenuItem = new ToolStripMenuItem(); + toolStripSeparator6 = new ToolStripSeparator(); exitiToolStripMenuItem = new ToolStripMenuItem(); + toolStripMenuItem11 = new ToolStripMenuItem(); + toolStripSeparator7 = new ToolStripSeparator(); contextMenuStrip1.SuspendLayout(); SuspendLayout(); // @@ -75,13 +79,14 @@ // // contextMenuStrip1 // - contextMenuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem1, toolStripMenuItem2, toolStripSeparator2, toolStripMenuItem4, toolStripMenuItem6, toolStripMenuItem9, toolStripSeparator4, toolStripMenuItem5, toolStripMenuItem3, toolStripSeparator1, exitiToolStripMenuItem }); + contextMenuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem1, toolStripMenuItem2, toolStripSeparator2, toolStripMenuItem4, toolStripMenuItem6, toolStripMenuItem9, toolStripSeparator4, toolStripMenuItem5, toolStripMenuItem3, toolStripSeparator1, toolStripMenuItem10, toolStripSeparator6, exitiToolStripMenuItem }); contextMenuStrip1.Name = "contextMenuStrip1"; - contextMenuStrip1.Size = new Size(205, 198); + contextMenuStrip1.Size = new Size(205, 248); contextMenuStrip1.Opening += contextMenuStrip1_Opening; // // toolStripMenuItem1 // + toolStripMenuItem1.Image = Resource1.play; toolStripMenuItem1.Name = "toolStripMenuItem1"; toolStripMenuItem1.Size = new Size(204, 22); toolStripMenuItem1.Text = "&Start"; @@ -89,6 +94,7 @@ // // toolStripMenuItem2 // + toolStripMenuItem2.Image = Resource1.pause; toolStripMenuItem2.Name = "toolStripMenuItem2"; toolStripMenuItem2.Size = new Size(204, 22); toolStripMenuItem2.Text = "Sto&p"; @@ -123,6 +129,7 @@ // toolStripMenuItem6 // toolStripMenuItem6.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItem7, toolStripMenuItem8, toolStripSeparator3, resetToolStripMenuItem }); + toolStripMenuItem6.Image = Resource1.search; toolStripMenuItem6.Name = "toolStripMenuItem6"; toolStripMenuItem6.Size = new Size(204, 22); toolStripMenuItem6.Text = "Zoom"; @@ -158,48 +165,37 @@ // // toolStripMenuItem9 // - toolStripMenuItem9.DropDownItems.AddRange(new ToolStripItem[] { showToolStripMenuItem, toolStripSeparator5, sizeToolStripMenuItem, colourToolStripMenuItem }); + toolStripMenuItem9.DropDownItems.AddRange(new ToolStripItem[] { sizeToolStripMenuItem, colourToolStripMenuItem }); + toolStripMenuItem9.Image = Resource1.crosshair; toolStripMenuItem9.Name = "toolStripMenuItem9"; toolStripMenuItem9.Size = new Size(204, 22); toolStripMenuItem9.Text = "Crosshair"; // - // showToolStripMenuItem - // - showToolStripMenuItem.Name = "showToolStripMenuItem"; - showToolStripMenuItem.Size = new Size(110, 22); - showToolStripMenuItem.Text = "Show"; - showToolStripMenuItem.Click += showToolStripMenuItem_Click; - // - // toolStripSeparator5 - // - toolStripSeparator5.Name = "toolStripSeparator5"; - toolStripSeparator5.Size = new Size(107, 6); - // // sizeToolStripMenuItem // - sizeToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { smallToolStripMenuItem, mediumToolStripMenuItem, largeToolStripMenuItem }); + sizeToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItem11, toolStripSeparator7, smallToolStripMenuItem, mediumToolStripMenuItem, largeToolStripMenuItem }); sizeToolStripMenuItem.Name = "sizeToolStripMenuItem"; - sizeToolStripMenuItem.Size = new Size(110, 22); + sizeToolStripMenuItem.Size = new Size(180, 22); sizeToolStripMenuItem.Text = "Size"; // // smallToolStripMenuItem // smallToolStripMenuItem.Name = "smallToolStripMenuItem"; - smallToolStripMenuItem.Size = new Size(119, 22); + smallToolStripMenuItem.Size = new Size(180, 22); smallToolStripMenuItem.Text = "Small"; smallToolStripMenuItem.Click += smallToolStripMenuItem_Click; // // mediumToolStripMenuItem // mediumToolStripMenuItem.Name = "mediumToolStripMenuItem"; - mediumToolStripMenuItem.Size = new Size(119, 22); + mediumToolStripMenuItem.Size = new Size(180, 22); mediumToolStripMenuItem.Text = "Medium"; mediumToolStripMenuItem.Click += mediumToolStripMenuItem_Click; // // largeToolStripMenuItem // largeToolStripMenuItem.Name = "largeToolStripMenuItem"; - largeToolStripMenuItem.Size = new Size(119, 22); + largeToolStripMenuItem.Size = new Size(180, 22); largeToolStripMenuItem.Text = "Large"; largeToolStripMenuItem.Click += largeToolStripMenuItem_Click; // @@ -207,7 +203,7 @@ // colourToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { agentaToolStripMenuItem, cyanToolStripMenuItem, yellowToolStripMenuItem, greenToolStripMenuItem, redToolStripMenuItem, blackToolStripMenuItem, whiteToolStripMenuItem }); colourToolStripMenuItem.Name = "colourToolStripMenuItem"; - colourToolStripMenuItem.Size = new Size(110, 22); + colourToolStripMenuItem.Size = new Size(180, 22); colourToolStripMenuItem.Text = "Colour"; // // agentaToolStripMenuItem @@ -274,6 +270,7 @@ // // toolStripMenuItem3 // + toolStripMenuItem3.Image = Resource1.fullscreen; toolStripMenuItem3.Name = "toolStripMenuItem3"; toolStripMenuItem3.ShortcutKeys = Keys.F11; toolStripMenuItem3.Size = new Size(204, 22); @@ -285,6 +282,34 @@ toolStripSeparator1.Name = "toolStripSeparator1"; toolStripSeparator1.Size = new Size(201, 6); // + // toolStripMenuItem10 + // + toolStripMenuItem10.DropDownItems.AddRange(new ToolStripItem[] { viewHelpToolStripMenuItem, aboutToolStripMenuItem }); + toolStripMenuItem10.Name = "toolStripMenuItem10"; + toolStripMenuItem10.Size = new Size(204, 22); + toolStripMenuItem10.Text = "&Help"; + // + // viewHelpToolStripMenuItem + // + viewHelpToolStripMenuItem.Image = Resource1.help_circle; + viewHelpToolStripMenuItem.Name = "viewHelpToolStripMenuItem"; + viewHelpToolStripMenuItem.ShortcutKeys = Keys.F1; + viewHelpToolStripMenuItem.Size = new Size(146, 22); + viewHelpToolStripMenuItem.Text = "View &Help"; + viewHelpToolStripMenuItem.Click += viewHelpToolStripMenuItem_Click; + // + // aboutToolStripMenuItem + // + aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; + aboutToolStripMenuItem.Size = new Size(146, 22); + aboutToolStripMenuItem.Text = "&About"; + aboutToolStripMenuItem.Click += aboutToolStripMenuItem_Click; + // + // toolStripSeparator6 + // + toolStripSeparator6.Name = "toolStripSeparator6"; + toolStripSeparator6.Size = new Size(201, 6); + // // exitiToolStripMenuItem // exitiToolStripMenuItem.Name = "exitiToolStripMenuItem"; @@ -292,6 +317,18 @@ exitiToolStripMenuItem.Text = "E&xit"; exitiToolStripMenuItem.Click += exitiToolStripMenuItem_Click; // + // toolStripMenuItem11 + // + toolStripMenuItem11.Name = "toolStripMenuItem11"; + toolStripMenuItem11.Size = new Size(180, 22); + toolStripMenuItem11.Text = "None"; + toolStripMenuItem11.Click += toolStripMenuItem11_Click; + // + // toolStripSeparator7 + // + toolStripSeparator7.Name = "toolStripSeparator7"; + toolStripSeparator7.Size = new Size(177, 6); + // // Form1 // AutoScaleDimensions = new SizeF(96F, 96F); @@ -327,10 +364,8 @@ private ToolStripMenuItem resetToolStripMenuItem; private ToolStripSeparator toolStripSeparator4; private ToolStripMenuItem toolStripMenuItem9; - private ToolStripMenuItem showToolStripMenuItem; private ToolStripMenuItem sizeToolStripMenuItem; private ToolStripMenuItem colourToolStripMenuItem; - private ToolStripSeparator toolStripSeparator5; private ToolStripMenuItem smallToolStripMenuItem; private ToolStripMenuItem mediumToolStripMenuItem; private ToolStripMenuItem largeToolStripMenuItem; @@ -341,5 +376,11 @@ private ToolStripMenuItem redToolStripMenuItem; private ToolStripMenuItem blackToolStripMenuItem; private ToolStripMenuItem whiteToolStripMenuItem; + private ToolStripMenuItem toolStripMenuItem10; + private ToolStripMenuItem viewHelpToolStripMenuItem; + private ToolStripMenuItem aboutToolStripMenuItem; + private ToolStripSeparator toolStripSeparator6; + private ToolStripMenuItem toolStripMenuItem11; + private ToolStripSeparator toolStripSeparator7; } } diff --git a/source/Form1.cs b/source/Form1.cs index 08d7e89..903f0b8 100644 --- a/source/Form1.cs +++ b/source/Form1.cs @@ -1,8 +1,8 @@ using System.ComponentModel; +using System.Diagnostics; using System.Drawing.Drawing2D; using System.Runtime.InteropServices; using SuzuMagnifier.Dtos; -using static System.Windows.Forms.Design.AxImporter; namespace SuzuMagnifier { @@ -27,7 +27,7 @@ namespace SuzuMagnifier private readonly System.Windows.Forms.Timer _timer = new(); private Bitmap? _bitmap; - private string jsonfigFilename; + private string _jsonfigFilename; public Form1() @@ -52,26 +52,31 @@ namespace SuzuMagnifier var args = GetCommandLine()!; - jsonfigFilename = args.Where(x => (x.Key.Equals("o") || x.Key.Equals("open"))).Select(x => x.Value).FirstOrDefault(); - if (string.IsNullOrWhiteSpace(jsonfigFilename)) + _jsonfigFilename = args.Where(x => (x.Key.Equals("o") || x.Key.Equals("open"))).Select(x => x.Value).FirstOrDefault(); + if (string.IsNullOrWhiteSpace(_jsonfigFilename)) { - jsonfigFilename = Path.ChangeExtension(Application.ExecutablePath, "jsonfig"); + _jsonfigFilename = Path.ChangeExtension(Application.ExecutablePath, "jsonfig"); } - if (System.IO.File.Exists(jsonfigFilename)) + if (System.IO.File.Exists(_jsonfigFilename)) { - var newSettings = await LoadSettings(jsonfigFilename); - if (newSettings == null) + this.SavedOptions = await LoadSettings(_jsonfigFilename); + + this.TopMost = this.SavedOptions!.ShowAlwaysOnTop; + this.HighQuality = this.SavedOptions.HighQuality; + this.ZoomFactor = this.SavedOptions.ZoomFactor; + this.UpdateFrequency = this.SavedOptions.UpdateFrequency; + this.CrosshairSize = this.SavedOptions.CrosshairSize; + + if (!string.IsNullOrWhiteSpace(this.SavedOptions.CrosshairColour)) { - newSettings = new SavedOptions(); + this.CrosshairColour = ColorTranslator.FromHtml(this.SavedOptions!.CrosshairColour); } - this.HighQuality = newSettings.HighQuality; - this.ZoomFactor = newSettings.ZoomFactor; - //this.UpdateFrequency = newSettings.UpdateFrequency; - this.ShowCrosshair = newSettings.ShowCrosshair; - this.CrosshairSize = newSettings.CrosshairSize; - this.CrosshairColour = newSettings.CrosshairColour; + if (this.SavedOptions!.AutoStart) + { + _timer.Start(); + } } } @@ -114,7 +119,7 @@ namespace SuzuMagnifier g.DrawImage(_bitmap, this.ClientRectangle); // Draw center crosshair - if (this.ShowCrosshair) + if (this.CrosshairSize > 0) { var cx = Divide(this.Width, 2); var cy = Divide(this.Height, 2); @@ -179,10 +184,15 @@ namespace SuzuMagnifier { base.OnFormClosing(e); + if (this.SavedOptions.ReadOnly) + { + return; + } + var result = MessageBox.Show("Do you want to save settings to file?", "Save Settings?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { - var result2 = await SaveSettings(jsonfigFilename); + var result2 = await SaveSettings(_jsonfigFilename); if (result2) { return; @@ -203,58 +213,20 @@ namespace SuzuMagnifier } + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public SavedOptions SavedOptions { get => field ?? new SavedOptions(); private set => field = value; } + [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool HighQuality { get; set; } = false; [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int ZoomFactor - { - get => field; - set - { - if (value < 0) - { - field = 1; - return; - } - - if (value > 20) - { - field = 20; - return; - } - - field = value; - } - } = 2; + public decimal ZoomFactor { get => field; set => field = Math.Clamp(value, 1, 20); } = 2; [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public int UpdateFrequency { get; set; } = 33; [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public bool ShowCrosshair { get; set; } = true; - - [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public int CrosshairSize - { - get => field; - set - { - if (value < 5) - { - field = 5; - return; - } - - if (value > 200) - { - field = 200; - return; - } - - field = value; - } - } = 20; + public int CrosshairSize { get => field; set => field = Math.Clamp(value, 0, 200); } = 20; [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Color CrosshairColour { get; set; } = Color.FromArgb(255, 255, 0); @@ -267,18 +239,20 @@ namespace SuzuMagnifier toolStripMenuItem5.Checked = this.TopMost; - showToolStripMenuItem.Checked = this.ShowCrosshair; + toolStripMenuItem11.Checked = (this.CrosshairSize == 0); smallToolStripMenuItem.Checked = (this.CrosshairSize == 10); mediumToolStripMenuItem.Checked = (this.CrosshairSize == 20); largeToolStripMenuItem.Checked = (this.CrosshairSize == 50); - agentaToolStripMenuItem.Checked = this.CrosshairColour == Color.FromArgb(255, 0, 255); - cyanToolStripMenuItem.Checked = this.CrosshairColour == Color.FromArgb(0, 255, 255); - yellowToolStripMenuItem.Checked = this.CrosshairColour == Color.FromArgb(255, 255, 0); - greenToolStripMenuItem.Checked = this.CrosshairColour == Color.FromArgb(0, 255, 0); - redToolStripMenuItem.Checked = this.CrosshairColour == Color.FromArgb(255, 0, 0); - blackToolStripMenuItem.Checked = this.CrosshairColour == Color.FromArgb(0, 0, 0); - whiteToolStripMenuItem.Checked = this.CrosshairColour == Color.FromArgb(255, 255, 255); + resetToolStripMenuItem.Checked = (this.ZoomFactor == 1); + + agentaToolStripMenuItem.Checked = (this.CrosshairColour == Color.FromArgb(255, 0, 255)); + cyanToolStripMenuItem.Checked = (this.CrosshairColour == Color.FromArgb(0, 255, 255)); + yellowToolStripMenuItem.Checked = (this.CrosshairColour == Color.FromArgb(255, 255, 0)); + greenToolStripMenuItem.Checked = (this.CrosshairColour == Color.FromArgb(0, 255, 0)); + redToolStripMenuItem.Checked = (this.CrosshairColour == Color.FromArgb(255, 0, 0)); + blackToolStripMenuItem.Checked = (this.CrosshairColour == Color.FromArgb(0, 0, 0)); + whiteToolStripMenuItem.Checked = (this.CrosshairColour == Color.FromArgb(255, 255, 255)); fasterToolStripMenuItem.Checked = !this.HighQuality; fasterToolStripMenuItem.Enabled = this.HighQuality; @@ -346,7 +320,7 @@ namespace SuzuMagnifier /// private void toolStripMenuItem7_Click(object sender, EventArgs e) { - this.ZoomFactor++; + this.ZoomFactor += 0.2m; } /// @@ -356,7 +330,7 @@ namespace SuzuMagnifier /// private void toolStripMenuItem8_Click(object sender, EventArgs e) { - this.ZoomFactor--; + this.ZoomFactor -= 0.2m; } /// @@ -468,6 +442,44 @@ namespace SuzuMagnifier } } + + /// + /// Help, view help + /// + /// + /// + private void viewHelpToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + Process.Start(new ProcessStartInfo + { + FileName = Resource1.AppHelpURL, + UseShellExecute = true + }); + } + catch (Exception) + { + } + } + + /// + /// Help, about + /// + /// + /// + private void aboutToolStripMenuItem_Click(object sender, EventArgs e) + { + var version = Application.ProductVersion ?? string.Empty; + if (version.Contains("+")) + { + version = version.Substring(0, (version.IndexOf("+"))); + } + + MessageBox.Show($"{Application.ProductName} v{version}", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + /// /// Exit /// @@ -485,17 +497,17 @@ namespace SuzuMagnifier } /// - /// Crosshair, toggle + /// Crosshair, size, off /// /// /// - private void showToolStripMenuItem_Click(object sender, EventArgs e) + private void toolStripMenuItem11_Click(object sender, EventArgs e) { - this.ShowCrosshair = !this.ShowCrosshair; + this.CrosshairSize = 0; } /// - /// Croisshair, size, small + /// Crosshair, size, small /// /// /// @@ -505,7 +517,7 @@ namespace SuzuMagnifier } /// - /// Croisshair, size, medium + /// Crosshair, size, medium /// /// /// @@ -515,7 +527,7 @@ namespace SuzuMagnifier } /// - /// Croisshair, size, large + /// Crosshair, size, large /// /// /// @@ -557,6 +569,11 @@ namespace SuzuMagnifier return (int)Math.Floor((decimal)x / y); } + private int Divide(int x, decimal y) + { + return (int)Math.Floor((decimal)x / y); + } + /// /// Get execution arguments. /// @@ -622,31 +639,38 @@ namespace SuzuMagnifier return null; } + SavedOptions response; try { - return System.Text.Json.JsonSerializer.Deserialize(sourceCode); + response = System.Text.Json.JsonSerializer.Deserialize(sourceCode); } catch (Exception) { return null; } + + if (!response!.Format.Equals(Resource1.FileFormat, StringComparison.CurrentCultureIgnoreCase)) + { + return null; + } + + return response; } private async Task SaveSettings(string filename) { - var result = new SavedOptions(); - result.AutoStart = false; - result.HighQuality = this.HighQuality; - result.ZoomFactor = this.ZoomFactor; - result.UpdateFrequency = this.UpdateFrequency; - result.ShowCrosshair = this.ShowCrosshair; - result.CrosshairSize = this.CrosshairSize; - result.CrosshairColour = this.CrosshairColour; + //_savedOptions.AutoStart = false; + this.SavedOptions.HighQuality = this.HighQuality; + this.SavedOptions.ZoomFactor = this.ZoomFactor; + this.SavedOptions.UpdateFrequency = this.UpdateFrequency; + this.SavedOptions.CrosshairSize = this.CrosshairSize; + this.SavedOptions.CrosshairColour = $"#{this.CrosshairColour.R:X2}{this.CrosshairColour.G:X2}{this.CrosshairColour.B:X2}"; + this.SavedOptions.ShowAlwaysOnTop = this.TopMost; string sourceCode = ""; try { - sourceCode = System.Text.Json.JsonSerializer.Serialize(result); + sourceCode = System.Text.Json.JsonSerializer.Serialize(this.SavedOptions); } catch (Exception) { diff --git a/source/Resource1.Designer.cs b/source/Resource1.Designer.cs new file mode 100644 index 0000000..0334797 --- /dev/null +++ b/source/Resource1.Designer.cs @@ -0,0 +1,141 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SuzuMagnifier { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resource1 { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resource1() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SuzuMagnifier.Resource1", typeof(Resource1).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to https://www.hiimray.co.uk. + /// + internal static string AppHelpURL { + get { + return ResourceManager.GetString("AppHelpURL", resourceCulture); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap crosshair { + get { + object obj = ResourceManager.GetObject("crosshair", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized string similar to suzumagnifier. + /// + internal static string FileFormat { + get { + return ResourceManager.GetString("FileFormat", resourceCulture); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap fullscreen { + get { + object obj = ResourceManager.GetObject("fullscreen", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap help_circle { + get { + object obj = ResourceManager.GetObject("help_circle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap pause { + get { + object obj = ResourceManager.GetObject("pause", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap play { + get { + object obj = ResourceManager.GetObject("play", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap search { + get { + object obj = ResourceManager.GetObject("search", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/source/Resource1.resx b/source/Resource1.resx new file mode 100644 index 0000000..2a8eef4 --- /dev/null +++ b/source/Resource1.resx @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + https://www.hiimray.co.uk + + + + Resources\crosshair.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + suzumagnifier + + + Resources\fullscreen.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + Resources\help-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + Resources\pause.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + Resources\play.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + Resources\search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/source/Resources/crosshair.png b/source/Resources/crosshair.png new file mode 100644 index 0000000..36fad1b Binary files /dev/null and b/source/Resources/crosshair.png differ diff --git a/source/Resources/fullscreen.png b/source/Resources/fullscreen.png new file mode 100644 index 0000000..3595ce0 Binary files /dev/null and b/source/Resources/fullscreen.png differ diff --git a/source/Resources/help-circle.png b/source/Resources/help-circle.png new file mode 100644 index 0000000..fa87ded Binary files /dev/null and b/source/Resources/help-circle.png differ diff --git a/source/Resources/pause.png b/source/Resources/pause.png new file mode 100644 index 0000000..9964b5c Binary files /dev/null and b/source/Resources/pause.png differ diff --git a/source/Resources/play.png b/source/Resources/play.png new file mode 100644 index 0000000..5058868 Binary files /dev/null and b/source/Resources/play.png differ diff --git a/source/Resources/raw/crosshair.svg b/source/Resources/raw/crosshair.svg new file mode 100644 index 0000000..b71ae59 --- /dev/null +++ b/source/Resources/raw/crosshair.svg @@ -0,0 +1,77 @@ + + + + + + + + + + diff --git a/source/Resources/raw/fullscreen.svg b/source/Resources/raw/fullscreen.svg new file mode 100644 index 0000000..a43dade --- /dev/null +++ b/source/Resources/raw/fullscreen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/Resources/raw/pause.svg b/source/Resources/raw/pause.svg new file mode 100644 index 0000000..c2dbdeb --- /dev/null +++ b/source/Resources/raw/pause.svg @@ -0,0 +1,59 @@ + + + + + + + diff --git a/source/Resources/raw/play.svg b/source/Resources/raw/play.svg new file mode 100644 index 0000000..2603a39 --- /dev/null +++ b/source/Resources/raw/play.svg @@ -0,0 +1,47 @@ + + + + + + diff --git a/source/Resources/search.png b/source/Resources/search.png new file mode 100644 index 0000000..0cdbcd5 Binary files /dev/null and b/source/Resources/search.png differ diff --git a/source/SuzuMagnifier.csproj b/source/SuzuMagnifier.csproj index 61fe9c4..3a399a7 100644 --- a/source/SuzuMagnifier.csproj +++ b/source/SuzuMagnifier.csproj @@ -6,7 +6,7 @@ true enable Suzu Magnifier - 0.1.0.145 + 0.1.0.227 Suzu Magnifier Hi, I'm Ray Ray Lam @@ -15,11 +15,11 @@ true - none + full - none + full @@ -33,4 +33,19 @@ + + + True + True + Resource1.resx + + + + + + ResXFileCodeGenerator + Resource1.Designer.cs + + + \ No newline at end of file diff --git a/wiki/screenshot-1-h240.png b/wiki/screenshot-1-h240.png new file mode 100644 index 0000000..f0285b5 Binary files /dev/null and b/wiki/screenshot-1-h240.png differ diff --git a/wiki/screenshot-1.png b/wiki/screenshot-1.png new file mode 100644 index 0000000..d4bb475 Binary files /dev/null and b/wiki/screenshot-1.png differ diff --git a/wiki/screenshot-2-h240.png b/wiki/screenshot-2-h240.png new file mode 100644 index 0000000..a58cf93 Binary files /dev/null and b/wiki/screenshot-2-h240.png differ diff --git a/wiki/screenshot-2.png b/wiki/screenshot-2.png new file mode 100644 index 0000000..94cf2d6 Binary files /dev/null and b/wiki/screenshot-2.png differ