Skip to content

Commit

Permalink
F4 Enable with Password
Browse files Browse the repository at this point in the history
  • Loading branch information
ITAgnesmeyer committed Jan 10, 2023
1 parent 07fc773 commit c812640
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions WebAssemblyViewer/BrowserOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class BrowserOptions
public bool TopMost { get; set; }

public bool DisableF4 { get; set; }
public bool EnableF4Password { get; set; }
public string DisableF4Password { get; set; }


Expand Down
24 changes: 14 additions & 10 deletions WebAssemblyViewer/BrowserWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,23 @@ private void OnAcceleratorKeyPressedF4(object sender, AcceleratorKeyPressedEvent

if (e.KeyVentType == KeyEventType.SystemKeyDown && e.VirtualKey == VirtualKeys.VK_F4)
{
if (this._Options.DisableF4)
if (this._Options.DisableF4 )
{
Diga.Core.Threading.UIDispatcher.UIThread.Post(() =>
if (this._Options.EnableF4Password)
{
DOMWindow win = this._Browser.GetDOMWindow();
string val = win.prompt("Enter your Password!","");
val = val.Replace("\"", "");
if (val == this._Options.DisableF4Password)
Diga.Core.Threading.UIDispatcher.UIThread.Post(() =>
{
this.Close();
}
});
DOMWindow win = this._Browser.GetDOMWindow();
string val = win.prompt("Enter your Password!","");
val = val.Replace("\"", "");
if (val == this._Options.DisableF4Password)
{
this.Close();
}
});

}


e.Handled = true;
Expand Down
18 changes: 16 additions & 2 deletions WebAssemblyViewer/EditWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class EditWindow : NativeWindow
private NativeCheckBox _ChkTopMost;
private NativeCheckBox _ChkMaximized;
private NativeCheckBox _ChkDisableF4;
private NativeCheckBox _ChkEnableF4WithPw;
private NativeTextBox _TxtDisableF4Password;
private NativeTextBox _TxtMonitoringUlr;
private NativeTextBox _TxtUserDataFolder;
Expand Down Expand Up @@ -55,6 +56,7 @@ private void ViewToOptions()
this._Options.BrowserUserDataFolder = this._TxtUserDataFolder.Text;
this._Options.BrowserExecutableFolder = this._TxtBrowserExecutable.Text;
this._Options.DisableF4 = this._ChkDisableF4.Checked;
this._Options.EnableF4Password = this._ChkEnableF4WithPw.Checked;
this._Options.DisableF4Password = this._TxtDisableF4Password.Text;
}

Expand All @@ -74,6 +76,7 @@ private void OptionsToView()
this._ChkTopMost.Checked = this._Options.TopMost;
this._ChkMaximized.Checked = this._Options.Maximized;
this._ChkDisableF4.Checked = this._Options.DisableF4;
this._ChkEnableF4WithPw.Checked = this._Options.EnableF4Password;
this._TxtDisableF4Password.Text = this._Options.DisableF4Password;
}

Expand Down Expand Up @@ -154,18 +157,28 @@ protected override void InitControls()
this._ChkDisableF4 = new NativeCheckBox()
{
Location = new Point(chkLeft, top),
Width = chkWidth,
Width = chkWidth ,
Height = textHeight,
Text = "Disable F4"
};

chkLeft += this._ChkDisableF4.Width + 10;

this._ChkEnableF4WithPw = new NativeCheckBox()
{
Location = new Point(chkLeft, top),
Width = chkWidth,
Height = textHeight,
Text = "PW Enable F4"
};
chkLeft += this._ChkEnableF4WithPw.Width + 10;
this._TxtDisableF4Password = new NativeTextBox
{
Location = new Point(chkLeft, top),
Width = chkWidth * 2,
Height = textHeight,
Text = ""
Text = "",

};
this._TxtDisableF4Password.Style |= EditBoxStyles.ES_PASSWORD | WindowStylesConst.WS_BORDER;

Expand Down Expand Up @@ -355,6 +368,7 @@ protected override void InitControls()
this.Controls.Add(this._ChkTopMost);
this.Controls.Add(this._ChkMaximized);
this.Controls.Add(this._ChkDisableF4);
this.Controls.Add(this._ChkEnableF4WithPw);
this.Controls.Add(this._TxtDisableF4Password);
this.Controls.Add(lblTitle);
this.Controls.Add(this._TxtTitle);
Expand Down
4 changes: 2 additions & 2 deletions WebAssemblyViewer/WebAssemblyViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>App.ico</ApplicationIcon>
<PlatformTarget>AnyCPU</PlatformTarget>
<AssemblyVersion>1.0.1.1</AssemblyVersion>
<FileVersion>1.0.1.1</FileVersion>
<AssemblyVersion>1.0.1.2</AssemblyVersion>
<FileVersion>1.0.1.2</FileVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net5.0|AnyCPU'">
Expand Down

0 comments on commit c812640

Please sign in to comment.