Skip to content

Commit

Permalink
Enable optimisations, Fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheArcaneBrony committed Dec 6, 2023
1 parent a593ae4 commit 656e562
Show file tree
Hide file tree
Showing 40 changed files with 403 additions and 442 deletions.
22 changes: 10 additions & 12 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

[*]
charset = utf-8
end_of_line = lf
Expand Down Expand Up @@ -320,7 +319,7 @@ dotnet_naming_style.lower_camel_case_style_1.capitalization = camel_case
dotnet_naming_style.t_upper_camel_case_style.capitalization = pascal_case
dotnet_naming_style.t_upper_camel_case_style.required_prefix = T
dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case
dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
dotnet_naming_symbols.constants_symbols.applicable_kinds = field
dotnet_naming_symbols.constants_symbols.required_modifiers = const
dotnet_naming_symbols.event_symbols.applicable_accessibilities = *
Expand Down Expand Up @@ -348,16 +347,16 @@ dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static
dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private
dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static,readonly
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static, readonly
dotnet_naming_symbols.property_symbols.applicable_accessibilities = *
dotnet_naming_symbols.property_symbols.applicable_kinds = property
dotnet_naming_symbols.public_fields_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
dotnet_naming_symbols.public_fields_symbols.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
dotnet_naming_symbols.public_fields_symbols.applicable_kinds = field
dotnet_naming_symbols.static_readonly_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
dotnet_naming_symbols.static_readonly_symbols.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
dotnet_naming_symbols.static_readonly_symbols.applicable_kinds = field
dotnet_naming_symbols.static_readonly_symbols.required_modifiers = static,readonly
dotnet_naming_symbols.static_readonly_symbols.required_modifiers = static, readonly
dotnet_naming_symbols.types_and_namespaces_symbols.applicable_accessibilities = *
dotnet_naming_symbols.types_and_namespaces_symbols.applicable_kinds = namespace,class,struct,enum,delegate
dotnet_naming_symbols.types_and_namespaces_symbols.applicable_kinds = namespace, class, struct, enum, delegate
dotnet_naming_symbols.type_parameters_symbols.applicable_accessibilities = *
dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter
dotnet_separate_import_directive_groups = false
Expand All @@ -372,9 +371,8 @@ dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:error
file_header_template =
file_header_template = # ReSharper properties

# ReSharper properties
resharper_alignment_tab_fill_style = use_spaces
resharper_align_first_arg_by_paren = false
resharper_align_linq_query = false
Expand Down Expand Up @@ -535,7 +533,7 @@ resharper_generator_mode = false
resharper_html_allow_far_alignment = true
resharper_html_attribute_indent = align_by_first_attribute
resharper_html_insert_final_newline = false
resharper_html_linebreak_before_elements = body,div,p,form,h1,h2,h3
resharper_html_linebreak_before_elements = body, div, p, form, h1, h2, h3
resharper_html_max_blank_lines_between_tags = 2
resharper_html_max_line_length = 180
resharper_html_pi_attribute_style = on_single_line
Expand Down Expand Up @@ -665,7 +663,7 @@ resharper_place_type_attribute_on_same_line = false
resharper_place_type_constraints_on_same_line = true
resharper_prefer_explicit_discard_declaration = false
resharper_prefer_separate_deconstructed_variables_declaration = false
resharper_preserve_spaces_inside_tags = pre,textarea
resharper_preserve_spaces_inside_tags = pre, textarea
resharper_qualified_using_at_nested_scope = false
resharper_quote_style = doublequoted
resharper_razor_prefer_qualified_reference = true
Expand Down Expand Up @@ -893,7 +891,7 @@ resharper_wrap_verbatim_interpolated_strings = no_wrap
resharper_xmldoc_allow_far_alignment = false
resharper_xmldoc_attribute_indent = single_indent
resharper_xmldoc_insert_final_newline = false
resharper_xmldoc_linebreak_before_elements = summary,remarks,example,returns,param,typeparam,value,para
resharper_xmldoc_linebreak_before_elements = summary, remarks, example, returns, param, typeparam, value, para
resharper_xmldoc_max_blank_lines_between_tags = 0
resharper_xmldoc_max_line_length = 180
resharper_xmldoc_pi_attribute_style = do_not_touch
Expand Down
2 changes: 1 addition & 1 deletion ArcaneLib.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public void Test1() {
Assert.Equal(2d, Util.Min(2d, 4d, 6d));
Assert.Equal(6d, Util.Max(2d, 4d, 6d));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ArcaneLibs\ArcaneLibs.csproj" />
<ProjectReference Include="..\ArcaneLibs\ArcaneLibs.csproj"/>
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

</Project>
16 changes: 6 additions & 10 deletions ArcaneLibs.Blazor.Components/AsyncImage.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
@using System.Threading.Tasks

<img src="@ImageUrl" />
<img src="@ImageUrl"/>

@code {

[Parameter]
public Task<string> ImageUrlTask { get; set; }
public required Task<string> ImageUrlTask { get; set; }

private string ImageUrl { get; set; }
private string? ImageUrl { get; set; }

protected override async Task OnParametersSetAsync()
{
ImageUrl = await ImageUrlTask;
}
}
protected override async Task OnParametersSetAsync() => ImageUrl = await ImageUrlTask;
}
10 changes: 5 additions & 5 deletions ArcaneLibs.Blazor.Components/DictionaryEditor.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<table>
@foreach (var i in Items.Keys) {
var key = i;
<input value="@Items[key]" @oninput="obj => inputChanged(obj, key)">
<input value="@Items[key]" @oninput="obj => InputChanged(obj, key)">
<button @onclick="() => { Items.Remove(key); ItemsChanged.InvokeAsync(); }">Remove</button>
<br/>
}
Expand All @@ -12,7 +12,7 @@
@code {

[Parameter]
public Dictionary<string, object> Items { get; set; } = new();
public Dictionary<string, object?> Items { get; set; } = new();

[Parameter]
[EditorRequired]
Expand All @@ -29,10 +29,10 @@
return base.OnInitializedAsync();
}

private void inputChanged(ChangeEventArgs obj, string key) {
private void InputChanged(ChangeEventArgs obj, string key) {
Console.WriteLine($"StringListEditor inputChanged {key} {obj.Value}");
Items[key] = obj.Value.ToString();
Items[key] = obj.Value?.ToString();
ItemsChanged.InvokeAsync();
}

}
}
31 changes: 0 additions & 31 deletions ArcaneLibs.Blazor.Components/ExampleJsInterop.cs

This file was deleted.

