Skip to content

Commit

Permalink
Begin work on identifier and value combo
Browse files Browse the repository at this point in the history
  • Loading branch information
juleswhi committed Mar 21, 2024
1 parent 44b5b88 commit ae6c3b8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
28 changes: 28 additions & 0 deletions src/FormSystem/FormHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
namespace FormSystem;

// Contains a bunch of extension methods
public enum ControlDirection
{
X,
Y
}

public static class FormHelper
{
public static void Center(this Control control, ControlDirection controlDirection)
{
switch(controlDirection)
{
case X:
control.Location = new Point((control.Parent!.Width / 2) - (int)0.5*(control.Width), control.Location.Y);
break;

case Y:
control.Location = new Point(control.Location.X, (control.Parent!.Height / 2) - (int)0.5*(control.Width));
break;
}
}

public static void CenterX(this Control control)
{
control.Location = new Point((control.Parent!.Width / 2) - (int)0.5 * (control.Width), control.Location.Y);
}
public static void CenterY(this Control control)
{
control.Location = new Point(control.Location.X, (control.Parent!.Height / 2) - (int)0.5 * (control.Width));
}
}
6 changes: 5 additions & 1 deletion src/Globals.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// System namespaces
global using System.Reflection;
// FormManager
global using FormSystem;
global using static FormSystem.FormHelper;
global using static FormSystem.ControlDirection;

// Scraper
global using static Scraper.ScrapeType;

// State
global using StateSystem;
global using static StateSystem.StateHelper;
global using static StateSystem.StateType;
global using State = System.Collections.Generic.Dictionary<System.Collections.Generic.IEnumerable<StateSystem.StateType>, object?>;
// global using State = System.Collections.Generic.Dictionary<System.Collections.Generic.IEnumerable<StateSystem.StateType>, object?>;
global using Password = (string Hashed, byte[] Salt);

// Misc
Expand Down
11 changes: 11 additions & 0 deletions src/StateSystem/State.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace StateSystem;

public class State : Dictionary<IEnumerable<StateType>, object?>
{
public static State From()
{
return GetGlobalState();
}

// Way of storing objects stored with arbitrary strings
}
4 changes: 1 addition & 3 deletions src/StateSystem/StateHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ExceptionSystem.ToolingExceptions;
using FormSystem;

namespace StateSystem;

Expand Down Expand Up @@ -184,7 +183,7 @@ public static State GlobalStateAdd(State state)

public static State GlobalStateRemove(State state)
{
FormManager.GlobalState = FormManager.GlobalState.Where(x => !state.ContainsKey(x.Key)).ToDictionary(x => x.Key, x => x.Value);
FormManager.GlobalState = (State)FormManager.GlobalState.Where(x => !state.ContainsKey(x.Key)).ToDictionary(x => x.Key, x => x.Value);
return FlagFailure;
}

Expand Down Expand Up @@ -356,7 +355,6 @@ public static IEnumerable<object> UnwrapAll(this State state)
}



/// <summary>
/// Unwraps a value, but allows null
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/StateSystem/StateType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ public enum StateType
FLAG_FAILURE,

FLAG_NONNULL,
FLAG_NULL
FLAG_NULL,

FLAG_IDENTIFIER,
FLAG_VALUE
}

0 comments on commit ae6c3b8

Please sign in to comment.