[update] 又一次优化窗口截图

This commit is contained in:
Dubi906w 2024-08-02 20:37:49 +08:00
parent a60b7b7535
commit 51aae53725
10 changed files with 720 additions and 244 deletions

View File

@ -123,6 +123,8 @@
</Reference>
<Reference Include="Microsoft.VisualBasic" />
<Reference Include="netstandard" />
<Reference Include="System.Management" />
<Reference Include="System.Management.Instrumentation" />
<Reference Include="System.Windows.Forms" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data.DataSetExtensions" />
@ -190,6 +192,15 @@
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="Shell32">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>50a7e9b0-70ef-11d1-b75a-00a0c90564fe</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\TimerDownNotice.wav" />
@ -209,9 +220,12 @@
<Resource Include="Resources\Icons-png\AdmoxWhiteboard.png" />
<Resource Include="Resources\Icons-png\check-box-background.png" />
<Resource Include="Resources\Icons-png\classic-icons\desktop-folder.png" />
<Resource Include="Resources\Icons-png\classic-icons\desktop-small-icon.png" />
<Resource Include="Resources\Icons-png\classic-icons\disk-drive.png" />
<Resource Include="Resources\Icons-png\classic-icons\documents-folder.png" />
<Resource Include="Resources\Icons-png\classic-icons\folder.png" />
<Resource Include="Resources\Icons-png\classic-icons\photo-small-icon.png" />
<Resource Include="Resources\Icons-png\classic-icons\program-icon.png" />
<Resource Include="Resources\Icons-png\classic-icons\user-folder.png" />
<Resource Include="Resources\Icons-png\Donview.png" />
<Resource Include="Resources\Icons-png\EasiNote3.png" />
@ -509,9 +523,12 @@
<None Remove="Resources\Icons-png\AdmoxBooth.png" />
<None Remove="Resources\Icons-png\AdmoxWhiteboard.png" />
<None Remove="Resources\Icons-png\classic-icons\desktop-folder.png" />
<None Remove="Resources\Icons-png\classic-icons\desktop-small-icon.png" />
<None Remove="Resources\Icons-png\classic-icons\disk-drive.png" />
<None Remove="Resources\Icons-png\classic-icons\documents-folder.png" />
<None Remove="Resources\Icons-png\classic-icons\folder.png" />
<None Remove="Resources\Icons-png\classic-icons\photo-small-icon.png" />
<None Remove="Resources\Icons-png\classic-icons\program-icon.png" />
<None Remove="Resources\Icons-png\classic-icons\user-folder.png" />
<None Remove="Resources\Icons-png\Donview.png" />
<None Remove="Resources\Icons-png\EasiNote3.png" />

View File

@ -186,7 +186,7 @@ namespace Ink_Canvas {
public static Settings Settings = new Settings();
public static string settingsFileName = "Settings.json";
private bool isLoaded = false;
public bool isLoaded = false;
[DllImport("user32.dll")]
static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);

View File

@ -1030,7 +1030,7 @@ namespace Ink_Canvas {
HideSubPanelsImmediately();
await Task.Delay(50);
//SaveScreenShotToDesktop();
var scrwin = new ScreenshotWindow(this);
var scrwin = new ScreenshotWindow(this,Settings);
scrwin.Show();
}

View File

