fix:issue #172
This commit is contained in:
@@ -98,7 +98,7 @@
|
||||
<Border x:Name="BorderBtnRand" MouseUp="BorderBtnRand_MouseUp" Background="#0066BF" Height="70" Width="200" CornerRadius="35">
|
||||
<ui:SimpleStackPanel Margin="3,0" Spacing="20" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Viewbox Margin="0,20">
|
||||
<ui:FontIcon Name="FontIconStart" Glyph="" Foreground="White"/>
|
||||
<ui:SymbolIcon Name="SymbolIconStart" Symbol="Contact" Foreground="White"/>
|
||||
</Viewbox>
|
||||
<TextBlock Text="开抽" Foreground="White" FontSize="32" Margin="-1,-1,4,0" VerticalAlignment="Center"/>
|
||||
</ui:SimpleStackPanel>
|
||||
@@ -113,7 +113,7 @@
|
||||
<Border x:Name="BorderBtnExternalCaller" MouseUp="BorderBtnExternalCaller_MouseUp" Background="#00B894" Height="50" Width="120" CornerRadius="25">
|
||||
<ui:SimpleStackPanel Margin="3,0" Spacing="8" Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Viewbox Margin="0,10">
|
||||
<ui:FontIcon Glyph="" Foreground="White"/>
|
||||
<ui:SymbolIcon Symbol="Globe" Foreground="White"/>
|
||||
</Viewbox>
|
||||
<TextBlock Text="外部点名" Foreground="White" FontSize="16" Margin="-1,-1,4,0" VerticalAlignment="Center"/>
|
||||
</ui:SimpleStackPanel>
|
||||
@@ -127,7 +127,7 @@
|
||||
</Border.Effect>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Viewbox Margin="15,12">
|
||||
<ui:FontIcon Glyph="" Foreground="Black"/>
|
||||
<ui:SymbolIcon Symbol="People" Foreground="Black"/>
|
||||
</Viewbox>
|
||||
<TextBlock Margin="-5,12,15,12" Name="TextBlockPeopleCount" Text="点击此处以导入名单" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</ui:SimpleStackPanel>
|
||||
@@ -137,7 +137,7 @@
|
||||
<DropShadowEffect Direction="0" ShadowDepth="0" Opacity="0.1" BlurRadius="3"/>
|
||||
</Border.Effect>
|
||||
<Viewbox Margin="14">
|
||||
<ui:FontIcon Glyph="" Foreground="White"/>
|
||||
<ui:SymbolIcon Symbol="Clear" Foreground="White"/>
|
||||
</Viewbox>
|
||||
</Border>
|
||||
</Canvas>
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Microsoft.VisualBasic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox;
|
||||
|
||||
namespace Ink_Canvas
|
||||
@@ -26,21 +24,12 @@ namespace Ink_Canvas
|
||||
{
|
||||
InitializeComponent();
|
||||
AnimationsHelper.ShowWithSlideFromBottomAndFade(this, 0.25);
|
||||
BorderBtnHelp.Visibility = !settings.RandSettings.DisplayRandWindowNamesInputBtn ? Visibility.Collapsed : Visibility.Visible;
|
||||
BorderBtnHelp.Visibility = settings.RandSettings.DisplayRandWindowNamesInputBtn == false ? Visibility.Collapsed : Visibility.Visible;
|
||||
RandMaxPeopleOneTime = settings.RandSettings.RandWindowOnceMaxStudents;
|
||||
RandDoneAutoCloseWaitTime = (int)settings.RandSettings.RandWindowOnceCloseLatency * 1000;
|
||||
|
||||
// 加载背景
|
||||
LoadBackground(settings);
|
||||
|
||||
// 设置窗口为置顶
|
||||
Topmost = true;
|
||||
|
||||
// 添加窗口关闭事件处理
|
||||
Closed += RandWindow_Closed;
|
||||
|
||||
// 添加窗口显示事件处理,确保置顶
|
||||
Loaded += RandWindow_Loaded;
|
||||
}
|
||||
|
||||
private void LoadBackground(Settings settings)
|
||||
@@ -80,22 +69,13 @@ namespace Ink_Canvas
|
||||
isAutoClose = IsAutoClose;
|
||||
PeopleControlPane.Opacity = 0.4;
|
||||
PeopleControlPane.IsHitTestVisible = false;
|
||||
BorderBtnHelp.Visibility = !settings.RandSettings.DisplayRandWindowNamesInputBtn ? Visibility.Collapsed : Visibility.Visible;
|
||||
BorderBtnHelp.Visibility = settings.RandSettings.DisplayRandWindowNamesInputBtn == false ? Visibility.Collapsed : Visibility.Visible;
|
||||
RandMaxPeopleOneTime = settings.RandSettings.RandWindowOnceMaxStudents;
|
||||
RandDoneAutoCloseWaitTime = (int)settings.RandSettings.RandWindowOnceCloseLatency * 1000;
|
||||
|
||||
// 加载背景
|
||||
LoadBackground(settings);
|
||||
|
||||
// 设置窗口为置顶
|
||||
Topmost = true;
|
||||
|
||||
// 添加窗口关闭事件处理
|
||||
Closed += RandWindow_Closed;
|
||||
|
||||
// 添加窗口显示事件处理,确保置顶
|
||||
Loaded += RandWindow_Loaded;
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
@@ -120,7 +100,7 @@ namespace Ink_Canvas
|
||||
if (RandMaxPeopleOneTime != -1 && TotalCount >= RandMaxPeopleOneTime) return;
|
||||
TotalCount++;
|
||||
LabelNumberCount.Text = TotalCount.ToString();
|
||||
FontIconStart.Glyph = "";
|
||||
SymbolIconStart.Symbol = Symbol.People;
|
||||
BorderBtnAdd.Opacity = 1;
|
||||
BorderBtnMinus.Opacity = 1;
|
||||
}
|
||||
@@ -132,7 +112,7 @@ namespace Ink_Canvas
|
||||
LabelNumberCount.Text = TotalCount.ToString();
|
||||
if (TotalCount == 1)
|
||||
{
|
||||
FontIconStart.Glyph = "";
|
||||
SymbolIconStart.Symbol = Symbol.Contact;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,70 +337,5 @@ namespace Ink_Canvas
|
||||
MessageBox.Show("无法调用外部点名:" + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口加载事件处理
|
||||
/// </summary>
|
||||
private void RandWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 使用延迟确保窗口完全加载后再应用置顶
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// 强制激活窗口
|
||||
Activate();
|
||||
Focus();
|
||||
|
||||
// 设置置顶
|
||||
Topmost = true;
|
||||
|
||||
// 使用Win32 API强制置顶
|
||||
var hwnd = new WindowInteropHelper(this).Handle;
|
||||
if (hwnd != IntPtr.Zero)
|
||||
{
|
||||
const int WS_EX_TOPMOST = 0x00000008;
|
||||
const int GWL_EXSTYLE = -20;
|
||||
const int SWP_NOMOVE = 0x0002;
|
||||
const int SWP_NOSIZE = 0x0001;
|
||||
const int SWP_SHOWWINDOW = 0x0040;
|
||||
const int SWP_NOOWNERZORDER = 0x0200;
|
||||
var HWND_TOPMOST = new IntPtr(-1);
|
||||
|
||||
// 设置窗口样式为置顶
|
||||
int exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
SetWindowLong(hwnd, GWL_EXSTYLE, exStyle | WS_EX_TOPMOST);
|
||||
|
||||
// 强制置顶
|
||||
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"RandWindow置顶失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}), DispatcherPriority.Loaded);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口关闭事件处理
|
||||
/// </summary>
|
||||
private void RandWindow_Closed(object sender, EventArgs e)
|
||||
{
|
||||
// 窗口关闭时的清理工作
|
||||
// 这里可以添加必要的清理代码
|
||||
}
|
||||
|
||||
#region Win32 API 声明
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user