improve:截图
This commit is contained in:
@@ -117,6 +117,15 @@
|
||||
BorderThickness="0"
|
||||
FontWeight="Medium"
|
||||
Click="FreehandModeButton_Click" />
|
||||
<Button Name="FullScreenButton"
|
||||
Content="全屏截图"
|
||||
Margin="4,0"
|
||||
Padding="12,6"
|
||||
Background="#7c3aed"
|
||||
Foreground="White"
|
||||
BorderThickness="0"
|
||||
FontWeight="Medium"
|
||||
Click="FullScreenButton_Click" />
|
||||
|
||||
<!-- 分隔线 -->
|
||||
<Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"
|
||||
|
||||
@@ -146,6 +146,7 @@ namespace Ink_Canvas
|
||||
_isFreehandMode = false;
|
||||
RectangleModeButton.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); // 蓝色
|
||||
FreehandModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||
FullScreenButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||
HintText.Text = "拖拽鼠标选择矩形区域";
|
||||
HintText.Visibility = Visibility.Visible;
|
||||
}
|
||||
@@ -158,10 +159,26 @@ namespace Ink_Canvas
|
||||
_isFreehandMode = true;
|
||||
FreehandModeButton.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); // 蓝色
|
||||
RectangleModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||
FullScreenButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||
HintText.Text = "按住鼠标左键绘制任意形状,松开直接截图";
|
||||
HintText.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
private void FullScreenButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 重置所有选择状态
|
||||
ResetSelectionState();
|
||||
|
||||
// 设置全屏截图模式
|
||||
_isFreehandMode = false;
|
||||
FullScreenButton.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); // 蓝色
|
||||
RectangleModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||
FreehandModeButton.Background = new SolidColorBrush(Color.FromRgb(107, 114, 128)); // 灰色
|
||||
|
||||
// 直接执行全屏截图
|
||||
PerformFullScreenCapture();
|
||||
}
|
||||
|
||||
private void ConfirmButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 在自由绘制模式下,确认按钮不执行任何操作
|
||||
@@ -786,6 +803,30 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
private void PerformFullScreenCapture()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取虚拟屏幕边界
|
||||
var virtualScreen = SystemInformation.VirtualScreen;
|
||||
|
||||
// 设置全屏截图区域
|
||||
SelectedArea = new DrawingRectangle(virtualScreen.X, virtualScreen.Y, virtualScreen.Width, virtualScreen.Height);
|
||||
SelectedPath = null; // 全屏截图不需要路径
|
||||
|
||||
// 直接关闭窗口并返回结果
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 如果全屏截图失败,记录错误并关闭窗口
|
||||
System.Diagnostics.Debug.WriteLine($"全屏截图失败: {ex.Message}");
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetSelectionState()
|
||||
{
|
||||
// 重置所有选择相关的状态
|
||||
|
||||
Reference in New Issue
Block a user