[update] ToolbarV2

This commit is contained in:
Dubi906w 2024-09-01 23:13:43 +08:00
parent afe742551e
commit 6a8220e7eb
7 changed files with 559 additions and 2 deletions

View File

@ -226,6 +226,7 @@
<Resource Include="Resources\Icons-png\eraser-outline.png" /> <Resource Include="Resources\Icons-png\eraser-outline.png" />
<Resource Include="Resources\Icons-png\HiteLightBoard.png" /> <Resource Include="Resources\Icons-png\HiteLightBoard.png" />
<Resource Include="Resources\Icons-png\ica.png" /> <Resource Include="Resources\Icons-png\ica.png" />
<Resource Include="Resources\Icons-png\icc-toolbar-v2.png" />
<Resource Include="Resources\Icons-png\icc-transparent-dark-small.png" /> <Resource Include="Resources\Icons-png\icc-transparent-dark-small.png" />
<Resource Include="Resources\Icons-png\icc-transparent-dark.png" /> <Resource Include="Resources\Icons-png\icc-transparent-dark.png" />
<Resource Include="Resources\Icons-png\icc-transparent.png" /> <Resource Include="Resources\Icons-png\icc-transparent.png" />
@ -533,6 +534,7 @@
<None Remove="Resources\Icons-png\HiteAnnotation.png" /> <None Remove="Resources\Icons-png\HiteAnnotation.png" />
<None Remove="Resources\Icons-png\HiteLightBoard.png" /> <None Remove="Resources\Icons-png\HiteLightBoard.png" />
<None Remove="Resources\Icons-png\ica.png" /> <None Remove="Resources\Icons-png\ica.png" />
<None Remove="Resources\Icons-png\icc-toolbar-v2.png" />
<None Remove="Resources\Icons-png\icc-transparent-dark-small.png" /> <None Remove="Resources\Icons-png\icc-transparent-dark-small.png" />
<None Remove="Resources\Icons-png\icc-transparent-dark.png" /> <None Remove="Resources\Icons-png\icc-transparent-dark.png" />
<None Remove="Resources\Icons-png\icc-transparent.png" /> <None Remove="Resources\Icons-png\icc-transparent.png" />

View File

@ -17,6 +17,9 @@
<Compile Update="Popups\ColorPalette.xaml.cs"> <Compile Update="Popups\ColorPalette.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Popups\FloatingToolBarV2.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Popups\ScreenshotWindow.xaml.cs"> <Compile Update="Popups\ScreenshotWindow.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@ -46,6 +49,9 @@
<Page Update="Popups\ColorPalette.xaml"> <Page Update="Popups\ColorPalette.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Popups\FloatingToolBarV2.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Popups\ScreenshotWindow.xaml"> <Page Update="Popups\ScreenshotWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>

View File

@ -270,6 +270,9 @@ namespace Ink_Canvas {
new HWND(new WindowInteropHelper(this).Handle) new HWND(new WindowInteropHelper(this).Handle)
}); });
var ftv2 = new FloatingToolBarV2();
ftv2.Show();
UpdateIndexInfoDisplay(); UpdateIndexInfoDisplay();
} }

View File

