Changed to implement interop for CursorClip

Added icons
This commit is contained in:
Ray 2026-07-11 16:17:26 +01:00
parent 6b1fd776ab
commit 3594cbd9df
22 changed files with 816 additions and 3274 deletions

View File

@ -2,8 +2,8 @@ rmdir /s /q "bin\"
rmdir /s /q "source\bin\" rmdir /s /q "source\bin\"
rmdir /s /q "source\obj\" rmdir /s /q "source\obj\"
dotnet restore RandomFileRunner.slnx dotnet restore CursorGuardRail.slnx
dotnet publish RandomFileRunner.slnx -r win-x64 -c Release /p:PublishSingleFile=true /p:SelfContained=false /p:PublishReadyToRunfalse=true /p:PublishDir="..\bin\" dotnet publish CursorGuardRail.slnx -r win-x64 -c Release /p:PublishSingleFile=true /p:SelfContained=false /p:PublishReadyToRunfalse=true /p:PublishDir="..\bin\"
rmdir /s /q "source\bin\" rmdir /s /q "source\bin\"
rmdir /s /q "source\obj\" rmdir /s /q "source\obj\"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -8,22 +8,22 @@
stroke-width="2" stroke-width="2"
stroke-linecap="round" stroke-linecap="round"
stroke-linejoin="round" stroke-linejoin="round"
class="lucide lucide-settings-icon lucide-settings" class="lucide lucide-shield-icon lucide-shield"
version="1.1" version="1.1"
id="svg6" id="svg4"
sodipodi:docname="icon.svg" sodipodi:docname="icon.svg"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" inkscape:export-filename="N:\D\icon_24.png"
inkscape:export-filename="L:\gitea-hiimray\random-file-runner\icon\icon_24.png"
inkscape:export-xdpi="96" inkscape:export-xdpi="96"
inkscape:export-ydpi="96" inkscape:export-ydpi="96"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"> xmlns:svg="http://www.w3.org/2000/svg">
<defs <defs
id="defs10" /> id="defs8" />
<sodipodi:namedview <sodipodi:namedview
id="namedview8" id="namedview6"
pagecolor="#ffffff" pagecolor="#ffffff"
bordercolor="#666666" bordercolor="#666666"
borderopacity="1.0" borderopacity="1.0"
@ -31,45 +31,38 @@
inkscape:pageopacity="0.0" inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0" inkscape:pagecheckerboard="0"
showgrid="false" showgrid="false"
inkscape:zoom="6.1282588" inkscape:zoom="17.333333"
inkscape:cx="39.244426" inkscape:cx="11.105769"
inkscape:cy="100.43636" inkscape:cy="13.355769"
inkscape:window-width="1920" inkscape:window-width="1920"
inkscape:window-height="1017" inkscape:window-height="1017"
inkscape:window-x="1912" inkscape:window-x="1912"
inkscape:window-y="-8" inkscape:window-y="-8"
inkscape:window-maximized="1" inkscape:window-maximized="1"
inkscape:current-layer="svg6" /> inkscape:current-layer="svg4" />
<g <g
id="g4122" id="g1767"
transform="matrix(5.3364034,0,0,5.3364034,-3.6586835e-6,-1.6104161e-5)" transform="scale(1.0096156)"
inkscape:export-filename="L:\gitea-hiimray\random-file-runner\icon\icon_128.png" inkscape:export-filename="N:\D\icon_64.png"
inkscape:export-xdpi="96" inkscape:export-xdpi="96"
inkscape:export-ydpi="96"> inkscape:export-ydpi="96">
<circle <rect
cx="11.942307" style="fill:none;fill-opacity:1;stroke:none;stroke-width:3.22801;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
cy="11.942308" id="rect1417"
r="6.590909" width="24"
id="circle2" height="24"
style="fill:#ffffff;fill-opacity:1;stroke:#1f9fde;stroke-width:1.31818;stroke-opacity:1" /> x="0"
y="0" />
<g
id="g1393">
<path <path
d="m 12.000001,0.7058837 c -0.77341,0 -1.52898,0.08109 -2.2588201,0.229412 v 1.747058 c -0.98114,0.236858 -1.89736,0.616834 -2.73529,1.129412 l -1.2353,-1.235294 c -0.63322,0.41961 -1.21193,0.911932 -1.74706,1.447059 -0.53513,0.535123 -1.02745,1.113842 -1.44706,1.747058 l 1.2353,1.235294 c -0.51259,0.837936 -0.89256,1.75416 -1.12941,2.7352936 H 0.93529083 c -0.14832,0.7298387 -0.22941,1.4854097 -0.22941,2.2588227 0,0.773412 0.0811,1.528983 0.22941,2.258823 H 2.6823609 c 0.23685,0.981134 0.61682,1.897354 1.12941,2.735293 l -1.2353,1.235294 c 0.41961,0.633216 0.91193,1.211934 1.44706,1.747059 0.53513,0.535127 1.11384,1.027452 1.74706,1.447061 l 1.2353,-1.235297 c 0.83793,0.512577 1.75415,0.892555 2.73529,1.129414 v 1.747059 c 0.7298401,0.148319 1.4854001,0.229411 2.2588201,0.229411 0.77341,0 1.52898,-0.08109 2.25882,-0.229411 v -1.747059 c 0.98113,-0.236859 1.89736,-0.616837 2.7353,-1.129414 l 1.23529,1.235297 c 0.63322,-0.419614 1.21193,-0.911934 1.74706,-1.447061 0.535128,-0.535125 1.027451,-1.113843 1.44706,-1.747059 l -1.23529,-1.235294 c 0.512571,-0.837939 0.89254,-1.754159 1.129408,-2.735293 h 1.747058 c 0.14832,-0.72984 0.229412,-1.485411 0.229412,-2.258823 0,-0.773413 -0.08109,-1.528984 -0.229412,-2.2588227 H 21.317649 C 21.080781,8.7600427 20.700812,7.8438187 20.188241,7.0058827 l 1.23529,-1.235294 c -0.419609,-0.633216 -0.911932,-1.211935 -1.44706,-1.747058 -0.53513,-0.535127 -1.11384,-1.027449 -1.74706,-1.447059 l -1.23529,1.235294 c -0.83794,-0.512578 -1.75417,-0.892554 -2.7353,-1.129412 v -1.747058 c -0.72984,-0.148323 -1.48541,-0.229412 -2.25882,-0.229412 z m 0,5.647058 c 3.11717,0 5.64706,2.5298806 5.64706,5.6470573 0,3.117176 -2.52989,5.647057 -5.64706,5.647057 -3.1171801,0 -5.6470601,-2.529881 -5.6470601,-5.647057 0,-3.1171767 2.52988,-5.6470573 5.6470601,-5.6470573 z" d="m 20,13 c 0,5 -3.5,7.5 -7.66,8.95 A 1,1 0 0 1 11.67,21.94 C 7.5,20.5 4,18 4,13 V 6 A 1,1 0 0 1 5,5 C 7,5 9.5,3.8 11.24,2.28 a 1.17,1.17 0 0 1 1.52,0 C 14.51,3.81 17,5 19,5 a 1,1 0 0 1 1,1 z"
id="path58241"
stroke-dashoffset="162"
stroke-miterlimit="4"
stroke-linejoin="round"
stroke-linecap="round"
stroke-width="1.41176"
stroke="#bf4d3c"
fill="#ffffff"
style="fill:#1f9fde;fill-opacity:1;stroke:#282828;stroke-opacity:1" />
<path
d="m 14.7,9.6 v 4.8"
id="path2" id="path2"
style="stroke:#000000;stroke-width:0.6;stroke-opacity:1" /> style="fill:#dfab46;fill-opacity:1;stroke:#1c1a19;stroke-opacity:1" />
<path <path
d="M 10.2087,9.6855 A 0.6,0.6 0 0 0 9.3,10.2 v 3.6 a 0.6,0.6 0 0 0 0.9087,0.5145 l 2.9991,-1.7994 a 0.6,0.6 0 0 0 9e-4,-1.0296 z" d="m 11.626705,12.385394 a 0.58396678,0.58396678 0 0 1 0.758689,-0.758689 l 10.553616,4.104184 a 0.58631203,0.58631203 0 0 1 -0.0387,1.105786 l -4.038518,1.252361 a 1.172624,1.172624 0 0 0 -0.773932,0.773932 l -1.251189,4.037345 a 0.58631203,0.58631203 0 0 1 -1.105786,0.0387 z"
id="path4" id="path915"
style="fill:#00abff;fill-opacity:1;stroke:#000000;stroke-width:0.6;stroke-opacity:1" /> style="fill:#4b75ff;fill-opacity:1;stroke:#092f63;stroke-width:1.17263;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 766 B

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1010 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
icon/icon_42.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-icon lucide-circle"><circle cx="12" cy="12" r="10"/></svg>

Before

Width:  |  Height:  |  Size: 267 B

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 64 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-skip-forward-icon lucide-skip-forward"><path d="M21 4v16"/><path d="M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z"/></svg>

Before

Width:  |  Height:  |  Size: 364 B

View File

@ -96,16 +96,6 @@ namespace CursorGuardRail {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap folder_minus {
get {
object obj = ResourceManager.GetObject("folder_minus", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>
@ -136,16 +126,6 @@ namespace CursorGuardRail {
} }
} }
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap save {
get {
object obj = ResourceManager.GetObject("save", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary> /// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap. /// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary> /// </summary>

View File

@ -130,9 +130,6 @@
<value>https://www.hiimray.co.uk</value> <value>https://www.hiimray.co.uk</value>
</data> </data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="folder_minus" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\folder-minus.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="help_circle" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="help_circle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\help-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\help-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
@ -142,9 +139,6 @@
<data name="refresh_cw" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="refresh_cw" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\refresh-cw.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\refresh-cw.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="save" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="settings" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="settings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>Resources\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>

View File

@ -4,7 +4,7 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net10.0-windows8.0</TargetFramework> <TargetFramework>net10.0-windows8.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<AssemblyName>randomfilerunner</AssemblyName> <AssemblyName>cursorguardrail</AssemblyName>
<Authors>Ray Lam</Authors> <Authors>Ray Lam</Authors>
<Company>Hi, I'm Ray</Company> <Company>Hi, I'm Ray</Company>
<Product>Cursor GuardRail</Product> <Product>Cursor GuardRail</Product>
@ -12,6 +12,7 @@
<ApplicationIcon>favicon.ico</ApplicationIcon> <ApplicationIcon>favicon.ico</ApplicationIcon>
<NoWin32Manifest>true</NoWin32Manifest> <NoWin32Manifest>true</NoWin32Manifest>
<Version>0.1.0.119</Version> <Version>0.1.0.119</Version>
<PackageIcon>icon_64.png</PackageIcon>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
@ -39,6 +40,13 @@
<Content Include="favicon.ico" /> <Content Include="favicon.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\icon\icon_64.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="RyzStudio" Version="10.1.2.33" /> <PackageReference Include="RyzStudio" Version="10.1.2.33" />
<PackageReference Include="RyzStudio.Windows.Forms" Version="10.3.0.97" /> <PackageReference Include="RyzStudio.Windows.Forms" Version="10.3.0.97" />
@ -60,8 +68,4 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="NewFolder\" />
</ItemGroup>
</Project> </Project>

View File

@ -41,7 +41,14 @@ namespace CursorGuardRail
exitToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); exitToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
hideOnLockToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
hideOnCloseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
alwaysShowSystemTrayIconToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
viewHelpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); viewHelpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
@ -54,6 +61,7 @@ namespace CursorGuardRail
toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
notifyIcon1 = new System.Windows.Forms.NotifyIcon(components); notifyIcon1 = new System.Windows.Forms.NotifyIcon(components);
toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
menuStrip1.SuspendLayout(); menuStrip1.SuspendLayout();
contextMenuStrip1.SuspendLayout(); contextMenuStrip1.SuspendLayout();
SuspendLayout(); SuspendLayout();
@ -128,7 +136,7 @@ namespace CursorGuardRail
// //
// menuStrip1 // menuStrip1
// //
menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { fileToolStripMenuItem, toolStripMenuItem1, toolsToolStripMenuItem, helpToolStripMenuItem1 }); menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { fileToolStripMenuItem, toolStripMenuItem1, toolStripMenuItem4, toolsToolStripMenuItem, helpToolStripMenuItem1 });
menuStrip1.Location = new System.Drawing.Point(0, 0); menuStrip1.Location = new System.Drawing.Point(0, 0);
menuStrip1.Name = "menuStrip1"; menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new System.Drawing.Size(464, 24); menuStrip1.Size = new System.Drawing.Size(464, 24);
@ -179,13 +187,58 @@ namespace CursorGuardRail
refreshToolStripMenuItem.Text = "&Refresh"; refreshToolStripMenuItem.Text = "&Refresh";
refreshToolStripMenuItem.Click += refreshToolStripMenuItem_Click; refreshToolStripMenuItem.Click += refreshToolStripMenuItem_Click;
// //
// toolStripMenuItem4
//
toolStripMenuItem4.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { hideOnLockToolStripMenuItem, hideOnCloseToolStripMenuItem, toolStripSeparator3, alwaysShowSystemTrayIconToolStripMenuItem });
toolStripMenuItem4.Name = "toolStripMenuItem4";
toolStripMenuItem4.Size = new System.Drawing.Size(44, 20);
toolStripMenuItem4.Text = "&View";
//
// hideOnLockToolStripMenuItem
//
hideOnLockToolStripMenuItem.Name = "hideOnLockToolStripMenuItem";
hideOnLockToolStripMenuItem.Size = new System.Drawing.Size(194, 22);
hideOnLockToolStripMenuItem.Text = "&Hide On Lock";
hideOnLockToolStripMenuItem.Click += hideOnLockToolStripMenuItem_Click;
//
// hideOnCloseToolStripMenuItem
//
hideOnCloseToolStripMenuItem.Name = "hideOnCloseToolStripMenuItem";
hideOnCloseToolStripMenuItem.Size = new System.Drawing.Size(194, 22);
hideOnCloseToolStripMenuItem.Text = "Hide On &Close";
hideOnCloseToolStripMenuItem.Click += hideOnCloseToolStripMenuItem_Click;
//
// toolStripSeparator3
//
toolStripSeparator3.Name = "toolStripSeparator3";
toolStripSeparator3.Size = new System.Drawing.Size(191, 6);
//
// alwaysShowSystemTrayIconToolStripMenuItem
//
alwaysShowSystemTrayIconToolStripMenuItem.Name = "alwaysShowSystemTrayIconToolStripMenuItem";
alwaysShowSystemTrayIconToolStripMenuItem.Size = new System.Drawing.Size(194, 22);
alwaysShowSystemTrayIconToolStripMenuItem.Text = "Show System &Tray Icon";
alwaysShowSystemTrayIconToolStripMenuItem.Click += alwaysShowSystemTrayIconToolStripMenuItem_Click;
//
// toolsToolStripMenuItem // toolsToolStripMenuItem
// //
toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { optionsToolStripMenuItem }); toolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem3, toolStripSeparator2, optionsToolStripMenuItem });
toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 20); toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
toolsToolStripMenuItem.Text = "&Tools"; toolsToolStripMenuItem.Text = "&Tools";
// //
// toolStripMenuItem3
//
toolStripMenuItem3.Name = "toolStripMenuItem3";
toolStripMenuItem3.Size = new System.Drawing.Size(177, 22);
toolStripMenuItem3.Text = "&Lock Cursor";
toolStripMenuItem3.Click += toolStripMenuItem2_Click;
//
// toolStripSeparator2
//
toolStripSeparator2.Name = "toolStripSeparator2";
toolStripSeparator2.Size = new System.Drawing.Size(174, 6);
//
// optionsToolStripMenuItem // optionsToolStripMenuItem
// //
optionsToolStripMenuItem.Enabled = false; optionsToolStripMenuItem.Enabled = false;
@ -259,26 +312,27 @@ namespace CursorGuardRail
// //
// contextMenuStrip1 // contextMenuStrip1
// //
contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem2, toolStripSeparator1, exitToolStripMenuItem }); contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem5, toolStripMenuItem2, toolStripSeparator1, exitToolStripMenuItem });
contextMenuStrip1.Name = "contextMenuStrip1"; contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new System.Drawing.Size(138, 54); contextMenuStrip1.Size = new System.Drawing.Size(181, 98);
contextMenuStrip1.Opening += contextMenuStrip1_Opening;
// //
// toolStripMenuItem2 // toolStripMenuItem2
// //
toolStripMenuItem2.Name = "toolStripMenuItem2"; toolStripMenuItem2.Name = "toolStripMenuItem2";
toolStripMenuItem2.Size = new System.Drawing.Size(137, 22); toolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem2.Text = "&Lock Cursor"; toolStripMenuItem2.Text = "&Lock Cursor";
toolStripMenuItem2.Click += toolStripMenuItem2_Click; toolStripMenuItem2.Click += toolStripMenuItem2_Click;
// //
// toolStripSeparator1 // toolStripSeparator1
// //
toolStripSeparator1.Name = "toolStripSeparator1"; toolStripSeparator1.Name = "toolStripSeparator1";
toolStripSeparator1.Size = new System.Drawing.Size(134, 6); toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
// //
// exitToolStripMenuItem // exitToolStripMenuItem
// //
exitToolStripMenuItem.Name = "exitToolStripMenuItem"; exitToolStripMenuItem.Name = "exitToolStripMenuItem";
exitToolStripMenuItem.Size = new System.Drawing.Size(137, 22); exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
exitToolStripMenuItem.Text = "Exit"; exitToolStripMenuItem.Text = "Exit";
exitToolStripMenuItem.Click += exitToolStripMenuItem2_Click; exitToolStripMenuItem.Click += exitToolStripMenuItem2_Click;
// //
@ -290,6 +344,13 @@ namespace CursorGuardRail
notifyIcon1.Visible = true; notifyIcon1.Visible = true;
notifyIcon1.MouseDoubleClick += notifyIcon1_MouseDoubleClick; notifyIcon1.MouseDoubleClick += notifyIcon1_MouseDoubleClick;
// //
// toolStripMenuItem5
//
toolStripMenuItem5.Name = "toolStripMenuItem5";
toolStripMenuItem5.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem5.Text = "&Show";
toolStripMenuItem5.Click += toolStripMenuItem5_Click;
//
// MainForm // MainForm
// //
AllowDrop = true; AllowDrop = true;
@ -337,6 +398,14 @@ namespace CursorGuardRail
private System.Windows.Forms.NotifyIcon notifyIcon1; private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
private System.Windows.Forms.ToolStripMenuItem hideOnLockToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem hideOnCloseToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem alwaysShowSystemTrayIconToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
} }
} }