18 changes: 9 additions & 9 deletions ArcaneLibs.Blazor.Components/FancyTextBox.razor
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
@using Microsoft.JSInterop
@inject IJSRuntime JsRuntime
@if (isVisible) {
<input autofocus type="@(IsPassword ? "password" : "text")" @bind="Value" @onfocusout="() => { isVisible = false; ValueChanged.InvokeAsync(Value); }" @ref="elementToFocus"/>
@if (_isVisible) {
<input autofocus type="@(IsPassword ? "password" : "text")" @bind="Value" @onfocusout="() => { _isVisible = false; ValueChanged.InvokeAsync(Value); }" @ref="_elementToFocus"/>
}
else {
<span class="fancy-textbox-inline" tabindex="0" style="@(string.IsNullOrEmpty(Value) ? "min-width: 50px;" : "") background-color: @BackgroundColor; color: @ForegroundColor" @onfocusin="() => isVisible = true">@(Formatter?.Invoke(Value) ?? (IsPassword ? string.Join("", Value.Select(x => '*')) : Value))</span>
<span class="fancy-textbox-inline" tabindex="0" style="@(string.IsNullOrEmpty(Value) ? "min-width: 50px;" : "") background-color: @BackgroundColor; color: @ForegroundColor" @onfocusin="() => _isVisible = true">@(Formatter?.Invoke(Value) ?? (IsPassword && Value is not null ? string.Join("", Value.Select(_ => '*')) : Value))</span>
}

@code {

[Parameter]
public string Value { get; set; }
public string? Value { get; set; }

[Parameter]
public bool IsPassword { get; set; } = false;
Expand All @@ -21,16 +21,16 @@ else {
[Parameter]
public Func<string?, string>? Formatter { get; set; }

private bool isVisible { get; set; } = false;
private bool _isVisible = false;

private ElementReference elementToFocus;
private ElementReference? _elementToFocus;

protected override async Task OnAfterRenderAsync(bool firstRender) => await JsRuntime.InvokeVoidAsync("BlazorFocusElement", elementToFocus);
protected override async Task OnAfterRenderAsync(bool firstRender) => await JsRuntime.InvokeVoidAsync("BlazorFocusElement", _elementToFocus);

[Parameter]
public string ForegroundColor { get; set; } = "#ffffffff";

[Parameter]
public string BackgroundColor { get; set; } = "#00000000";

}
}
12 changes: 5 additions & 7 deletions ArcaneLibs.Blazor.Components/LinkButton.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@
@ChildContent
</a>

@* ReSharper disable once InconsistentNaming *@
@code {

[Parameter]
public string? href { get; set; }

[Parameter]
public RenderFragment ChildContent { get; set; }
public required RenderFragment? ChildContent { get; set; }

[Parameter]
public string? Color { get; set; }

[Parameter]
public Func<Task>? OnClick { get; set; }

[Parameter]
public bool Round { get; set; }

private void Callback() {
if (OnClick is not null)
OnClick();
}
private void Callback() => OnClick?.Invoke();

}
}
56 changes: 24 additions & 32 deletions ArcaneLibs.Blazor.Components/ModalWindow.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@using Microsoft.JSInterop
@using ArcaneLibs.Extensions
<div class="r-modal" style="top: @(_y)px; left: @(_x)px;">
<div class="titlebar" @onmousedown="MouseDown" @onmouseup="MouseUp" @onmousemove="MouseMove" @onmouseleave="MouseMove">
<b class="title" @ref="_titleRef">@Title</b>
Expand Down Expand Up @@ -29,10 +27,10 @@
public double MinWidth { get; set; } = 100;

[Parameter]
public Action OnCloseClicked { get; set; }
public required Action OnCloseClicked { get; set; }

[Parameter]
public bool Collapsed { get; set; } = false;
public bool Collapsed { get; set; }

private ElementReference _titleRef;

Expand All @@ -45,43 +43,37 @@
await base.OnInitializedAsync();
}

protected override async Task OnAfterRenderAsync(bool firstRender) {
//set minwidth to title width
// MinWidth = await JSRuntime.InvokeAsync<int>("getWidth", _titleRef) + 75;
await base.OnAfterRenderAsync(firstRender);
}

private void WindowDrag(DragEventArgs obj) {
Console.WriteLine("Drag: " + obj.ToJson());

_x += obj.MovementX;
_y += obj.MovementY;
protected override async Task OnAfterRenderAsync(bool firstRender) => await base.OnAfterRenderAsync(firstRender);

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

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

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

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

_x += obj.ClientX - dragX;
_y += obj.ClientY - dragY;
dragX = obj.ClientX;
dragY = obj.ClientY;
_x += obj.ClientX - _dragX;
_y += obj.ClientY - _dragY;
_dragX = obj.ClientX;
_dragY = obj.ClientY;
StateHasChanged();
}

}
}
2 changes: 2 additions & 0 deletions ArcaneLibs.Blazor.Components/ModalWindow.razor.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
height: fit-content;
z-index: 1000;
}

.r-modal:hover {
z-index: 1001;
}
Expand Down Expand Up @@ -43,6 +44,7 @@
background-color: #111;
cursor: pointer;
}

.r-modal > .titlebar > .btncollapse {
position: absolute;
top: 0;
Expand Down
Binary file removed ArcaneLibs.Blazor.Components/wwwroot/background.png
Binary file not shown.
6 changes: 0 additions & 6 deletions ArcaneLibs.Blazor.Components/wwwroot/exampleJsInterop.js

This file was deleted.

Loading

0 comments on commit 656e562

Please sign in to comment.