Skip to content

Commit

Permalink
给DanmaOnly窗口增加置顶功能
Browse files Browse the repository at this point in the history
  • Loading branch information
CHKZL committed Jul 3, 2024
1 parent 9457588 commit 2a5d7f8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Desktop/Views/Windows/DanmaOnlyWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<ui:ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="复制" Click="CopyMenuItem_Click"/>
<Separator/>
<MenuItem Header="设置本窗口置顶状态" Click="MenuItem_TopMost_Click"/>
</ContextMenu>
</ui:ListView.ContextMenu>
<ui:ListView.View>
Expand Down
36 changes: 36 additions & 0 deletions Desktop/Views/Windows/DanmaOnlyWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Core.LiveChat;
using Core.LogModule;
using Core.RuntimeObject;
using Notification.Wpf;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Expand Down Expand Up @@ -28,6 +29,10 @@ public partial class DanmaOnlyWindow : FluentWindow
{
RoomCardClass roomCard;
public ObservableCollection<DanmaOnly> DanmaCollection = new();
/// <summary>
/// 当前窗口的置顶状态
/// </summary>
private bool TopMostSwitch = false;
public DanmaOnlyWindow(RoomCardClass Card)
{
InitializeComponent();
Expand Down Expand Up @@ -177,5 +182,36 @@ private void DanmaOnly_DanmaInput_KeyDown(object sender, System.Windows.Input.Ke
DanmaOnly_DanmaInput.Clear();
}
}

private void MenuItem_TopMost_Click(object sender, RoutedEventArgs e)
{
if (TopMostSwitch)
{
this.Topmost = false;
TopMostSwitch = false;
SetNotificatom("撤销窗口置顶", $"{roomCard.Name}({roomCard.RoomId})窗口置顶已关闭");
}
else
{
this.Topmost = true;
TopMostSwitch = true;
SetNotificatom("打开窗口置顶", $"{roomCard.Name}({roomCard.RoomId})窗口置顶已打开");
}
}
private void SetNotificatom(string Title, string Message = "'")
{
Dispatcher.Invoke(() =>
{
MainWindow.notificationManager.Show(new NotificationContent
{
Title = Title,
Message = Message,
Type = NotificationType.Success,
Background = (System.Windows.Media.Brush)new BrushConverter().ConvertFromString("#00CC33")

});
});

}
}
}

0 comments on commit 2a5d7f8

Please sign in to comment.