@ -195,7 +195,9 @@ namespace Ink_Canvas {
if (isFloatingBarChangingHideMode) return; if (isFloatingBarChangingHideMode) return;
try { try {
var windowProcessName = ForegroundWindowInfo.ProcessName(); var windowProcessName = ForegroundWindowInfo.ProcessName();
Trace.WriteLine(windowProcessName);
var windowTitle = ForegroundWindowInfo.WindowTitle(); var windowTitle = ForegroundWindowInfo.WindowTitle();
Trace.WriteLine(windowTitle);
//LogHelper.WriteLogToFile("windowTitle | " + windowTitle + " | windowProcessName | " + windowProcessName); //LogHelper.WriteLogToFile("windowTitle | " + windowTitle + " | windowProcessName | " + windowProcessName);
if (windowProcessName == "EasiNote") { if (windowProcessName == "EasiNote") {
@ -207,8 +209,7 @@ namespace Ink_Canvas {
Trace.WriteLine(ForegroundWindowInfo.ProcessPath()); Trace.WriteLine(ForegroundWindowInfo.ProcessPath());
Trace.WriteLine(version); Trace.WriteLine(version);
Trace.WriteLine(prodName); Trace.WriteLine(prodName);
if (version.StartsWith("5.") && Settings.Automation.IsAutoFoldInEasiNote && (!(windowTitle.Length == 0 && ForegroundWindowInfo.WindowRect().Height < 500) || if (version.StartsWith("5.") && Settings.Automation.IsAutoFoldInEasiNote ) { // EasiNote5
!Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno)) { // EasiNote5
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null); if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);
} else if (version.StartsWith("3.") && Settings.Automation.IsAutoFoldInEasiNote3) { // EasiNote3 } else if (version.StartsWith("3.") && Settings.Automation.IsAutoFoldInEasiNote3) { // EasiNote3
if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null); if (!unfoldFloatingBarByUser && !isFloatingBarFolded) FoldFloatingBar_MouseUp(null, null);

View File

@ -0,0 +1,184 @@
<Window x:Class="Ink_Canvas.FloatingToolBarV2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Ink_Canvas"
mc:Ignorable="d" WindowStyle="None" Background="Transparent" AllowsTransparency="True" ResizeMode="NoResize"
Title="FloatingToolBarV2">
<Window.Resources>
<DrawingImage x:Key="CursorIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V22 H22 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M22,22z M0,0z M21.7989,9.16526L0.143036,0.143036 9.16526,21.7989 11.8305,13.9518 18.6892,20.8105 20.8105,18.6892 13.9518,11.8305 21.7989,9.16526z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="PenIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M20.4786,1.42438C19.9985,1.23743 19.4847,1.15194 18.9698,1.17319 18.4549,1.19444 17.9499,1.32197 17.4869,1.54789 17.0368,1.76752 16.6358,2.07554 16.3083,2.45361L3.85516,14.9067 9.08243,20.134 21.5311,7.68529C21.9113,7.36382 22.223,6.96912 22.447,6.52438 22.6786,6.06462 22.8113,5.56167 22.8365,5.04763 22.8616,4.5336 22.7787,4.02012 22.593,3.54002 22.4073,3.05994 22.1232,2.62403 21.759,2.25988 21.3949,1.89574 20.9587,1.61132 20.4786,1.42438z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M7.28056,21.1605L2.8286,16.7086 1.15912,22.83 7.28056,21.1605z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="EraserIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M15.6314,20.7262L22.7921,13.5655C24.3494,12.141,24.2819,9.81776,22.8105,8.34633L16.7793,2.31508C15.3547,0.757753,13.0315,0.825236,11.5601,2.29666L4.38099,9.47574 15.6314,20.7262z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M14.2172,22.1404L2.96677,10.89 1.20761,12.6491C-0.34971,14.0737,-0.281711,16.3974,1.18971,17.8688L6.15089,22.83 13.5276,22.83 14.2172,22.1404z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="TrashBinIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M2.15454,7.07729L2.15454,5.1082 7.07727,5.1082 7.07727,4.12365C7.07727,3.30648 7.47109,2.57791 7.98305,2.0758 8.49501,1.56383 9.22358,1.17001 10.0309,1.17001L13.9691,1.17001C14.7863,1.17001 15.5148,1.56383 16.0169,2.0758 16.5289,2.58776 16.9227,3.31632 16.9227,4.12365L16.9227,5.1082 21.8454,5.1082 21.8454,7.07729 2.15454,7.07729z" />
<GeometryDrawing Brush="#222222" Geometry="F0 M24,24z M0,0z M4.12363,19.7779C4.12363,20.6148 4.51745,21.3729 5.02941,21.8947 5.54138,22.4165 6.26994,22.83 7.07727,22.83L16.9227,22.83C17.7399,22.83 18.4685,22.4165 18.9706,21.8947 19.4825,21.3729 19.8764,20.6148 19.8764,19.7779L19.8764,8.06183 4.12363,8.06183 4.12363,19.7779z M12.9845,11.0155L14.9536,11.0155 14.9536,18.8918 12.9845,18.8918 12.9845,11.0155z M9.04636,11.0155L11.0154,11.0155 11.0154,18.8918 9.04636,18.8918 9.04636,11.0155z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="ShapesIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V17 H16 V0 H0 Z">
<GeometryDrawing Brush="#FF222222" Geometry="F1 M16,17z M0,0z M12.2976,7.55061L7.97358,0.466797 3.63956,7.55061 12.2976,7.55061z" />
<GeometryDrawing Brush="#FF222222" Geometry="F1 M16,17z M0,0z M7.18147,9.38298L0.0976562,9.38298 0.0976562,16.4668 7.18147,16.4668 7.18147,9.38298z" />
<GeometryDrawing Brush="#FF222222" Geometry="F1 M16,17z M0,0z M12.2976,9.38298C10.3414,9.38298 8.75565,10.9687 8.75565,12.9249 8.75565,14.881 10.3414,16.4668 12.2976,16.4668 14.2537,16.4668 15.8395,14.881 15.8395,12.9249 15.8395,10.9687 14.2537,9.38298 12.2976,9.38298z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="SelectIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M2.12162,2.12162C2.73093,1.51232,3.55732,1.17001,4.41901,1.17001L5.50201,1.17001 5.50201,3.33601 4.41901,3.33601C4.13178,3.33601 3.85632,3.45011 3.65321,3.65321 3.45011,3.85632 3.33601,4.13178 3.33601,4.41901L3.33601,5.50201 1.17001,5.50201 1.17001,4.41901C1.17001,3.55732,1.51232,2.73093,2.12162,2.12162z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M18.498,1.17001L19.581,1.17001C20.4427,1.17001 21.2691,1.51232 21.8784,2.12162 22.4877,2.73093 22.83,3.55732 22.83,4.41901L22.83,5.50201 20.664,5.50201 20.664,4.41901C20.664,4.13178 20.5499,3.85632 20.3468,3.65321 20.1437,3.45011 19.8682,3.33601 19.581,3.33601L18.498,3.33601 18.498,1.17001z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M3.33601,19.581L3.33601,18.498 1.17001,18.498 1.17001,19.581C1.17001,20.4427 1.51232,21.2691 2.12162,21.8784 2.73093,22.4877 3.55732,22.83 4.41901,22.83L5.50201,22.83 5.50201,20.664 4.41901,20.664C4.13178,20.664 3.85632,20.5499 3.65321,20.3468 3.45011,20.1437 3.33601,19.8682 3.33601,19.581z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M7.66801,1.17001L10.917,1.17001 10.917,3.33601 7.66801,3.33601 7.66801,1.17001z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M12,20.664L7.66801,20.664 7.66801,22.83 12,22.83 12,20.664z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M13.083,1.17001L16.332,1.17001 16.332,3.33601 13.083,3.33601 13.083,1.17001z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M3.33601,10.917L3.33601,7.66801 1.17001,7.66801 1.17001,10.917 3.33601,10.917z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M22.83,7.66801L22.83,12 20.664,12 20.664,7.66801 22.83,7.66801z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M3.33601,16.332L3.33601,13.083 1.17001,13.083 1.17001,16.332 3.33601,16.332z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M10.7469,10.747L22.83,15.781 18.4517,17.2681 22.2785,21.0949 21.0949,22.2785 17.2681,18.4517 15.781,22.83 10.7469,10.747z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="UndoIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M8.71408,16.8493L0.874451,9.00964 8.71408,1.17001 8.71408,7.42358 15.7239,7.42358C16.7074,7.42358 17.6791,7.62744 18.583,8.02124 19.4866,8.41493 20.3023,8.98966 20.9857,9.70849 21.6689,10.4271 22.2069,11.276 22.5726,12.2047 22.9383,13.1333 23.1256,14.126 23.1256,15.1268 23.1256,16.1276 22.9383,17.1203 22.5726,18.0489 22.2069,18.9776 21.6689,19.8264 20.9857,20.5451 20.3023,21.2639 19.4866,21.8387 18.583,22.2324 17.6791,22.6262 16.7074,22.83 15.7239,22.83L10.437,22.83 10.437,19.6579 15.7239,19.6579C16.2679,19.6579 16.8086,19.5453 17.3159,19.3243 17.8235,19.1031 18.29,18.7767 18.6867,18.3594 19.0835,17.942 19.4023,17.4422 19.6211,16.8866 19.8399,16.3308 19.9534,15.7326 19.9534,15.1268 19.9534,14.5209 19.8399,13.9227 19.6211,13.367 19.4023,12.8114 19.0835,12.3115 18.6867,11.8941 18.29,11.4769 17.8235,11.1505 17.3159,10.9293 16.8086,10.7083 16.2679,10.5957 15.7239,10.5957L8.71408,10.5957 8.71408,16.8493z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="RedoIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M15.2859,16.8493L23.1255,9.00964 15.2859,1.17001 15.2859,7.42358 8.27607,7.42358C7.29262,7.42358 6.32086,7.62744 5.41703,8.02124 4.51341,8.41493 3.69773,8.98966 3.01434,9.70849 2.33111,10.4271 1.79312,11.276 1.42741,12.2047 1.06174,13.1333 0.874422,14.126 0.874422,15.1268 0.874422,16.1276 1.06174,17.1203 1.42741,18.0489 1.79312,18.9776 2.33111,19.8264 3.01434,20.5451 3.69773,21.2639 4.51341,21.8387 5.41703,22.2324 6.32086,22.6262 7.29262,22.83 8.27607,22.83L13.563,22.83 13.563,19.6579 8.27607,19.6579C7.7321,19.6579 7.19139,19.5453 6.68406,19.3243 6.17652,19.1031 5.70999,18.7767 5.31333,18.3594 4.91651,17.942 4.59775,17.4422 4.37894,16.8866 4.1601,16.3308 4.04656,15.7326 4.04656,15.1268 4.04656,14.5209 4.1601,13.9227 4.37894,13.367 4.59775,12.8114 4.91651,12.3115 5.31333,11.8941 5.70999,11.4769 6.17652,11.1505 6.68406,10.9293 7.19139,10.7083 7.7321,10.5957 8.27607,10.5957L15.2859,10.5957 15.2859,16.8493z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="GestureIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F0 M24,24z M0,0z M7.82154,10.0753L7.82154,3.74613C7.82154,3.06603 8.08946,2.40655 8.57377,1.92224 9.05808,1.43793 9.70726,1.17001 10.3977,1.17001 11.0881,1.17001 11.7372,1.43793 12.2216,1.92224 12.7059,2.40655 12.9738,3.05573 12.9738,3.74613L12.9738,6.37308C13.1415,6.33947 13.3139,6.32225 13.489,6.32225 14.1794,6.32225 14.8286,6.59016 15.3129,7.07447 15.4484,7.21001 15.567,7.35845 15.6675,7.5171 15.9551,7.40916 16.2634,7.35269 16.5803,7.35269 17.2707,7.35269 17.9199,7.62061 18.4042,8.10492 18.5461,8.24683 18.6695,8.4029 18.7729,8.57001 19.6856,8.26338 20.7674,8.45871 21.4647,9.15599 21.949,9.6403 22.2169,10.2998 22.2169,10.9799L22.2169,15.6169C22.2169,17.5438 21.4647,19.3574 20.1045,20.7176 18.7443,22.0778 16.9307,22.83 15.0038,22.83L13.149,22.83C13.149,22.83 13.0039,22.83 12.7969,22.83 12.5898,22.83 10.7068,22.4694 9.75878,21.9541 8.70773,21.3874 7.81124,20.563 7.15175,19.5738L6.94566,19.2647C6.60562,18.7494 5.49273,16.8019 3.52458,13.3087 3.19484,12.7213 3.1021,12.0412 3.27727,11.3818 3.45245,10.7326 3.86463,10.1761 4.44168,9.83608 5.00842,9.49604 5.66791,9.35177 6.31709,9.43421 6.86548,9.50385 7.39181,9.7279 7.82154,10.0753z M10.037,3.38547C10.1297,3.28243 10.2637,3.23091 10.3977,3.23091 10.5316,3.23091 10.6656,3.29273 10.7583,3.38547 10.8614,3.47821 10.9129,3.61217 10.9129,3.74613L10.9129,11.4745C10.9129,12.0412 11.3766,12.5049 11.9433,12.5049 12.5101,12.5049 12.9738,12.0412 12.9738,11.4745L12.9738,8.89836C12.9738,8.7644 13.0356,8.63045 13.1283,8.53771 13.2211,8.43466 13.355,8.38314 13.489,8.38314 13.623,8.38314 13.7569,8.44497 13.8497,8.53771 13.9527,8.63045 14.0042,8.7644 14.0042,8.89836L14.0042,11.4745C14.0042,12.0412 14.4679,12.5049 15.0347,12.5049 15.6014,12.5049 16.0651,12.0412 16.0651,11.4745L16.0651,9.92881C16.0651,9.79485 16.1269,9.66089 16.2197,9.56815 16.3124,9.46511 16.4464,9.41359 16.5803,9.41359 16.7143,9.41359 16.8483,9.47541 16.941,9.56815 17.044,9.66089 17.0956,9.79485 17.0956,9.92881L17.0956,10.5869C17.0752,10.7163 17.0646,10.8477 17.0646,10.9799 17.0646,11.0661 17.0754,11.1499 17.0956,11.2301L17.0956,11.4745C17.0956,12.0412 17.5593,12.5049 18.126,12.5049 18.6928,12.5049 19.1565,12.0412 19.1565,11.4745L19.1565,10.8128C19.1834,10.7399 19.2266,10.6727 19.2801,10.6192 19.4759,10.4234 19.8159,10.4234 20.0117,10.6192 20.1148,10.712 20.1663,10.8459 20.1663,10.9799L20.1663,15.6169C20.1663,16.9977 19.6408,18.296 18.6618,19.2647 17.6829,20.2333 16.3949,20.7691 15.0141,20.7691L13.1593,20.7691C12.3143,20.7691 11.4796,20.5527 10.7274,20.1509 9.98548,19.749 9.3363,19.1616 8.8726,18.4506L8.66651,18.1415C8.35737,17.6675 7.23419,15.7096 5.31756,12.2989 5.24543,12.1752 5.23512,12.0412 5.26604,11.9073 5.30725,11.7733 5.38969,11.6703 5.50304,11.5981 5.66791,11.4951 5.874,11.4539 6.06978,11.4745 6.26557,11.5054 6.45105,11.5878 6.59531,11.7321L8.11007,13.2469C8.49419,13.631 9.10425,13.648 9.50833,13.2978 9.73651,13.1084 9.88244,12.8229 9.88244,12.5049L9.88244,3.74613C9.88244,3.61217,9.94426,3.47821,10.037,3.38547z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M2.99905,6.31195L1.78313,4.65293 2.61779,4.04497C3.46275,3.4267,4.37985,2.89087,5.33817,2.46838L6.27587,2.0459 7.12084,3.93162 6.18313,4.3541C5.35878,4.72506,4.56533,5.17846,3.83372,5.71429L2.99905,6.32225 2.99905,6.31195z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M18.2806,5.20935L19.1565,5.75549 20.259,4.01404 19.3832,3.4679C18.1157,2.67446,16.7452,2.0768,15.3026,1.68523L14.303,1.41731 13.7672,3.40607 14.7667,3.67399C16.0033,4.00373,17.1883,4.51895,18.2806,5.20935z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="MoreIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M3.336,1.17001C2.13975,1.17001,1.17,2.13976,1.17,3.33601L1.17,8.75101C1.17,9.94726,2.13975,10.917,3.336,10.917L8.751,10.917C9.94725,10.917,10.917,9.94726,10.917,8.75101L10.917,3.33601C10.917,2.13976,9.94725,1.17001,8.751,1.17001L3.336,1.17001z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M15.249,1.17001C14.0527,1.17001,13.083,2.13976,13.083,3.33601L13.083,8.75101C13.083,9.94726,14.0527,10.917,15.249,10.917L20.664,10.917C21.8602,10.917,22.83,9.94726,22.83,8.75101L22.83,3.33601C22.83,2.13976,21.8602,1.17001,20.664,1.17001L15.249,1.17001z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M3.336,13.083C2.13975,13.083,1.17,14.0528,1.17,15.249L1.17,20.664C1.17,21.8603,2.13975,22.83,3.336,22.83L8.751,22.83C9.94725,22.83,10.917,21.8603,10.917,20.664L10.917,15.249C10.917,14.0528,9.94725,13.083,8.751,13.083L3.336,13.083z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M15.249,13.083C14.0527,13.083,13.083,14.0528,13.083,15.249L13.083,20.664C13.083,21.8603,14.0527,22.83,15.249,22.83L20.664,22.83C21.8602,22.83,22.83,21.8603,22.83,20.664L22.83,15.249C22.83,14.0528,21.8602,13.083,20.664,13.083L15.249,13.083z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="FoldIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F0 M24,24z M0,0z M22.8347,21.5006L2.50417,1.17001 1.16525,2.50893 5.45737,6.80104C3.85257,8.10197 2.53265,9.72576 1.64954,11.5964 1.53559,11.8433 1.52609,12.1282 1.63055,12.3751L1.63055,12.3941C1.63055,12.4131 1.64954,12.4321 1.65904,12.4606 1.68752,12.5175 1.72551,12.5935 1.77299,12.698 1.87744,12.8974 2.01988,13.1822 2.21929,13.5146 2.61812,14.1793 3.21635,15.0719 4.04249,15.9645 5.69477,17.7497 8.30612,19.5919 11.981,19.5919 13.7282,19.5919 15.4375,19.1551 16.9568,18.31L21.4768,22.83 22.8158,21.4911 22.8347,21.5006z M11.9905,15.8791C12.5033,15.8696 13.0066,15.7556 13.4719,15.5467 13.6428,15.4707 13.7852,15.3758 13.9372,15.2808L8.72394,10.0676C8.62898,10.2195 8.53402,10.3715 8.45805,10.5329 8.24915,10.9982 8.1257,11.5015 8.1257,12.0143 8.1162,12.527 8.21116,13.0303 8.40108,13.5051 8.591,13.9799 8.87587,14.4072 9.23671,14.768 9.59755,15.1289 10.0249,15.4138 10.4997,15.6037 10.9745,15.7936 11.4777,15.8791 11.9905,15.8791z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M10.9063,6.37657C11.2749,6.33269 11.6452,6.30726 12,6.30726 14.974,6.30726 17.1134,7.78595 18.5447,9.32737 19.2601,10.0978 19.7852,10.8712 20.1309,11.4519 20.2587,11.6665 20.3611,11.8535 20.4389,12.0025 20.0809,12.6966 19.6562,13.3505 19.1703,13.9543L18.5749,14.694 20.0544,15.8848 20.6498,15.145C21.3248,14.3064 21.8966,13.387 22.3556,12.4078 22.4706,12.1625 22.475,11.8789 22.3683,11.6299L22.3669,11.6266 22.364,11.6201 22.3551,11.5998C22.3477,11.5833 22.3375,11.5605 22.3243,11.5319 22.2979,11.4748 22.2598,11.3946 22.2098,11.2945 22.1097,11.0944 21.9615,10.8142 21.7628,10.4805 21.3666,9.81482 20.7641,8.92644 19.9364,8.03508 18.2816,6.25295 15.6731,4.4081 12,4.4081 11.5572,4.4081 11.1108,4.43965 10.6818,4.49072L9.73885,4.60297 9.96336,6.48883 10.9063,6.37657z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Window.Resources>
<Grid Name="ToolbarV2" RenderTransformOrigin=".5,.5">
<Grid Name="ToolBarV2Grid" HorizontalAlignment="Left" Margin="6" Height="48">
<DockPanel>
<DockPanel.Effect>
<DropShadowEffect Opacity="0.3" ShadowDepth="1"></DropShadowEffect>
</DockPanel.Effect>
<Image DockPanel.Dock="Left" Height="48" HorizontalAlignment="Left">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V120 H63 V0 H0 Z">
<GeometryDrawing Brush="#fafafa" Geometry="F1 M63,120z M0,0z M62.6465,-0.00390625L60.3128,-0.00390625C34.3338,-0.00390625 21.3443,-0.00390625 12.5491,7.09435 10.7817,8.52078 9.17117,10.1313 7.74474,11.8988 0.646484,20.6939 0.646484,33.6834 0.646484,59.6624 0.646484,85.6414 0.646484,98.6309 7.74474,107.426 9.17117,109.194 10.7817,110.804 12.5491,112.23 21.3443,119.329 34.3338,119.329 60.3128,119.329L62.6465,119.329 62.6465,-0.00390625z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<Image DockPanel.Dock="Right" Height="48" HorizontalAlignment="Left">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V120 H63 V0 H0 Z">
<GeometryDrawing Brush="#fafafa" Geometry="F1 M63,120z M0,0z M0.447266,119.495L2.78091,119.495C28.7599,119.495 41.7495,119.495 50.5446,112.396 52.312,110.97 53.9226,109.36 55.349,107.592 62.4473,98.797 62.4473,85.8074 62.4473,59.8284 62.4473,33.8494 62.4473,20.8599 55.349,12.0648 53.9226,10.2973 52.312,8.6868 50.5446,7.26037 41.7495,0.162109 28.7599,0.162109 2.78091,0.162109L0.447266,0.162109 0.447266,119.495z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<Border Background="#fafafa" Height="48" Margin="-1,0,-1,0.25" VerticalAlignment="Center"></Border>
</DockPanel>
<StackPanel Orientation="Horizontal" Margin="4,0">
<Grid Name="HeadIcon" RenderTransformOrigin=".5,.5" MouseMove="HeadIconButton_MouseMove" MouseDown="HeadIconButton_MouseDown" MouseUp="HeadIconButton_MouseUp" Width="42" Height="42" Margin="0,0,2,0">
<Image Name="HeadIconImage" Height="42" Width="42" Source="../Resources/Icons-png/icc-toolbar-v2.png" RenderOptions.BitmapScalingMode="HighQuality"></Image>
</Grid>
<ItemsControl Name="ToolBarItemsControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:FloatingBarItem}">
<StackPanel Orientation="Horizontal">
<Grid MouseDown="ToolbarButton_MouseDown" MouseUp="ToolbarButton_MouseUp" MouseLeave="ToolbarButton_MouseLeave" Tag="{Binding}" Visibility="{Binding _itemVisibility}" Margin="2,0,0,0" Width="42" Height="42">
<Image Height="42" Width="42">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V120 H120 V0 H0 Z">
<GeometryDrawing Brush="{Binding _backgroundBrush}" Geometry="F1 M120,120z M0,0z M0.443359,59.9384C0.443359,33.9607 0.443359,20.9718 7.54095,12.1769 8.96777,10.4089 10.5788,8.79785 12.3468,7.37103 21.1418,0.273438 34.1306,0.273438 60.1084,0.273438 86.0861,0.273438 99.075,0.273438 107.87,7.37103 109.638,8.79785 111.249,10.4089 112.676,12.1769 119.773,20.9718 119.773,33.9607 119.773,59.9384 119.773,85.9162 119.773,98.905 112.676,107.7 111.249,109.468 109.638,111.079 107.87,112.506 99.075,119.603 86.0861,119.603 60.1084,119.603 34.1306,119.603 21.1418,119.603 12.3468,112.506 10.5788,111.079 8.96777,109.468 7.54095,107.7 0.443359,98.905 0.443359,85.9162 0.443359,59.9384z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<Image Height="42" Width="42" Opacity="0">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V120 H120 V0 H0 Z">
<GeometryDrawing Brush="#e1e1e1" Geometry="F1 M120,120z M0,0z M0.443359,59.9384C0.443359,33.9607 0.443359,20.9718 7.54095,12.1769 8.96777,10.4089 10.5788,8.79785 12.3468,7.37103 21.1418,0.273438 34.1306,0.273438 60.1084,0.273438 86.0861,0.273438 99.075,0.273438 107.87,7.37103 109.638,8.79785 111.249,10.4089 112.676,12.1769 119.773,20.9718 119.773,33.9607 119.773,59.9384 119.773,85.9162 119.773,98.905 112.676,107.7 111.249,109.468 109.638,111.079 107.87,112.506 99.075,119.603 86.0861,119.603 60.1084,119.603 34.1306,119.603 21.1418,119.603 12.3468,112.506 10.5788,111.079 8.96777,109.468 7.54095,107.7 0.443359,98.905 0.443359,85.9162 0.443359,59.9384z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<Image Height="21" Source="{Binding IconSource}"/>
</Grid>
<Border Visibility="{Binding _separatorVisibility}" Width="1" Height="28" CornerRadius="0.5" Background="#e1e1e1" Margin="3,0,1,0"></Border>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Grid>
</Grid>
</Window>

View File

@ -0,0 +1,361 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Ink_Canvas
{
public enum FloatingBarItemType {
Button,
StateButton,
Separator
}
public class FloatingBarItem {
public string Name { get; set; }
public ImageSource IconSource { get; set; }
public bool Selected { get; set; } = false;
public bool IsVisible { get; set; } = true;
public string IconSourceResourceKey { get; set; }
public FloatingBarItemType Type { get; set; }
public MainWindow.ICCToolsEnum ToolType { get; set; }
public SolidColorBrush _backgroundBrush {
get {
if (Selected) return new SolidColorBrush(Color.FromRgb(37, 99, 235));
return new SolidColorBrush(Colors.Transparent);
}
}
public Visibility _itemVisibility {
get {
if (!IsVisible) return Visibility.Collapsed;
return Type != FloatingBarItemType.Separator ? Visibility.Visible : Visibility.Collapsed;
}
}
public Visibility _separatorVisibility {
get {
if (!IsVisible) return Visibility.Collapsed;
return Type != FloatingBarItemType.Separator ? Visibility.Collapsed : Visibility.Visible;
}
}
}
/// <summary>
/// FloatingToolBarV2.xaml 的交互逻辑
/// </summary>
public partial class FloatingToolBarV2 : Window {
public FloatingToolBarV2() {
InitializeComponent();
ToolBarItemsControl.ItemsSource = ToolbarItems;
//var clonedDrawing = (FindResource("CursorIcon") as DrawingImage).Clone();
//((clonedDrawing.Drawing as DrawingGroup).Children[0] as
// GeometryDrawing).Brush = new SolidColorBrush(Colors.Black);
ToolbarItems.Add(new FloatingBarItem() {
Name = "Cursor",
IconSource = FindResource("CursorIcon") as DrawingImage,
IconSourceResourceKey = "CursorIcon",
IsVisible = true,
Selected = false,
ToolType = MainWindow.ICCToolsEnum.CursorMode,
Type = FloatingBarItemType.StateButton,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Pen",
IconSource = FindResource("PenIcon") as DrawingImage,
IconSourceResourceKey = "PenIcon",
IsVisible = true,
Selected = false,
ToolType = MainWindow.ICCToolsEnum.PenMode,
Type = FloatingBarItemType.StateButton,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Clear",
IconSource = FindResource("TrashBinIcon") as DrawingImage,
IconSourceResourceKey = "TrashBinIcon",
IsVisible = true,
Selected = false,
Type = FloatingBarItemType.Button,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "SeparatorA",
IsVisible = true,
Type = FloatingBarItemType.Separator,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Eraser",
IconSource = FindResource("EraserIcon") as DrawingImage,
IconSourceResourceKey = "EraserIcon",
IsVisible = true,
Selected = false,
ToolType = MainWindow.ICCToolsEnum.EraseByGeometryMode,
Type = FloatingBarItemType.StateButton,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "ShapeDrawing",
IconSource = FindResource("ShapesIcon") as DrawingImage,
IconSourceResourceKey = "ShapesIcon",
IsVisible = true,
Selected = false,
Type = FloatingBarItemType.Button,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Select",
IconSource = FindResource("SelectIcon") as DrawingImage,
IconSourceResourceKey = "SelectIcon",
IsVisible = true,
Selected = false,
ToolType = MainWindow.ICCToolsEnum.LassoMode,
Type = FloatingBarItemType.StateButton,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "SeparatorB",
IsVisible = true,
Type = FloatingBarItemType.Separator,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Undo",
IconSource = FindResource("UndoIcon") as DrawingImage,
IconSourceResourceKey = "UndoIcon",
IsVisible = true,
Selected = false,
Type = FloatingBarItemType.Button,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Redo",
IconSource = FindResource("RedoIcon") as DrawingImage,
IconSourceResourceKey = "RedoIcon",
IsVisible = true,
Selected = false,
Type = FloatingBarItemType.Button,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "SeparatorC",
IsVisible = true,
Type = FloatingBarItemType.Separator,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Gesture",
IconSource = FindResource("GestureIcon") as DrawingImage,
IconSourceResourceKey = "GestureIcon",
IsVisible = true,
Selected = false,
Type = FloatingBarItemType.Button,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Menu",
IconSource = FindResource("MoreIcon") as DrawingImage,
IconSourceResourceKey = "MoreIcon",
IsVisible = true,
Selected = false,
Type = FloatingBarItemType.Button,
});
ToolbarItems.Add(new FloatingBarItem() {
Name = "Fold",
IconSource = FindResource("FoldIcon") as DrawingImage,
IconSourceResourceKey = "FoldIcon",
IsVisible = true,
Selected = false,
Type = FloatingBarItemType.Button,
});
ReMeasureToolBar();
UpdateToolBarSelectedTool(MainWindow.ICCToolsEnum.CursorMode);
UpdateToolBarVariant(1);
double widthInDevicePixels = GetSystemMetrics(0); // SM_CXSCREEN
double widthInDIP = SystemParameters.WorkArea.Right; // Device independent pixels.
double scalingFactor = widthInDIP/widthInDevicePixels;
ScalingFactor = scalingFactor;
}
private double ScalingFactor;
public ObservableCollection<FloatingBarItem> ToolbarItems { get; set; } =
new ObservableCollection<FloatingBarItem>();
private Grid _mouseDownButton = null;
private bool _isMouseDownHeadIcon = false;
private double CaculateToolBarWindowWidth(Collection<FloatingBarItem> toolbarItems) {
// ------------------------------------------------------//
var containerMargin = 4D; // 内容StackPanel的Margin
var itemWidth = 42D; // 按钮宽度
var itemsSpacing = 2D; // 按钮之间的间距
var headIconSpacingRight = 4D; // icc图标的右间距
var separatorWidth = 1D; // 分隔符宽度
var separatorSpacing = 3D; // 分隔符左右的间距
// ------------------------------------------------------//
var _width = containerMargin * 2 + itemWidth + headIconSpacingRight - itemsSpacing;
foreach (var i in toolbarItems) {
if (!i.IsVisible) continue;
if (i.Type != FloatingBarItemType.Separator) _width += itemsSpacing + itemWidth;
else _width += separatorSpacing + separatorWidth + separatorSpacing - itemsSpacing;
}
return _width;
}
/// <summary>
/// 修改工具栏的变体
/// </summary>
/// <param name="variant">0为全长1为鼠标模式下变体2为迷你3为仅小图标</param>
private void UpdateToolBarVariant(int variant) {
IEnumerable<FloatingBarItem> items;
if (variant == 0) items = ToolbarItems.AsEnumerable();
else if (variant == 1)
items = ToolbarItems.Where((item, i) => (new string[] {
"Cursor", "Pen", "Clear", "SeparatorC", "Gesture", "Menu", "Fold"
}).Contains(item.Name));
else if (variant == 2)
items = ToolbarItems.Where((item, i) => (new string[] {
"Cursor", "Pen", "Clear"
}).Contains(item.Name));
else throw new NotImplementedException();
foreach (var fi in ToolbarItems) {
fi.IsVisible = items.Contains(fi);
}
CollectionViewSource.GetDefaultView(ToolbarItems).Refresh();
ReMeasureToolBar();
}
private void UpdateToolBarSelectedTool(MainWindow.ICCToolsEnum type) {
var _i = ToolbarItems.Where((item, i) =>
item.Type == FloatingBarItemType.StateButton &&
item.ToolType == type).Single();
var nowSelected = ToolbarItems.Where((item, i) =>
item.Selected);
if (nowSelected.Any() && nowSelected.Count()==1 && _i == nowSelected.Single()) return;
foreach (var fi in ToolbarItems) {
if (fi.Type == FloatingBarItemType.Separator) continue;
fi.Selected = false;
fi.IconSource = FindResource(fi.IconSourceResourceKey) as ImageSource;
}
_i.Selected = true;
var clonedIcon = _i.IconSource.Clone() as DrawingImage;
foreach (var d in (clonedIcon.Drawing as DrawingGroup).Children)
((GeometryDrawing)d).Brush = new SolidColorBrush(Colors.White);
_i.IconSource = clonedIcon;
CollectionViewSource.GetDefaultView(ToolbarItems).Refresh();
}
private void ReMeasureToolBar() {
var barWidth = CaculateToolBarWindowWidth(ToolbarItems);
ToolBarV2Grid.Width = barWidth;
Width = barWidth + 6 * 2; // 6是工具栏和窗口的Margin
Height = 48 + 6 * 2; // 48是工具栏高度
}
private void OnToolSelectionChanged(FloatingBarItem sender) {
if (sender.Selected && sender.ToolType != MainWindow.ICCToolsEnum.CursorMode)
UpdateToolBarVariant(0);
else UpdateToolBarVariant(1);
}
private void ToolbarButton_MouseDown(object sender, MouseButtonEventArgs e) {
if (_mouseDownButton != null) return;
var gd = sender as Grid;
var itemData = gd.Tag as FloatingBarItem;
_mouseDownButton = gd;
if (!itemData.Selected) {
var bgImg = gd.Children[1] as Image;
bgImg.Opacity = 1;
}
}
private void ToolbarButton_MouseUp(object sender, MouseButtonEventArgs e) {
if (_mouseDownButton == null || _mouseDownButton != sender) return;
ToolbarButton_MouseLeave(sender, null);
var gd = sender as Grid;
var itemData = gd.Tag as FloatingBarItem;
if (itemData.Type == FloatingBarItemType.StateButton) {
UpdateToolBarSelectedTool(itemData.ToolType);
OnToolSelectionChanged(itemData);
}
}
[DllImport("USER32.DLL", SetLastError = true)]
public static extern int GetSystemMetrics(int nIndex);
private void ToolbarButton_MouseLeave(object sender, MouseEventArgs e) {
if (_mouseDownButton == null || _mouseDownButton != sender) return;
var itemData = _mouseDownButton.Tag as FloatingBarItem;
if (!itemData.Selected) {
var bgImg = _mouseDownButton.Children[1] as Image;
bgImg.Opacity = 0;
}
_mouseDownButton = null;
}
public Point prevPoint = new Point(0,0);
public Point lastPoint = new Point(0, 0);
public bool isInMovingMode = false;
public double winLeft = 0;
public double winTop = 0;
private void HeadIconButton_MouseDown(object sender, MouseButtonEventArgs e) {
if (_isMouseDownHeadIcon) return;
_isMouseDownHeadIcon = true;
var gd = sender as Grid;
prevPoint = e.GetPosition(ToolBarV2Grid);
winLeft = Left;
winTop = Top;
Trace.WriteLine(prevPoint);
gd.CaptureMouse();
gd.RenderTransform = new ScaleTransform(0.95, 0.95);
isInMovingMode = false;
}
private void HeadIconButton_MouseMove(object sender, MouseEventArgs e) {
if (_isMouseDownHeadIcon == false) return;
var nowPt = e.GetPosition(ToolBarV2Grid);
lastPoint = nowPt;
var deltaX = nowPt.X - prevPoint.X;
var deltaY = nowPt.Y - prevPoint.Y;
if (Math.Abs(deltaY) > 16 || Math.Abs(deltaX) > 16) isInMovingMode = true;
if (isInMovingMode) {
ToolbarV2.RenderTransform = null;
HeadIconImage.RenderTransform = null;
var mp = System.Windows.Forms.Control.MousePosition;
Top = mp.Y * ScalingFactor - prevPoint.Y - 6;
Left = mp.X * ScalingFactor - prevPoint.X - 6;
} else {
ToolbarV2.RenderTransform = new TranslateTransform(deltaX / 3, deltaY / 3);
HeadIconImage.RenderTransform = new TranslateTransform(deltaX / 8, deltaY / 8);
}
}
private void HeadIconButton_MouseUp(object sender, MouseButtonEventArgs e) {
if (_isMouseDownHeadIcon == false) return;
_isMouseDownHeadIcon = false;
var gd = sender as Grid;
gd.ReleaseMouseCapture();
gd.RenderTransform = null;
ToolbarV2.RenderTransform = null;
HeadIconImage.RenderTransform = null;
isInMovingMode = false;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB