Procházet zdrojové kódy

Dev: Reload UI, hide elements for crash

HOME před 5 měsíci
rodič
revize
17d514d29b

+ 50 - 22
PCC.Gui/Gui/MudIse/MainMudIse.razor

@@ -1,4 +1,8 @@
-@inject IEventBus EventBus;
+@using Color = MudBlazor.Color
+@using Size = MudBlazor.Size
+@using Microsoft.JSInterop
+@inject IEventBus EventBus;
+@inject IJSRuntime JSRuntime;
 
 @* Required *@
 <MudThemeProvider />
@@ -11,7 +15,6 @@
 <MudSnackbarProvider />
 
 @{
-
     RenderFragment<ItemChild> RenderItemChild = (ItemChild child) => __builder=>
     {
         <MudPaper Class="pa-1 my-1">
@@ -21,7 +24,12 @@
                     <MudIcon Icon="@Icons.Material.Sharp.ConnectWithoutContact"></MudIcon>
                     <MudIcon Icon="@Icons.Custom.Uncategorized.AlertSuccess"></MudIcon>
                 </MudStack>
-                <MudButton Color="MudBlazor.Color.Inherit" Class="pa-3 rounded-0 hideable" Style="min-width: 0;"><MudIcon Icon="@Icons.Material.Outlined.Menu" /></MudButton>
+                <MudMenu Icon="@Icons.Material.Outlined.Menu" Variant="Variant.Filled" AnchorOrigin="Origin.BottomRight" TransformOrigin="Origin.TopRight" Color="Color.Default" Size="Size.Large">
+                    <MudMenuItem Icon="@Icons.Material.Sharp.PrivateConnectivity">Connect</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.DisabledByDefault">Disconnect</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.Edit">Edit...</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.Delete" IconColor="Color.Error">Delete Trusted Peer</MudMenuItem>
+                </MudMenu>
             </MudStack>
         </MudPaper>
     };
@@ -35,7 +43,12 @@
                     <MudIcon Icon="@Icons.Material.Sharp.Start"></MudIcon>
                     <MudIcon Icon="@Icons.Custom.Uncategorized.AlertSuccess"></MudIcon>
                 </MudStack>
-                <MudButton Color="MudBlazor.Color.Inherit" Class="pa-3 rounded-0 hideable" Style="min-width: 0;"><MudIcon Icon="@Icons.Material.Outlined.Menu" /></MudButton>
+                <MudMenu Icon="@Icons.Material.Outlined.Menu" Variant="Variant.Filled" AnchorOrigin="Origin.BottomRight" TransformOrigin="Origin.TopRight" Color="Color.Default" Size="Size.Large">
+                    <MudMenuItem Icon="@Icons.Material.Sharp.PlayArrow" >Start Listener</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.Stop" >Stop Listener</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.Edit" >Edit...</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.Delete" IconColor="Color.Error">Delete Local Peer</MudMenuItem>
+                </MudMenu>
             </MudStack>
             <MudDropContainer T="ItemChild" Items="@context.Children" ItemsSelector="(_, _) => true" Class="flex-grow-1">
                 <ChildContent>
@@ -54,7 +67,12 @@
         <MudStack StretchItems="StretchItems.End" AlignItems="AlignItems.Stretch" Spacing="1" Style="width:100%;height:100%">
             <MudStack Row AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Spacing="1" Class="mud-paper mud-paper-square stack-adorner">
                 <MudText Class="hideable">Contacts</MudText>
-                <MudButton Color="MudBlazor.Color.Inherit" Class="pa-3 rounded-0 hideable" Style="min-width: 0;"><MudIcon Icon="@Icons.Material.Outlined.Menu" /></MudButton>
+                <MudMenu Icon="@Icons.Material.Outlined.Menu" Variant="Variant.Filled" AnchorOrigin="Origin.BottomRight" TransformOrigin="Origin.TopRight" Color="Color.Default" Size="Size.Large">
+                    <MudMenuItem Icon="@Icons.Material.Sharp.Add">Add Local Peer...</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.Settings">Settings...</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.Refresh" IconColor="Color.Warning" OnClick="@ReloadUI">Reload UI</MudMenuItem>
+                    <MudMenuItem Icon="@Icons.Material.Sharp.ExitToApp" IconColor="Color.Error">Quit</MudMenuItem>
+                </MudMenu>
             </MudStack>
             <MudStack Row Class="mud-background-gray stack-adorner" Style="overflow-x: auto;">
                 <MudDropContainer T="Item" Items="_items" ItemsSelector="(_, _) =>true " Class="flex-grow-1">
@@ -69,28 +87,30 @@
             </MudStack>
         </MudStack>
     };
-
 }
 
-<Splitter Direction="SplitterDirection.Horizontal" Style="height:100%">
-    <SplitterSection Style="height:100%">
-        @RenderContacts
-    </SplitterSection>
-    <SplitterSection>
-        <Splitter Direction="SplitterDirection.Vertical">
-            <SplitterSection>
-                <div>Chat!</div>
-            </SplitterSection>
-            <SplitterSection>
-                <div>Input!</div>
-            </SplitterSection>
-        </Splitter>
-
-    </SplitterSection>
-</Splitter>
+@if (_isReloadingUI == false)
+{
+    <Splitter Direction="SplitterDirection.Horizontal">
+        <SplitterSection>
+            @RenderContacts
+        </SplitterSection>
+        <SplitterSection>
+            <Splitter Direction="SplitterDirection.Vertical">
+                <SplitterSection>
+                    <div>Chat!</div>
+                </SplitterSection>
+                <SplitterSection>
+                    <div>Input!</div>
+                </SplitterSection>
+            </Splitter>
+        </SplitterSection>
+    </Splitter>
+}
 
 @code {
     private bool _isUiShown = false;
+    private bool _isReloadingUI = false;
 
     protected override async Task OnAfterRenderAsync(bool firstRender)
     {
@@ -101,6 +121,14 @@
         EventBus.Publish<UiShownEvent>();
     }
 
+
+    private void ReloadUI()
+    {
+        _isReloadingUI = true;
+        StateHasChanged();
+        JSRuntime.InvokeVoidAsync("window.location.reload");
+    }
+
     private List<Item> _items = new()
     {
         new()

+ 3 - 0
PCC.Gui/Gui/MudIse/MainMudIse.razor.css

@@ -0,0 +1,3 @@
+body {
+    asdf:ffff;
+}

+ 1 - 0
PCC.Gui/Gui/PccMainForm.cs

@@ -36,6 +36,7 @@ namespace PCC.Gui
 
             async void LocalMethod(LoggingEvent le)
             {
+                if (ApplicationInitializationPanel.Visible == false) return;
                 ApplicationInitializationStatusLabel.Text = $"{le.LogLevel} {le.Content}";
                 Application.DoEvents();
             }

+ 1 - 1
PCC.Gui/wwwroot/index-mud-ise.html

@@ -14,7 +14,7 @@
     <link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
     <link href="_content/Blazorise.Bootstrap5/blazorise.bootstrap5.css" rel="stylesheet" />
 
-    <link href="WinFormsBlazor.styles.css" rel="stylesheet" />
+    <link href="PCC.Gui.styles.css" rel="stylesheet" />
 </head>
 
 <body class="mud-height-full" style="margin:0">