Skip to content

Commit

Permalink
扩展关闭功能,允许退出整个应用;
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet9 committed Nov 1, 2022
1 parent 0c2068f commit 5ead013
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/BlazorChat.BlazorServer/Services/WindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public bool IsMaximized()
return true;
}

public void Close()
public void Close(bool allWindow)
{
}
}
2 changes: 1 addition & 1 deletion src/WPFBlazorChat.Core/Services/IWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public interface IWindowService
void Minimize();
void Maximize();
bool IsMaximized();
void Close();
void Close(bool allWindow = false);
}
2 changes: 1 addition & 1 deletion src/WPFBlazorChat.WebApp/Views/MainView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
Title="关闭窗体"
Type="AlertTypes.Warning"
OnCancel="() => _showComfirmDialog = false"
OnOk="WindowService.Close">
OnOk="() => WindowService.Close(true)">
您确认关闭吗?没事,待会儿再打开就是!
</PConfirm>
<!--确认对话框结束-->
Expand Down
7 changes: 4 additions & 3 deletions src/WPFBlazorChat.WebApp/Views/WeChatView.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
Label="搜索"
Outlined
Dense
required></MTextField>
required>
</MTextField>
<MAppBarTitle>Title</MAppBarTitle>
<MSpacer></MSpacer>

<MButton Icon OnClick="WindowService.Minimize">
<MIcon>mdi-window-minimize</MIcon>
</MButton>
Expand All @@ -32,7 +33,7 @@
<MIcon>mdi-window-maximize</MIcon>
}
</MButton>
<MButton Icon OnClick="WindowService.Close">
<MButton Icon OnClick="() => WindowService.Close()">
<MIcon>mdi-close</MIcon>
</MButton>
</MAppBar>
Expand Down
8 changes: 7 additions & 1 deletion src/WPFBlazorChat/Services/WindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ public bool IsMaximized()
return false;
}

public void Close()
public void Close(bool allWindow = false)
{
if (allWindow)
{
Application.Current?.Shutdown();
return;
}

var window = GetActiveWindow();
if (window != null)
{
Expand Down

0 comments on commit 5ead013

Please sign in to comment.