@ -17,10 +17,13 @@ using Vanara.PInvoke;
using Encoder = System.Drawing.Imaging.Encoder;
using OperatingSystem = OSVersionExtension.OperatingSystem;
using PixelFormat = System.Drawing.Imaging.PixelFormat;
using System.Management;
using System.Windows.Shapes;
using Path = System.IO.Path;
using Rectangle = System.Drawing.Rectangle;
namespace Ink_Canvas {
public partial class MainWindow : Window {
#region MagnificationAPI ICC窗口
#region Dubi906w
@ -155,7 +158,8 @@ namespace Ink_Canvas {
IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
// 設定窗體樣式和排布
int style = GetWindowLong(windowHostHandle, GWL_STYLE);
style &= ~WS_CAPTION; // 隐藏标题栏style &= ~WS_THICKFRAME; // 禁止窗口拉伸
style &= ~WS_CAPTION; // 隐藏标题栏
style &= ~WS_THICKFRAME; // 禁止窗口拉伸
SetWindowLong(windowHostHandle, GWL_STYLE, style);
SetWindowPos(windowHostHandle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOSIZE | SWP_FRAMECHANGED);
// 設定額外樣式
@ -166,11 +170,42 @@ namespace Ink_Canvas {
// 設定放大鏡工廠
Magnification.MAGTRANSFORM matrix = new Magnification.MAGTRANSFORM();
matrix[0, 0] = 1.0f;
matrix[0, 1] = 0.0f;
matrix[0, 2] = 0.0f;
matrix[1, 0] = 0.0f;
matrix[1, 1] = 1.0f;
matrix[2, 2] = 1.0f;
matrix[1, 2] = 0.0f;
matrix[2, 0] = 1.0f;
matrix[2, 1] = 0.0f;
matrix[2, 2] = 0.0f;
if (!Magnification.MagSetWindowTransform(hwndMag, matrix)) return;
// 設定放大鏡轉化矩乘陣列
Magnification.MAGCOLOREFFECT magEffect = new Magnification.MAGCOLOREFFECT();
magEffect[0, 0] = 1.0f;
magEffect[0, 1] = 0.0f;
magEffect[0, 2] = 0.0f;
magEffect[0, 3] = 0.0f;
magEffect[0, 4] = 0.0f;
magEffect[1, 0] = 0.0f;
magEffect[1, 1] = 1.0f;
magEffect[1, 2] = 0.0f;
magEffect[1, 3] = 0.0f;
magEffect[1, 4] = 0.0f;
magEffect[2, 0] = 0.0f;
magEffect[2, 1] = 0.0f;
magEffect[2, 2] = 1.0f;
magEffect[2, 3] = 0.0f;
magEffect[2, 4] = 0.0f;
magEffect[3, 0] = 0.0f;
magEffect[3, 1] = 0.0f;
magEffect[3, 2] = 0.0f;
magEffect[3, 3] = 1.0f;
magEffect[3, 4] = 0.0f;
magEffect[4, 0] = 0.0f;
magEffect[4, 1] = 0.0f;
magEffect[4, 2] = 0.0f;
magEffect[4, 3] = 0.0f;
magEffect[4, 4] = 1.0f;
if (!Magnification.MagSetColorEffect(hwndMag, magEffect)) return;
// 顯示窗體
ShowWindow(windowHostHandle, SW_SHOW);
@ -202,6 +237,7 @@ namespace Ink_Canvas {
memoryGraphics.ReleaseHdc();
callbackAction(bmp);
}
// 反注册宿主窗口
UnregisterClass("ICCMagnifierWindowHost", IntPtr.Zero);
// 销毁宿主窗口
@ -209,7 +245,8 @@ namespace Ink_Canvas {
DestroyWindow(windowHostHandle);
}
public Task<Bitmap> SaveScreenshotToDesktopByMagnificationAPIAsync(HWND[] hwndsList, bool isUsingCallback = false) {
public Task<Bitmap> SaveScreenshotToDesktopByMagnificationAPIAsync(HWND[] hwndsList,
bool isUsingCallback = false) {
return Task.Run(() => {
var t = new TaskCompletionSource<Bitmap>();
SaveScreenshotToDesktopByMagnificationAPI(hwndsList, bitmap => t.TrySetResult(bitmap), isUsingCallback);
@ -276,6 +313,45 @@ namespace Ink_Canvas {
[DllImport("dwmapi.dll")]
static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out bool pvAttribute, int cbAttribute);
[DllImport("dwmapi.dll")]
static extern int DwmGetWindowAttribute(IntPtr hwnd, DwmWindowAttribute dwAttribute, out RECT pvAttribute, int cbAttribute);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetLayeredWindowAttributes(IntPtr hwnd, out uint crKey, out byte bAlpha, out uint dwFlags);
public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool EnumChildWindows(IntPtr hwndParent, EnumWindowsProc lpEnumFunc, IntPtr lParam);
[DllImport("user32.dll", SetLastError=true)]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint processId);
enum DwmWindowAttribute : uint {
NCRenderingEnabled = 1,
NCRenderingPolicy,
TransitionsForceDisabled,
AllowNCPaint,
CaptionButtonBounds,
NonClientRtlLayout,
ForceIconicRepresentation,
Flip3DPolicy,
ExtendedFrameBounds,
HasIconicBitmap,
DisallowPeek,
ExcludedFromPeek,
Cloak,
Cloaked,
FreezeRepresentation,
PassiveUpdateMode,
UseHostBackdropBrush,
UseImmersiveDarkMode = 20,
WindowCornerPreference = 33,
BorderColor,
CaptionColor,
TextColor,
VisibleFrameBorderThickness,
SystemBackdropType,
Last
}
public Icon GetAppIcon(IntPtr hwnd) {
IntPtr iconHandle = SendMessage(hwnd, 0x7F, 2, 0);
@ -303,6 +379,9 @@ namespace Ink_Canvas {
public RECT Rect { get; set; }
public WINDOWPLACEMENT Placement { get; set; }
public HWND hwnd { get; set; }
public RECT RealRect { get; set; }
public Rectangle ContentRect { get; set; }
public IntPtr Handle { get; set; }
}
public struct WINDOWPLACEMENT {
@ -334,7 +413,7 @@ namespace Ink_Canvas {
new HWND(hShellWnd), new HWND(hDefView), new HWND(folderView), new HWND(taskBar)
};
var excludedWindowTitle = new string[] {
"NVIDIA GeForce Overlay"
"NVIDIA GeForce Overlay", "Ink Canvas 画板", "Ink Canvas Annotation", "Ink Canvas Artistry", "InkCanvasForClass"
};
excluded.AddRange(excludedHwnds);
if (!EnumDesktopWindows(IntPtr.Zero, new EnumDesktopWindowsDelegate((hwnd, param) => {
@ -342,16 +421,19 @@ namespace Ink_Canvas {
var isvisible = IsWindowVisible(hwnd);
if (!isvisible) return true;
var windowLong = (int)GetWindowLongPtr(hwnd, -20);
GetLayeredWindowAttributes(hwnd, out uint crKey, out byte bAlpha, out uint dwFlags);
if ((windowLong & 0x00000080L) != 0) return true;
DwmGetWindowAttribute(hwnd, 14, out bool isCloacked, Marshal.SizeOf(typeof(bool)));
if ((windowLong & 0x00080000) != 0 && (dwFlags & 0x00000002) != 0 && bAlpha == 0) return true; //分层窗口且全透明
DwmGetWindowAttribute(hwnd, (int)DwmWindowAttribute.Cloaked, out bool isCloacked, Marshal.SizeOf(typeof(bool)));
DwmGetWindowAttribute(hwnd, DwmWindowAttribute.ExtendedFrameBounds, out RECT realRect, Marshal.SizeOf(typeof(RECT)));
if (isCloacked) return true;
var icon = GetAppIcon(hwnd);
var length = GetWindowTextLength(hwnd) + 1;
var title = new StringBuilder(length);
GetWindowText(hwnd, title, length);
if (title.ToString().Length == 0) return true;
// if (title.ToString().Length == 0) return true;
// 這裡懶得做 Alt Tab窗口的校驗了直接窗體標題黑名單
if (excludedWindowTitle.Contains(title.ToString())) return true;
if (excludedWindowTitle.Equals(title.ToString())) return true;
RECT rect;
WINDOWPLACEMENT placement = new WINDOWPLACEMENT();
GetWindowPlacement(hwnd, ref placement);
@ -359,6 +441,7 @@ namespace Ink_Canvas {
GetWindowRect(hwnd, out rect);
var w = rect.Width;
var h = rect.Height;
Trace.WriteLine($"x: {realRect.X - rect.X} y: {realRect.Y - rect.Y} w: {realRect.Width} h: {realRect.Height}");
if (w == 0 || h == 0) return true;
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
Graphics memoryGraphics = Graphics.FromImage(bmp);
@ -373,6 +456,9 @@ namespace Ink_Canvas {
Height = h,
Rect = rect,
Placement = placement,
RealRect = realRect,
Handle = hwnd,
ContentRect = new Rectangle(realRect.X - rect.X, realRect.Y - rect.Y, realRect.Width, realRect.Height),
});
memoryGraphics.ReleaseHdc(hdc);
System.GC.Collect();
@ -383,9 +469,57 @@ namespace Ink_Canvas {
return windows.ToArray();
}
public static string GetProcessPathByPid(int processId) {
string query = $"SELECT Name, ExecutablePath FROM Win32_Process WHERE ProcessId = {processId}";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject obj in searcher.Get()) {
string executablePath = obj["ExecutablePath"]?.ToString();
if (!string.IsNullOrEmpty(executablePath)) return executablePath;
}
return "";
}
public async Task<string> GetProcessPathByPidAsync(int processId) {
var result = await Task.Run(() => GetProcessPathByPid(processId));
return result;
}
private static string GetAppFriendlyName(string filePath)
{
var versionInfo = FileVersionInfo.GetVersionInfo(filePath);
return versionInfo.FileDescription;
}
public async Task<WindowInformation[]> GetAllWindowsAsync(HWND[] excludedHwnds) {
var windows = await Task.Run(() => GetAllWindows(excludedHwnds));
return windows;
var _wins = new List<WindowInformation>(){};
foreach (var w in windows) {
_wins.Add(w);
}
foreach (var windowInformation in windows) {
if (windowInformation.Title.Length == 0) {
GetWindowThreadProcessId(windowInformation.Handle, out uint Pid);
if (Pid != 0) {
var _path = Path.GetFullPath(await GetProcessPathByPidAsync((int)Pid));
var processPath = Path.GetFullPath(Process.GetCurrentProcess().MainModule.FileName);
if (string.Equals(_path, processPath, StringComparison.OrdinalIgnoreCase) || _path == "") {
_wins.Remove(windowInformation);
} else {
var _des = GetAppFriendlyName(_path);
Trace.WriteLine(_des);
if (_des == null) {
_wins.Remove(windowInformation);
} else {
var index = _wins.IndexOf(windowInformation);
_wins[index].Title = _des;
}
}
} else {
_wins.Remove(windowInformation);
}
}
}
return _wins.ToArray();
}
#endregion
@ -398,6 +532,7 @@ namespace Ink_Canvas {
using (Graphics memoryGrahics = Graphics.FromImage(bitmap)) {
memoryGrahics.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);
}
return bitmap;
}
@ -405,10 +540,8 @@ namespace Ink_Canvas {
#region API
private BitmapImage BitmapToImageSource(Bitmap bitmap)
{
using (MemoryStream memory = new MemoryStream())
{
private BitmapImage BitmapToImageSource(Bitmap bitmap) {
using (MemoryStream memory = new MemoryStream()) {
bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp);
memory.Position = 0;
BitmapImage bitmapimage = new BitmapImage();
@ -444,8 +577,7 @@ namespace Ink_Canvas {
public HWND[] ExcludedHwnds { get; set; } = new HWND[] { };
}
private static ImageCodecInfo GetEncoderInfo(string mimeType)
{
private static ImageCodecInfo GetEncoderInfo(string mimeType) {
foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageEncoders())
if (codec.MimeType == mimeType)
return codec;
@ -461,23 +593,32 @@ namespace Ink_Canvas {
if (OSVersion.GetOperatingSystem() >= OperatingSystem.Windows81) {
bitmap = await SaveScreenshotToDesktopByMagnificationAPIAsync(ex.ToArray(), false);
} else {
if (ex.Count != 0) foreach (var hwnd in ex) ShowWindow(hwnd.DangerousGetHandle(), 0);
if (ex.Count != 0)
foreach (var hwnd in ex)
ShowWindow(hwnd.DangerousGetHandle(), 0);
bitmap = GetScreenshotBitmap();
foreach (var hwnd in ex) ShowWindow(hwnd.DangerousGetHandle(), 5);
}
} else if (config.SnapshotMethod == SnapshotMethod.MagnificationAPIWithPrintWindow || config.SnapshotMethod == SnapshotMethod.MagnificationAPIWithCallback) {
} else if (config.SnapshotMethod == SnapshotMethod.MagnificationAPIWithPrintWindow ||
config.SnapshotMethod == SnapshotMethod.MagnificationAPIWithCallback) {
if (!(OSVersion.GetOperatingSystem() >= OperatingSystem.Windows81))
throw new Exception("您的系統版本不支持 MagnificationAPI 截圖!");
bitmap = await SaveScreenshotToDesktopByMagnificationAPIAsync(ex.ToArray(),config.SnapshotMethod == SnapshotMethod.MagnificationAPIWithCallback);
bitmap = await SaveScreenshotToDesktopByMagnificationAPIAsync(ex.ToArray(),
config.SnapshotMethod == SnapshotMethod.MagnificationAPIWithCallback);
} else if (config.SnapshotMethod == SnapshotMethod.GraphicsAPICopyFromScreen) {
if (ex.Count != 0) foreach (var hwnd in ex) ShowWindow(hwnd.DangerousGetHandle(), 0);
if (ex.Count != 0)
foreach (var hwnd in ex)
ShowWindow(hwnd.DangerousGetHandle(), 0);
bitmap = GetScreenshotBitmap();
foreach (var hwnd in ex) ShowWindow(hwnd.DangerousGetHandle(), 5);
}
if (bitmap.Width == 1 && bitmap.Height == 1) throw new Exception("截圖失敗");
try {
if (config.IsCopyToClipboard) Clipboard.SetImage(BitmapToImageSource(bitmap));
} catch (NotSupportedException e) {}
}
catch (NotSupportedException e) { }
if (config.IsSaveToLocal) {
var fullPath = config.BitmapSavePath.FullName;
if (!config.BitmapSavePath.Exists) config.BitmapSavePath.Create();
@ -486,10 +627,13 @@ namespace Ink_Canvas {
.Replace("[HH]", DateTime.Now.Hour.ToString()).Replace("[mm]", DateTime.Now.Minute.ToString())
.Replace("[ss]", DateTime.Now.Second.ToString()).Replace("[width]", bitmap.Width.ToString())
.Replace("[height]", bitmap.Height.ToString());
var finalPath = (fullPath.EndsWith("\\") ? fullPath.Substring(0, fullPath.Length - 1) : fullPath) + $"\\{fileName}";
var finalPath = (fullPath.EndsWith("\\") ? fullPath.Substring(0, fullPath.Length - 1) : fullPath) +
$"\\{fileName}";
bitmap.Save(finalPath, config.OutputMIMEType == OutputImageMIMEFormat.Png ? ImageFormat.Png :
config.OutputMIMEType == OutputImageMIMEFormat.Bmp ? ImageFormat.Bmp : ImageFormat.Jpeg);
}
bitmap.Dispose();
return bitmap;
}

View File

@ -270,8 +270,11 @@ namespace Ink_Canvas {
}
//private DirectoryInfo GetDirectoryBySettings()
private DirectoryInfo GetDirectoryBySettings() {
var si = Settings.Storage.StorageLocation;
throw new NotImplementedException();
return new DirectoryInfo("");
}
private DirectoryInfo GetDirectoryInfoByIndex(int index) {
var autoSavedInkPath = new DirectoryInfo(storageLocationItems[ComboBoxStoragePath.SelectedIndex].Path+"\\AutoSavedInk");

View File

@ -6,18 +6,39 @@
xmlns:local="clr-namespace:Ink_Canvas.Popups"
xmlns:modern="http://schemas.inkore.net/lib/ui/wpf/modern"
mc:Ignorable="d" AllowsTransparency="True" Background="Transparent"
WindowStyle="None" ResizeMode="NoResize" ShowInTaskbar="False"
Title="ScreenshotWindow" Height="220" Width="360" Topmost="True">
WindowStyle="None" ResizeMode="NoResize" ShowInTaskbar="False" WindowState="Maximized"
KeyDown="ScreenshotWindow_OnKeyDown"
Title="ScreenshotWindow" Width="1920" Height="1080" Topmost="True">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<DrawingImage x:Key="LoadingBlackDrawingImage">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
<GeometryDrawing Brush="#FF222222" Geometry="F1 M16,16z M0,0z M7.97866,1.05463C7.88823,1.0548 7.798,1.06331 7.70913,1.08003 4.70969,1.23997 2.08169,3.30185 1.25795,6.20893 0.49488,9.22696 1.82645,12.4419 4.50014,14.0371 7.21817,15.5554 10.6675,15.1016 12.9005,12.9316 15.0709,10.6989 15.5243,7.25016 14.006,4.5312 15.5126,7.25687 15.038,10.6938 12.8712,12.9023 10.6434,15.0497 7.21718,15.4792 4.54116,13.9668 1.92311,12.3914 0.626806,9.23612 1.36147,6.29487 0.653131,9.24292 1.98362,12.3666 4.58217,13.8964 7.23613,15.3673 10.6076,14.9008 12.756,12.7871 14.8504,10.6193 15.2698,7.25855 13.7931,4.65425 15.2461,7.27223 14.7845,10.6101 12.6974,12.7285 10.5597,14.7962 7.23254,15.2126 4.6642,13.7539 2.14585,12.2446 0.888133,9.18174 1.59975,6.35737 0.914456,9.18855 2.2044,12.2197 4.70327,13.6835 7.24954,15.1008 10.5239,14.6473 12.5822,12.6132 14.5969,10.5356 15.0033,7.27391 13.5802,4.77729 14.9796,7.28759 14.531,10.5265 12.5236,12.5546 10.476,14.5427 7.2479,14.9461 4.78725,13.541 2.36858,12.0977 1.14946,9.12542 1.83803,6.41792 1.17578,9.13222 2.42714,12.0729 4.82631,13.4706 7.26489,14.8343 10.4402,14.3938 12.4083,12.4394 14.3433,10.4519 14.7367,7.28732 13.3673,4.89839 14.713,7.301 14.2775,10.4428 12.3498,12.3808 10.3924,14.2892 7.2613,14.6796 4.90835,13.3281 2.58936,11.9509 1.41078,9.07104 2.07631,6.48042 1.43711,9.07785 2.64987,11.926 4.94936,13.2578 7.28025,14.5677 10.3565,14.1402 12.2345,12.2656 14.0898,10.3682 14.4702,7.30267 13.1544,5.02143 14.4465,7.31636 14.024,10.3591 12.1759,12.207 10.3087,14.0357 7.27666,14.413 5.03139,13.1152 2.8121,11.804 1.67015,9.01472 2.31264,6.54097 1.69648,9.02152 2.87261,11.7792 5.07241,13.0449 7.29561,14.3012 10.2728,13.8867 12.0607,12.0918 13.8363,10.2845 14.2037,7.31803 12.9415,5.14448 14.18,7.33171 13.7705,10.2754 12.0021,12.0331 10.225,13.7822 7.29202,14.1465 5.15444,12.9023 3.03484,11.6571 1.93148,8.96035 2.55092,6.60347 1.9578,8.96716 3.09535,11.6323 5.19545,12.832 7.31097,14.0347 10.1891,13.6332 11.8869,11.9179 13.5828,10.2008 13.9371,7.33339 12.7287,5.26753 13.9134,7.34707 13.5169,10.1917 11.8283,11.8593 10.1413,13.5286 7.30738,13.88 5.27749,12.6894 3.25757,11.5103 2.19281,8.90403 2.7892,6.66401 2.21913,8.91084 3.31808,11.4854 5.3185,12.6191 7.32633,13.7681 10.1054,13.3797 11.713,11.7441 13.3293,10.1171 13.6706,7.34875 12.5158,5.39057 13.6469,7.36243 13.2634,10.108 11.6544,11.6855 10.0576,13.2751 7.32273,13.6134 5.40053,12.4765 3.48031,11.3634 2.45413,8.8477 3.02749,6.72456 2.48045,8.85451 3.54082,11.3386 5.44155,12.4062 7.34168,13.5016 10.0217,13.1262 11.5392,11.5703 13.0758,10.0334 13.4041,7.3641 12.3029,5.51362 13.3804,7.37778 13.0099,10.0243 11.4806,11.5117 9.97389,13.0216 7.3381,13.3469 5.52358,12.2636 3.70304,11.2166 2.71546,8.79333 3.26577,6.78706 2.74178,8.80014 3.76355,11.1917 5.5646,12.1933 7.35705,13.2351 9.93804,12.8727 11.3654,11.3964 12.8222,9.94974 13.1375,7.37946 12.09,5.63667 13.1138,7.39314 12.7564,9.94061 11.3068,11.3378 9.8902,12.7681 7.35345,13.0804 5.64663,12.0507 3.92578,11.0697 2.97483,8.73701 3.5021,6.84761 3.00115,8.74381 3.98629,11.0449 5.68764,11.9804 7.3724,12.9685 9.85435,12.6191 11.1915,11.2226 12.5687,9.86605 12.871,7.39482 11.8771,5.75972 12.8473,7.4085 12.5029,9.85692 11.133,11.164 9.80651,12.5146 7.36881,12.8138 5.76967,11.8378 4.14852,10.9229 3.23615,8.68263 3.74038,6.91011 3.26248,8.68944 4.20903,10.898 5.81069,11.7675 7.38776,12.702 9.77065,12.3656 11.0177,11.0488 12.3152,9.78235 12.6045,7.41019 11.6642,5.88276 12.5808,7.42387 12.2494,9.77322 10.9591,10.9902 9.72281,12.2611 7.38417,12.5473 5.89272,11.6249 4.37125,10.776 3.49748,8.62631 3.97866,6.97065 3.52413,8.63319 4.43201,10.7498 5.93374,11.5527 7.40284,12.433 9.68601,12.1097 10.8419,10.873 12.0588,9.69723 12.3356,7.42595 11.4494,6.00776 12.3234,7.43297 12.0258,9.69328 10.8126,10.8437 9.66222,12.0569 7.40191,12.3545 5.9767,11.4804 4.50712,10.6832 3.63409,8.57548 4.10952,6.97261 4.49922,5.34676 6.30735,3.95946 7.97866,4.00386L7.97866,3.99994C7.97932,3.99994 7.97999,3.99994 7.98066,3.99994 8.37116,3.9997 8.74559,3.84446 9.02172,3.56834 9.29784,3.29221 9.45307,2.91778 9.45331,2.52728 9.45307,2.13679 9.29784,1.76235 9.02171,1.48623 8.74559,1.21011 8.37116,1.05487 7.98066,1.05463 7.97999,1.05463 7.97932,1.05463 7.97866,1.05463z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="LoadingWhiteDrawingImage">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
<GeometryDrawing Brush="White" Geometry="F1 M16,16z M0,0z M7.97866,1.05463C7.88823,1.0548 7.798,1.06331 7.70913,1.08003 4.70969,1.23997 2.08169,3.30185 1.25795,6.20893 0.49488,9.22696 1.82645,12.4419 4.50014,14.0371 7.21817,15.5554 10.6675,15.1016 12.9005,12.9316 15.0709,10.6989 15.5243,7.25016 14.006,4.5312 15.5126,7.25687 15.038,10.6938 12.8712,12.9023 10.6434,15.0497 7.21718,15.4792 4.54116,13.9668 1.92311,12.3914 0.626806,9.23612 1.36147,6.29487 0.653131,9.24292 1.98362,12.3666 4.58217,13.8964 7.23613,15.3673 10.6076,14.9008 12.756,12.7871 14.8504,10.6193 15.2698,7.25855 13.7931,4.65425 15.2461,7.27223 14.7845,10.6101 12.6974,12.7285 10.5597,14.7962 7.23254,15.2126 4.6642,13.7539 2.14585,12.2446 0.888133,9.18174 1.59975,6.35737 0.914456,9.18855 2.2044,12.2197 4.70327,13.6835 7.24954,15.1008 10.5239,14.6473 12.5822,12.6132 14.5969,10.5356 15.0033,7.27391 13.5802,4.77729 14.9796,7.28759 14.531,10.5265 12.5236,12.5546 10.476,14.5427 7.2479,14.9461 4.78725,13.541 2.36858,12.0977 1.14946,9.12542 1.83803,6.41792 1.17578,9.13222 2.42714,12.0729 4.82631,13.4706 7.26489,14.8343 10.4402,14.3938 12.4083,12.4394 14.3433,10.4519 14.7367,7.28732 13.3673,4.89839 14.713,7.301 14.2775,10.4428 12.3498,12.3808 10.3924,14.2892 7.2613,14.6796 4.90835,13.3281 2.58936,11.9509 1.41078,9.07104 2.07631,6.48042 1.43711,9.07785 2.64987,11.926 4.94936,13.2578 7.28025,14.5677 10.3565,14.1402 12.2345,12.2656 14.0898,10.3682 14.4702,7.30267 13.1544,5.02143 14.4465,7.31636 14.024,10.3591 12.1759,12.207 10.3087,14.0357 7.27666,14.413 5.03139,13.1152 2.8121,11.804 1.67015,9.01472 2.31264,6.54097 1.69648,9.02152 2.87261,11.7792 5.07241,13.0449 7.29561,14.3012 10.2728,13.8867 12.0607,12.0918 13.8363,10.2845 14.2037,7.31803 12.9415,5.14448 14.18,7.33171 13.7705,10.2754 12.0021,12.0331 10.225,13.7822 7.29202,14.1465 5.15444,12.9023 3.03484,11.6571 1.93148,8.96035 2.55092,6.60347 1.9578,8.96716 3.09535,11.6323 5.19545,12.832 7.31097,14.0347 10.1891,13.6332 11.8869,11.9179 13.5828,10.2008 13.9371,7.33339 12.7287,5.26753 13.9134,7.34707 13.5169,10.1917 11.8283,11.8593 10.1413,13.5286 7.30738,13.88 5.27749,12.6894 3.25757,11.5103 2.19281,8.90403 2.7892,6.66401 2.21913,8.91084 3.31808,11.4854 5.3185,12.6191 7.32633,13.7681 10.1054,13.3797 11.713,11.7441 13.3293,10.1171 13.6706,7.34875 12.5158,5.39057 13.6469,7.36243 13.2634,10.108 11.6544,11.6855 10.0576,13.2751 7.32273,13.6134 5.40053,12.4765 3.48031,11.3634 2.45413,8.8477 3.02749,6.72456 2.48045,8.85451 3.54082,11.3386 5.44155,12.4062 7.34168,13.5016 10.0217,13.1262 11.5392,11.5703 13.0758,10.0334 13.4041,7.3641 12.3029,5.51362 13.3804,7.37778 13.0099,10.0243 11.4806,11.5117 9.97389,13.0216 7.3381,13.3469 5.52358,12.2636 3.70304,11.2166 2.71546,8.79333 3.26577,6.78706 2.74178,8.80014 3.76355,11.1917 5.5646,12.1933 7.35705,13.2351 9.93804,12.8727 11.3654,11.3964 12.8222,9.94974 13.1375,7.37946 12.09,5.63667 13.1138,7.39314 12.7564,9.94061 11.3068,11.3378 9.8902,12.7681 7.35345,13.0804 5.64663,12.0507 3.92578,11.0697 2.97483,8.73701 3.5021,6.84761 3.00115,8.74381 3.98629,11.0449 5.68764,11.9804 7.3724,12.9685 9.85435,12.6191 11.1915,11.2226 12.5687,9.86605 12.871,7.39482 11.8771,5.75972 12.8473,7.4085 12.5029,9.85692 11.133,11.164 9.80651,12.5146 7.36881,12.8138 5.76967,11.8378 4.14852,10.9229 3.23615,8.68263 3.74038,6.91011 3.26248,8.68944 4.20903,10.898 5.81069,11.7675 7.38776,12.702 9.77065,12.3656 11.0177,11.0488 12.3152,9.78235 12.6045,7.41019 11.6642,5.88276 12.5808,7.42387 12.2494,9.77322 10.9591,10.9902 9.72281,12.2611 7.38417,12.5473 5.89272,11.6249 4.37125,10.776 3.49748,8.62631 3.97866,6.97065 3.52413,8.63319 4.43201,10.7498 5.93374,11.5527 7.40284,12.433 9.68601,12.1097 10.8419,10.873 12.0588,9.69723 12.3356,7.42595 11.4494,6.00776 12.3234,7.43297 12.0258,9.69328 10.8126,10.8437 9.66222,12.0569 7.40191,12.3545 5.9767,11.4804 4.50712,10.6832 3.63409,8.57548 4.10952,6.97261 4.49922,5.34676 6.30735,3.95946 7.97866,4.00386L7.97866,3.99994C7.97932,3.99994 7.97999,3.99994 7.98066,3.99994 8.37116,3.9997 8.74559,3.84446 9.02172,3.56834 9.29784,3.29221 9.45307,2.91778 9.45331,2.52728 9.45307,2.13679 9.29784,1.76235 9.02171,1.48623 8.74559,1.21011 8.37116,1.05487 7.98066,1.05463 7.97999,1.05463 7.97932,1.05463 7.97866,1.05463z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Window.Resources>
<Grid>
<Border Background="#fafafa" BorderBrush="#3b82f6" BorderThickness="2" CornerRadius="24,12,24,24" Margin="12">
<modern:SimpleStackPanel Orientation="Vertical" Spacing="2">
<Grid Margin="16,12">
<Border Name="ScreenshotPanel" VerticalAlignment="Bottom" Height="180" Width="430" Background="#fafafa" BorderBrush="#3b82f6" BorderThickness="2" CornerRadius="24,12,24,24" Margin="0,0,0,32">
<Grid>
<Grid>
<modern:SimpleStackPanel Name="MainFuncPanel" Orientation="Vertical" Spacing="2">
<Grid Margin="13.5,16,13.5,6">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Name="FullScreenIcon" Margin="0,0,4,0" Grid.Column="0" CornerRadius="18" Background="#1618181b" Height="78">
<Border Name="FullScreenIcon" Margin="2.5,0,2.5,0" Grid.Column="0" CornerRadius="16" Background="#1618181b" Height="78">
<modern:SimpleStackPanel Spacing="2" Orientation="Vertical" VerticalAlignment="Center">
<Image Width="40" Height="40">
<Image.Source>
@ -33,7 +54,7 @@
<TextBlock Name="FullScreenIconText" Text="全屏截图" FontSize="14" HorizontalAlignment="Center"></TextBlock>
</modern:SimpleStackPanel>
</Border>
<Border Name="WindowIcon" Margin="4,0,4,0" Grid.Column="1" CornerRadius="18" Background="#1618181b" Height="78">
<Border Name="WindowIcon" Margin="2.5,0,2.5,0" Grid.Column="1" CornerRadius="16" Background="#1618181b" Height="78">
<modern:SimpleStackPanel Spacing="2" Orientation="Vertical" VerticalAlignment="Center">
<Image Width="40" Height="40">
<Image.Source>
@ -49,7 +70,7 @@
<TextBlock Name="WindowIconText" Text="窗口截图" FontSize="14" HorizontalAlignment="Center"></TextBlock>
</modern:SimpleStackPanel>
</Border>
<Border Name="SelectionIcon" Margin="4,0,0,0" Grid.Column="2" CornerRadius="18" Background="#1618181b" Height="78">
<Border Name="SelectionIcon" Margin="2.5,0,2.5,0" Grid.Column="2" CornerRadius="16" Background="#1618181b" Height="78">
<modern:SimpleStackPanel Spacing="2" Orientation="Vertical" VerticalAlignment="Center">
<Image Width="40" Height="40">
<Image.Source>
@ -65,43 +86,97 @@
<TextBlock Name="SelectionIconText" Text="选区截图" FontSize="14" HorizontalAlignment="Center"></TextBlock>
</modern:SimpleStackPanel>
</Border>
</Grid>
<Grid>
<Border Name="CaptureButton" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" Margin="20,0,0,0" Height="72" Width="72" CornerRadius="36" BorderBrush="#2563eb" BorderThickness="5">
<Border.RenderTransform>
<ScaleTransform ScaleX="1" ScaleY="1"></ScaleTransform>
</Border.RenderTransform>
<Border Height="52" Width="52" CornerRadius="24" Background="#2563eb">
<Image Width="28" Height="28">
<Border Name="DesktopIcon" Margin="2.5,0,2.5,0" Grid.Column="3" CornerRadius="16" Background="#1618181b" Height="78">
<modern:SimpleStackPanel Spacing="2" Orientation="Vertical" VerticalAlignment="Center">
<Image Width="40" Height="40">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="White" Geometry="F1 M24,24z M0,0z M15,3C15.5046,2.99984 15.9906,3.19041 16.3605,3.5335 16.7305,3.87659 16.9572,4.34684 16.995,4.85L17,5C17,5.24493 17.09,5.48134 17.2527,5.66437 17.4155,5.84741 17.6397,5.96434 17.883,5.993L18,6 19,6C19.7652,5.99996 20.5015,6.29233 21.0583,6.81728 21.615,7.34224 21.9501,8.06011 21.995,8.824L22,9 22,18C22,18.7652 21.7077,19.5015 21.1827,20.0583 20.6578,20.615 19.9399,20.9501 19.176,20.995L19,21 5,21C4.23479,21 3.49849,20.7077 2.94174,20.1827 2.38499,19.6578 2.04989,18.9399 2.005,18.176L2,18 2,9C1.99996,8.23479 2.29233,7.49849 2.81728,6.94174 3.34224,6.38499 4.06011,6.04989 4.824,6.005L5,6 6,6C6.26522,6 6.51957,5.89464 6.70711,5.70711 6.89464,5.51957 7,5.26522 7,5 6.99984,4.49542 7.19041,4.00943 7.5335,3.63945 7.87659,3.26947 8.34685,3.04284 8.85,3.005L9,3 15,3z M12,10C11.2566,9.99994 10.5396,10.2759 9.98813,10.7744 9.43662,11.2729 9.08984,11.9584 9.015,12.698L9.004,12.85 9,13 9.004,13.15C9.03335,13.7362 9.23402,14.301 9.58117,14.7743 9.92832,15.2476 10.4067,15.6087 10.957,15.8128 11.5074,16.0169 12.1055,16.0551 12.6773,15.9226 13.2491,15.7901 13.7695,15.4928 14.174,15.0675 14.5786,14.6422 14.8494,14.1076 14.9531,13.5298 15.0568,12.9521 14.9887,12.3566 14.7572,11.8172 14.5258,11.2778 14.1412,10.8181 13.6511,10.4951 13.1611,10.1721 12.587,9.99995 12,10z" />
<GeometryDrawing Brush="#18181b" Geometry="F0 M24,24z M0,0z M2.58579,3.58579C2.96086,3.21071,3.46957,3,4,3L20,3C20.5304,3 21.0391,3.21071 21.4142,3.58579 21.7893,3.96086 22,4.46957 22,5L22,13C22,13.5523 21.5523,14 21,14 20.4477,14 20,13.5523 20,13L20,5 4,5 4,15 9,15 12.5,15C13.0523,15 13.5,15.4477 13.5,16 13.5,16.5523 13.0523,17 12.5,17L10,17 10,19 12.5,19C13.0523,19 13.5,19.4477 13.5,20 13.5,20.5523 13.0523,21 12.5,21L9,21 7,21C6.44772,21 6,20.5523 6,20 6,19.4477 6.44772,19 7,19L8,19 8,17 4,17C3.46957,17 2.96086,16.7893 2.58579,16.4142 2.21071,16.0391 2,15.5304 2,15L2,5C2,4.46957,2.21071,3.96086,2.58579,3.58579z M20,19.4142L16.7071,22.7071C16.3166,23.0976 15.6834,23.0976 15.2929,22.7071 14.9024,22.3166 14.9024,21.6834 15.2929,21.2929L18.5858,18 16.5,18C15.9477,18 15.5,17.5523 15.5,17 15.5,16.4477 15.9477,16 16.5,16L20.9993,16 21,16C21.001,16 21.002,16 21.003,16 21.1375,16.0004 21.2657,16.0273 21.3828,16.0759 21.5007,16.1247 21.6112,16.197 21.7071,16.2929 21.8902,16.476 21.9874,16.7123 21.9989,16.952 21.9996,16.968 22,16.984 22,17 22,17.0003 22,17.0007 22,17.001L22,21.5C22,22.0523 21.5523,22.5 21,22.5 20.4477,22.5 20,22.0523 20,21.5L20,19.4142z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Name="DesktopIconText" Text="显示桌面" FontSize="14" HorizontalAlignment="Center"></TextBlock>
</modern:SimpleStackPanel>
</Border>
</Border>
<modern:SimpleStackPanel Orientation="Vertical" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0">
</Grid>
<Grid>
<modern:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="24">
<modern:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<CheckBox MinWidth="0" Name="ToggleSwitchAutoHideToolbar" IsChecked="True" FontWeight="Bold"/>
<TextBlock Foreground="#18181b" Text="截图时隐藏ICC" VerticalAlignment="Center"
<CheckBox MinWidth="0" Name="ToggleSwitchCopyToClipBoard" IsChecked="True" FontWeight="Bold"/>
<Image Width="18" Height="18" Margin="0,0,3,0">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#18181b" Geometry="F0 M24,24z M0,0z M4,5C4,4.45228,4.45228,4,5,4L15,4C15.1876,4 15.266,4.04268 15.3156,4.07864 15.3868,4.13032 15.4886,4.23877 15.626,4.486 15.8945,4.96868 16.5033,5.14237 16.986,4.87396 17.4687,4.60554 17.6424,3.99667 17.374,3.514 17.1694,3.14623 16.8962,2.75468 16.4904,2.46011 16.063,2.14982 15.5624,2 15,2L5,2C3.34772,2,2,3.34772,2,5L2,15 2,15.0024C2.00128,15.5315 2.1422,16.0508 2.40853,16.5079 2.67485,16.965 3.05714,17.3437 3.51674,17.6057 3.99654,17.8793 4.60722,17.7121 4.88075,17.2323 5.15427,16.7525 4.98705,16.1418 4.50726,15.8683 4.35355,15.7806 4.2257,15.654 4.13662,15.5011 4.04772,15.3485 4.0006,15.1752 4,14.9986L4,5z M8.48825,8.48825C8.80088,8.17563,9.22488,8,9.667,8L18.333,8C18.5519,8 18.7687,8.04312 18.9709,8.12689 19.1732,8.21067 19.357,8.33346 19.5117,8.48825 19.6665,8.64305 19.7893,8.82682 19.8731,9.02907 19.9569,9.23132 20,9.44808 20,9.667L20,18.333C20,18.5519 19.9569,18.7687 19.8731,18.9709 19.7893,19.1732 19.6665,19.3569 19.5117,19.5117 19.3569,19.6665 19.1732,19.7893 18.9709,19.8731 18.7687,19.9569 18.5519,20 18.333,20L9.667,20C9.44808,20 9.23132,19.9569 9.02907,19.8731 8.82682,19.7893 8.64305,19.6665 8.48825,19.5117 8.33346,19.357 8.21067,19.1732 8.12689,18.9709 8.04312,18.7687 8,18.5519 8,18.333L8,9.667C8,9.22488,8.17563,8.80088,8.48825,8.48825z M9.667,6C8.69445,6 7.76174,6.38634 7.07404,7.07404 6.38634,7.76174 6,8.69445 6,9.667L6,18.333C6,18.8146 6.09485,19.2914 6.27913,19.7363 6.46342,20.1812 6.73353,20.5854 7.07404,20.926 7.41455,21.2665 7.8188,21.5366 8.2637,21.7209 8.7086,21.9052 9.18544,22 9.667,22L18.333,22C18.8146,22 19.2914,21.9052 19.7363,21.7209 20.1812,21.5366 20.5854,21.2665 20.926,20.926 21.2665,20.5854 21.5366,20.1812 21.7209,19.7363 21.9052,19.2914 22,18.8146 22,18.333L22,9.667C22,9.18544 21.9052,8.7086 21.7209,8.2637 21.5366,7.8188 21.2665,7.41455 20.926,7.07404 20.5854,6.73353 20.1812,6.46342 19.7363,6.27913 19.2914,6.09485 18.8146,6 18.333,6L9.667,6z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Foreground="#18181b" Text="复制到剪贴板" VerticalAlignment="Center"
FontSize="14" />
</modern:SimpleStackPanel>
<modern:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<CheckBox MinWidth="0" Name="ToggleSwitchAttachInk" IsChecked="True"
FontFamily="Microsoft YaHei UI" FontWeight="Bold"/>
<Image Width="18" Height="18" Margin="0,0,3,0">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#18181b" Geometry="F0 M24,24z M0,0z M18.0959,19.9954C18.1916,19.9863,18.2834,19.9638,18.3693,19.9296L18.0959,19.9954z" />
<GeometryDrawing Brush="#18181b" Geometry="F0 M24,24z M0,0z M18,2C16.3267,2,15,3.32672,15,5L15,7 15,17C15,17.2652,15.1054,17.5196,15.2929,17.7071L15.5858,18 5,18C4.73478,18 4.48043,17.8946 4.29289,17.7071 4.10536,17.5196 4,17.2652 4,17 4,16.7348 4.10536,16.4804 4.29289,16.2929 4.48043,16.1054 4.73478,16 5,16L9,16C9.79565,16 10.5587,15.6839 11.1213,15.1213 11.6839,14.5587 12,13.7957 12,13 12,12.2043 11.6839,11.4413 11.1213,10.8787 10.5587,10.3161 9.79565,10 9,10L6,10C5.44772,10 5,10.4477 5,11 5,11.5523 5.44772,12 6,12L9,12C9.26522,12 9.51957,12.1054 9.70711,12.2929 9.89464,12.4804 10,12.7348 10,13 10,13.2652 9.89464,13.5196 9.70711,13.7071 9.51957,13.8946 9.26522,14 9,14L5,14C4.20435,14 3.44129,14.3161 2.87868,14.8787 2.31607,15.4413 2,16.2044 2,17 2,17.7956 2.31607,18.5587 2.87868,19.1213 3.44129,19.6839 4.20435,20 5,20L18,20C18.0171,20 18.0341,19.9996 18.051,19.9987 18.0659,19.9979 18.0809,19.9969 18.0959,19.9954L18.3693,19.9296C18.4923,19.8808,18.6076,19.8066,18.7071,19.7071L20.7071,17.7071C20.8946,17.5196,21,17.2652,21,17L21,5C21,3.32672,19.6733,2,18,2z M18,4C17.4313,4,17,4.43128,17,5L17,6 19,6 19,5C19,4.43128,18.5687,4,18,4z M17,16.5858L18,17.5858 19,16.5858 19,8 17,8 17,16.5858z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Foreground="#18181b" Text="附带批注墨迹" VerticalAlignment="Center"
FontSize="14" />
</modern:SimpleStackPanel>
</modern:SimpleStackPanel>
</Grid>
</modern:SimpleStackPanel>
<Border Padding="0,0,0,24" CornerRadius="24" Background="#88FFFFFF" Name="LoadingOverlay" Visibility="Collapsed">
<modern:SimpleStackPanel RenderTransformOrigin="0.5,0.5" Orientation="Vertical" Spacing="8" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Width="32" Height="32" Source="{StaticResource LoadingBlackDrawingImage}">
<Image.RenderTransform>
<RotateTransform CenterX="16" CenterY="16" />
</Image.RenderTransform>
<Image.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)"
To="360" Duration="0:0:1.5" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
<TextBlock FontSize="14" Foreground="#1b1b1f" VerticalAlignment="Center" Text="截图中..."></TextBlock>
</modern:SimpleStackPanel>
</Border>
<Border MouseDown="CloseButton_CloseWindow" BorderBrush="#2563eb" BorderThickness="1" Width="32" Height="32" CornerRadius="16" Background="#3b82f6" HorizontalAlignment="Right" VerticalAlignment="Top">
</Grid>
<Border VerticalAlignment="Bottom" Height="34" CornerRadius="0,0,24,24" Background="#f4f4f5" BorderBrush="#d4d4d8" BorderThickness="0,1,0,0" Padding="24,0">
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Width="230">
<TextBlock VerticalAlignment="Center" FontSize="12" Foreground="#52525b" TextTrimming="CharacterEllipsis" Text="Screenshot-2024-01-02-23-45-12.png"/>
</StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center" FontSize="12" Foreground="#52525b" Margin="0,-0.5,4,0" FontWeight="Bold" Text="保存路径: "/>
<Image Width="16" Height="16" VerticalAlignment="Center" Source="../Resources/Icons-png/classic-icons/desktop-small-icon.png"></Image>
<TextBlock VerticalAlignment="Center" FontSize="12" Foreground="#52525b" Margin="4,-0.5,0,0" Text="桌面"/>
</StackPanel>
</Grid>
</Border>
<Border MouseDown="CloseButton_CloseWindow" Margin="-16" BorderBrush="#2563eb" BorderThickness="1" Width="32" Height="32" CornerRadius="16" Background="#3b82f6" HorizontalAlignment="Right" VerticalAlignment="Top">
<Image Height="21" Width="21">
<Image.Source>
<DrawingImage>
@ -115,4 +190,92 @@
</Image>
</Border>
</Grid>
</Border>
<Border Name="WindowScreenshotOverlay" Background="#dd09090b" Visibility="Visible">
<Grid>
<modern:SimpleStackPanel Margin="48,36" Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Top">
<TextBlock Text="窗口截图" FontWeight="Bold" Foreground="White" FontSize="48"/>
<TextBlock Text="点击需要截取的窗口即可截图" Margin="0,8,0,0" Foreground="#d4d4d8" FontSize="18"/>
<StackPanel Name="NeedAdminTextPanel" Orientation="Horizontal" Margin="0,8,0,0">
<Image VerticalAlignment="Center" Width="26" Height="26" Source="../Resources/Icons-png/uac_icon.png"/>
<TextBlock FontWeight="Bold" VerticalAlignment="Center" Text="您当前未以管理员权限运行 icc ,这会导致部分以管理员权限运行的程序窗口无法被截取" Margin="6,0,0,0" Foreground="White" FontSize="18"/>
</StackPanel>
</modern:SimpleStackPanel>
<Grid Name="WindowScreenshotWindowsGrid">
<modern:ScrollViewerEx Name="WindowsItemsScrollViewer" PreviewMouseWheel="WindowsItemsScrollViewer_PreviewMouseWheel" IsManipulationEnabled="True" VerticalScrollBarVisibility="Hidden" Margin="36,178,36,0">
<ItemsControl Name="WindowsItemsControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Margin="0,0,0,56" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<modern:SimpleStackPanel Visibility="{Binding Visibility}" Width="{Binding Width}" Tag="{Binding}" Orientation="Vertical" Margin="14">
<Grid Height="24">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,0,0">
<Image Width="24" Height="24" Source="{Binding Icon}"/>
<TextBlock Foreground="White" Width="{Binding TextBlockWidth}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="8,0,0,0" FontSize="17" Text="{Binding Title}"/>
</StackPanel>
</Grid>
<Grid Margin="0,6,0,0">
<Image Height="226" Source="{Binding Snapshot}"/>
<Border BorderBrush="#991b1b" BorderThickness="2" Background="#18181b" Visibility="{Binding ShouldDisplayFailedBorder}" Height="226" Width="{Binding Width}">
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
<Image HorizontalAlignment="Center" Height="32" Width="32" Source="../Resources/Icons-png/uac_icon.png"/>
<TextBlock HorizontalAlignment="Center" Foreground="White" FontWeight="Bold" FontSize="18" Margin="0,6,0,0">无法截取</TextBlock>
<TextBlock HorizontalAlignment="Center" Foreground="#d4d4d8" FontSize="14" Margin="0,6,0,0">ICC的权限不足</TextBlock>
</StackPanel>
</Border>
</Grid>
</modern:SimpleStackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</modern:ScrollViewerEx>
</Grid>
<Border Padding="0,0,0,24" CornerRadius="24" Background="#8809090b" Name="WindowsSnapshotLoadingOverlay" Visibility="Collapsed">
<modern:SimpleStackPanel RenderTransformOrigin="0.5,0.5" Orientation="Vertical" Spacing="8" VerticalAlignment="Center" HorizontalAlignment="Center">
<Image Width="32" Height="32" Source="{StaticResource LoadingWhiteDrawingImage}">
<Image.RenderTransform>
<RotateTransform CenterX="16" CenterY="16" />
</Image.RenderTransform>
<Image.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(Image.RenderTransform).(RotateTransform.Angle)"
To="360" Duration="0:0:1.5" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
<TextBlock FontSize="14" Foreground="White" VerticalAlignment="Center" Text="加载中..."></TextBlock>
</modern:SimpleStackPanel>
</Border>
<Border Padding="16,0" Height="56" VerticalAlignment="Bottom" Background="#18181b" BorderBrush="#3f3f46" BorderThickness="0,2,0,0">
<modern:SimpleStackPanel Orientation="Horizontal" Spacing="48">
<Border Name="EscBorder" Padding="12,0">
<modern:SimpleStackPanel Orientation="Horizontal" Spacing="10" Height="56">
<Image Height="28" VerticalAlignment="Center">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V33 H79 V0 H0 Z">
<GeometryDrawing Brush="#FFFFFFFF" Geometry="F0 M79,33z M0,0z M16.6025,0.119141C7.76598,0.119141 0.602539,7.28258 0.602539,16.1191 0.602539,24.9557 7.76598,32.1191 16.6025,32.1191L62.6025,32.1191C71.4391,32.1191 78.6025,24.9557 78.6025,16.1191 78.6025,7.28258 71.4391,0.119141 62.6025,0.119141L16.6025,0.119141z M39.1369,7.52734C39.9529,7.52734 40.8409,7.57534 41.8009,7.67134 42.7609,7.75134 43.6969,7.92734 44.6089,8.19934L44.3689,10.6233C43.6649,10.6073 42.8409,10.5913 41.8969,10.5753 40.9529,10.5593 40.0249,10.5513 39.1129,10.5513 38.6649,10.5513 38.2809,10.5673 37.9609,10.5993 37.6569,10.6153 37.4089,10.6793 37.2169,10.7913 37.0249,10.8873 36.8889,11.0393 36.8089,11.2473 36.7289,11.4553 36.6889,11.7433 36.6889,12.1113 36.6889,12.6713 36.8169,13.0793 37.0729,13.3353 37.3449,13.5913 37.8009,13.8233 38.4409,14.0313L41.6329,15.0633C42.9609,15.5113 43.8809,16.1193 44.3929,16.8873 44.9049,17.6553 45.1609,18.6633 45.1609,19.9113 45.1609,20.8553 45.0489,21.6393 44.8249,22.2633 44.6009,22.8873 44.2489,23.3753 43.7689,23.7273 43.2889,24.0793 42.6569,24.3273 41.8729,24.4713 41.0889,24.6313 40.1289,24.7113 38.9929,24.7113 38.4489,24.7113 37.6729,24.6713 36.6649,24.5913 35.6569,24.5273 34.5049,24.3513 33.2089,24.0633L33.4489,21.4713C34.3929,21.4873 35.2089,21.5113 35.8969,21.5433 36.6009,21.5593 37.2009,21.5753 37.6969,21.5913L38.9929,21.5913C39.6329,21.5913 40.1289,21.5513 40.4809,21.4713 40.8489,21.3913 41.1049,21.2313 41.2489,20.9913 41.3929,20.7513 41.4649,20.4073 41.4649,19.9593 41.4649,19.5753 41.4089,19.2713 41.2969,19.0473 41.2009,18.8073 41.0329,18.6233 40.7929,18.4953 40.5689,18.3513 40.2569,18.2233 39.8569,18.1113L36.4969,16.9593C35.2329,16.4953 34.3369,15.8873 33.8089,15.1353 33.2809,14.3833 33.0169,13.3913 33.0169,12.1593 33.0169,11.1993 33.1289,10.4233 33.3529,9.83134 33.5929,9.22334 33.9529,8.75134 34.4329,8.41534 34.9289,8.07934 35.5609,7.84734 36.3289,7.71934 37.1129,7.59134 38.0489,7.52734 39.1369,7.52734z M23.1979,7.76734C24.0939,7.76734 24.9979,7.77534 25.9099,7.79134 26.8219,7.79134 27.7179,7.80734 28.5979,7.83934 29.4779,7.87134 30.3019,7.92734 31.0699,8.00734L30.9019,10.6713 24.5419,10.6713C24.1419,10.6713 23.8379,10.7753 23.6299,10.9833 23.4379,11.1913 23.3419,11.4953 23.3419,11.8953L23.3419,14.4873 30.0139,14.4873 30.0139,17.0793 23.3419,17.0793 23.3419,20.3433C23.3419,20.7433 23.4379,21.0473 23.6299,21.2553 23.8379,21.4633 24.1419,21.5673 24.5419,21.5673L30.9019,21.5673 31.0699,24.2313C30.3019,24.2953 29.4779,24.3513 28.5979,24.3993 27.7179,24.4313 26.8219,24.4473 25.9099,24.4473 24.9979,24.4633 24.0939,24.4713 23.1979,24.4713 22.1419,24.4713 21.2859,24.1673 20.6299,23.5593 19.9899,22.9353 19.6699,22.1273 19.6699,21.1353L19.6699,11.1033C19.6699,10.0953 19.9899,9.28734 20.6299,8.67934 21.2859,8.07134 22.1419,7.76734 23.1979,7.76734z M56.1994,7.62334C55.6554,7.57534 54.9914,7.55134 54.2074,7.55134 52.4954,7.55134 51.1194,7.83134 50.0794,8.39134 49.0554,8.93534 48.3114,9.83134 47.8474,11.0793 47.3994,12.3273 47.1754,14.0073 47.1754,16.1193 47.1754,18.2313 47.3994,19.9113 47.8474,21.1593 48.3114,22.4073 49.0554,23.3113 50.0794,23.8713 51.1194,24.4153 52.4954,24.6873 54.2074,24.6873 55.3914,24.6873 56.3834,24.6313 57.1834,24.5193 57.9834,24.4233 58.7674,24.2553 59.5354,24.0153L59.2234,21.3273C58.4874,21.4073 57.7434,21.4633 56.9914,21.4953 56.2394,21.5273 55.3114,21.5433 54.2074,21.5433 53.3914,21.5433 52.7514,21.3833 52.2874,21.0633 51.8394,20.7433 51.5194,20.1913 51.3274,19.4073 51.1354,18.6073 51.0394,17.5113 51.0394,16.1193 51.0394,14.7273 51.1354,13.6393 51.3274,12.8553 51.5194,12.0553 51.8394,11.4953 52.2874,11.1753 52.7514,10.8553 53.3914,10.6953 54.2074,10.6953 54.9114,10.6953 55.5114,10.7033 56.0074,10.7193 56.5194,10.7193 56.9914,10.7273 57.4234,10.7433 57.8714,10.7593 58.3594,10.7833 58.8874,10.8153L59.1754,8.12734C58.6794,7.98334 58.1994,7.87134 57.7354,7.79134 57.2714,7.71134 56.7594,7.65534 56.1994,7.62334z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="18" Foreground="White" VerticalAlignment="Center" Text="退出窗口截图"/>
</modern:SimpleStackPanel>
</Border>
</modern:SimpleStackPanel>
</Border>
</Grid>
</Border>
</Grid>
</Window>

View File

@ -1,10 +1,13 @@
using System;
using Ink_Canvas.Helpers;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -16,11 +19,15 @@ using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Shell;
using System.Xml.Linq;
using Vanara.PInvoke;
using Color = System.Windows.Media.Color;
using Shell32;
using static Ink_Canvas.MainWindow;
namespace Ink_Canvas.Popups
{
@ -30,45 +37,186 @@ namespace Ink_Canvas.Popups
public partial class ScreenshotWindow : Window {
private MainWindow mainWindow;
private Settings settings;
public ScreenshotWindow(MainWindow mainWin) {
public ScreenshotWindow(MainWindow mainWin, Settings s) {
InitializeComponent();
mainWindow = mainWin;
settings = s;
iconList = new Border[] {
FullScreenIcon,
WindowIcon,
SelectionIcon
};
iconGeometryList = new GeometryDrawing[] {
FullScreenIconGeometry,
WindowIconsGeometry,
SelectionIconGeometry,
};
iconTextList = new TextBlock[] {
FullScreenIconText,
WindowIconText,
SelectionIconText,
SelectionIcon,
DesktopIcon
};
foreach (var b in iconList) {
b.MouseLeave += IconMouseLeave;
b.MouseUp += IconMouseUp;
b.MouseDown += IconMouseDown;
b.Background = new SolidColorBrush(Colors.Transparent);
}
CaptureButton.MouseUp += CaptureButton_MouseUp;
CaptureButton.MouseDown += CaptureButton_MouseDown;
CaptureButton.MouseLeave += CaptureButton_MouseLeave;
UpdateModeIconSelection();
ReArrangeWindowPosition();
mainWin.Hide();
if (DwmCompositionHelper.DwmIsCompositionEnabled()) {
AllowsTransparency = false;
Background = new SolidColorBrush(Colors.Transparent);
WindowChrome.SetWindowChrome(this, new WindowChrome() {
GlassFrameThickness = new Thickness(-1),
CaptionHeight = 0,
CornerRadius = new CornerRadius(0),
ResizeBorderThickness = new Thickness(0),
});
} else {
AllowsTransparency = true;
Background = new SolidColorBrush(Color.FromArgb(1,0,0,0));
}
ToggleSwitchCopyToClipBoard.IsChecked = settings.Snapshot.CopyScreenshotToClipboard;
ToggleSwitchAttachInk.IsChecked = settings.Snapshot.AttachInkWhenScreenshot;
ToggleSwitchCopyToClipBoard.Checked += ToggleSwitchCopyToClipBoard_CheckChanged;
ToggleSwitchCopyToClipBoard.Unchecked += ToggleSwitchCopyToClipBoard_CheckChanged;
ToggleSwitchAttachInk.Checked += ToggleSwitchAttachInk_CheckChanged;
ToggleSwitchAttachInk.Unchecked += ToggleSwitchAttachInk_CheckChanged;
WindowsItemsControl.ItemsSource = _winInfos;
WindowScreenshotOverlay.Visibility = Visibility.Collapsed;
WindowsSnapshotLoadingOverlay.Visibility = Visibility.Collapsed;
EscBorder.MouseDown += EscBorder_MouseDown;
EscBorder.MouseUp += EscBorder_MouseUp;
EscBorder.MouseLeave += EscBorder_MouseLeave;
var identity = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(identity);
NeedAdminTextPanel.Visibility = principal.IsInRole(WindowsBuiltInRole.Administrator) ? Visibility.Collapsed : Visibility.Visible;
if (principal.IsInRole(WindowsBuiltInRole.Administrator)) {
WindowsItemsScrollViewer.Margin = new Thickness(36, 148, 36, 0);
} else {
WindowsItemsScrollViewer.Margin = new Thickness(36, 178, 36, 0);
}
}
private bool isEscBorderDown = false;
private void EscBorder_MouseLeave(object sender, MouseEventArgs e) {
if (!isEscBorderDown) return;
isEscBorderDown = false;
EscBorder.Background = new SolidColorBrush(Colors.Transparent);
}
private void EscBorder_MouseUp(object sender, MouseButtonEventArgs e) {
if (!isEscBorderDown) return;
if (isWindowsSnapshotLoaded == false) return;
EscBorder_MouseLeave(null, null);
ScreenshotPanel.Visibility = Visibility.Visible;
WindowScreenshotOverlay.Visibility = Visibility.Collapsed;
_winInfos.Clear();
isWindowsSnapshotLoaded = null;
}
private void EscBorder_MouseDown(object sender, MouseButtonEventArgs e) {
if (isEscBorderDown) return;
isEscBorderDown = true;
EscBorder.Background = new SolidColorBrush(Color.FromRgb(39, 39, 42));
}
private ObservableCollection<WinInfo> _winInfos = new ObservableCollection<WinInfo>();
private bool AllOneColor(Bitmap bmp)
{
// Lock the bitmap's bits.
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height);
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, bmp.PixelFormat);
// Get the address of the first line.
IntPtr ptr = bmpData.Scan0;
// Declare an array to hold the bytes of the bitmap.
int bytes = bmpData.Stride * bmp.Height;
byte[] rgbValues = new byte[bytes];
// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
bool AllOneColor = true;
for (int index = 0; index < rgbValues.Length; index++) {
//compare the current A or R or G or B with the A or R or G or B at position 0,0.
if (rgbValues[index] != rgbValues[index % 4]) {
AllOneColor= false;
break;
}
}
// Unlock the bits.
bmp.UnlockBits(bmpData);
return AllOneColor;
}
private async Task<bool> AllOneColorAsync(Bitmap bmp) {
var result = await Task.Run(() => AllOneColor(bmp));
return result;
}
private BitmapImage BitmapToImageSource(Bitmap bitmap)
{
using (MemoryStream memory = new MemoryStream())
{
bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp);
memory.Position = 0;
BitmapImage bitmapimage = new BitmapImage();
bitmapimage.BeginInit();
bitmapimage.StreamSource = memory;
bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
bitmapimage.EndInit();
return bitmapimage;
}
}
private static ImageSource IconToImageSource(Icon icon)
{
ImageSource imageSource = Imaging.CreateBitmapSourceFromHIcon(
icon.Handle,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
return imageSource;
}
private class WinInfo {
public string Title { get; set; }
public BitmapImage Snapshot { get; set; }
public ImageSource Icon { get; set; }
public HWND Handle { get; set; }
public Bitmap OriginBitmap { get; set; }
public double Width { get; set; }
public double TextBlockWidth { get; set; }
public bool IsAllOneColor { get; set; }
public bool IsDisplayFailedBorder { get; set; }
public Visibility ShouldDisplayFailedBorder {
get => IsDisplayFailedBorder ? Visibility.Visible : Visibility.Collapsed;
}
public bool IsHidden { get; set; }
public Visibility Visibility {
get => IsHidden ? Visibility.Collapsed : Visibility.Visible;
}
}
private Border lastDownIcon;
private int selectedMode = 0;
private void ToggleSwitchCopyToClipBoard_CheckChanged(object sender, RoutedEventArgs e) {
if (!mainWindow.isLoaded) return;
mainWindow.ToggleSwitchCopyScreenshotToClipboard.IsOn = ToggleSwitchCopyToClipBoard.IsChecked ?? true;
}
private void ToggleSwitchAttachInk_CheckChanged(object sender, RoutedEventArgs e) {
if (!mainWindow.isLoaded) return;
mainWindow.ToggleSwitchAttachInkWhenScreenshot.IsOn = ToggleSwitchAttachInk.IsChecked ?? true;
}
private void ReArrangeWindowPosition() {
var workAreaWidth = SystemParameters.WorkArea.Width;
@ -79,57 +227,15 @@ namespace Ink_Canvas.Popups
Top = workAreaHeight - Height - toolbarHeight - 64;
}
private void UpdateModeIconSelection() {
foreach (var b in iconList) b.Background = new SolidColorBrush(Colors.Transparent);
foreach (var g in iconGeometryList) g.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
foreach (var t in iconTextList) t.Foreground = new SolidColorBrush(Color.FromRgb(24, 24, 27));
iconList[selectedMode].Background = new SolidColorBrush(Color.FromRgb(37, 99, 235));
iconGeometryList[selectedMode].Brush = new SolidColorBrush(Colors.White);
iconTextList[selectedMode].Foreground = new SolidColorBrush(Colors.White);
}
private bool isCaptureButtonDown = false;
private void CaptureButton_MouseDown(object sender, MouseButtonEventArgs e) {
if (isCaptureButtonDown) return;
isCaptureButtonDown = true;
var sb = new Storyboard();
var animation = new DoubleAnimation {
From = 1,
To = 0.9,
Duration = TimeSpan.FromMilliseconds(200)
};
var animation2 = new DoubleAnimation {
From = 1,
To = 0.9,
Duration = TimeSpan.FromMilliseconds(200)
};
var animation3 = new ThicknessAnimation() {
From = new Thickness(5),
To = new Thickness(7),
Duration = TimeSpan.FromMilliseconds(200)
};
Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleX)"));
Storyboard.SetTargetProperty(animation2, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleY)"));
Storyboard.SetTargetProperty(animation3, new PropertyPath(Border.BorderThicknessProperty));
animation.EasingFunction = new CubicEase();
animation2.EasingFunction = new CubicEase();
animation3.EasingFunction = new CubicEase();
sb.Children.Add(animation);
sb.Children.Add(animation2);
sb.Children.Add(animation3);
sb.Begin(CaptureButton);
}
private void CaptureButton_MouseUp(object sender, MouseButtonEventArgs e) {
if (isCaptureButtonDown != true) return;
CaptureButton_MouseLeave(sender, null);
if (selectedMode == 0) CaptureFullScreen();
}
private async void CaptureFullScreen() {
LoadingOverlay.Visibility = Visibility.Visible;
MainFuncPanel.Effect = new BlurEffect() {
KernelType = KernelType.Gaussian,
Radius = 24,
RenderingBias = RenderingBias.Performance,
};
try {
var bm = await mainWindow.FullscreenSnapshot(new MainWindow.SnapshotConfig() {
BitmapSavePath =
@ -137,60 +243,30 @@ namespace Ink_Canvas.Popups
ExcludedHwnds = new HWND[] {
new HWND(new WindowInteropHelper(this).Handle)
},
IsCopyToClipboard = true,
IsCopyToClipboard = settings.Snapshot.CopyScreenshotToClipboard,
IsSaveToLocal = true,
OutputMIMEType = MainWindow.OutputImageMIMEFormat.Png,
});
bm.Dispose();
LoadingOverlay.Visibility = Visibility.Collapsed;
MainFuncPanel.Effect = null;
mainWindow.ShowNewToast("已保存截图到桌面!", MW_Toast.ToastType.Success, 3000);
await Task.Delay(1);
Close();
}
catch (Exception e) {
LoadingOverlay.Visibility = Visibility.Collapsed;
MainFuncPanel.Effect = null;
mainWindow.ShowNewToast($"截图失败!{e.Message}", MW_Toast.ToastType.Error, 3000);
await Task.Delay(1);
Close();
}
}
private void CaptureButton_MouseLeave(object sender, MouseEventArgs e) {
if (isCaptureButtonDown != true) return;
var sb = new Storyboard();
var animation = new DoubleAnimation {
From = 0.9,
To = 1,
Duration = TimeSpan.FromMilliseconds(200)
};
var animation2 = new DoubleAnimation {
From = 0.9,
To = 1,
Duration = TimeSpan.FromMilliseconds(200)
};
var animation3 = new ThicknessAnimation() {
From = new Thickness(7),
To = new Thickness(5),
Duration = TimeSpan.FromMilliseconds(200)
};
Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleX)"));
Storyboard.SetTargetProperty(animation2, new PropertyPath("(UIElement.RenderTransform).(ScaleTransform.ScaleY)"));
Storyboard.SetTargetProperty(animation3, new PropertyPath(Border.BorderThicknessProperty));
animation.EasingFunction = new CubicEase();
animation2.EasingFunction = new CubicEase();
animation3.EasingFunction = new CubicEase();
sb.Children.Add(animation);
sb.Children.Add(animation2);
sb.Children.Add(animation3);
sb.Begin(CaptureButton);
isCaptureButtonDown = false;
}
private void IconMouseLeave(object sender, MouseEventArgs e) {
if (lastDownIcon == null) return;
lastDownIcon = null;
var b = (Border)sender;
if (Array.IndexOf(iconList,b)!=selectedMode)
b.Background = new SolidColorBrush(Colors.Transparent);
}
@ -198,20 +274,18 @@ namespace Ink_Canvas.Popups
if (lastDownIcon != null) return;
lastDownIcon = (Border)sender;
var b = (Border)sender;
if (Array.IndexOf(iconList,b)!=selectedMode)
b.Background = new SolidColorBrush(Color.FromArgb(22, 24, 24, 27));
}
private WindowScreenshotGridWindow _screenshotGridWindow = null;
private bool? isWindowsSnapshotLoaded = false;
private async void IconMouseUp(object sender, MouseButtonEventArgs e) {
if (lastDownIcon == null) return;
IconMouseLeave(sender, null);
var index = Array.IndexOf(iconList, (Border)sender);
selectedMode = index;
UpdateModeIconSelection();
if (selectedMode == 1) {
/*if (selectedMode == 1) {
try {
MainWindow.WindowInformation[] windows = await mainWindow.GetAllWindowsAsync(new HWND[] {
new HWND(new WindowInteropHelper(this).Handle), new HWND(new WindowInteropHelper(mainWindow).Handle)
@ -226,12 +300,57 @@ namespace Ink_Canvas.Popups
_screenshotGridWindow.Close();
} catch (Exception ex) { }
}*/
if (Array.IndexOf(iconList, (Border)sender) == 0) {
CaptureFullScreen();
} else if (Array.IndexOf(iconList, (Border)sender) == 3) {
Shell shellObject = new Shell();
shellObject.ToggleDesktop();
} else if (Array.IndexOf(iconList, ((Border)sender)) == 1) {
isWindowsSnapshotLoaded = false;
await Dispatcher.InvokeAsync(() => {
_winInfos.Clear();
ScreenshotPanel.Visibility = Visibility.Collapsed;
WindowScreenshotOverlay.Visibility = Visibility.Visible;
WindowsSnapshotLoadingOverlay.Visibility = Visibility.Visible;
WindowScreenshotWindowsGrid.Effect = new BlurEffect() {
KernelType = KernelType.Gaussian,
RenderingBias = RenderingBias.Performance,
Radius = 32,
};
});
var wins = await mainWindow.GetAllWindowsAsync(new HWND[] {
new HWND(new WindowInteropHelper(this).Handle)
});
foreach (var windowInformation in wins) {
var bitmapHeight = windowInformation.WindowBitmap.Height;
var w = windowInformation.WindowBitmap.Width * (226D / bitmapHeight);
var allonecolor = await AllOneColorAsync(windowInformation.WindowBitmap);
_winInfos.Add(new WinInfo() {
Title = windowInformation.Title,
Snapshot = BitmapToImageSource(windowInformation.WindowBitmap.Clone(windowInformation.ContentRect,windowInformation.WindowBitmap.PixelFormat)),
Handle = windowInformation.hwnd,
OriginBitmap = windowInformation.WindowBitmap,
Icon = windowInformation.AppIcon == null ? new BitmapImage(new Uri("pack://application:,,,/Resources/Icons-png/classic-icons/program-icon.png")) : IconToImageSource(windowInformation.AppIcon),
Width = w,
TextBlockWidth = w - 48 - 8,
IsAllOneColor = allonecolor,
IsDisplayFailedBorder = allonecolor,
IsHidden = settings.Snapshot.OnlySnapshotMaximizeWindow,
});
if (Array.IndexOf(wins, windowInformation)>= wins.Length - 1) Dispatcher.InvokeAsync(() => {
WindowScreenshotWindowsGrid.Effect = null;
WindowsSnapshotLoadingOverlay.Visibility = Visibility.Collapsed;});
}
Dispatcher.InvokeAsync(() => {
WindowScreenshotWindowsGrid.Effect = null;
WindowsSnapshotLoadingOverlay.Visibility = Visibility.Collapsed;});
isWindowsSnapshotLoaded = true;
}
}
private Border[] iconList = new Border[] { };
private GeometryDrawing[] iconGeometryList = new GeometryDrawing[] { };
private TextBlock[] iconTextList = new TextBlock[] { };
private void CloseButton_CloseWindow(object sender, MouseButtonEventArgs e) {
Close();
@ -241,5 +360,35 @@ namespace Ink_Canvas.Popups
mainWindow.Show();
base.OnClosed(e);
}
private void ScreenshotWindow_OnKeyDown(object sender, KeyEventArgs e) {
if (e.Key == Key.Escape) {
if (isWindowsSnapshotLoaded==false) return;
ScreenshotPanel.Visibility = Visibility.Visible;
WindowScreenshotOverlay.Visibility = Visibility.Collapsed;
_winInfos.Clear();
isWindowsSnapshotLoaded = null;
}
}
public void WindowsItemsScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) {
var scrollViewer = (ScrollViewer)sender;
var sb = new Storyboard();
var ofs = scrollViewer.VerticalOffset;
var animation = new DoubleAnimation
{
From = ofs,
To = ofs - e.Delta * 2.5,
Duration = TimeSpan.FromMilliseconds(155)
};
animation.EasingFunction = new CubicEase() {
EasingMode = EasingMode.EaseOut,
};
Storyboard.SetTargetProperty(animation, new PropertyPath(ColorPalette.ScrollViewerBehavior.VerticalOffsetProperty));
Storyboard.SetTargetName(animation,"WindowsItemsScrollViewer");
sb.Children.Add(animation);
scrollViewer.ScrollToVerticalOffset(ofs);
sb.Begin(scrollViewer);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB