Skip to content

Commit

Permalink
Updated regex values, added ability to select all copy paste in text …
Browse files Browse the repository at this point in the history
…boxes. Set min length on mac address.
  • Loading branch information
Justin Davis committed Jan 6, 2024
1 parent cce2d81 commit d810a3e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 15 deletions.
74 changes: 63 additions & 11 deletions Controls/RegExTextBox.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
using System.Text.RegularExpressions;
using System.ComponentModel;
using System.Text.RegularExpressions;

namespace ConsoleServiceTool
{
public partial class RegExTextBox : TextBox
{
private bool IsCopy = false;
private bool IsPaste = false;
private bool IsAll = false;

public int MinLength { get; set; } = -1;

public RegExTextBox()
{
Expand All @@ -27,25 +33,71 @@ protected override void OnTextChanged(EventArgs e)
base.OnTextChanged(e);
}

protected override void OnValidating(CancelEventArgs e)
{
if (MinLength >= 0)
{
if (TextLength < MinLength)
{
Undo();
ClearUndo();
}
}
if (!string.IsNullOrEmpty(RegEx))
{
var expression = new Regex(RegEx);
// e.Cancel = expression.IsMatch(Text);
if (!expression.IsMatch(Text))
{
Undo();
ClearUndo();
}
}
base.OnValidating(e);
}

protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
{
IsCopy = true;
}
if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
{
IsPaste = true;
}

if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control)
{
IsAll = true;
}

base.OnKeyDown(e);
}

protected override void OnKeyPress(KeyPressEventArgs e)
{
switch (e.KeyChar)
if (!IsCopy && !IsPaste && !IsAll)
{
case (char)Keys.Back:
break;
default:
if (RegEx != default)
{
e.Handled = ValidateKeyPress(e.KeyChar);
}
break;
switch (e.KeyChar)
{
case (char)Keys.Back:
break;
default:
if (!string.IsNullOrEmpty(RegEx))
{
e.Handled = ValidateKeyPress(e.KeyChar);
}
break;
}
}
IsCopy = IsAll = IsPaste = false;
base.OnKeyPress(e);
}

private bool ValidateKeyPress(char c)
{
if (RegEx == default) return true;
if (string.IsNullOrEmpty(RegEx)) return true;
var expression = new Regex(RegEx);
return !expression.IsMatch(new char[] {c});
}
Expand Down
12 changes: 9 additions & 3 deletions Form1.Designer.cs

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

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Console Service Tool (C.S.T.) is a W.I.P comprehensive tool designed to assist u


PS5 NOR Patching Kinda Added - I mean dont use if you dont know what you are doing. In theory it patches fine. I dont have a PS5 to test ATM.
What patches work. Serial Number, Motherboard Serial, Console Type (Disk, or Digital)
What patches work. Serial Number, Motherboard Serial, Console Type (Disk, or Digital), Board ID and MAC Address.


![image](https://github.com/amoamare/ConsoleServiceTool/assets/15149902/29c901a4-5217-4c65-81cf-ea83caf73bd3)

Expand Down

0 comments on commit d810a3e

Please sign in to comment.