View File

@ -6,7 +6,6 @@ using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using RyzStudio.Windows.Forms; using RyzStudio.Windows.Forms;
using static CursorGuardRail.MainForm;
namespace CursorGuardRail namespace CursorGuardRail
{ {
@ -33,14 +32,15 @@ namespace CursorGuardRail
private readonly Timer _timer; private readonly Timer _timer;
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
notifyIcon1.Visible = this.ShowTrayIcon;
screensLayout1.Padding = new Padding(10); screensLayout1.Padding = new Padding(10);
_timer = new() { Interval = 50 }; _timer = new() { Interval = 150 };
_timer.Tick += (_, _) => _timer.Tick += (_, _) =>
{ {
if (Cursor.Clip != _lockCursorArea.Value) if (Cursor.Clip != _lockCursorArea.Value)
@ -50,6 +50,13 @@ namespace CursorGuardRail
}; };
} }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
ClipCursor(Rectangle.Empty);
}
protected async override void OnShown(EventArgs e) protected async override void OnShown(EventArgs e)
{ {
base.OnShown(e); base.OnShown(e);
@ -58,13 +65,11 @@ namespace CursorGuardRail
{ {
UIControl.Invoke(screensLayout1, (_) => screensLayout1.InvalidateScreens()); UIControl.Invoke(screensLayout1, (_) => screensLayout1.InvalidateScreens());
}); });
//memoBox1.Focus();
} }
protected override void OnFormClosing(FormClosingEventArgs e) protected override void OnFormClosing(FormClosingEventArgs e)
{ {
if (!_requestExit) if ((this.HideOnClose && !_requestExit) || _timer.Enabled)
{ {
e.Cancel = true; e.Cancel = true;
@ -72,23 +77,43 @@ namespace CursorGuardRail
return; return;
} }
if (_timer.Enabled) _timer.Stop();
ClipCursor(Rectangle.Empty); ClipCursor(Rectangle.Empty);
base.OnFormClosing(e); base.OnFormClosing(e);
} }
protected override void OnResize(EventArgs e)
public AppSession CurrentSession
{ {
get if (this.WindowState == FormWindowState.Minimized)
{ {
if (field == null) field = new AppSession(); if (this.ShowTrayIcon) this.Hide();
}
return field; base.OnResize(e);
} }
private set => field = value;
public new void Show()
{
notifyIcon1.Visible = this.ShowTrayIcon || _timer.Enabled;
this.WindowState = FormWindowState.Normal;
this.BringToFront();
base.Show();
} }
public new void Hide()
{
notifyIcon1.Visible = true;
this.WindowState = FormWindowState.Normal;
base.Hide();
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool IsCursorLocked public bool IsCursorLocked
{ {
@ -99,7 +124,6 @@ namespace CursorGuardRail
dialogFooter1.Button1.Checked = value; dialogFooter1.Button1.Checked = value;
dialogFooter1.Button1Text = value ? "&Unlock Cursor" : "&Lock Cursor"; dialogFooter1.Button1Text = value ? "&Unlock Cursor" : "&Lock Cursor";
toolStripMenuItem2.Text = value ? "&Unlock Cursor" : "&Lock Cursor";
if (value) if (value)
{ {
@ -110,26 +134,51 @@ namespace CursorGuardRail
return; return;
} }
//ClipCursor(_lockCursorArea.Value);
_timer.Start(); _timer.Start();
//notifyIcon1.Visible = true;
if (this.HideOnLock) this.Close();
} }
else else
{ {
ClipCursor(Rectangle.Empty); ClipCursor(Rectangle.Empty);
if (_timer.Enabled) notifyIcon1.Visible = value || !this.Visible;
{
_timer.Stop(); if (_timer.Enabled) _timer.Stop();
}
} }
} }
} = false; } = false;
public bool HideOnLock { get; private set; } = true;
public bool HideOnClose { get; private set; } = false;
public bool ShowTrayIcon
{
get => field;
private set
{
field = value;
notifyIcon1.Visible = value || _timer.Enabled;
}
} = false;
private void menuStrip1_MenuActivate(object sender, EventArgs e) private void menuStrip1_MenuActivate(object sender, EventArgs e)
{ {
//saveAsToolStripMenuItem.Enabled = (!this.IsBusy && (this.SearchPathList.Count > 0)); toolStripMenuItem3.Checked = this.IsCursorLocked;
//toolStripMenuItem2.Enabled = (!this.IsBusy && (_foundFiles.Count > 0)); hideOnLockToolStripMenuItem.Checked = this.HideOnLock;
hideOnCloseToolStripMenuItem.Checked = this.HideOnClose;
alwaysShowSystemTrayIconToolStripMenuItem.Checked = this.ShowTrayIcon;
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
{
toolStripMenuItem2.Checked = this.IsCursorLocked;
} }
#region Main Menu #region Main Menu
@ -175,6 +224,36 @@ namespace CursorGuardRail
} }
/// <summary>
/// Hide on lock
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void hideOnLockToolStripMenuItem_Click(object sender, EventArgs e)
{
this.HideOnLock = !this.HideOnLock;
}
/// <summary>
/// Hide on close
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void hideOnCloseToolStripMenuItem_Click(object sender, EventArgs e)
{
this.HideOnClose = !this.HideOnClose;
}
/// <summary>
/// Always show system tray icon
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void alwaysShowSystemTrayIconToolStripMenuItem_Click(object sender, EventArgs e)
{
this.ShowTrayIcon = !this.ShowTrayIcon;
}
/// <summary> /// <summary>
/// Options /// Options
/// </summary> /// </summary>
@ -216,34 +295,6 @@ namespace CursorGuardRail
#endregion #endregion
/// <summary>
/// Hide/show
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.Visible)
{
this.Hide();
}
else
{
this.Show();
}
}
/// <summary>
/// Lock/unlock cursor
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
this.IsCursorLocked = !this.IsCursorLocked;
}
/// <summary> /// <summary>
/// Refresh /// Refresh
/// </summary> /// </summary>
@ -282,6 +333,49 @@ namespace CursorGuardRail
} }
/// <summary>
/// Lock/unlock cursor
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem2_Click(object sender, EventArgs e)
{
this.IsCursorLocked = !this.IsCursorLocked;
}
#region System tray icon
/// <summary>
/// Hide/show
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (this.Visible)
{
this.Hide();
}
else
{
this.Show();
}
}
/// <summary>
/// Show
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem5_Click(object sender, EventArgs e)
{
this.Show();
}
#endregion
/// <summary> /// <summary>
/// Enable /// Enable
/// </summary> /// </summary>
@ -337,10 +431,10 @@ namespace CursorGuardRail
{ {
var rect2 = new RECT var rect2 = new RECT
{ {
Left = rect.X, Left = rect.Left,
Top = rect.Y, Top = rect.Top,
Right = rect.Width, Right = rect.Right,
Bottom = rect.Height Bottom = rect.Bottom
}; };
ClipCursor(ref rect2); ClipCursor(ref rect2);

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB