Skip to content

Commit

Permalink
Further cleanup, remove template component
Browse files Browse the repository at this point in the history
  • Loading branch information
TheArcaneBrony committed Dec 6, 2023
1 parent 656e562 commit 788516b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
3 changes: 0 additions & 3 deletions ArcaneLibs.Blazor.Components/Component1.razor

This file was deleted.

6 changes: 0 additions & 6 deletions ArcaneLibs.Blazor.Components/Component1.razor.css

This file was deleted.

13 changes: 2 additions & 11 deletions ArcaneLibs.Blazor.Components/ModalWindow.razor
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,18 @@

protected override async Task OnAfterRenderAsync(bool firstRender) => await base.OnAfterRenderAsync(firstRender);

// private void WindowDrag(DragEventArgs obj) {
// Console.WriteLine("Drag: " + obj.ToJson());
//
// _x += obj.MovementX;
// _y += obj.MovementY;
//
// StateHasChanged();
// }
private bool _isDragging;
private double _dragX;
private double _dragY;

private void MouseDown(MouseEventArgs obj) {
_isDragging = true;
_dragX = obj.ClientX;
_dragY = obj.ClientY;
}

private void MouseUp(MouseEventArgs obj) => _isDragging = false;

private void MouseMove(MouseEventArgs obj) {
if (!_isDragging) return;

Expand Down
13 changes: 6 additions & 7 deletions ArcaneLibs/Extensions/DictionaryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,28 @@ namespace ArcaneLibs.Extensions;

[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Public API: extension methods")]
public static class DictionaryExtensions {
public static void RemoveAll<K, V>(this IDictionary<K, V> dict, Func<K, V, bool> match) {
foreach (var key in dict.Keys.ToArray()
.Where(key => match(key, dict[key])))
public static void RemoveAll<TK, TV>(this IDictionary<TK, TV> dict, Func<TK, TV, bool> match) {
foreach (var key in dict.Keys.ToArray().Where(key => match(key, dict[key])))
dict.Remove(key);
}

public static bool ChangeKey<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey oldKey, TKey newKey) {
if (!dict.Remove(oldKey, out var value))
return false;

dict[newKey] = value; // or dict.Add(newKey, value) depending on ur comfort
dict[newKey] = value;
return true;
}

public static Y GetOrCreate<X, Y>(this IDictionary<X, Y> dict, X key) where Y : new() {
public static TY GetOrCreate<TX, TY>(this IDictionary<TX, TY> dict, TX key) where TY : new() {
if (dict.TryGetValue(key, out var value)) return value;

value = new Y();
value = new TY();
dict.Add(key, value);
return value;
}

public static Y GetOrCreate<X, Y>(this IDictionary<X, Y> dict, X key, Func<X, Y> valueFactory) {
public static TY GetOrCreate<TX, TY>(this IDictionary<TX, TY> dict, TX key, Func<TX, TY> valueFactory) {
if (dict.TryGetValue(key, out var value)) return value;

value = valueFactory(key);
Expand Down

0 comments on commit 788516b

Please sign in to comment.