diff --git a/InkCanvasForClass/App.xaml.cs b/InkCanvasForClass/App.xaml.cs
index a9dc9c6..af2a2a8 100644
--- a/InkCanvasForClass/App.xaml.cs
+++ b/InkCanvasForClass/App.xaml.cs
@@ -1,13 +1,20 @@
using Hardcodet.Wpf.TaskbarNotification;
using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern.Controls;
+using Newtonsoft.Json;
using System;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
+using iNKORE.UI.WPF.Helpers;
+using Newtonsoft.Json.Linq;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using MessageBox = System.Windows.MessageBox;
using Window = System.Windows.Window;
+using System.Windows.Shell;
+using Ookii.Dialogs.Wpf;
+using System.Diagnostics;
namespace Ink_Canvas
{
@@ -39,7 +46,7 @@ namespace Ink_Canvas
void App_Startup(object sender, StartupEventArgs e)
{
- /*if (!StoreHelper.IsStoreApp) */RootPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
+ RootPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
LogHelper.NewLog(string.Format("Ink Canvas Starting (Version: {0})", Assembly.GetExecutingAssembly().GetName().Version.ToString()));
@@ -49,19 +56,65 @@ namespace Ink_Canvas
if (!ret && !e.Args.Contains("-m")) //-m multiple
{
LogHelper.NewLog("Detected existing instance");
- MessageBox.Show("已有一个程序实例正在运行");
+
+ if (TaskDialog.OSSupportsTaskDialogs) {
+ using (TaskDialog dialog = new TaskDialog())
+ {
+ dialog.WindowTitle = "InkCanvasForClass";
+ dialog.MainIcon = TaskDialogIcon.Warning;
+ dialog.MainInstruction = "已有一个实例正在运行";
+ dialog.Content = "这意味着 InkCanvasForClass 正在运行,而您又运行了主程序一遍。如果频繁出现该弹窗且ICC无法正常启动时,请尝试 “以多开模式启动”。";
+ TaskDialogButton customButton = new TaskDialogButton("以多开模式启动");
+ customButton.Default = false;
+ dialog.ButtonClicked += (object s, TaskDialogItemClickedEventArgs _e) => {
+ if (_e.Item == customButton)
+ {
+ Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m");
+ }
+ };
+ TaskDialogButton okButton = new TaskDialogButton(ButtonType.Ok);
+ okButton.Default = true;
+ dialog.Buttons.Add(customButton);
+ dialog.Buttons.Add(okButton);
+ TaskDialogButton button = dialog.ShowDialog();
+ }
+ }
+
LogHelper.NewLog("Ink Canvas automatically closed");
Environment.Exit(0);
}
- if (e.Args.Contains("--v6")) //-v6 进入ICCX(v6)
- {
- MessageBox.Show("检测到进入ICCX");
- } else {
- mainWin = new MainWindow();
- mainWin.Show();
+
+ var isUsingWindowChrome = false;
+ try {
+ if (File.Exists(App.RootPath + "Settings.json")) {
+ try {
+ string text = File.ReadAllText(App.RootPath + "Settings.json");
+ var obj = JObject.Parse(text);
+ isUsingWindowChrome = (bool)obj.SelectToken("startup.enableWindowChromeRendering");
+ }
+ catch { }
+ }
+ } catch (Exception ex) {
+ LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error);
}
+ mainWin = new MainWindow();
+
+ if (isUsingWindowChrome) {
+ mainWin.AllowsTransparency = false;
+ WindowChrome wc = new WindowChrome();
+ wc.GlassFrameThickness = new Thickness(-1);
+ wc.CaptionHeight = 0;
+ wc.CornerRadius = new CornerRadius(0);
+ wc.ResizeBorderThickness = new Thickness(0);
+ WindowChrome.SetWindowChrome(mainWin, wc);
+ } else {
+ mainWin.AllowsTransparency = true;
+ WindowChrome.SetWindowChrome(mainWin, null);
+ }
+ mainWin.Show();
+
_taskbar = (TaskbarIcon)FindResource("TaskbarTrayIcon");
StartArgs = e.Args;
diff --git a/InkCanvasForClass/Helpers/ColorUtilities.cs b/InkCanvasForClass/Helpers/ColorUtilities.cs
new file mode 100644
index 0000000..9049a43
--- /dev/null
+++ b/InkCanvasForClass/Helpers/ColorUtilities.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media;
+
+namespace Ink_Canvas.Helpers
+{
+ public class ColorUtilities {
+
+ ///
+ /// 获取一个颜色的人眼感知亮度,并以 0~1 之间的小数表示。
+ ///
+ public static double GetGrayLevel(Color color) {
+ return (0.299 * color.R + 0.587 * color.G + 0.114 * color.B) / 255;
+ }
+
+ ///
+ /// 根据人眼感知亮度返回前景色到底是黑色还是白色
+ ///
+ /// GetGrayLevel返回的人眼感知亮度
+ /// Color
+ public static Color GetReverseForegroundColor(double grayLevel) => grayLevel > 0.5 ? Colors.Black : Colors.White;
+ }
+}
diff --git a/InkCanvasForClass/Helpers/Converters.cs b/InkCanvasForClass/Helpers/Converters.cs
index 1d21995..09f4fc0 100644
--- a/InkCanvasForClass/Helpers/Converters.cs
+++ b/InkCanvasForClass/Helpers/Converters.cs
@@ -5,61 +5,6 @@ using System.Windows.Data;
namespace Ink_Canvas.Converter
{
- public class BooleanToVisibilityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if ((bool)value == true)
- {
- return Visibility.Visible;
- }
- else
- {
- return Visibility.Collapsed;
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if ((bool)value == true)
- {
- return Visibility.Visible;
- }
- else
- {
- return Visibility.Collapsed;
- }
- }
- }
- public class VisibilityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- Visibility visibility = (Visibility)value;
- if (visibility == Visibility.Visible)
- {
- return Visibility.Collapsed;
- }
- else
- {
- return Visibility.Visible;
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- Visibility visibility = (Visibility)value;
- if (visibility == Visibility.Visible)
- {
- return Visibility.Collapsed;
- }
- else
- {
- return Visibility.Visible;
- }
- }
- }
-
public class IntNumberToString : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
diff --git a/InkCanvasForClass/Helpers/DrawingVisualCanvas.cs b/InkCanvasForClass/Helpers/DrawingVisualCanvas.cs
new file mode 100644
index 0000000..57374ef
--- /dev/null
+++ b/InkCanvasForClass/Helpers/DrawingVisualCanvas.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Windows;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using Pen = System.Windows.Media.Pen;
+
+namespace Ink_Canvas.Helpers
+{
+
+ public class DrawingVisualCanvas : FrameworkElement
+ {
+ private VisualCollection _children;
+ public DrawingVisual DrawingVisual = new DrawingVisual();
+
+ public DrawingVisualCanvas()
+ {
+ _children = new VisualCollection(this) {
+ DrawingVisual // 初始化DrawingVisual
+ };
+ }
+
+ protected override int VisualChildrenCount => _children.Count;
+
+ protected override Visual GetVisualChild(int index)
+ {
+ if (index < 0 || index >= _children.Count) throw new ArgumentOutOfRangeException();
+ return _children[index];
+ }
+ }
+}
diff --git a/InkCanvasForClass/Helpers/DwmCompositionHelper.cs b/InkCanvasForClass/Helpers/DwmCompositionHelper.cs
new file mode 100644
index 0000000..60d12e0
--- /dev/null
+++ b/InkCanvasForClass/Helpers/DwmCompositionHelper.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Ink_Canvas.Helpers
+{
+ public class DwmCompositionHelper{
+ public const string LibraryName = "Dwmapi.dll";
+
+ [DllImport(LibraryName, ExactSpelling = true, PreserveSig = false)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ public static extern bool DwmIsCompositionEnabled();
+ }
+}
diff --git a/InkCanvasForClass/Helpers/InkStrokesOverlay.cs b/InkCanvasForClass/Helpers/InkStrokesOverlay.cs
new file mode 100644
index 0000000..01d591d
--- /dev/null
+++ b/InkCanvasForClass/Helpers/InkStrokesOverlay.cs
@@ -0,0 +1,95 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.Runtime.Remoting.Contexts;
+using System.Windows;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+using Pen = System.Windows.Media.Pen;
+
+namespace Ink_Canvas.Helpers
+{
+
+ public class InkStrokesOverlay : FrameworkElement
+ {
+ private VisualCollection _children;
+ private ImprovedDrawingVisual _layer = new ImprovedDrawingVisual();
+ private StrokeCollection cachedStrokeCollection = new StrokeCollection();
+ private DrawingGroup cachedDrawingGroup = new DrawingGroup();
+ private bool isCached = false;
+ private DrawingContext context;
+
+ public class ImprovedDrawingVisual: DrawingVisual {
+ public ImprovedDrawingVisual() {
+ CacheMode = new BitmapCache() {
+ EnableClearType = false,
+ RenderAtScale = 1,
+ SnapsToDevicePixels = false
+ };
+ }
+ }
+
+ public InkStrokesOverlay()
+ {
+ _children = new VisualCollection(this) {
+ _layer // 初始化DrawingVisual
+ };
+ }
+
+ protected override int VisualChildrenCount => _children.Count;
+
+ protected override Visual GetVisualChild(int index)
+ {
+ if (index < 0 || index >= _children.Count) throw new ArgumentOutOfRangeException();
+ return _children[index];
+ }
+
+ public DrawingContext Open() {
+ context = _layer.RenderOpen();
+ return context;
+ }
+
+ public void Close() {
+ context.Close();
+ }
+
+ public void DrawStrokes(StrokeCollection strokes, Matrix? matrixTransform, bool isOneTimeDrawing = true) {
+ if (isOneTimeDrawing) {
+ context = _layer.RenderOpen();
+ }
+
+ if (matrixTransform != null) context.PushTransform(new MatrixTransform((Matrix)matrixTransform));
+
+ if (strokes.Count != 0) {
+ if (!isCached || (isCached && !strokes.Equals(cachedStrokeCollection))) {
+ cachedStrokeCollection = strokes;
+ cachedDrawingGroup = new DrawingGroup();
+ var gp_context = cachedDrawingGroup.Open();
+ var stks_cloned = strokes.Clone();
+ foreach (var stroke in stks_cloned) {
+ stroke.DrawingAttributes.Width += 2;
+ stroke.DrawingAttributes.Height += 2;
+ }
+ stks_cloned.Draw(gp_context);
+ foreach (var ori_stk in strokes) {
+ var geo = ori_stk.GetGeometry();
+ gp_context.DrawGeometry(new SolidColorBrush(Colors.White),null,geo);
+
+ }
+ gp_context.Close();
+ }
+ }
+
+ context.DrawDrawing(cachedDrawingGroup);
+
+ if (matrixTransform != null) context.Pop();
+
+ if (isOneTimeDrawing) {
+ context.Close();
+ }
+ }
+ }
+}
diff --git a/InkCanvasForClass/Helpers/PerformanceTransparentWin.Win32.cs b/InkCanvasForClass/Helpers/PerformanceTransparentWin.Win32.cs
new file mode 100644
index 0000000..8746f7f
--- /dev/null
+++ b/InkCanvasForClass/Helpers/PerformanceTransparentWin.Win32.cs
@@ -0,0 +1,600 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Ink_Canvas.Helpers {
+ public partial class PerformanceTransparentWin {
+ static class Win32 {
+
+ public enum WM
+ {
+ NULL = 0x0000,
+ CREATE = 0x0001,
+ DESTROY = 0x0002,
+ MOVE = 0x0003,
+ SIZE = 0x0005,
+ ACTIVATE = 0x0006,
+ SETFOCUS = 0x0007,
+ KILLFOCUS = 0x0008,
+ ENABLE = 0x000A,
+ SETREDRAW = 0x000B,
+ SETTEXT = 0x000C,
+ GETTEXT = 0x000D,
+ GETTEXTLENGTH = 0x000E,
+ PAINT = 0x000F,
+ CLOSE = 0x0010,
+ QUERYENDSESSION = 0x0011,
+ QUERYOPEN = 0x0013,
+ ENDSESSION = 0x0016,
+ QUIT = 0x0012,
+ ERASEBKGND = 0x0014,
+ SYSCOLORCHANGE = 0x0015,
+ SHOWWINDOW = 0x0018,
+ WININICHANGE = 0x001A,
+ SETTINGCHANGE = WININICHANGE,
+ DEVMODECHANGE = 0x001B,
+ ACTIVATEAPP = 0x001C,
+ FONTCHANGE = 0x001D,
+ TIMECHANGE = 0x001E,
+ CANCELMODE = 0x001F,
+ SETCURSOR = 0x0020,
+ MOUSEACTIVATE = 0x0021,
+ CHILDACTIVATE = 0x0022,
+ QUEUESYNC = 0x0023,
+ GETMINMAXINFO = 0x0024,
+ PAINTICON = 0x0026,
+ ICONERASEBKGND = 0x0027,
+ NEXTDLGCTL = 0x0028,
+ SPOOLERSTATUS = 0x002A,
+ DRAWITEM = 0x002B,
+ MEASUREITEM = 0x002C,
+ DELETEITEM = 0x002D,
+ VKEYTOITEM = 0x002E,
+ CHARTOITEM = 0x002F,
+ SETFONT = 0x0030,
+ GETFONT = 0x0031,
+ SETHOTKEY = 0x0032,
+ GETHOTKEY = 0x0033,
+ QUERYDRAGICON = 0x0037,
+ COMPAREITEM = 0x0039,
+ GETOBJECT = 0x003D,
+ COMPACTING = 0x0041,
+ COMMNOTIFY = 0x0044 /* no longer suported */,
+ WINDOWPOSCHANGING = 0x0046,
+ WINDOWPOSCHANGED = 0x0047,
+ POWER = 0x0048,
+ COPYDATA = 0x004A,
+ CANCELJOURNAL = 0x004B,
+ NOTIFY = 0x004E,
+ INPUTLANGCHANGEREQUEST = 0x0050,
+ INPUTLANGCHANGE = 0x0051,
+ TCARD = 0x0052,
+ HELP = 0x0053,
+ USERCHANGED = 0x0054,
+ NOTIFYFORMAT = 0x0055,
+ CONTEXTMENU = 0x007B,
+ STYLECHANGING = 0x007C,
+ STYLECHANGED = 0x007D,
+ DISPLAYCHANGE = 0x007E,
+ GETICON = 0x007F,
+ SETICON = 0x0080,
+ NCCREATE = 0x0081,
+ NCDESTROY = 0x0082,
+ NCCALCSIZE = 0x0083,
+ NCHITTEST = 0x0084,
+ NCPAINT = 0x0085,
+ NCACTIVATE = 0x0086,
+ GETDLGCODE = 0x0087,
+ SYNCPAINT = 0x0088,
+ NCMOUSEMOVE = 0x00A0,
+ NCLBUTTONDOWN = 0x00A1,
+ NCLBUTTONUP = 0x00A2,
+ NCLBUTTONDBLCLK = 0x00A3,
+ NCRBUTTONDOWN = 0x00A4,
+ NCRBUTTONUP = 0x00A5,
+ NCRBUTTONDBLCLK = 0x00A6,
+ NCMBUTTONDOWN = 0x00A7,
+ NCMBUTTONUP = 0x00A8,
+ NCMBUTTONDBLCLK = 0x00A9,
+ NCXBUTTONDOWN = 0x00AB,
+ NCXBUTTONUP = 0x00AC,
+ NCXBUTTONDBLCLK = 0x00AD,
+ INPUT_DEVICE_CHANGE = 0x00FE,
+ INPUT = 0x00FF,
+ KEYFIRST = 0x0100,
+ KEYDOWN = 0x0100,
+ KEYUP = 0x0101,
+ CHAR = 0x0102,
+ DEADCHAR = 0x0103,
+ SYSKEYDOWN = 0x0104,
+ SYSKEYUP = 0x0105,
+ SYSCHAR = 0x0106,
+ SYSDEADCHAR = 0x0107,
+ UNICHAR = 0x0109,
+ KEYLAST = 0x0109,
+ IME_STARTCOMPOSITION = 0x010D,
+ IME_ENDCOMPOSITION = 0x010E,
+ IME_COMPOSITION = 0x010F,
+ IME_KEYLAST = 0x010F,
+ INITDIALOG = 0x0110,
+ COMMAND = 0x0111,
+ SYSCOMMAND = 0x0112,
+ TIMER = 0x0113,
+ HSCROLL = 0x0114,
+ VSCROLL = 0x0115,
+ INITMENU = 0x0116,
+ INITMENUPOPUP = 0x0117,
+ GESTURE = 0x0119,
+ GESTURENOTIFY = 0x011A,
+ MENUSELECT = 0x011F,
+ MENUCHAR = 0x0120,
+ ENTERIDLE = 0x0121,
+ MENURBUTTONUP = 0x0122,
+ MENUDRAG = 0x0123,
+ MENUGETOBJECT = 0x0124,
+ UNINITMENUPOPUP = 0x0125,
+ MENUCOMMAND = 0x0126,
+ CHANGEUISTATE = 0x0127,
+ UPDATEUISTATE = 0x0128,
+ QUERYUISTATE = 0x0129,
+ CTLCOLORMSGBOX = 0x0132,
+ CTLCOLOREDIT = 0x0133,
+ CTLCOLORLISTBOX = 0x0134,
+ CTLCOLORBTN = 0x0135,
+ CTLCOLORDLG = 0x0136,
+ CTLCOLORSCROLLBAR = 0x0137,
+ CTLCOLORSTATIC = 0x0138,
+ MOUSEFIRST = 0x0200,
+ MOUSEMOVE = 0x0200,
+ LBUTTONDOWN = 0x0201,
+ LBUTTONUP = 0x0202,
+ LBUTTONDBLCLK = 0x0203,
+ RBUTTONDOWN = 0x0204,
+ RBUTTONUP = 0x0205,
+ RBUTTONDBLCLK = 0x0206,
+ MBUTTONDOWN = 0x0207,
+ MBUTTONUP = 0x0208,
+ MBUTTONDBLCLK = 0x0209,
+ MOUSEWHEEL = 0x020A,
+ XBUTTONDOWN = 0x020B,
+ XBUTTONUP = 0x020C,
+ XBUTTONDBLCLK = 0x020D,
+ MOUSEHWHEEL = 0x020E,
+ MOUSELAST = 0x020E,
+ PARENTNOTIFY = 0x0210,
+ ENTERMENULOOP = 0x0211,
+ EXITMENULOOP = 0x0212,
+ NEXTMENU = 0x0213,
+ SIZING = 0x0214,
+ CAPTURECHANGED = 0x0215,
+ MOVING = 0x0216,
+ POWERBROADCAST = 0x0218,
+ DEVICECHANGE = 0x0219,
+ MDICREATE = 0x0220,
+ MDIDESTROY = 0x0221,
+ MDIACTIVATE = 0x0222,
+ MDIRESTORE = 0x0223,
+ MDINEXT = 0x0224,
+ MDIMAXIMIZE = 0x0225,
+ MDITILE = 0x0226,
+ MDICASCADE = 0x0227,
+ MDIICONARRANGE = 0x0228,
+ MDIGETACTIVE = 0x0229,
+ MDISETMENU = 0x0230,
+ ENTERSIZEMOVE = 0x0231,
+ EXITSIZEMOVE = 0x0232,
+ DROPFILES = 0x0233,
+ MDIREFRESHMENU = 0x0234,
+ POINTERDEVICECHANGE = 0x238,
+ POINTERDEVICEINRANGE = 0x239,
+ POINTERDEVICEOUTOFRANGE = 0x23A,
+ TOUCH = 0x0240,
+ NCPOINTERUPDATE = 0x0241,
+ NCPOINTERDOWN = 0x0242,
+ NCPOINTERUP = 0x0243,
+ POINTERUPDATE = 0x0245,
+ POINTERDOWN = 0x0246,
+ POINTERUP = 0x0247,
+ POINTERENTER = 0x0249,
+ POINTERLEAVE = 0x024A,
+ POINTERACTIVATE = 0x024B,
+ POINTERCAPTURECHANGED = 0x024C,
+ TOUCHHITTESTING = 0x024D,
+ POINTERWHEEL = 0x024E,
+ POINTERHWHEEL = 0x024F,
+ IME_SETCONTEXT = 0x0281,
+ IME_NOTIFY = 0x0282,
+ IME_CONTROL = 0x0283,
+ IME_COMPOSITIONFULL = 0x0284,
+ IME_SELECT = 0x0285,
+ IME_CHAR = 0x0286,
+ IME_REQUEST = 0x0288,
+ IME_KEYDOWN = 0x0290,
+ IME_KEYUP = 0x0291,
+ MOUSEHOVER = 0x02A1,
+ MOUSELEAVE = 0x02A3,
+ NCMOUSEHOVER = 0x02A0,
+ NCMOUSELEAVE = 0x02A2,
+ WTSSESSION_CHANGE = 0x02B1,
+ TABLET_FIRST = 0x02c0,
+ TABLET_LAST = 0x02df,
+ DPICHANGED = 0x02E0,
+ CUT = 0x0300,
+ COPY = 0x0301,
+ PASTE = 0x0302,
+ CLEAR = 0x0303,
+ UNDO = 0x0304,
+ RENDERFORMAT = 0x0305,
+ RENDERALLFORMATS = 0x0306,
+ DESTROYCLIPBOARD = 0x0307,
+ DRAWCLIPBOARD = 0x0308,
+ PAINTCLIPBOARD = 0x0309,
+ VSCROLLCLIPBOARD = 0x030A,
+ SIZECLIPBOARD = 0x030B,
+ ASKCBFORMATNAME = 0x030C,
+ CHANGECBCHAIN = 0x030D,
+ HSCROLLCLIPBOARD = 0x030E,
+ QUERYNEWPALETTE = 0x030F,
+ PALETTEISCHANGING = 0x0310,
+ PALETTECHANGED = 0x0311,
+ HOTKEY = 0x0312,
+ PRINT = 0x0317,
+ PRINTCLIENT = 0x0318,
+ APPCOMMAND = 0x0319,
+ THEMECHANGED = 0x031A,
+ CLIPBOARDUPDATE = 0x031D,
+ DWMCOMPOSITIONCHANGED = 0x031E,
+ DWMNCRENDERINGCHANGED = 0x031F,
+ DWMCOLORIZATIONCOLORCHANGED = 0x0320,
+ DWMWINDOWMAXIMIZEDCHANGE = 0x0321,
+ DWMSENDICONICTHUMBNAIL = 0x0323,
+ DWMSENDICONICLIVEPREVIEWBITMAP = 0x0326,
+ GETTITLEBARINFOEX = 0x033F,
+ HANDHELDFIRST = 0x0358,
+ HANDHELDLAST = 0x035F,
+ AFXFIRST = 0x0360,
+ AFXLAST = 0x037F,
+ PENWINFIRST = 0x0380,
+ PENWINLAST = 0x038F,
+ APP = 0x8000,
+ USER = 0x0400
+ }
+
+ ///
+ /// 扩展的窗口风格
+ /// 这是 long 类型的,如果想要使用 int 类型请使用 类
+ ///
+ /// 代码:[Extended Window Styles (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx )
+ /// code from [Extended Window Styles (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx )
+ [Flags]
+ public enum ExtendedWindowStyles : long {
+ ///
+ /// The window accepts drag-drop files
+ ///
+ WS_EX_ACCEPTFILES = 0x00000010L,
+
+ ///
+ /// Forces a top-level window onto the taskbar when the window is visible
+ ///
+ WS_EX_APPWINDOW = 0x00040000L,
+
+ ///
+ /// The window has a border with a sunken edge.
+ ///
+ WS_EX_CLIENTEDGE = 0x00000200L,
+
+ ///
+ /// Paints all descendants of a window in bottom-to-top painting order using double-buffering. For more information, see Remarks. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 2000: This style is not supported.
+ ///
+ WS_EX_COMPOSITED = 0x02000000L,
+
+ ///
+ /// The title bar of the window includes a question mark. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a child window, the child receives a WM_HELP message. The child window should pass the message to the parent window procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the child window.WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles.
+ ///
+ WS_EX_CONTEXTHELP = 0x00000400L,
+
+ ///
+ /// The window itself contains child windows that should take part in dialog box navigation. If this style is specified, the dialog manager recurses into children of this window when performing navigation operations such as handling the TAB key, an arrow key, or a keyboard mnemonic.
+ ///
+ WS_EX_CONTROLPARENT = 0x00010000L,
+
+ ///
+ /// The window has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter.
+ ///
+ WS_EX_DLGMODALFRAME = 0x00000001L,
+
+ ///
+ /// The window is a layered window. This style cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC.Windows 8: The WS_EX_LAYERED style is supported for top-level windows and child windows. Previous Windows versions support WS_EX_LAYERED only for top-level windows.
+ ///
+ WS_EX_LAYERED = 0x00080000,
+
+ ///
+ /// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the horizontal origin of the window is on the right edge. Increasing horizontal values advance to the left.
+ ///
+ WS_EX_LAYOUTRTL = 0x00400000L,
+
+ ///
+ /// The window has generic left-aligned properties. This is the default.
+ ///
+ WS_EX_LEFT = 0x00000000L,
+
+ ///
+ /// If the shell language is Hebrew, Arabic, or another language that supports reading order alignment, the vertical scroll bar (if present) is to the left of the client area. For other languages, the style is ignored.
+ ///
+ WS_EX_LEFTSCROLLBAR = 0x00004000L,
+
+ ///
+ /// The window text is displayed using left-to-right reading-order properties. This is the default.
+ ///
+ WS_EX_LTRREADING = 0x00000000L,
+
+ ///
+ /// The window is a MDI child window.
+ ///
+ WS_EX_MDICHILD = 0x00000040L,
+
+ ///
+ /// A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.To activate the window, use the SetActiveWindow or SetForegroundWindow function.The window does not appear on the taskbar by default. To force the window to appear on the taskbar, use the WS_EX_APPWINDOW style.
+ ///
+ WS_EX_NOACTIVATE = 0x08000000L,
+
+ ///
+ /// The window does not pass its window layout to its child windows.
+ ///
+ WS_EX_NOINHERITLAYOUT = 0x00100000L,
+
+ ///
+ /// The child window created with this style does not send the WM_PARENTNOTIFY message to its parent window when it is created or destroyed.
+ ///
+ WS_EX_NOPARENTNOTIFY = 0x00000004L,
+
+ ///
+ /// The window does not render to a redirection surface. This is for windows that do not have visible content or that use mechanisms other than surfaces to provide their visual.
+ ///
+ WS_EX_NOREDIRECTIONBITMAP = 0x00200000L,
+
+ ///
+ /// The window is an overlapped window.
+ ///
+ WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE),
+
+ ///
+ /// The window is palette window, which is a modeless dialog box that presents an array of commands.
+ ///
+ WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST),
+
+ ///
+ /// The window has generic "right-aligned" properties. This depends on the window class. This style has an effect only if the shell language is Hebrew, Arabic, or another language that supports reading-order alignment; otherwise, the style is ignored.Using the WS_EX_RIGHT style for static or edit controls has the same effect as using the SS_RIGHT or ES_RIGHT style, respectively. Using this style with button controls has the same effect as using BS_RIGHT and BS_RIGHTBUTTON styles.
+ ///
+ WS_EX_RIGHT = 0x00001000L,
+
+ ///
+ /// The vertical scroll bar (if present) is to the right of the client area. This is the default.
+ ///
+ WS_EX_RIGHTSCROLLBAR = 0x00000000L,
+
+ ///
+ /// If the shell language is Hebrew, Arabic, or another language that supports reading-order alignment, the window text is displayed using right-to-left reading-order properties. For other languages, the style is ignored.
+ ///
+ WS_EX_RTLREADING = 0x00002000L,
+
+ ///
+ /// The window has a three-dimensional border style intended to be used for items that do not accept user input.
+ ///
+ WS_EX_STATICEDGE = 0x00020000L,
+
+ ///
+ /// The window is intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by right-clicking or by typing ALT+SPACE.
+ ///
+ WS_EX_TOOLWINDOW = 0x00000080L,
+
+ ///
+ /// The window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function.
+ ///
+ WS_EX_TOPMOST = 0x00000008L,
+
+ ///
+ /// The window should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted.To achieve transparency without these restrictions, use the SetWindowRgn function.
+ ///
+ WS_EX_TRANSPARENT = 0x00000020L,
+
+ ///
+ /// The window has a border with a raised edge
+ ///
+ WS_EX_WINDOWEDGE = 0x00000100L
+ }
+
+ public static partial class User32 {
+ ///
+ /// 获得指定窗口的信息
+ ///
+ /// 指定窗口的句柄
+ /// 需要获得的信息的类型 请使用
+ ///
+ // This static method is required because Win32 does not support
+ // GetWindowLongPtr directly
+ public static IntPtr GetWindowLongPtr(IntPtr hWnd, GetWindowLongFields nIndex) =>
+ GetWindowLongPtr(hWnd, (int)nIndex);
+
+ ///
+ /// 获得指定窗口的信息
+ ///
+ /// 指定窗口的句柄
+ /// 需要获得的信息的类型 请使用
+ ///
+ // This static method is required because Win32 does not support
+ // GetWindowLongPtr directly
+ public static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex) {
+ return IntPtr.Size > 4
+#pragma warning disable CS0618 // 类型或成员已过时
+ ? GetWindowLongPtr_x64(hWnd, nIndex)
+ : new IntPtr(GetWindowLong(hWnd, nIndex));
+#pragma warning restore CS0618 // 类型或成员已过时
+ }
+
+ ///
+ /// 获得指定窗口的信息
+ ///
+ /// 指定窗口的句柄
+ /// 需要获得的信息的类型 请使用
+ ///
+ [Obsolete("请使用 GetWindowLongPtr 解决 x86 和 x64 需要使用不同方法")]
+ [DllImport(LibraryName, CharSet = Properties.BuildCharSet)]
+ public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
+
+ ///
+ /// 获得指定窗口的信息
+ ///
+ /// 指定窗口的句柄
+ /// 需要获得的信息的类型 请使用
+ ///
+ [Obsolete("请使用 GetWindowLongPtr 解决 x86 和 x64 需要使用不同方法")]
+ [DllImport(LibraryName, CharSet = Properties.BuildCharSet, EntryPoint = "GetWindowLongPtr")]
+ public static extern IntPtr GetWindowLongPtr_x64(IntPtr hWnd, int nIndex);
+
+ ///
+ /// 改变指定窗口的属性
+ ///
+ /// 窗口句柄
+ ///
+ /// 指定将设定的大于等于0的偏移值。有效值的范围从0到额外类的存储空间的字节数减4:例如若指定了12或多于12个字节的额外窗口存储空间,则应设索引位8来访问第三个4字节,同样设置0访问第一个4字节,4访问第二个4字节。要设置其他任何值,可以指定下面值之一
+ /// 从 GetWindowLongFields 可以找到所有的值
+ ///
+ /// 指定的替换值
+ ///
+ public static IntPtr SetWindowLongPtr(IntPtr hWnd, GetWindowLongFields nIndex, IntPtr dwNewLong) =>
+ SetWindowLongPtr(hWnd, (int)nIndex, dwNewLong);
+
+ ///
+ /// 改变指定窗口的属性
+ ///
+ /// 窗口句柄
+ /// 指定将设定的大于等于0的偏移值。有效值的范围从0到额外类的存储空间的字节数减4:例如若指定了12或多于12个字节的额外窗口存储空间,则应设索引位8来访问第三个4字节,同样设置0访问第一个4字节,4访问第二个4字节。要设置其他任何值,可以指定下面值之一
+ /// 从 GetWindowLongFields 可以找到所有的值
+ ///
+ /// GetWindowLongFields.GWL_EXSTYLE -20 设定一个新的扩展风格。
+ /// GWL_HINSTANCE -6 设置一个新的应用程序实例句柄。
+ /// GWL_ID -12 设置一个新的窗口标识符。
+ /// GWL_STYLE -16 设定一个新的窗口风格。
+ /// GWL_USERDATA -21 设置与窗口有关的32位值。每个窗口均有一个由创建该窗口的应用程序使用的32位值。
+ /// GWL_WNDPROC -4 为窗口设定一个新的处理函数。
+ /// GWL_HWNDPARENT -8 改变子窗口的父窗口,应使用SetParent函数
+ ///
+ /// 指定的替换值
+ ///
+ // This static method is required because Win32 does not support
+ // GetWindowLongPtr directly
+ public static IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong) {
+ return IntPtr.Size > 4
+#pragma warning disable CS0618 // 类型或成员已过时
+ ? SetWindowLongPtr_x64(hWnd, nIndex, dwNewLong)
+ : new IntPtr(SetWindowLong(hWnd, nIndex, dwNewLong.ToInt32()));
+#pragma warning restore CS0618 // 类型或成员已过时
+ }
+
+ ///
+ /// 改变指定窗口的属性
+ ///
+ /// 窗口句柄
+ /// 指定将设定的大于等于0的偏移值。有效值的范围从0到额外类的存储空间的字节数减4:例如若指定了12或多于12个字节的额外窗口存储空间,则应设索引位8来访问第三个4字节,同样设置0访问第一个4字节,4访问第二个4字节。要设置其他任何值,可以指定下面值之一
+ /// 从 GetWindowLongFields 可以找到所有的值
+ ///
+ /// GetWindowLongFields.GWL_EXSTYLE -20 设定一个新的扩展风格。
+ /// GWL_HINSTANCE -6 设置一个新的应用程序实例句柄。
+ /// GWL_ID -12 设置一个新的窗口标识符。
+ /// GWL_STYLE -16 设定一个新的窗口风格。
+ /// GWL_USERDATA -21 设置与窗口有关的32位值。每个窗口均有一个由创建该窗口的应用程序使用的32位值。
+ /// GWL_WNDPROC -4 为窗口设定一个新的处理函数。
+ /// GWL_HWNDPARENT -8 改变子窗口的父窗口,应使用SetParent函数
+ ///
+ /// 指定的替换值
+ ///
+ [Obsolete("请使用 SetWindowLongPtr 解决 x86 和 x64 需要使用不同方法")]
+ [DllImport(LibraryName, CharSet = Properties.BuildCharSet)]
+ public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
+
+ ///
+ /// 改变指定窗口的属性
+ ///
+ /// 窗口句柄
+ /// 指定将设定的大于等于0的偏移值。有效值的范围从0到额外类的存储空间的字节数减4:例如若指定了12或多于12个字节的额外窗口存储空间,则应设索引位8来访问第三个4字节,同样设置0访问第一个4字节,4访问第二个4字节。要设置其他任何值,可以指定下面值之一
+ /// 从 GetWindowLongFields 可以找到所有的值
+ ///
+ /// GetWindowLongFields.GWL_EXSTYLE -20 设定一个新的扩展风格。
+ /// GWL_HINSTANCE -6 设置一个新的应用程序实例句柄。
+ /// GWL_ID -12 设置一个新的窗口标识符。
+ /// GWL_STYLE -16 设定一个新的窗口风格。
+ /// GWL_USERDATA -21 设置与窗口有关的32位值。每个窗口均有一个由创建该窗口的应用程序使用的32位值。
+ /// GWL_WNDPROC -4 为窗口设定一个新的处理函数。
+ /// GWL_HWNDPARENT -8 改变子窗口的父窗口,应使用SetParent函数
+ ///
+ /// 指定的替换值
+ ///
+ [DllImport(LibraryName, CharSet = Properties.BuildCharSet, EntryPoint = "SetWindowLongPtr")]
+ [Obsolete("请使用 SetWindowLongPtr 解决 x86 和 x64 需要使用不同方法")]
+ public static extern IntPtr SetWindowLongPtr_x64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
+
+ public const string LibraryName = "user32";
+ }
+
+ internal static class Properties {
+#if !ANSI
+ public const CharSet BuildCharSet = CharSet.Unicode;
+#else
+ public const CharSet BuildCharSet = CharSet.Ansi;
+#endif
+ }
+
+ ///
+ /// 用于在 的 int index 传入
+ ///
+ /// 代码:[GetWindowLong function (Windows)](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633584(v=vs.85).aspx )
+ public enum GetWindowLongFields {
+ ///
+ /// 设定一个新的扩展风格
+ /// Retrieves the extended window styles
+ ///
+ GWL_EXSTYLE = -20,
+
+ ///
+ /// 设置一个新的应用程序实例句柄
+ /// Retrieves a handle to the application instance
+ ///
+ GWL_HINSTANCE = -6,
+
+ ///
+ /// 改变子窗口的父窗口
+ /// Retrieves a handle to the parent window, if any
+ ///
+ GWL_HWNDPARENT = -8,
+
+ ///
+ /// 设置一个新的窗口标识符
+ /// Retrieves the identifier of the window
+ ///
+ GWL_ID = -12,
+
+ ///
+ /// 设定一个新的窗口风格
+ /// Retrieves the window styles
+ ///
+ GWL_STYLE = -16,
+
+ ///
+ /// 设置与窗口有关的32位值。每个窗口均有一个由创建该窗口的应用程序使用的32位值
+ /// Retrieves the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero
+ ///
+ GWL_USERDATA = -21,
+
+ ///
+ /// 为窗口设定一个新的处理函数
+ /// Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure
+ ///
+ GWL_WNDPROC = -4,
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/InkCanvasForClass/Helpers/PerformanceTransparentWin.cs b/InkCanvasForClass/Helpers/PerformanceTransparentWin.cs
new file mode 100644
index 0000000..c61cf2a
--- /dev/null
+++ b/InkCanvasForClass/Helpers/PerformanceTransparentWin.cs
@@ -0,0 +1,205 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;
+using System.Windows.Controls;
+using System.Windows.Interop;
+using System.Windows.Shell;
+using System.Windows;
+using System.Windows.Media;
+
+namespace Ink_Canvas.Helpers
+{
+ ///
+ /// 高性能透明桌面窗口
+ ///
+ public partial class PerformanceTransparentWin : Window
+ {
+
+ static class BrushCreator
+ {
+ ///
+ /// 尝试从缓存获取或创建颜色笔刷
+ ///
+ /// 对应的字符串颜色
+ /// 已经被 Freeze 的颜色笔刷
+ public static SolidColorBrush GetOrCreate(string color)
+ {
+ if (!color.StartsWith("#"))
+ {
+ throw new ArgumentException($"输入的{nameof(color)}不是有效颜色,需要使用 # 开始");
+ // 如果不使用 # 开始将会在 ConvertFromString 出现异常
+ }
+
+ if (TryGetBrush(color, out var brushValue))
+ {
+ return (SolidColorBrush)brushValue;
+ }
+
+ object convertColor;
+
+ try
+ {
+ convertColor = ColorConverter.ConvertFromString(color);
+ }
+ catch (FormatException)
+ {
+ // 因为在 ConvertFromString 会抛出的是 令牌无效 难以知道是为什么传入的不对
+ throw new ArgumentException($"输入的{nameof(color)}不是有效颜色");
+ }
+
+ if (convertColor == null)
+ {
+ throw new ArgumentException($"输入的{nameof(color)}不是有效颜色");
+ }
+
+ var brush = new SolidColorBrush((Color)convertColor);
+ if (TryFreeze(brush))
+ {
+ BrushCacheList.Add(color, new WeakReference(brush));
+ }
+
+ return brush;
+ }
+
+ private static Dictionary> BrushCacheList { get; } =
+ new Dictionary>();
+
+ private static bool TryGetBrush(string key, out Brush brush)
+ {
+ if (BrushCacheList.TryGetValue(key, out var brushValue))
+ {
+ if (brushValue.TryGetTarget(out brush))
+ {
+ return true;
+ }
+ else
+ {
+ // 被回收的资源
+ BrushCacheList.Remove(key);
+ }
+ }
+
+ brush = null;
+ return false;
+ }
+
+ private static bool TryFreeze(Freezable freezable)
+ {
+ if (freezable.CanFreeze)
+ {
+ freezable.Freeze();
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ ///
+ /// 创建高性能透明桌面窗口
+ ///
+ public PerformanceTransparentWin()
+ {
+ WindowStyle = WindowStyle.None;
+ ResizeMode = ResizeMode.NoResize;
+
+ WindowChrome.SetWindowChrome(this,
+ new WindowChrome { GlassFrameThickness = WindowChrome.GlassFrameCompleteThickness, CaptionHeight = 0 });
+
+ var visualTree = new FrameworkElementFactory(typeof(Border));
+ visualTree.SetValue(Border.BackgroundProperty, new TemplateBindingExtension(Window.BackgroundProperty));
+ var childVisualTree = new FrameworkElementFactory(typeof(ContentPresenter));
+ childVisualTree.SetValue(UIElement.ClipToBoundsProperty, true);
+ visualTree.AppendChild(childVisualTree);
+
+ Template = new ControlTemplate
+ {
+ TargetType = typeof(Window),
+ VisualTree = visualTree,
+ };
+
+ _dwmEnabled = DwmCompositionHelper.DwmIsCompositionEnabled();
+ if (_dwmEnabled)
+ {
+ _hwnd = new WindowInteropHelper(this).EnsureHandle();
+ Loaded += PerformanceDesktopTransparentWindow_Loaded;
+ Background = Brushes.Transparent;
+ }
+ else
+ {
+ AllowsTransparency = true;
+ Background = BrushCreator.GetOrCreate("#0100000");
+ _hwnd = new WindowInteropHelper(this).EnsureHandle();
+ }
+ }
+
+ ///
+ /// 设置点击穿透到后面透明的窗口
+ ///
+ public void SetTransparentHitThrough()
+ {
+ if (_dwmEnabled)
+ {
+ Win32.User32.SetWindowLongPtr(_hwnd, Win32.GetWindowLongFields.GWL_EXSTYLE,
+ (IntPtr)(int)((long)Win32.User32.GetWindowLongPtr(_hwnd, Win32.GetWindowLongFields.GWL_EXSTYLE) | (long)Win32.ExtendedWindowStyles.WS_EX_TRANSPARENT));
+ }
+ else
+ {
+ Background = Brushes.Transparent;
+ }
+ }
+
+ ///
+ /// 设置点击命中,不会穿透到后面的窗口
+ ///
+ public void SetTransparentNotHitThrough()
+ {
+ if (_dwmEnabled)
+ {
+ Win32.User32.SetWindowLongPtr(_hwnd, Win32.GetWindowLongFields.GWL_EXSTYLE,
+ (IntPtr)(int)((long)Win32.User32.GetWindowLongPtr(_hwnd, Win32.GetWindowLongFields.GWL_EXSTYLE) & ~(long)Win32.ExtendedWindowStyles.WS_EX_TRANSPARENT));
+ }
+ else
+ {
+ Background = BrushCreator.GetOrCreate("#0100000");
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct STYLESTRUCT
+ {
+ public int styleOld;
+ public int styleNew;
+ }
+
+ private void PerformanceDesktopTransparentWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ ((HwndSource)PresentationSource.FromVisual(this)).AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
+ {
+ //想要让窗口透明穿透鼠标和触摸等,需要同时设置 WS_EX_LAYERED 和 WS_EX_TRANSPARENT 样式,
+ //确保窗口始终有 WS_EX_LAYERED 这个样式,并在开启穿透时设置 WS_EX_TRANSPARENT 样式
+ //但是WPF窗口在未设置 AllowsTransparency = true 时,会自动去掉 WS_EX_LAYERED 样式(在 HwndTarget 类中),
+ //如果设置了 AllowsTransparency = true 将使用WPF内置的低性能的透明实现,
+ //所以这里通过 Hook 的方式,在不使用WPF内置的透明实现的情况下,强行保证这个样式存在。
+ if (msg == (int)Win32.WM.STYLECHANGING && (long)wParam == (long)Win32.GetWindowLongFields.GWL_EXSTYLE)
+ {
+ var styleStruct = (STYLESTRUCT)Marshal.PtrToStructure(lParam, typeof(STYLESTRUCT));
+ styleStruct.styleNew |= (int)Win32.ExtendedWindowStyles.WS_EX_LAYERED;
+ Marshal.StructureToPtr(styleStruct, lParam, false);
+ handled = true;
+ }
+ return IntPtr.Zero;
+ });
+ }
+
+ ///
+ /// 是否开启 DWM 了,如果开启了,那么才可以使用高性能的桌面透明窗口
+ ///
+ private readonly bool _dwmEnabled;
+ private readonly IntPtr _hwnd;
+ }
+}
diff --git a/InkCanvasForClass/Helpers/RectangleSelectionViewer.cs b/InkCanvasForClass/Helpers/RectangleSelectionViewer.cs
new file mode 100644
index 0000000..79e70dc
--- /dev/null
+++ b/InkCanvasForClass/Helpers/RectangleSelectionViewer.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Windows;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Animation;
+
+namespace Ink_Canvas.Helpers
+{
+
+ public class RectangleSelectionViewer : FrameworkElement
+ {
+ private VisualCollection _children;
+ private DrawingVisual _layer = new DrawingVisual();
+ private Pen defaultPen = new Pen();
+
+ public RectangleSelectionViewer()
+ {
+ _children = new VisualCollection(this) {
+ _layer // 初始化DrawingVisual
+ };
+ defaultPen.Thickness = 2;
+ defaultPen.Brush = new SolidColorBrush(Color.FromRgb(37, 99, 235));
+ defaultPen.DashStyle = DashStyles.Dash;
+ }
+
+ protected override int VisualChildrenCount => _children.Count;
+
+ protected override Visual GetVisualChild(int index)
+ {
+ if (index < 0 || index >= _children.Count) throw new ArgumentOutOfRangeException();
+ return _children[index];
+ }
+
+ public void DrawSelectionBox(Rect rect) {
+ DrawingContext context = _layer.RenderOpen();
+ context.DrawRoundedRectangle(new SolidColorBrush(Color.FromArgb(78, 96, 165, 250)), defaultPen, rect, 4, 4);
+ context.Close();
+ }
+
+ public void ClearDrawing() {
+ DrawingContext context = _layer.RenderOpen();
+ context.Close();
+ }
+ }
+}
diff --git a/InkCanvasForClass/InkCanvasForClass.csproj b/InkCanvasForClass/InkCanvasForClass.csproj
index f1d7ebc..dfbd0d9 100644
--- a/InkCanvasForClass/InkCanvasForClass.csproj
+++ b/InkCanvasForClass/InkCanvasForClass.csproj
@@ -147,7 +147,9 @@
+
+
@@ -183,7 +185,11 @@
-
+
+
+
+
+
@@ -343,6 +349,7 @@
+
@@ -489,7 +496,11 @@
-
+
+
+
+
+
@@ -531,6 +542,7 @@
+
diff --git a/InkCanvasForClass/InkCanvasForClass.csproj.user b/InkCanvasForClass/InkCanvasForClass.csproj.user
index 2ece275..a01fe20 100644
--- a/InkCanvasForClass/InkCanvasForClass.csproj.user
+++ b/InkCanvasForClass/InkCanvasForClass.csproj.user
@@ -11,10 +11,31 @@
Code
+
+ Code
+
+
+ Designer
+
+
+ Designer
+
Designer
+
+ Designer
+
+
+ Designer
+
+
+ Designer
+
+
+ Designer
+
\ No newline at end of file
diff --git a/InkCanvasForClass/MainWindow.xaml b/InkCanvasForClass/MainWindow.xaml
index db5ff0c..4628ccd 100644
--- a/InkCanvasForClass/MainWindow.xaml
+++ b/InkCanvasForClass/MainWindow.xaml
@@ -6,8 +6,9 @@
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:c="clr-namespace:Ink_Canvas.Converter"
xmlns:Controls="http://schemas.microsoft.com/netfx/2009/xaml/presentation" xmlns:popups="clr-namespace:Ink_Canvas.Popups"
+ xmlns:inkCanvas="clr-namespace:Ink_Canvas"
+ xmlns:helpers="clr-namespace:Ink_Canvas.Helpers"
mc:Ignorable="d"
- AllowsTransparency="True"
WindowStyle="None"
ResizeMode="NoResize"
WindowState="Maximized"
@@ -20,6 +21,7 @@
Closing="Window_Closing"
Closed="Window_Closed"
PreviewKeyDown="Main_Grid_PreviewKeyDown"
+ PreviewKeyUp="Main_Grid_PreviewKeyUp"
Height="12000" Width="1440"
FontFamily="Microsoft YaHei UI"
MouseWheel="Window_MouseWheel"
@@ -30,31 +32,41 @@
Stylus.IsFlicksEnabled="False"
Stylus.IsTapFeedbackEnabled="False"
DpiChanged="MainWindow_OnDpiChanged"
+ PreviewStylusButtonDown="mainWin_StylusButtonDown"
+ PreviewStylusButtonUp="mainWin_StylusButtonUp"
+ PreviewStylusMove="mainWin_StylusMove"
+ PreviewStylusInAirMove="mainWin_StylusInAirMove"
Stylus.IsTouchFeedbackEnabled="False">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -106,8 +118,8 @@
-
-
+
+
@@ -117,26 +129,27 @@
+
+ TouchUp="Main_Grid_TouchUp" TouchDown="Main_Grid_TouchDown"
+ TouchMove="inkCanvas_TouchMove"
+ ManipulationDelta="Main_Grid_ManipulationDelta"
+ ManipulationCompleted="Main_Grid_ManipulationCompleted"
+ ManipulationInertiaStarting="inkCanvas_ManipulationInertiaStarting"
+ IsManipulationEnabled="True"
+ EditingModeChanged="inkCanvas_EditingModeChanged"
+ EditingModeInverted="None"
+ PreviewTouchDown="inkCanvas_PreviewTouchDown"
+ PreviewTouchUp="inkCanvas_PreviewTouchUp"
+ MouseDown="inkCanvas_MouseDown"
+ MouseMove="inkCanvas_MouseMove"
+ MouseUp="inkCanvas_MouseUp"
+ PreviewMouseRightButtonDown="InkCanvas_MouseRightButtonDown"
+ PreviewMouseRightButtonUp="InkCanvas_MouseRightButtonUp"
+ ManipulationStarting="inkCanvas_ManipulationStarting"
+ SelectionChanged="inkCanvas_SelectionChanged"
+ StrokeCollected="inkCanvas_StrokeCollected" ClipToBounds="False" Background="Transparent" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
-
+
@@ -2224,13 +2437,13 @@
+ Opacity="{Binding ElementName=SymbolIconUndo, Path=IsEnabled, Converter={StaticResource IsEnabledToOpacityConverter}}">
@@ -2242,7 +2455,8 @@
-
@@ -2250,13 +2464,13 @@
MouseDown="Border_MouseDown" MouseUp="SymbolIconRedo_MouseUp"
BorderThickness="0,1,1,1"
BorderBrush="#a1a1aa"
- IsEnabled="{Binding ElementName=BtnRedo, Path=IsEnabled}"
+ IsEnabled="{Binding ElementName=SymbolIconRedo, Path=IsEnabled}"
Background="#f4f4f5"
Opacity="0.95">
+ Opacity="{Binding ElementName=SymbolIconRedo, Path=IsEnabled, Converter={StaticResource IsEnabledToOpacityConverter}}">
@@ -2268,7 +2482,7 @@
-
@@ -2810,7 +3024,7 @@
-
@@ -2827,7 +3041,7 @@
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Foreground="{Binding ElementName=BtnExit, Path=Foreground}"
Background="{Binding ElementName=BtnExit, Path=Background}" />
-
+ -->
@@ -4459,11 +4673,11 @@
MouseLeave="FloatingBarToolBtnMouseLeaveFeedback_Panel"
Background="Transparent" Orientation="Vertical"
HorizontalAlignment="Center" Margin="0,-2"
- IsEnabled="{Binding ElementName=BtnUndo, Path=IsEnabled}"
+ IsEnabled="False"
Width="28">
+ Opacity="{Binding ElementName=SymbolIconUndo, Path=IsEnabled, Converter={StaticResource IsEnabledToOpacityConverter}}">
@@ -4476,7 +4690,7 @@
@@ -4487,11 +4701,11 @@
MouseLeave="FloatingBarToolBtnMouseLeaveFeedback_Panel"
Background="Transparent" Orientation="Vertical"
HorizontalAlignment="Center"
- IsEnabled="{Binding ElementName=BtnRedo, Path=IsEnabled}"
+ IsEnabled="False"
Width="28" Margin="0,-2">
+ Opacity="{Binding ElementName=SymbolIconRedo, Path=IsEnabled, Converter={StaticResource IsEnabledToOpacityConverter}}">
@@ -4504,7 +4718,7 @@
@@ -5055,7 +5269,7 @@
MouseDown="Border_MouseDown" MouseUp="ImagePPTControlEnd_MouseUp"
Background="{DynamicResource FloatBarBackground}" CornerRadius="4" BorderThickness="1"
BorderBrush="{DynamicResource FloatBarBorderBrush}"
- Visibility="{Binding ElementName=BtnPPTSlideShowEnd, Path=Visibility}">
+ Visibility="Collapsed">
@@ -5580,10 +5794,43 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -6019,6 +6266,61 @@
FontFamily="Microsoft YaHei UI" FontWeight="Bold"
Toggled="ToggleSwitchEnableMouseWheelGesture_Toggled" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -6704,17 +7006,6 @@
IsOn="True" FontFamily="Microsoft YaHei UI" FontWeight="Bold"
Toggled="ToggleSwitchEnableTwoFingerGestureInPresentationMode_Toggled" />
-
-
-
-
-
@@ -6982,6 +7273,37 @@
Name="ToggleSwitchIsDisableCloseWindow" IsOn="True"
FontFamily="Microsoft YaHei UI" FontWeight="Bold" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
@@ -7703,11 +8025,11 @@
0%
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -7805,7 +8157,7 @@
+ Text="6.0.0" />
@@ -7871,7 +8223,7 @@
- ICC 的开发者
+ InkCanvasForClass
@@ -7890,7 +8242,7 @@
- ICA 的开发者
+ Ink Canvas Artistry
@@ -7909,23 +8261,30 @@
- Ink Canvas 的开发者
+ Ink Canvas
- ICC 仓库源:
+ icc! Gitea源:
+
+ icc! Github源:
+
+
+
+
ICA 仓库源:
-
+
@@ -8116,7 +8475,10 @@
Text="© 2024 Dubi906w(Kriastans) 版权所有" FontWeight="Bold"
TextWrapping="Wrap" Foreground="White" />
+
{
isFloatingBarOutsideScreen = IsOutsideOfScreenHelper.IsOutsideOfScreen(ViewboxFloatingBar);
- isInPPTPresentationMode = BtnPPTSlideShowEnd.Visibility == Visibility.Visible;
+ isInPPTPresentationMode = BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible;
});
if (isFloatingBarOutsideScreen) dpiChangedDelayAction.DebounceAction(3000, null, () => {
if (!isFloatingBarFolded)
@@ -279,7 +281,7 @@ namespace Ink_Canvas {
var isInPPTPresentationMode = false;
Dispatcher.Invoke(() => {
isFloatingBarOutsideScreen = IsOutsideOfScreenHelper.IsOutsideOfScreen(ViewboxFloatingBar);
- isInPPTPresentationMode = BtnPPTSlideShowEnd.Visibility == Visibility.Visible;
+ isInPPTPresentationMode = BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible;
});
if (isFloatingBarOutsideScreen) dpiChangedDelayAction.DebounceAction(3000,null, () => {
if (!isFloatingBarFolded)
diff --git a/InkCanvasForClass/MainWindow_cs/MW_AutoFold.cs b/InkCanvasForClass/MainWindow_cs/MW_AutoFold.cs
index 1bccafb..9ccb2a2 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_AutoFold.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_AutoFold.cs
@@ -25,8 +25,7 @@ namespace Ink_Canvas {
WaterMarkTime.Visibility = Visibility.Collapsed;
WaterMarkDate.Visibility = Visibility.Collapsed;
BlackBoardWaterMark.Visibility = Visibility.Collapsed;
- BtnSwitch_Click(BtnSwitch, null);
- BtnExit.Foreground = Brushes.White;
+ BtnSwitch_Click(null, null);
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
new Thread(new ThreadStart(() => {
Thread.Sleep(200);
@@ -202,7 +201,7 @@ namespace Ink_Canvas {
LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed;
});
- if (sender == null || StackPanelPPTControls.Visibility == Visibility.Visible)
+ if (sender == null || BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible)
unfoldFloatingBarByUser = false;
else
unfoldFloatingBarByUser = true;
@@ -218,7 +217,7 @@ namespace Ink_Canvas {
await Task.Delay(0);
await Dispatcher.InvokeAsync(() => {
- if (StackPanelPPTControls.Visibility == Visibility.Visible)
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible)
{
var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString();
var dopsc = dops.ToCharArray();
@@ -228,7 +227,7 @@ namespace Ink_Canvas {
if (dopsc[3] == '2' && isDisplayingOrHidingBlackboard == false) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation);
}
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible)
ViewboxFloatingBarMarginAnimation(60);
else
ViewboxFloatingBarMarginAnimation(100, true);
diff --git a/InkCanvasForClass/MainWindow_cs/MW_BoardIcons.cs b/InkCanvasForClass/MainWindow_cs/MW_BoardIcons.cs
index c5d9333..bf935b8 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_BoardIcons.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_BoardIcons.cs
@@ -63,6 +63,11 @@ namespace Ink_Canvas {
}
inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
}
+
+ // update tool selection
+ SelectedMode = ICCToolsEnum.EraseByGeometryMode;
+ ForceUpdateToolSelection(null);
+
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
drawingShapeMode = 0;
@@ -70,10 +75,6 @@ namespace Ink_Canvas {
CancelSingleFingerDragMode();
HideSubPanels("eraser");
-
- // update tool selection
- SelectedMode = ICCToolsEnum.EraseByGeometryMode;
- ForceUpdateToolSelection(null);
}
}
@@ -85,6 +86,10 @@ namespace Ink_Canvas {
forceEraser = true;
forcePointEraser = false;
+ // update tool selection
+ SelectedMode = ICCToolsEnum.EraseByStrokeMode;
+ ForceUpdateToolSelection(null);
+
inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
drawingShapeMode = 0;
@@ -93,9 +98,6 @@ namespace Ink_Canvas {
CancelSingleFingerDragMode();
HideSubPanels("eraserByStrokes");
- // update tool selection
- SelectedMode = ICCToolsEnum.EraseByStrokeMode;
- ForceUpdateToolSelection(null);
//}
}
diff --git a/InkCanvasForClass/MainWindow_cs/MW_Colors.cs b/InkCanvasForClass/MainWindow_cs/MW_Colors.cs
index d8f0e04..3bcdc9e 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_Colors.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_Colors.cs
@@ -28,7 +28,7 @@ namespace Ink_Canvas {
AnimationsHelper.HideWithSlideAndFade(BlackboardRightSide);
}
- BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
+ BtnHideInkCanvas_Click(null, null);
}
var strokes = inkCanvas.GetSelectedStrokes();
diff --git a/InkCanvasForClass/MainWindow_cs/MW_ContextMenus.xaml b/InkCanvasForClass/MainWindow_cs/MW_ContextMenus.xaml
new file mode 100644
index 0000000..c8afce8
--- /dev/null
+++ b/InkCanvasForClass/MainWindow_cs/MW_ContextMenus.xaml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/InkCanvasForClass/MainWindow_cs/MW_Eraser.cs b/InkCanvasForClass/MainWindow_cs/MW_Eraser.cs
new file mode 100644
index 0000000..15babaf
--- /dev/null
+++ b/InkCanvasForClass/MainWindow_cs/MW_Eraser.cs
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Ink;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace Ink_Canvas {
+ public partial class MainWindow : Window {
+
+ public bool isUsingGeometryEraser = false;
+ private IncrementalStrokeHitTester hitTester = null;
+
+ public double eraserWidth = 64;
+ public bool isEraserCircleShape = false;
+ public bool isUsingStrokesEraser = false;
+
+ private Matrix scaleMatrix = new Matrix();
+
+ private void EraserOverlay_Loaded(object sender, RoutedEventArgs e) {
+ var bd = (Border)sender;
+ bd.StylusDown += ((o, args) => {
+ e.Handled = true;
+ if (args.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) ((Border)o).CaptureStylus();
+ EraserOverlay_PointerDown(sender);
+ });
+ bd.StylusUp += ((o, args) => {
+ e.Handled = true;
+ if (args.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus) ((Border)o).ReleaseStylusCapture();
+ EraserOverlay_PointerUp(sender);
+ });
+ bd.StylusMove += ((o, args) => {
+ e.Handled = true;
+ EraserOverlay_PointerMove(sender, args.GetPosition(Main_Grid));
+ });
+ bd.MouseDown += ((o, args) => {
+ ((Border)o).CaptureMouse();
+ EraserOverlay_PointerDown(sender);
+ });
+ bd.MouseUp += ((o, args) => {
+ ((Border)o).ReleaseMouseCapture();
+ EraserOverlay_PointerUp(sender);
+ });
+ bd.MouseMove += ((o, args) => {
+ EraserOverlay_PointerMove(sender, args.GetPosition(Main_Grid));
+ });
+ bd.StylusButtonUp += (o, args) => {
+ Trace.WriteLine("ButtonUp!!!!!");
+ };
+ }
+
+ private void EraserOverlay_PointerDown(object sender) {
+ if (isUsingGeometryEraser) return;
+
+ // lock
+ isUsingGeometryEraser = true;
+
+ // caculate height
+ var _h = eraserWidth * 56 / 38;
+
+ // init hittester
+ hitTester = inkCanvas.Strokes.GetIncrementalStrokeHitTester(new RectangleStylusShape(
+ eraserWidth, _h));
+ hitTester.StrokeHit += EraserGeometry_StrokeHit;
+
+ // eraser bitmap cache
+ EraserOverlay_DrawingVisual.CacheMode = new BitmapCache();
+
+ // caculate scale matrix
+ var scaleX = eraserWidth / 38;
+ var scaleY = _h / 56;
+ scaleMatrix = new Matrix();
+ scaleMatrix.ScaleAt(scaleX,scaleY,0,0);
+ }
+
+ private void EraserOverlay_PointerUp(object sender) {
+ if (!isUsingGeometryEraser) return;
+
+ // unlock
+ isUsingGeometryEraser = false;
+
+ // release capture
+ ((Border)sender).ReleaseMouseCapture();
+
+ // hide eraser feedback
+ var ct = EraserOverlay_DrawingVisual.DrawingVisual.RenderOpen();
+ ct.DrawRectangle(new SolidColorBrush(Colors.Transparent),null,new Rect(0,0,ActualWidth,ActualHeight));
+ ct.Close();
+
+ // end hittest
+ hitTester.EndHitTesting();
+ }
+
+ private void EraserGeometry_StrokeHit(object sender,
+ StrokeHitEventArgs args) {
+ StrokeCollection eraseResult =
+ args.GetPointEraseResults();
+ StrokeCollection strokesToReplace = new StrokeCollection();
+ strokesToReplace.Add(args.HitStroke);
+
+ // replace the old stroke with the new one.
+ if (eraseResult.Count > 0) {
+ inkCanvas.Strokes.Replace(strokesToReplace, eraseResult);
+ } else {
+ inkCanvas.Strokes.Remove(strokesToReplace);
+ }
+ }
+
+ private void EraserOverlay_PointerMove(object sender, Point pt) {
+ if (!isUsingGeometryEraser) return;
+
+ if (isUsingStrokesEraser) {
+ inkCanvas.Strokes.Remove(inkCanvas.Strokes.HitTest(pt));
+ } else {
+ // draw eraser feedback
+ var ct = EraserOverlay_DrawingVisual.DrawingVisual.RenderOpen();
+ var mt = scaleMatrix;
+ var _h = eraserWidth * 56 / 38;
+ mt.Translate(pt.X - eraserWidth / 2, pt.Y - _h / 2);
+ ct.PushTransform(new MatrixTransform(mt));
+ ct.DrawDrawing(FindResource(isEraserCircleShape?"EraserCircleDrawingGroup":"EraserDrawingGroup") as DrawingGroup);
+ ct.Pop();
+ ct.Close();
+
+ // add point to hittester
+ hitTester.AddPoint(pt);
+ }
+
+ }
+ }
+}
diff --git a/InkCanvasForClass/MainWindow_cs/MW_Eraser.xaml b/InkCanvasForClass/MainWindow_cs/MW_Eraser.xaml
new file mode 100644
index 0000000..f6cdf56
--- /dev/null
+++ b/InkCanvasForClass/MainWindow_cs/MW_Eraser.xaml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/InkCanvasForClass/MainWindow_cs/MW_FloatingBarIcons.cs b/InkCanvasForClass/MainWindow_cs/MW_FloatingBarIcons.cs
index a6bb5cb..cd7a390 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_FloatingBarIcons.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_FloatingBarIcons.cs
@@ -119,7 +119,7 @@ namespace Ink_Canvas {
|| BorderFloatingBarMainControls.Visibility != Visibility.Visible) {
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
} else if (isVisible == true) {
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible)
EnableTwoFingerGestureBorder.Visibility = Visibility.Collapsed;
else EnableTwoFingerGestureBorder.Visibility = Visibility.Visible;
} else {
@@ -144,7 +144,7 @@ namespace Ink_Canvas {
ViewboxFloatingBar.Margin = new Thickness(xPos, yPos, -2000, -200);
pos = e.GetPosition(null);
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible)
pointPPT = new Point(xPos, yPos);
else
pointDesktop = new Point(xPos, yPos);
@@ -317,7 +317,7 @@ namespace Ink_Canvas {
}
if (mode != null && autoAlignCenter) {
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) {
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) {
await Task.Delay(50);
ViewboxFloatingBarMarginAnimation(60);
} else if (Topmost == true) //非黑板
@@ -346,8 +346,8 @@ namespace Ink_Canvas {
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == SymbolIconUndo && lastBorderMouseDownObject != SymbolIconUndo) return;
- if (!BtnUndo.IsEnabled) return;
- BtnUndo_Click(BtnUndo, null);
+ if (!SymbolIconUndo.IsEnabled) return;
+ BtnUndo_Click(null, null);
HideSubPanels();
}
@@ -358,8 +358,8 @@ namespace Ink_Canvas {
((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent);
if (sender == SymbolIconRedo && lastBorderMouseDownObject != SymbolIconRedo) return;
- if (!BtnRedo.IsEnabled) return;
- BtnRedo_Click(BtnRedo, null);
+ if (!SymbolIconRedo.IsEnabled) return;
+ BtnRedo_Click(null, null);
HideSubPanels();
}
@@ -392,15 +392,6 @@ namespace Ink_Canvas {
RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
//进入黑板
- /*
- if (Not_Enter_Blackboard_fir_Mouse_Click) {// BUG-Fixed_tmp:程序启动后直接进入白板会导致后续撤销功能、退出白板无法恢复墨迹
- BtnColorRed_Click(BorderPenColorRed, null);
- await Task.Delay(200);
- SimulateMouseClick.SimulateMouseClickAtTopLeft();
- await Task.Delay(10);
- Not_Enter_Blackboard_fir_Mouse_Click = false;
- }
- */
new Thread(new ThreadStart(() => {
Thread.Sleep(100);
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(60); });
@@ -416,7 +407,7 @@ namespace Ink_Canvas {
AnimationsHelper.HideWithSlideAndFade(BlackboardRightSide);
}
- BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
+ BtnHideInkCanvas_Click(null, null);
}
if (Settings.Gesture.AutoSwitchTwoFingerGesture) // 自动关闭多指书写、开启双指移动
@@ -454,7 +445,7 @@ namespace Ink_Canvas {
//关闭黑板
HideSubPanelsImmediately();
- if (StackPanelPPTControls.Visibility == Visibility.Visible) {
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) {
var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString();
var dopsc = dops.ToCharArray();
if (dopsc[0] == '2' && isDisplayingOrHidingBlackboard == false)
@@ -470,7 +461,7 @@ namespace Ink_Canvas {
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) SaveScreenshot(true);
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Collapsed)
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Collapsed)
new Thread(new ThreadStart(() => {
Thread.Sleep(300);
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(100, true); });
@@ -481,7 +472,7 @@ namespace Ink_Canvas {
Application.Current.Dispatcher.Invoke(() => { ViewboxFloatingBarMarginAnimation(60); });
})).Start();
- if (System.Windows.Controls.Canvas.GetLeft(FloatingbarSelectionBG) != 28) PenIcon_Click(null, null);
+ if (SelectedMode != ICCToolsEnum.PenMode) PenIcon_Click(null, null);
if (Settings.Gesture.AutoSwitchTwoFingerGesture) // 自动启用多指书写
ToggleSwitchEnableTwoFingerTranslate.IsOn = false;
@@ -492,13 +483,12 @@ namespace Ink_Canvas {
BlackBoardWaterMark.Visibility = Visibility.Collapsed;
}
- BtnSwitch_Click(BtnSwitch, null);
+ BtnSwitch_Click(null, null);
- if (currentMode == 0 && inkCanvas.Strokes.Count == 0 && BtnPPTSlideShowEnd.Visibility != Visibility.Visible)
+ if (currentMode == 0 && inkCanvas.Strokes.Count == 0 && BorderFloatingBarExitPPTBtn.Visibility != Visibility.Visible)
CursorIcon_Click(null, null);
- BtnExit.Foreground = Brushes.White;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
+ //ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
new Thread(new ThreadStart(() => {
Thread.Sleep(200);
@@ -511,19 +501,6 @@ namespace Ink_Canvas {
#endregion
- private async void SymbolIconCursor_Click(object sender, RoutedEventArgs e) {
- if (currentMode != 0) {
- ImageBlackboard_MouseUp(null, null);
- } else {
- BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
-
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) {
- await Task.Delay(100);
- ViewboxFloatingBarMarginAnimation(60);
- }
- }
- }
-
#region 清空畫布按鈕
private void SymbolIconDelete_MouseUp(object sender, MouseButtonEventArgs e) {
@@ -534,11 +511,18 @@ namespace Ink_Canvas {
if (inkCanvas.GetSelectedStrokes().Count > 0) {
inkCanvas.Strokes.Remove(inkCanvas.GetSelectedStrokes());
+ // cancel
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
+ inkCanvas.Opacity = 1;
+ InkSelectionStrokesOverlay.Visibility = Visibility.Collapsed;
+ InkSelectionStrokesBackgroundInkCanvas.Visibility = Visibility.Collapsed;
+ InkSelectionStrokesOverlay.DrawStrokes(new StrokeCollection(), new Matrix());
+ UpdateStrokeSelectionBorder(false, null);
+ RectangleSelectionHitTestBorder.Visibility = Visibility.Visible;
} else if (inkCanvas.Strokes.Count > 0) {
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber) {
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible)
SavePPTScreenshot($"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
else
SaveScreenshot(true);
@@ -649,6 +633,19 @@ namespace Ink_Canvas {
#region 主要的工具按鈕事件
+ private async void SymbolIconCursor_Click(object sender, RoutedEventArgs e) {
+ if (currentMode != 0) {
+ ImageBlackboard_MouseUp(null, null);
+ } else {
+ BtnHideInkCanvas_Click(null, null);
+
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) {
+ await Task.Delay(100);
+ ViewboxFloatingBarMarginAnimation(60);
+ }
+ }
+ }
+
private async void CursorIcon_Click(object sender, RoutedEventArgs e)
{
if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel)
@@ -659,11 +656,11 @@ namespace Ink_Canvas {
if (inkCanvas.Strokes.Count > 0 &&
inkCanvas.Strokes.Count > Settings.Automation.MinimumAutomationStrokeNumber)
{
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) SavePPTScreenshot($"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) SavePPTScreenshot($"{pptName}/{previousSlideID}_{DateTime.Now:HH-mm-ss}");
else SaveScreenshot(true);
}
- if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible)
+ if (BorderFloatingBarExitPPTBtn.Visibility != Visibility.Visible)
{
if (Settings.Canvas.HideStrokeWhenSelecting)
{
@@ -709,10 +706,6 @@ namespace Ink_Canvas {
RestoreStrokes(true);
}
- BtnSwitch.Content = BtnSwitchTheme.Content.ToString() == "浅色" ? "黑板" : "白板";
-
- StackPanelPPTButtons.Visibility = Visibility.Visible;
- BtnHideInkCanvas.Content = "显示\n画板";
CheckEnableTwoFingerGestureBtnVisibility(false);
@@ -727,10 +720,12 @@ namespace Ink_Canvas {
await Task.Delay(50);
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible)
ViewboxFloatingBarMarginAnimation(60);
else
ViewboxFloatingBarMarginAnimation(100, true);
+
+ RectangleSelectionHitTestBorder.Visibility = Visibility.Collapsed;
}
private void PenIcon_Click(object sender, RoutedEventArgs e)
@@ -756,24 +751,8 @@ namespace Ink_Canvas {
/*if (forceEraser && currentMode == 0)
BtnColorRed_Click(sender, null);*/
- if (GridBackgroundCover.Visibility == Visibility.Collapsed)
- {
- if (BtnSwitchTheme.Content.ToString() == "浅色")
- BtnSwitch.Content = "黑板";
- else
- BtnSwitch.Content = "白板";
- StackPanelPPTButtons.Visibility = Visibility.Visible;
- }
- else
- {
- BtnSwitch.Content = "屏幕";
- StackPanelPPTButtons.Visibility = Visibility.Collapsed;
- }
-
- BtnHideInkCanvas.Content = "隐藏\n画板";
StackPanelCanvasControls.Visibility = Visibility.Visible;
- //AnimationsHelper.ShowWithSlideFromLeftAndFade(StackPanelCanvasControls);
CheckEnableTwoFingerGestureBtnVisibility(true);
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
ColorSwitchCheck();
@@ -787,36 +766,44 @@ namespace Ink_Canvas {
{
if (inkCanvas.EditingMode == InkCanvasEditingMode.Ink)
{
- if (PenPalette.Visibility == Visibility.Visible)
- {
- AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
- AnimationsHelper.HideWithSlideAndFade(BorderTools);
- AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
- AnimationsHelper.HideWithSlideAndFade(PenPalette);
- AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
- AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
- AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
- AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
- AnimationsHelper.HideWithSlideAndFade(BorderTools);
- AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
- AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
- AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
- }
- else
- {
- AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
- AnimationsHelper.HideWithSlideAndFade(BorderTools);
- AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
- AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
- AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
- AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
- AnimationsHelper.HideWithSlideAndFade(BorderTools);
- AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
- AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
- AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
- AnimationsHelper.ShowWithSlideFromBottomAndFade(PenPalette);
- AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardPenPalette);
+ //if (PenPalette.Visibility == Visibility.Visible)
+ //{
+ // AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
+ // AnimationsHelper.HideWithSlideAndFade(BorderTools);
+ // AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
+ // AnimationsHelper.HideWithSlideAndFade(PenPalette);
+ // AnimationsHelper.HideWithSlideAndFade(BoardPenPalette);
+ // AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
+ // AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
+ // AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
+ // AnimationsHelper.HideWithSlideAndFade(BorderTools);
+ // AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
+ // AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
+ // AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
+ //}
+ //else
+ //{
+ // AnimationsHelper.HideWithSlideAndFade(EraserSizePanel);
+ // AnimationsHelper.HideWithSlideAndFade(BorderTools);
+ // AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
+ // AnimationsHelper.HideWithSlideAndFade(BorderDrawShape);
+ // AnimationsHelper.HideWithSlideAndFade(BoardBorderDrawShape);
+ // AnimationsHelper.HideWithSlideAndFade(BoardEraserSizePanel);
+ // AnimationsHelper.HideWithSlideAndFade(BorderTools);
+ // AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
+ // AnimationsHelper.HideWithSlideAndFade(TwoFingerGestureBorder);
+ // AnimationsHelper.HideWithSlideAndFade(BoardTwoFingerGestureBorder);
+ // AnimationsHelper.ShowWithSlideFromBottomAndFade(PenPalette);
+ // AnimationsHelper.ShowWithSlideFromBottomAndFade(BoardPenPalette);
+ //}
+
+ if (PenPaletteV2Popup.IsOpen == false) {
+ var transform = Pen_Icon.TransformToVisual(Main_Grid);
+ var pt = transform.Transform(new Point(0, 0));
+ PenPaletteV2Popup.VerticalOffset = pt.Y;
+ PenPaletteV2Popup.HorizontalOffset = pt.X - 32;
}
+ PenPaletteV2Popup.IsOpen = !PenPaletteV2Popup.IsOpen;
}
else
{
@@ -861,49 +848,31 @@ namespace Ink_Canvas {
forceEraser = true;
forcePointEraser = true;
- if (Settings.Canvas.EraserShapeType == 0)
- {
- double k = 1;
- switch (Settings.Canvas.EraserSize)
- {
- case 0:
- k = 0.5;
- break;
- case 1:
- k = 0.8;
- break;
- case 3:
- k = 1.25;
- break;
- case 4:
- k = 1.8;
- break;
- }
- inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
- }
- else if (Settings.Canvas.EraserShapeType == 1)
+ double width = 24;
+ switch (Settings.Canvas.EraserSize)
{
- double k = 1;
- switch (Settings.Canvas.EraserSize)
- {
- case 0:
- k = 0.7;
- break;
- case 1:
- k = 0.9;
- break;
- case 3:
- k = 1.2;
- break;
- case 4:
- k = 1.6;
- break;
- }
-
- inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
+ case 0:
+ width = 24;
+ break;
+ case 1:
+ width = 38;
+ break;
+ case 2:
+ width = 46;
+ break;
+ case 3:
+ width = 62;
+ break;
+ case 4:
+ width = 78;
+ break;
}
+ eraserWidth = width;
+ isEraserCircleShape = Settings.Canvas.EraserShapeType == 0;
+ isUsingStrokesEraser = false;
+
if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint)
{
if (EraserSizePanel.Visibility == Visibility.Collapsed)
@@ -961,6 +930,12 @@ namespace Ink_Canvas {
forceEraser = true;
forcePointEraser = false;
+ isUsingStrokesEraser = true;
+
+ // update tool selection
+ SelectedMode = ICCToolsEnum.EraseByStrokeMode;
+ ForceUpdateToolSelection(null);
+
inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
drawingShapeMode = 0;
@@ -969,10 +944,6 @@ namespace Ink_Canvas {
CancelSingleFingerDragMode();
HideSubPanels("eraserByStrokes");
-
- // update tool selection
- SelectedMode = ICCToolsEnum.EraseByStrokeMode;
- ForceUpdateToolSelection(null);
}
#endregion
@@ -1409,7 +1380,7 @@ namespace Ink_Canvas {
toolbarHeight - ViewboxFloatingBarScaleTransform.ScaleY * 3;
if (MarginFromEdge != -60) {
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) {
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) {
if (pointPPT.X != -1 || pointPPT.Y != -1) {
if (Math.Abs(pointPPT.Y - pos.Y) > 50)
pos = pointPPT;
@@ -1553,11 +1524,12 @@ namespace Ink_Canvas {
drawingShapeMode = 0;
inkCanvas.IsManipulationEnabled = false;
if (inkCanvas.EditingMode == InkCanvasEditingMode.Select) {
- var selectedStrokes = new StrokeCollection();
- foreach (var stroke in inkCanvas.Strokes)
- if (stroke.GetBounds().Width > 0 && stroke.GetBounds().Height > 0)
- selectedStrokes.Add(stroke);
- inkCanvas.Select(selectedStrokes);
+ //var selectedStrokes = new StrokeCollection();
+ //foreach (var stroke in inkCanvas.Strokes)
+ // if (stroke.GetBounds().Width > 0 && stroke.GetBounds().Height > 0)
+ // selectedStrokes.Add(stroke);
+ //inkCanvas.Select(selectedStrokes);
+ inkCanvas.Select(inkCanvas.Strokes);
}
else {
inkCanvas.EditingMode = InkCanvasEditingMode.Select;
@@ -1594,20 +1566,15 @@ namespace Ink_Canvas {
#region Left Side Panel
private void BtnFingerDragMode_Click(object sender, RoutedEventArgs e) {
- if (isSingleFingerDragMode) {
- isSingleFingerDragMode = false;
- BtnFingerDragMode.Content = "单指\n拖动";
- }
- else {
- isSingleFingerDragMode = true;
- BtnFingerDragMode.Content = "多指\n拖动";
- }
+ isSingleFingerDragMode = !isSingleFingerDragMode;
}
private void BtnUndo_Click(object sender, RoutedEventArgs e) {
if (inkCanvas.GetSelectedStrokes().Count != 0) {
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
inkCanvas.Select(new StrokeCollection());
+ UpdateStrokeSelectionBorder(false, null);
+ RectangleSelectionHitTestBorder.Visibility = Visibility.Visible;
}
var item = timeMachine.Undo();
@@ -1618,6 +1585,8 @@ namespace Ink_Canvas {
if (inkCanvas.GetSelectedStrokes().Count != 0) {
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
inkCanvas.Select(new StrokeCollection());
+ UpdateStrokeSelectionBorder(false, null);
+ RectangleSelectionHitTestBorder.Visibility = Visibility.Visible;
}
var item = timeMachine.Redo();
@@ -1732,17 +1701,10 @@ namespace Ink_Canvas {
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
- if (isSingleFingerDragMode) BtnFingerDragMode_Click(BtnFingerDragMode, null);
+ if (isSingleFingerDragMode) BtnFingerDragMode_Click(null, null);
isLongPressSelected = false;
}
- private void BtnHideControl_Click(object sender, RoutedEventArgs e) {
- if (StackPanelControl.Visibility == Visibility.Visible)
- StackPanelControl.Visibility = Visibility.Hidden;
- else
- StackPanelControl.Visibility = Visibility.Visible;
- }
-
private int currentMode = 0;
private void BtnSwitch_Click(object sender, RoutedEventArgs e) {
@@ -1757,30 +1719,10 @@ namespace Ink_Canvas {
SaveStrokes(true);
ClearStrokes(true);
RestoreStrokes();
-
- if (BtnSwitchTheme.Content.ToString() == "浅色") {
- BtnSwitch.Content = "黑板";
- BtnExit.Foreground = Brushes.White;
- }
- else {
- BtnSwitch.Content = "白板";
- if (isPresentationHaveBlackSpace) {
- BtnExit.Foreground = Brushes.White;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.White;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
- }
- else {
- BtnExit.Foreground = Brushes.Black;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.White;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
- }
- }
-
- StackPanelPPTButtons.Visibility = Visibility.Visible;
}
Topmost = true;
- BtnHideInkCanvas_Click(BtnHideInkCanvas, e);
+ BtnHideInkCanvas_Click(null, e);
}
else {
switch (++currentMode % 2) {
@@ -1795,27 +1737,6 @@ namespace Ink_Canvas {
ClearStrokes(true);
RestoreStrokes(true);
- if (BtnSwitchTheme.Content.ToString() == "浅色") {
- BtnSwitch.Content = "黑板";
- BtnExit.Foreground = Brushes.White;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.Black;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
- }
- else {
- BtnSwitch.Content = "白板";
- if (isPresentationHaveBlackSpace) {
- BtnExit.Foreground = Brushes.White;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.White;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
- }
- else {
- BtnExit.Foreground = Brushes.Black;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.White;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
- }
- }
-
- StackPanelPPTButtons.Visibility = Visibility.Visible;
Topmost = true;
break;
case 1: //黑板或白板模式
@@ -1829,17 +1750,6 @@ namespace Ink_Canvas {
ClearStrokes(true);
RestoreStrokes();
- BtnSwitch.Content = "屏幕";
- if (BtnSwitchTheme.Content.ToString() == "浅色") {
- BtnExit.Foreground = Brushes.White;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.Black;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
- }
- else {
- BtnExit.Foreground = Brushes.Black;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.White;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
- }
var bgC = BoardPagesSettingsList[CurrentWhiteboardIndex - 1].BackgroundColor;
if (bgC == BlackboardBackgroundColorEnum.BlackBoardGreen
@@ -1848,8 +1758,7 @@ namespace Ink_Canvas {
|| bgC == BlackboardBackgroundColorEnum.RealBlack)
BtnColorWhite_Click(null, null);
else BtnColorBlack_Click(null, null);
-
- StackPanelPPTButtons.Visibility = Visibility.Collapsed;
+
Topmost = false;
break;
}
@@ -1868,24 +1777,10 @@ namespace Ink_Canvas {
GridBackgroundCoverHolder.Visibility = Visibility.Visible;
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
-
- if (GridBackgroundCover.Visibility == Visibility.Collapsed) {
- if (BtnSwitchTheme.Content.ToString() == "浅色")
- BtnSwitch.Content = "黑板";
- else
- BtnSwitch.Content = "白板";
- StackPanelPPTButtons.Visibility = Visibility.Visible;
- }
- else {
- BtnSwitch.Content = "屏幕";
- StackPanelPPTButtons.Visibility = Visibility.Collapsed;
- }
-
- BtnHideInkCanvas.Content = "隐藏\n画板";
}
else {
// Auto-clear Strokes 要等待截图完成再清理笔记
- if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible) {
+ if (BorderFloatingBarExitPPTBtn.Visibility != Visibility.Visible) {
if (isLoaded && Settings.Automation.IsAutoClearWhenExitingWritingMode)
if (inkCanvas.Strokes.Count > 0) {
if (Settings.Automation.IsAutoSaveStrokesAtClear && inkCanvas.Strokes.Count >
@@ -1929,14 +1824,6 @@ namespace Ink_Canvas {
SaveStrokes();
RestoreStrokes(true);
}
-
- if (BtnSwitchTheme.Content.ToString() == "浅色")
- BtnSwitch.Content = "黑板";
- else
- BtnSwitch.Content = "白板";
-
- StackPanelPPTButtons.Visibility = Visibility.Visible;
- BtnHideInkCanvas.Content = "显示\n画板";
}
if (GridTransparencyFakeBackground.Background == Brushes.Transparent) {
@@ -1953,24 +1840,6 @@ namespace Ink_Canvas {
}
}
- private void BtnSwitchSide_Click(object sender, RoutedEventArgs e) {
- if (ViewBoxStackPanelMain.HorizontalAlignment == HorizontalAlignment.Right) {
- ViewBoxStackPanelMain.HorizontalAlignment = HorizontalAlignment.Left;
- ViewBoxStackPanelShapes.HorizontalAlignment = HorizontalAlignment.Right;
- }
- else {
- ViewBoxStackPanelMain.HorizontalAlignment = HorizontalAlignment.Right;
- ViewBoxStackPanelShapes.HorizontalAlignment = HorizontalAlignment.Left;
- }
- }
-
- private void StackPanel_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) {
- if (((StackPanel)sender).Visibility == Visibility.Visible)
- GridForLeftSideReservedSpace.Visibility = Visibility.Collapsed;
- else
- GridForLeftSideReservedSpace.Visibility = Visibility.Visible;
- }
-
#endregion
}
}
\ No newline at end of file
diff --git a/InkCanvasForClass/MainWindow_cs/MW_Hotkeys.cs b/InkCanvasForClass/MainWindow_cs/MW_Hotkeys.cs
index 5f7660b..d7eb313 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_Hotkeys.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_Hotkeys.cs
@@ -1,22 +1,54 @@
-using System.Windows;
+using System;
+using System.Diagnostics;
+using System.Windows;
using System.Windows.Input;
+using static Ink_Canvas.Popups.ColorPalette;
namespace Ink_Canvas {
public partial class MainWindow : Window {
private void Window_MouseWheel(object sender, MouseWheelEventArgs e) {
- if (StackPanelPPTControls.Visibility != Visibility.Visible || currentMode != 0) return;
+ if (BorderFloatingBarExitPPTBtn.Visibility != Visibility.Visible || currentMode != 0) return;
if (e.Delta >= 120)
- BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null);
- else if (e.Delta <= -120) BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null);
+ BtnPPTSlidesUp_Click(null, null);
+ else if (e.Delta <= -120) BtnPPTSlidesDown_Click(null, null);
}
private void Main_Grid_PreviewKeyDown(object sender, KeyEventArgs e) {
- if (StackPanelPPTControls.Visibility != Visibility.Visible || currentMode != 0) return;
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible || currentMode == 0) {
+ if (e.Key == Key.Down || e.Key == Key.PageDown || e.Key == Key.Right || e.Key == Key.N ||
+ e.Key == Key.Space) BtnPPTSlidesDown_Click(null, null);
+ if (e.Key == Key.Up || e.Key == Key.PageUp || e.Key == Key.Left || e.Key == Key.P)
+ BtnPPTSlidesUp_Click(null, null);
+ };
+ if (e.Key == Key.LeftCtrl) {
+ Trace.WriteLine("KeyDown");
+ isControlKeyDown = true;
+ ControlKeyDownEvent?.Invoke(this,e);
+ }
+ if (e.Key == Key.LeftShift) {
+ Trace.WriteLine("KeyDown");
+ isShiftKeyDown = true;
+ ShiftKeyDownEvent?.Invoke(this,e);
+ }
+ }
- if (e.Key == Key.Down || e.Key == Key.PageDown || e.Key == Key.Right || e.Key == Key.N ||
- e.Key == Key.Space) BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null);
- if (e.Key == Key.Up || e.Key == Key.PageUp || e.Key == Key.Left || e.Key == Key.P)
- BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null);
+ public bool isControlKeyDown = false;
+ public bool isShiftKeyDown = false;
+
+ public event EventHandler ControlKeyDownEvent;
+ public event EventHandler ShiftKeyDownEvent;
+ public event EventHandler ControlKeyUpEvent;
+ public event EventHandler ShiftKeyUpEvent;
+
+ private void Main_Grid_PreviewKeyUp(object sender, KeyEventArgs e) {
+ if (e.Key == Key.LeftCtrl) {
+ isControlKeyDown = false;
+ ControlKeyUpEvent?.Invoke(this,e);
+ };
+ if (e.Key == Key.LeftShift) {
+ isShiftKeyDown = false;
+ ShiftKeyUpEvent?.Invoke(this,e);
+ }
}
private void Window_KeyDown(object sender, KeyEventArgs e) {
@@ -47,7 +79,7 @@ namespace Ink_Canvas {
private void KeyExit(object sender, ExecutedRoutedEventArgs e) {
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) BtnPPTSlideShowEnd_Click(BtnPPTSlideShowEnd, null);
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) BtnPPTSlideShowEnd_Click(null, null);
}
private void KeyChangeToDrawTool(object sender, ExecutedRoutedEventArgs e) {
diff --git a/InkCanvasForClass/MainWindow_cs/MW_InkCanvas.cs b/InkCanvasForClass/MainWindow_cs/MW_InkCanvas.cs
new file mode 100644
index 0000000..bbebc67
--- /dev/null
+++ b/InkCanvasForClass/MainWindow_cs/MW_InkCanvas.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Ink_Canvas
+{
+ public class IccInkCanvas : InkCanvas {
+ public IccInkCanvas() {
+
+ }
+ }
+}
diff --git a/InkCanvasForClass/MainWindow_cs/MW_PPT.cs b/InkCanvasForClass/MainWindow_cs/MW_PPT.cs
index d1195cd..2dddbdd 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_PPT.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_PPT.cs
@@ -56,11 +56,11 @@ namespace Ink_Canvas {
if (pptApplication == null) throw new Exception();
//BtnCheckPPT.Visibility = Visibility.Collapsed;
- StackPanelPPTControls.Visibility = Visibility.Visible;
+ BorderFloatingBarExitPPTBtn.Visibility = Visibility.Visible;
}
catch {
//BtnCheckPPT.Visibility = Visibility.Visible;
- StackPanelPPTControls.Visibility = Visibility.Collapsed;
+ BorderFloatingBarExitPPTBtn.Visibility = Visibility.Collapsed;
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
@@ -139,7 +139,7 @@ namespace Ink_Canvas {
}
catch {
//StackPanelPPTControls.Visibility = Visibility.Collapsed;
- Application.Current.Dispatcher.Invoke(() => { BtnPPTSlideShow.Visibility = Visibility.Collapsed; });
+ Application.Current.Dispatcher.Invoke(() => { BorderFloatingBarExitPPTBtn.Visibility = Visibility.Collapsed; });
timerCheckPPT.Start();
}
}
@@ -192,15 +192,13 @@ namespace Ink_Canvas {
}, () => { IsShowingRestoreHiddenSlidesWindow = false; },
() => { IsShowingRestoreHiddenSlidesWindow = false; }).ShowDialog();
}
-
- BtnPPTSlideShow.Visibility = Visibility.Visible;
}), DispatcherPriority.Normal);
}
//检测是否有自动播放
if (Settings.PowerPointSettings.IsNotifyAutoPlayPresentation
// && presentation.SlideShowSettings.AdvanceMode == PpSlideShowAdvanceMode.ppSlideShowUseSlideTimings
- && BtnPPTSlideShowEnd.Visibility != Visibility.Visible) {
+ && BorderFloatingBarExitPPTBtn.Visibility != Visibility.Visible) {
bool hasSlideTimings = false;
foreach (Slide slide in presentation.Slides) {
if (slide.SlideShowTransition.AdvanceOnTime == MsoTriState.msoTrue &&
@@ -237,8 +235,7 @@ namespace Ink_Canvas {
pptApplication = null;
timerCheckPPT.Start();
Application.Current.Dispatcher.Invoke(() => {
- BtnPPTSlideShow.Visibility = Visibility.Collapsed;
- BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed;
+ BorderFloatingBarExitPPTBtn.Visibility = Visibility.Collapsed;
});
}
@@ -417,18 +414,6 @@ namespace Ink_Canvas {
if (Math.Abs(screenRatio - 16.0 / 9) <= -0.01) {
if (Wn.Presentation.PageSetup.SlideWidth / Wn.Presentation.PageSetup.SlideHeight < 1.65) {
isPresentationHaveBlackSpace = true;
- //isButtonBackgroundTransparent = ToggleSwitchTransparentButtonBackground.IsOn;
-
- if (BtnSwitchTheme.Content.ToString() == "深色") {
- //Light
- BtnExit.Foreground = Brushes.White;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.White;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark;
- //BtnExit.Background = new SolidColorBrush(StringToColor("#AACCCCCC"));
- } else {
- //Dark
- //BtnExit.Background = new SolidColorBrush(StringToColor("#AA555555"));
- }
}
} else if (screenRatio == -256 / 135) { }
@@ -471,7 +456,7 @@ namespace Ink_Canvas {
LogHelper.WriteLogToFile($"Loaded {count.ToString()} saved strokes");
}
- StackPanelPPTControls.Visibility = Visibility.Visible;
+ BorderFloatingBarExitPPTBtn.Visibility = Visibility.Visible;
// -- old --
//if (Settings.PowerPointSettings.IsShowBottomPPTNavigationPanel && !isFloatingBarFolded)
@@ -494,15 +479,13 @@ namespace Ink_Canvas {
UpdatePPTBtnStyleSettingsStatus();
}
- BtnPPTSlideShow.Visibility = Visibility.Collapsed;
- BtnPPTSlideShowEnd.Visibility = Visibility.Visible;
- ViewBoxStackPanelMain.Margin = new Thickness(10, 10, 10, 10);
+ BorderFloatingBarExitPPTBtn.Visibility = Visibility.Visible;
ViewboxFloatingBar.Opacity = Settings.Appearance.ViewboxFloatingBarOpacityInPPTValue;
if (Settings.PowerPointSettings.IsShowCanvasAtNewSlideShow &&
!Settings.Automation.IsAutoFoldInPPTSlideShow &&
GridTransparencyFakeBackground.Background == Brushes.Transparent && !isFloatingBarFolded) {
- BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
+ BtnHideInkCanvas_Click(null, null);
}
if (currentMode != 0)
@@ -519,7 +502,7 @@ namespace Ink_Canvas {
//BtnSwitch.Content = BtnSwitchTheme.Content.ToString() == "浅色" ? "黑板" : "白板";
//StackPanelPPTButtons.Visibility = Visibility.Visible;
ImageBlackboard_MouseUp(null,null);
- BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
+ BtnHideInkCanvas_Click(null, null);
}
//ClearStrokes(true);
@@ -592,24 +575,12 @@ namespace Ink_Canvas {
await Application.Current.Dispatcher.InvokeAsync(() => {
isPresentationHaveBlackSpace = false;
- if (BtnSwitchTheme.Content.ToString() == "深色") {
- //Light
- BtnExit.Foreground = Brushes.Black;
- //SymbolIconBtnColorBlackContent.Foreground = Brushes.White;
- ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
- } else {
- //Dark
- }
-
- BtnPPTSlideShow.Visibility = Visibility.Visible;
- BtnPPTSlideShowEnd.Visibility = Visibility.Collapsed;
- StackPanelPPTControls.Visibility = Visibility.Collapsed;
+ BorderFloatingBarExitPPTBtn.Visibility = Visibility.Collapsed;
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
- ViewBoxStackPanelMain.Margin = new Thickness(10, 10, 10, 55);
if (currentMode != 0) {
ImageBlackboard_MouseUp(null,null);
@@ -618,7 +589,7 @@ namespace Ink_Canvas {
ClearStrokes(true);
if (GridTransparencyFakeBackground.Background != Brushes.Transparent)
- BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
+ BtnHideInkCanvas_Click(null, null);
ViewboxFloatingBar.Opacity = Settings.Appearance.ViewboxFloatingBarOpacityValue;
});
@@ -704,7 +675,7 @@ namespace Ink_Canvas {
})).Start();
}
catch {
- StackPanelPPTControls.Visibility = Visibility.Collapsed;
+ BorderFloatingBarExitPPTBtn.Visibility = Visibility.Collapsed;
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
@@ -743,7 +714,7 @@ namespace Ink_Canvas {
})).Start();
}
catch {
- StackPanelPPTControls.Visibility = Visibility.Collapsed;
+ BorderFloatingBarExitPPTBtn.Visibility = Visibility.Collapsed;
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
@@ -916,7 +887,7 @@ namespace Ink_Canvas {
{
PPTRBPreviousButtonFeedbackBorder.Opacity = 0;
}
- BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null);
+ BtnPPTSlidesUp_Click(null, null);
}
@@ -965,11 +936,11 @@ namespace Ink_Canvas {
{
PPTRBNextButtonFeedbackBorder.Opacity = 0;
}
- BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null);
+ BtnPPTSlidesDown_Click(null, null);
}
private void ImagePPTControlEnd_MouseUp(object sender, MouseButtonEventArgs e) {
- BtnPPTSlideShowEnd_Click(BtnPPTSlideShowEnd, null);
+ BtnPPTSlideShowEnd_Click(null, null);
}
}
}
\ No newline at end of file
diff --git a/InkCanvasForClass/MainWindow_cs/MW_SelectionGestures.cs b/InkCanvasForClass/MainWindow_cs/MW_SelectionGestures.cs
index b5cc24b..2540c3e 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_SelectionGestures.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_SelectionGestures.cs
@@ -1,13 +1,21 @@
using iNKORE.UI.WPF.Modern.Controls;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing.Drawing2D;
+using System.Linq;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
+using System.Windows.Media.Media3D;
+using System.Windows.Resources;
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
+using Matrix = System.Windows.Media.Matrix;
using Point = System.Windows.Point;
namespace Ink_Canvas {
@@ -22,36 +30,194 @@ namespace Ink_Canvas {
private bool isStrokeSelectionCloneOn = false;
- private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e) {
- if (lastBorderMouseDownObject != sender) return;
+ #region StrokesSelectionToolbarButtons
- if (isStrokeSelectionCloneOn) {
- BorderStrokeSelectionClone.Background = Brushes.Transparent;
+ private Border BorderStrokeSelectionToolButtonMouseDown = null;
- isStrokeSelectionCloneOn = false;
- }
- else {
- BorderStrokeSelectionClone.Background = new SolidColorBrush(StringToColor("#FF1ED760"));
-
- isStrokeSelectionCloneOn = true;
- }
+ private void BorderStrokeSelectionToolButton_MouseDown(object sender, MouseButtonEventArgs e) {
+ var bd = (Border)sender;
+ BorderStrokeSelectionToolButtonMouseDown = bd;
+ var innerBd = (Border)bd.Child;
+ if (bd.Name != "BorderStrokeSelectionDelete") innerBd.Background = new SolidColorBrush(Color.FromArgb(24, 9, 9, 11));
+ else innerBd.Background = new SolidColorBrush(Color.FromRgb(254, 202, 202));
}
+ private void BorderStrokeSelectionToolButton_MouseLeave(object sender, MouseEventArgs e) {
+ if (BorderStrokeSelectionToolButtonMouseDown == null) return;
+
+ var innerBd = (Border)BorderStrokeSelectionToolButtonMouseDown.Child;
+ innerBd.Background = new SolidColorBrush(Colors.Transparent);
+ BorderStrokeSelectionToolButtonMouseDown = null;
+ }
+
+ private void UpdateStrokesSelectionCloneToolButtonLimitStatus() {
+ UpdateSelectionToolbarOtherIconLockedStatus(isStrokeSelectionCloneOn);
+ BorderStrokeSelectionLock.IsHitTestVisible = !isStrokeSelectionCloneOn;
+ BorderStrokeSelectionLock.Opacity = isStrokeSelectionCloneOn ? 0.5 : 1;
+ BorderStrokeSelectionLock.IsEnabled = !isStrokeSelectionCloneOn;
+ BorderStrokeSelectionClone.IsHitTestVisible = true;
+ BorderStrokeSelectionClone.Opacity = 1;
+ BorderStrokeSelectionClone.IsEnabled = true;
+ }
+
+ ///
+ /// 墨迹克隆按钮
+ ///
+ ///
+ ///
+ private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
+
+ var bd = (Border)sender;
+ var innerBd = (Border)bd.Child;
+
+ // toolbutton
+ BorderStrokeSelectionToolButton_MouseLeave(sender, e);
+
+ if (isStrokeSelectionCloneOn) {
+ isStrokeSelectionCloneOn = false;
+ innerBd.Background = new SolidColorBrush(Colors.Transparent);
+ BorderStrokeSelectionCloneGeometryIcon.Brush = new SolidColorBrush(Color.FromRgb(24, 24, 27));
+ } else {
+ isStrokeSelectionCloneOn = true;
+ innerBd.Background = new SolidColorBrush(Color.FromRgb(187, 247, 208));
+ BorderStrokeSelectionCloneGeometryIcon.Brush = new SolidColorBrush(Color.FromRgb(21, 128, 61));
+ }
+
+ UpdateStrokesSelectionCloneToolButtonLimitStatus();
+ }
+
+ ///
+ /// 复制到白板或复制到新页面
+ ///
+ ///
+ ///
private void BorderStrokeSelectionCloneToNewBoard_MouseUp(object sender, MouseButtonEventArgs e) {
- if (lastBorderMouseDownObject != sender) return;
+ if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
+
+ // toolbutton
+ BorderStrokeSelectionToolButton_MouseLeave(sender, e);
var strokes = inkCanvas.GetSelectedStrokes();
inkCanvas.Select(new StrokeCollection());
+ CancelCurrentStrokesSelection();
strokes = strokes.Clone();
- BtnWhiteBoardAdd_Click(null, null);
+ if (currentMode == 0) ImageBlackboard_MouseUp(null, null);
+ else BtnWhiteBoardAdd_Click(null, null);
inkCanvas.Strokes.Add(strokes);
}
+ ///
+ /// 删除墨迹
+ ///
+ ///
+ ///
private void BorderStrokeSelectionDelete_MouseUp(object sender, MouseButtonEventArgs e) {
- if (lastBorderMouseDownObject != sender) return;
+ if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
SymbolIconDelete_MouseUp(sender, e);
+
+ // toolbutton
+ BorderStrokeSelectionToolButton_MouseLeave(sender, e);
+
+ // cancel
+ GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
+ inkCanvas.Opacity = 1;
+ InkSelectionStrokesOverlay.Visibility = Visibility.Collapsed;
+ InkSelectionStrokesBackgroundInkCanvas.Visibility = Visibility.Collapsed;
+ InkSelectionStrokesOverlay.DrawStrokes(new StrokeCollection(), new Matrix());
+ UpdateStrokeSelectionBorder(false, null);
+ RectangleSelectionHitTestBorder.Visibility = Visibility.Visible;
}
+
+ ///
+ /// 墨迹的 更多 菜单
+ ///
+ ///
+ ///
+ private void BorderStrokeMoreMenuButton_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
+
+ var cm = this.FindResource("StrokesSelectionMoreMenuButtonContextMenu") as ContextMenu;
+ cm.IsOpen = true;
+
+ // toolbutton
+ BorderStrokeSelectionToolButton_MouseLeave(sender, e);
+ }
+
+ ///
+ /// 通用的墨迹矩阵操作
+ ///
+ ///
+ private void MatrixStrokes(Func func) {
+ var m = new Matrix();
+
+ Point center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
+ inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
+ center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
+
+ m = func(m,center);
+
+ var targetStrokes = inkCanvas.GetSelectedStrokes();
+ foreach (var stroke in targetStrokes) stroke.Transform(m, false);
+
+ if (DrawingAttributesHistory.Count > 0)
+ {
+ timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
+ DrawingAttributesHistory = new Dictionary>();
+ foreach (var item in DrawingAttributesHistoryFlag)
+ {
+ item.Value.Clear();
+ }
+ }
+ }
+
+ private void __tb_preview__(object sender, MouseButtonEventArgs e) {
+ // toolbutton
+ BorderStrokeSelectionToolButton_MouseLeave(sender, e);
+
+ // update preview and border
+ InkSelectionStrokesOverlay.DrawStrokes(inkCanvas.GetSelectedStrokes(), new Matrix());
+ UpdateStrokeSelectionBorder(true, inkCanvas.GetSelectionBounds());
+ updateBorderStrokeSelectionControlLocation();
+ }
+
+ ///
+ /// 旋转墨迹按钮
+ ///
+ ///
+ ///
+ private void ImageRotate_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
+
+ Trace.WriteLine("12323112323232323231123123");
+
+ MatrixStrokes((m, cent) => {
+ m.RotateAt((((Border)sender).Name=="BorderImageRotate45"?45:90) * (StrokesRotateClockwise == 0 ? 1 : -1), cent.X, cent.Y);
+ return m;
+ });
+
+ __tb_preview__(sender, e);
+ }
+
+ ///
+ /// 翻转墨迹按钮
+ ///
+ ///
+ ///
+ private void ImageFlip_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
+
+ MatrixStrokes((m, cent) => {
+ m.ScaleAt((((Border)sender).Name=="BorderImageFlipHorizontal"?-1:1),(((Border)sender).Name=="BorderImageFlipVertical"?-1:1),cent.X,cent.Y);
+ return m;
+ });
+
+ __tb_preview__(sender, e);
+ }
+
+ #endregion
+
private void GridPenWidthDecrease_MouseUp(object sender, MouseButtonEventArgs e) {
if (lastBorderMouseDownObject != sender) return;
ChangeStrokeThickness(0.8);
@@ -93,132 +259,21 @@ namespace Ink_Canvas {
}
}
- private void ImageFlipHorizontal_MouseUp(object sender, MouseButtonEventArgs e) {
- if (lastBorderMouseDownObject != sender) return;
-
- var m = new Matrix();
-
- // Find center of element and then transform to get current location of center
- var fe = e.Source as FrameworkElement;
- var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
- center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
- inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
- center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
-
- // Update matrix to reflect translation/rotation
- m.ScaleAt(-1, 1, center.X, center.Y); // 缩放
-
- var targetStrokes = inkCanvas.GetSelectedStrokes();
- foreach (var stroke in targetStrokes) stroke.Transform(m, false);
-
- if (DrawingAttributesHistory.Count > 0)
- {
- //var collecion = new StrokeCollection();
- //foreach (var item in DrawingAttributesHistory)
- //{
- // collecion.Add(item.Key);
- //}
- timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
- DrawingAttributesHistory = new Dictionary>();
- foreach (var item in DrawingAttributesHistoryFlag)
- {
- item.Value.Clear();
- }
- }
-
- //updateBorderStrokeSelectionControlLocation();
+ private enum StrokesRotateClockwiseEnum {
+ RotateClockwise,
+ RotateCounterClockwise,
}
+ private StrokesRotateClockwiseEnum StrokesRotateClockwise = StrokesRotateClockwiseEnum.RotateClockwise;
- private void ImageFlipVertical_MouseUp(object sender, MouseButtonEventArgs e) {
- if (lastBorderMouseDownObject != sender) return;
+ private void ImageRotateClockwise_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
- var m = new Matrix();
+ StrokesRotateClockwise = (StrokesRotateClockwiseEnum)(StrokesRotateClockwise == 0 ? 1 : 0);
- // Find center of element and then transform to get current location of center
- var fe = e.Source as FrameworkElement;
- var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
- center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
- inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
- center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
+ BorderImageRotateClockwise.RenderTransform = new ScaleTransform(StrokesRotateClockwise == 0 ? 1 : -1, 1);
- // Update matrix to reflect translation/rotation
- m.ScaleAt(1, -1, center.X, center.Y); // 缩放
-
- var targetStrokes = inkCanvas.GetSelectedStrokes();
- foreach (var stroke in targetStrokes) stroke.Transform(m, false);
-
- if (DrawingAttributesHistory.Count > 0)
- {
- timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
- DrawingAttributesHistory = new Dictionary>();
- foreach (var item in DrawingAttributesHistoryFlag)
- {
- item.Value.Clear();
- }
- }
- }
-
- private void ImageRotate45_MouseUp(object sender, MouseButtonEventArgs e) {
- if (lastBorderMouseDownObject != sender) return;
-
- var m = new Matrix();
-
- // Find center of element and then transform to get current location of center
- var fe = e.Source as FrameworkElement;
- var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
- center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
- inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
- center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
-
- // Update matrix to reflect translation/rotation
- m.RotateAt(45, center.X, center.Y); // 旋转
-
- var targetStrokes = inkCanvas.GetSelectedStrokes();
- foreach (var stroke in targetStrokes) stroke.Transform(m, false);
-
- if (DrawingAttributesHistory.Count > 0)
- {
- timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
- DrawingAttributesHistory = new Dictionary>();
- foreach (var item in DrawingAttributesHistoryFlag)
- {
- item.Value.Clear();
- }
- }
- }
-
- private void ImageRotate90_MouseUp(object sender, MouseButtonEventArgs e) {
- if (lastBorderMouseDownObject != sender) return;
-
- var m = new Matrix();
-
- // Find center of element and then transform to get current location of center
- var fe = e.Source as FrameworkElement;
- var center = new Point(fe.ActualWidth / 2, fe.ActualHeight / 2);
- center = new Point(inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Width / 2,
- inkCanvas.GetSelectionBounds().Top + inkCanvas.GetSelectionBounds().Height / 2);
- center = m.Transform(center); // 转换为矩阵缩放和旋转的中心点
-
- // Update matrix to reflect translation/rotation
- m.RotateAt(90, center.X, center.Y); // 旋转
-
- var targetStrokes = inkCanvas.GetSelectedStrokes();
- foreach (var stroke in targetStrokes) stroke.Transform(m, false);
-
- if (DrawingAttributesHistory.Count > 0)
- {
- var collecion = new StrokeCollection();
- foreach (var item in DrawingAttributesHistory)
- {
- collecion.Add(item.Key);
- }
- timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
- DrawingAttributesHistory = new Dictionary>();
- foreach (var item in DrawingAttributesHistoryFlag)
- {
- item.Value.Clear();
- }
- }
+ // toolbutton
+ BorderStrokeSelectionToolButton_MouseLeave(sender, e);
}
#endregion
@@ -226,14 +281,62 @@ namespace Ink_Canvas {
private bool isGridInkCanvasSelectionCoverMouseDown = false;
private StrokeCollection StrokesSelectionClone = new StrokeCollection();
+ private bool isRectangleSelectionMouseDown = false;
+ private Point rectangleSelection_FirstPoint = new Point(0, 0);
+ private Point rectangleSelection_LastPoint = new Point(0, 0);
+
private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e) {
isGridInkCanvasSelectionCoverMouseDown = true;
}
private void GridInkCanvasSelectionCover_MouseUp(object sender, MouseButtonEventArgs e) {
- if (!isGridInkCanvasSelectionCoverMouseDown) return;
isGridInkCanvasSelectionCoverMouseDown = false;
- GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
+ CancelCurrentStrokesSelection();
+ }
+
+ private void RectangleSelectionHitTestBorder_MouseDown(object sender, MouseButtonEventArgs e)
+ {
+ RectangleSelectionHitTestBorder.CaptureMouse();
+ isRectangleSelectionMouseDown = true;
+ var pt = e.GetPosition(Main_Grid);
+ rectangleSelection_FirstPoint = pt;
+ }
+
+ private void RectangleSelectionHitTestBorder_MouseMove(object sender, MouseEventArgs e)
+ {
+ if (!isRectangleSelectionMouseDown) return;
+ var pt = e.GetPosition(Main_Grid);
+ rectangleSelection_LastPoint = pt;
+ RectangleSelection.DrawSelectionBox(new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint));
+ }
+
+ private void RectangleSelectionHitTestBorder_MouseUp(object sender, MouseButtonEventArgs e)
+ {
+ RectangleSelectionHitTestBorder.ReleaseMouseCapture();
+ isRectangleSelectionMouseDown = false;
+ var pt = e.GetPosition(Main_Grid);
+ rectangleSelection_LastPoint = pt;
+
+ var ilh = inkCanvas.Strokes.GetIncrementalLassoHitTester(1);
+ var rct = new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint);
+
+ void func(object s, LassoSelectionChangedEventArgs _e) {
+ var _ilh = s as IncrementalLassoHitTester;
+ if (_e.SelectedStrokes.Count==0) UpdateStrokeSelectionBorder(false, null);
+ inkCanvas.Select(_e.SelectedStrokes);
+ _ilh.EndHitTesting();
+ }
+
+ ilh.SelectionChanged += func;
+ ilh.AddPoints(new Point[] {
+ rct.TopLeft,
+ rct.TopRight,
+ rct.BottomRight,
+ rct.BottomLeft,
+ rct.TopLeft
+ });
+
+ RectangleSelection.ClearDrawing();
}
private void BtnSelect_Click(object sender, RoutedEventArgs e) {
@@ -258,38 +361,844 @@ namespace Ink_Canvas {
}
}
- private double BorderStrokeSelectionControlWidth = 490.0;
- private double BorderStrokeSelectionControlHeight = 80.0;
- private bool isProgramChangeStrokeSelection = false;
+
+ private Border[] StrokeSelectionBorderHandles = new Border[] { };
+
+ #region StrokeSelectionBorder
+
+ private bool isLockedStrokeSelectionHandle = false;
+ private Border lockedStrokeSelectionHandle = null;
+ private StrokeSelectionBorderHandlesEnum? lockedStrokeSelectionBorderHandleType = null;
+
+ private Rect? originalSelectionBounds = null;
+ private Rect? resizedSelectionBounds = null;
+
+ private Point? resizingFirstPoint = null;
+ private Point? resizingLastPoint = null;
+
+ private void StrokeSelectionBorderHandle_MouseDown(object sender, MouseButtonEventArgs e) {
+ if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return;
+ // lock
+ isLockedStrokeSelectionHandle = true;
+ var bd = (Border)sender;
+ lockedStrokeSelectionHandle = bd;
+ if (bd.Name != "StrokeSelectionRotateHandle") {
+ var index = StrokeSelectionBorderGrid.Children.IndexOf((Border)sender) - 3;
+ lockedStrokeSelectionBorderHandleType = (StrokeSelectionBorderHandlesEnum)index;
+ } else {
+ lockedStrokeSelectionBorderHandleType = StrokeSelectionBorderHandlesEnum.Rotate;
+ }
+
+ // capture
+ // TODO 这里还需要对触摸屏幕的单个TouchDevice进行Capture
+ bd.CaptureMouse();
+
+ // hide selectionToolBar
+ BorderStrokeSelectionControl.Visibility = Visibility.Collapsed;
+
+ // resize toast
+ var sb = inkCanvas.GetSelectionBounds();
+ if (!(sb.Width < 96 && sb.Height < 64)) {
+ StrokeSelectionSizeToast.Visibility = Visibility.Visible;
+ ((TextBlock)StrokeSelectionSizeToastInner.Children[0]).Text = Math.Round(sb.Width, 2).ToString();
+ ((TextBlock)StrokeSelectionSizeToastInner.Children[2]).Text = Math.Round(sb.Height, 2).ToString();
+ var lti = (int)lockedStrokeSelectionBorderHandleType;
+ System.Windows.Controls.Canvas.SetLeft(StrokeSelectionSizeToast, double.NaN);
+ System.Windows.Controls.Canvas.SetRight(StrokeSelectionSizeToast, double.NaN);
+ System.Windows.Controls.Canvas.SetTop(StrokeSelectionSizeToast, double.NaN);
+ System.Windows.Controls.Canvas.SetBottom(StrokeSelectionSizeToast, double.NaN);
+ if (lti == 0 || lti == 2 || lti == 4 || lti == 7) System.Windows.Controls.Canvas.SetLeft(StrokeSelectionSizeToast,1);
+ else System.Windows.Controls.Canvas.SetRight(StrokeSelectionSizeToast, 1);
+ if (lti == 0 || lti == 1 || lti == 4 || lti == 6) System.Windows.Controls.Canvas.SetTop(StrokeSelectionSizeToast, 1);
+ else System.Windows.Controls.Canvas.SetBottom(StrokeSelectionSizeToast, 1);
+ } else {
+ StrokeSelectionSizeToast.Visibility = Visibility.Collapsed;
+ }
+
+ // record first pt
+ var nowWindowPosition = e.GetPosition(Main_Grid);
+ resizingFirstPoint = nowWindowPosition;
+
+ // record original bounds
+ var transform = StrokeSelectionBorder.TransformToVisual(Main_Grid);
+ var ori_lt = transform.Transform(new Point(0, 0));
+ var ori_rb = transform.Transform(new Point(StrokeSelectionBorder.Width, StrokeSelectionBorder.Height));
+ originalSelectionBounds = new Rect(ori_lt, ori_rb);
+ }
+
+ private void StrokeSelectionBorderHandle_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (!isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return;
+
+ // resize strokes and preview strokes
+ SelectedStrokesResize(inkCanvas.GetSelectedStrokes(), (StrokeSelectionBorderHandlesEnum)lockedStrokeSelectionBorderHandleType,
+ (Rect)originalSelectionBounds, (Rect)resizedSelectionBounds);
+ InkSelectionStrokesOverlay.DrawStrokes(inkCanvas.GetSelectedStrokes(), new Matrix());
+
+ // display selectionToolBar
+ var bd = new Binding("Visibility");
+ bd.Source = GridInkCanvasSelectionCover;
+ BorderStrokeSelectionControl.SetBinding(Border.VisibilityProperty, bd);
+ updateBorderStrokeSelectionControlLocation();
+
+ // unlock
+ isLockedStrokeSelectionHandle = false;
+ lockedStrokeSelectionBorderHandleType = null;
+
+ // release capture
+ // TODO 这里还需要对触摸屏幕的单个TouchDevice进行ReleaseCapture
+ lockedStrokeSelectionHandle.ReleaseMouseCapture();
+
+ // unlock
+ lockedStrokeSelectionHandle = null;
+
+ // resize toast
+ StrokeSelectionSizeToast.Visibility = Visibility.Collapsed;
+ }
+
+ private void StrokeSelectionBorderHandle_MouseMove(object sender, MouseEventArgs e) {
+
+ if (!isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return;
+
+ var bd = (Border)sender;
+ var nowWindowPosition = e.GetPosition(Main_Grid);
+
+ // record last pt
+ var rlp = nowWindowPosition;
+
+ // resize preview border
+ var isReverseWidth = false; // 是否逆向 resize Width,true 為調小,false為調大
+ var isReverseHeight = false; // 是否逆向 resize Height,true 為調小,false為調大
+ if (lockedStrokeSelectionBorderHandleType == StrokeSelectionBorderHandlesEnum.LeftTop) {
+ isReverseWidth = ((Point)rlp).X > ((Point)resizingFirstPoint).X;
+ isReverseHeight = ((Point)rlp).Y > ((Point)resizingFirstPoint).Y;
+ } else if (lockedStrokeSelectionBorderHandleType == StrokeSelectionBorderHandlesEnum.RightTop) {
+ isReverseWidth = ((Point)rlp).X < ((Point)resizingFirstPoint).X;
+ isReverseHeight = ((Point)rlp).Y > ((Point)resizingFirstPoint).Y;
+ } else if (lockedStrokeSelectionBorderHandleType == StrokeSelectionBorderHandlesEnum.LeftBottom) {
+ isReverseWidth = ((Point)rlp).X > ((Point)resizingFirstPoint).X;
+ isReverseHeight = ((Point)rlp).Y < ((Point)resizingFirstPoint).Y;
+ } else if (lockedStrokeSelectionBorderHandleType == StrokeSelectionBorderHandlesEnum.RightBottom) {
+ isReverseWidth = ((Point)rlp).X < ((Point)resizingFirstPoint).X;
+ isReverseHeight = ((Point)rlp).Y < ((Point)resizingFirstPoint).Y;
+ } else if (lockedStrokeSelectionBorderHandleType == StrokeSelectionBorderHandlesEnum.Top) {
+ isReverseWidth = false;
+ isReverseHeight = ((Point)rlp).Y > ((Point)resizingFirstPoint).Y;
+ } else if (lockedStrokeSelectionBorderHandleType == StrokeSelectionBorderHandlesEnum.Bottom) {
+ isReverseWidth = false;
+ isReverseHeight = ((Point)rlp).Y < ((Point)resizingFirstPoint).Y;
+ } else if (lockedStrokeSelectionBorderHandleType == StrokeSelectionBorderHandlesEnum.Left) {
+ isReverseWidth = ((Point)rlp).X > ((Point)resizingFirstPoint).X;
+ isReverseHeight = false;
+ } else if (lockedStrokeSelectionBorderHandleType == StrokeSelectionBorderHandlesEnum.Right) {
+ isReverseWidth = ((Point)rlp).X < ((Point)resizingFirstPoint).X;
+ isReverseHeight = false;
+ }
+
+ // caculate height width left top
+ var l = Math.Round(
+ ((Rect)originalSelectionBounds).Left +
+ ((int)lockedStrokeSelectionBorderHandleType == 0 || (int)lockedStrokeSelectionBorderHandleType == 2 || (int)lockedStrokeSelectionBorderHandleType == 4
+ ? new Rect(((Point)resizingFirstPoint), ((Point)rlp)).Width *
+ (isReverseWidth ? 1 : -1)
+ : 0), 0);
+ var t = Math.Round(
+ ((Rect)originalSelectionBounds).Top +
+ ((int)lockedStrokeSelectionBorderHandleType == 0 || (int)lockedStrokeSelectionBorderHandleType == 1 || (int)lockedStrokeSelectionBorderHandleType == 6
+ ? new Rect(((Point)resizingFirstPoint), ((Point)rlp)).Height *
+ (isReverseHeight ? 1 : -1)
+ : 0), 0);
+ var w = (int)lockedStrokeSelectionBorderHandleType != 6 && (int)lockedStrokeSelectionBorderHandleType != 7 ? Math.Round(((Rect)originalSelectionBounds).Width + new Rect(((Point)resizingFirstPoint),
+ ((Point)rlp)).Width * (isReverseWidth ? -1 : 1), 0) : ((Rect)originalSelectionBounds).Width;
+ var h = (int)lockedStrokeSelectionBorderHandleType != 4 && (int)lockedStrokeSelectionBorderHandleType != 5 ? Math.Round(((Rect)originalSelectionBounds).Height + new Rect(((Point)resizingFirstPoint),
+ ((Point)rlp)).Height * (isReverseHeight ? -1 : 1), 0) : ((Rect)originalSelectionBounds).Height;
+
+ var final_w = Math.Round(w,0);
+ var final_h = Math.Round(h,0);
+
+ if (isShiftKeyDown) {
+ var scaleW = w / ((Rect)originalSelectionBounds).Width;
+ var scaleH = h / ((Rect)originalSelectionBounds).Height;
+
+ final_w = Math.Round(((Rect)originalSelectionBounds).Width * Math.Max(scaleW, scaleH),0);
+ final_h = Math.Round(((Rect)originalSelectionBounds).Height * Math.Max(scaleW, scaleH),0);
+ }
+
+ if (final_w >= 1 && final_h >= 1) {
+ StrokeSelectionBorder.Width = final_w;
+ StrokeSelectionBorder.Height = final_h;
+
+ System.Windows.Controls.Canvas.SetLeft(StrokeSelectionBorder, l);
+ System.Windows.Controls.Canvas.SetTop(StrokeSelectionBorder, t);
+
+ resizingLastPoint = rlp;
+
+ if (!(final_w < 96 && final_h < 64)) StrokeSelectionSizeToast.Visibility = Visibility.Visible;
+ else StrokeSelectionSizeToast.Visibility = Visibility.Collapsed;
+
+ // resize toast text
+ ((TextBlock)StrokeSelectionSizeToastInner.Children[0]).Text = final_w.ToString();
+ ((TextBlock)StrokeSelectionSizeToastInner.Children[2]).Text = final_h.ToString();
+
+ // record resized bounds
+ var transform = StrokeSelectionBorder.TransformToVisual(Main_Grid);
+ var ori_lt = transform.Transform(new Point(0, 0));
+ var ori_rb = transform.Transform(new Point(StrokeSelectionBorder.Width, StrokeSelectionBorder.Height));
+ resizedSelectionBounds = new Rect(ori_lt, ori_rb);
+
+ // preview resize
+ SelectedStrokesResize(inkCanvas.GetSelectedStrokes(), (StrokeSelectionBorderHandlesEnum)lockedStrokeSelectionBorderHandleType,
+ (Rect)originalSelectionBounds, (Rect)resizedSelectionBounds, true);
+ }
+ }
+
+ private Point? movingFirstPoint = null;
+ private Point? movingLastPoint = null;
+
+ private double movingFirstBorderLeft = 0;
+ private double movingFirstBorderTop = 0;
+
+ private bool isLockedStrokeSelectionMove = false;
+
+ private bool isProgramChangeStrokesSelection = false;
+
+ private void StrokeSelectionBorder_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || !isLockedStrokeSelectionMove) return;
+
+ // release capture
+ var bd = (Border)sender;
+ bd.ReleaseMouseCapture();
+
+ // record last move point
+ var pt = e.GetPosition(Main_Grid);
+ movingLastPoint = pt;
+
+ // caculate offset
+ var offX = ((Point)movingLastPoint).X - ((Point)movingFirstPoint).X;
+ var offY = ((Point)movingLastPoint).Y - ((Point)movingFirstPoint).Y;
+
+ // unlock
+ isLockedStrokeSelectionMove = false;
+
+ if (isStrokeSelectionCloneOn) {
+ // transform strokes
+ var matrix = new Matrix();
+ matrix.Translate(((Point)movingLastPoint).X-((Point)movingFirstPoint).X, ((Point)movingLastPoint).Y - ((Point)movingFirstPoint).Y);
+
+ isProgramChangeStrokesSelection = true;
+ var ori = inkCanvas.GetSelectedStrokes();
+ inkCanvas.Select(new StrokeCollection());
+ clonedStrokes = ori.Clone();
+ inkCanvas.Select(ori);
+ isProgramChangeStrokesSelection = false;
+
+ clonedStrokes.Transform(matrix,false);
+
+ // add to inkcanvas
+ inkCanvas.Strokes.Add(clonedStrokes);
+
+ InkSelectionStrokesOverlay.DrawStrokes(inkCanvas.GetSelectedStrokes(), new Matrix());
+ InkSelectionStrokesBackgroundInkCanvas.Strokes.Add(clonedStrokes);
+
+ } else {
+ if (isStrokesSelectionBorderMovingUseRenderTransform) {
+ StrokeSelectionBorderTranslateTransform.X = 0;
+ StrokeSelectionBorderTranslateTransform.Y = 0;
+ System.Windows.Controls.Canvas.SetLeft(StrokeSelectionBorder, movingFirstBorderLeft + offX);
+ System.Windows.Controls.Canvas.SetTop(StrokeSelectionBorder, movingFirstBorderTop + offY);
+ }
+
+ // preview
+ SelectedStrokesMove(inkCanvas.GetSelectedStrokes(), (Point)movingFirstPoint, (Point)movingLastPoint, true);
+
+ // transform strokes
+ SelectedStrokesMove(inkCanvas.GetSelectedStrokes(), (Point)movingFirstPoint, (Point)movingLastPoint);
+
+ // display selectionToolBar
+ var _bd = new Binding("Visibility");
+ _bd.Source = GridInkCanvasSelectionCover;
+ BorderStrokeSelectionControl.SetBinding(Border.VisibilityProperty, _bd);
+ updateBorderStrokeSelectionControlLocation();
+
+ // hide move toast
+ StrokeSelectionMoveToast.Visibility = Visibility.Collapsed;
+ }
+
+
+ }
+
+ private void StrokeSelectionBorder_MouseDown(object sender, MouseButtonEventArgs e) {
+ if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || isLockedStrokeSelectionMove) return;
+
+ // record first move point
+ var pt = e.GetPosition(Main_Grid);
+ movingFirstPoint = pt;
+
+ // capture mouse
+ var bd = (Border)sender;
+ bd.CaptureMouse();
+
+ // lock
+ isLockedStrokeSelectionMove = true;
+
+ // record first border position
+ movingFirstBorderLeft = System.Windows.Controls.Canvas.GetLeft(StrokeSelectionBorder);
+ movingFirstBorderTop = System.Windows.Controls.Canvas.GetTop(StrokeSelectionBorder);
+ }
+
+ private bool isStrokesSelectionBorderMovingUseRenderTransform = true;
+
+ private StrokeCollection clonedStrokes;
+
+ private void StrokeSelectionBorder_MouseMove(object sender, MouseEventArgs e) {
+ if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || !isLockedStrokeSelectionMove) return;
+
+ // record last move point
+ var pt = e.GetPosition(Main_Grid);
+ movingLastPoint = pt;
+
+ // caculate offset
+ var offX = ((Point)movingLastPoint).X - ((Point)movingFirstPoint).X;
+ var offY = ((Point)movingLastPoint).Y - ((Point)movingFirstPoint).Y;
+
+ if (isStrokeSelectionCloneOn) {
+
+ var matrix = new Matrix();
+ matrix.Translate(((Point)movingLastPoint).X-((Point)movingFirstPoint).X, ((Point)movingLastPoint).Y - ((Point)movingFirstPoint).Y);
+
+ InkSelectionStrokesOverlay.Open();
+ InkSelectionStrokesOverlay.DrawStrokes(inkCanvas.GetSelectedStrokes(), new Matrix(), false);
+ InkSelectionStrokesOverlay.DrawStrokes(inkCanvas.GetSelectedStrokes(), matrix, false);
+ InkSelectionStrokesOverlay.Close();
+
+ } else {
+ // preview
+ SelectedStrokesMove(inkCanvas.GetSelectedStrokes(), (Point)movingFirstPoint, (Point)movingLastPoint, true);
+
+ // relocate border position
+ if (isStrokesSelectionBorderMovingUseRenderTransform) {
+ StrokeSelectionBorderTranslateTransform.X = offX;
+ StrokeSelectionBorderTranslateTransform.Y = offY;
+ } else {
+ System.Windows.Controls.Canvas.SetLeft(StrokeSelectionBorder, movingFirstBorderLeft + offX);
+ System.Windows.Controls.Canvas.SetTop(StrokeSelectionBorder, movingFirstBorderTop + offY);
+ }
+
+ // display move toast
+ if (StrokeSelectionMoveToast.Visibility == Visibility.Collapsed) StrokeSelectionMoveToast.Visibility = Visibility.Visible;
+
+ // move toast text
+ ((TextBlock)((StackPanel)StrokeSelectionMoveToastInner.Children[0]).Children[0]).Text =
+ $"X: {Math.Round(System.Windows.Controls.Canvas.GetLeft(StrokeSelectionBorder), 2)}";
+ ((TextBlock)((StackPanel)StrokeSelectionMoveToastInner.Children[0]).Children[1]).Text =
+ $"Y: {Math.Round(System.Windows.Controls.Canvas.GetTop(StrokeSelectionBorder),2)}";
+ ((TextBlock)((StackPanel)StrokeSelectionMoveToastInner.Children[1]).Children[1]).Text =
+ $"Δx: {Math.Round(offX,2)}";
+ ((TextBlock)((StackPanel)StrokeSelectionMoveToastInner.Children[1]).Children[2]).Text =
+ $"Δy: {Math.Round(offY,2)}";
+
+ // hide selectionToolBar
+ if (BorderStrokeSelectionControl.Visibility != Visibility.Collapsed) BorderStrokeSelectionControl.Visibility = Visibility.Collapsed;
+ }
+ }
+
+ private Point? StrokesRotateSelectionBoundsCenterPoint = null;
+ private Point? rotatingLastPoint = null;
+ private bool isLockedStrokeSelectionRotate = false;
+
+ private void StrokeSelectionRotateHandle_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || !isLockedStrokeSelectionRotate) return;
+
+ // unlock
+ isLockedStrokeSelectionRotate = false;
+
+ // record last point
+ var pt = e.GetPosition(Main_Grid);
+ rotatingLastPoint = pt;
+
+ // caculate rotate angle
+ var vec1 = new double[] {
+ ((Point)rotatingLastPoint).X - ((Point)StrokesRotateSelectionBoundsCenterPoint).X ,
+ ((Point)rotatingLastPoint).Y - ((Point)StrokesRotateSelectionBoundsCenterPoint).Y
+ };
+ var vec_base = new double[] {
+ 0,
+ ((Point)StrokesRotateSelectionBoundsCenterPoint).Y
+ };
+ var cosine = (vec_base[0] * vec1[0] + vec_base[1] * vec1[1]) /
+ (Math.Sqrt(Math.Pow(vec_base[0], 2) + Math.Pow(vec_base[1], 2)) *
+ Math.Sqrt(Math.Pow(vec1[0], 2) + Math.Pow(vec1[1], 2)));
+ var angle = Math.Acos(cosine);
+
+ // 判斷在第幾象限
+ var isIn2And3Quadrant = ((Point)rotatingLastPoint).X <= ((Point)StrokesRotateSelectionBoundsCenterPoint).X;
+
+ // final angle
+ var rotateAngle = Math.Round(180 + 180 * (angle / Math.PI) * (isIn2And3Quadrant ? 1 : -1), 0);
+
+ // release capture
+ var bd = (Border)sender;
+ bd.ReleaseMouseCapture();
+
+ // hide rotate toast
+ StrokeSelectionRotateToast.Visibility = Visibility.Collapsed;
+
+ // hide guideline overlay
+ InkSelectionRotateGuidelineOverlay.Visibility = Visibility.Collapsed;
+
+ // border rotate reset
+ StrokeSelectionBorderRotateTransform.Angle = 0;
+ StrokeSelectionBorderRotateTransform.CenterX = 0;
+ StrokeSelectionBorderRotateTransform.CenterY = 0;
+
+ // rotate stroke
+ SelectedStrokesRotate(inkCanvas.GetSelectedStrokes(), rotateAngle,
+ (Point)StrokesRotateSelectionBoundsCenterPoint);
+
+ // border re-caculate strokes bounds
+ UpdateStrokeSelectionBorder(true, inkCanvas.GetSelectionBounds());
+
+ // display selectionToolBar
+ var _bd = new Binding("Visibility");
+ _bd.Source = GridInkCanvasSelectionCover;
+ BorderStrokeSelectionControl.SetBinding(Border.VisibilityProperty, _bd);
+ updateBorderStrokeSelectionControlLocation();
+ }
+
+ private void StrokeSelectionRotateHandle_MouseDown(object sender, MouseButtonEventArgs e) {
+ if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return;
+
+ // lock
+ isLockedStrokeSelectionRotate = true;
+
+ // record center point
+ var bounds = inkCanvas.GetSelectionBounds();
+ StrokesRotateSelectionBoundsCenterPoint = new Point(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2);
+
+ // capture mouse
+ var bd = (Border)sender;
+ bd.CaptureMouse();
+ }
+
+ private void StrokeSelectionRotateHandle_MouseMove(object sender, MouseEventArgs e) {
+ if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || !isLockedStrokeSelectionRotate) return;
+
+ // record last point
+ var pt = e.GetPosition(Main_Grid);
+ rotatingLastPoint = pt;
+
+ // caculate rotate angle
+ var vec1 = new double[] {
+ ((Point)rotatingLastPoint).X - ((Point)StrokesRotateSelectionBoundsCenterPoint).X ,
+ ((Point)rotatingLastPoint).Y - ((Point)StrokesRotateSelectionBoundsCenterPoint).Y
+ };
+ var vec_base = new double[] {
+ 0,
+ ((Point)StrokesRotateSelectionBoundsCenterPoint).Y
+ };
+ var cosine = (vec_base[0] * vec1[0] + vec_base[1] * vec1[1]) /
+ (Math.Sqrt(Math.Pow(vec_base[0],2) + Math.Pow(vec_base[1],2)) *
+ Math.Sqrt(Math.Pow(vec1[0],2) + Math.Pow(vec1[1],2)));
+ var angle = Math.Acos(cosine);
+
+ // 判斷在第幾象限
+ var isIn2And3Quadrant = ((Point)rotatingLastPoint).X <= ((Point)StrokesRotateSelectionBoundsCenterPoint).X;
+
+ // final angle
+ var rotateAngle = Math.Round(180 + 180 * (angle / Math.PI) * (isIn2And3Quadrant ? 1 : -1), 0);
+
+ // display guideline overlay
+ if (InkSelectionRotateGuidelineOverlay.Visibility == Visibility.Collapsed)
+ InkSelectionRotateGuidelineOverlay.Visibility = Visibility.Visible;
+
+ var guidelinePen1 = new Pen(); // guideline1 thickness1 dash yellow opacity255
+ guidelinePen1.Brush = new SolidColorBrush(Color.FromRgb(245, 158, 11));
+ guidelinePen1.DashStyle = DashStyles.Dash;
+ guidelinePen1.Thickness = 1;
+
+ var guidelinePen2 = new Pen(); // guideline2 thickness2 dash yellow opacity255
+ guidelinePen2.Brush = new SolidColorBrush(Color.FromRgb(245, 158, 11));
+ guidelinePen2.DashStyle = DashStyles.Dash;
+ guidelinePen2.Thickness = 2.5;
+
+ var guidelinePen3 = new Pen(); // guideline3 thickness1 dash yellow opacity72
+ guidelinePen3.Brush = new SolidColorBrush(Color.FromArgb(72, 245, 158, 11));
+ guidelinePen3.DashStyle = DashStyles.Dash;
+ guidelinePen3.Thickness = 1;
+
+ var guidelinePen4 = new Pen(); // guideline4 thickness1 dot green opacity255
+ guidelinePen4.Brush = new SolidColorBrush(Color.FromRgb(34, 197, 94));
+ guidelinePen4.DashStyle = DashStyles.Dot;
+ guidelinePen4.Thickness = 1;
+
+ var guidelineSnapAngle = 0;
+ // draw guideline
+ var dv = InkSelectionRotateGuidelineOverlay.DrawingVisual;
+ using (DrawingContext dc = dv.RenderOpen()) {
+ dc.DrawLine(guidelinePen1, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X,0));
+ dc.DrawLine(guidelinePen3, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X,Main_Grid.ActualHeight));
+ dc.DrawLine(guidelinePen2, (Point)StrokesRotateSelectionBoundsCenterPoint, (Point)rotatingLastPoint);
+
+ var QuadrantOneLongest = Math.Max(
+ Main_Grid.ActualWidth - ((Point)StrokesRotateSelectionBoundsCenterPoint).X,
+ ((Point)StrokesRotateSelectionBoundsCenterPoint).Y);
+ //30 angle
+ if (rotateAngle >= 26 && rotateAngle <= 34) {
+ dc.DrawLine(guidelinePen4, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X + QuadrantOneLongest, ((Point)StrokesRotateSelectionBoundsCenterPoint).Y - QuadrantOneLongest * Math.Sqrt(3)));
+ guidelineSnapAngle = 30;
+ }
+ //45 angle
+ if (rotateAngle >= 41 && rotateAngle <= 49) {
+ dc.DrawLine(guidelinePen4, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X+QuadrantOneLongest, ((Point)StrokesRotateSelectionBoundsCenterPoint).Y - QuadrantOneLongest));
+ guidelineSnapAngle = 45;
+ }
+ //60 angle
+ if (rotateAngle >= 56 && rotateAngle <= 64) {
+ dc.DrawLine(guidelinePen4, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X + QuadrantOneLongest *Math.Sqrt(3), ((Point)StrokesRotateSelectionBoundsCenterPoint).Y - QuadrantOneLongest));
+ guidelineSnapAngle = 60;
+ }
+ //90 angle
+ if (rotateAngle >= 86 && rotateAngle <= 94) {
+ dc.DrawLine(guidelinePen4, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X + QuadrantOneLongest, ((Point)StrokesRotateSelectionBoundsCenterPoint).Y));
+ guidelineSnapAngle = 90;
+ }
+ var QuadrantFourLongest = Math.Max(
+ Main_Grid.ActualWidth - ((Point)StrokesRotateSelectionBoundsCenterPoint).X,
+ Main_Grid.ActualHeight - ((Point)StrokesRotateSelectionBoundsCenterPoint).Y);
+ //120 angle
+ if (rotateAngle >= 116 && rotateAngle <= 124) {
+ dc.DrawLine(guidelinePen4, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X + QuadrantFourLongest * Math.Sqrt(3), ((Point)StrokesRotateSelectionBoundsCenterPoint).Y + QuadrantFourLongest));
+ guidelineSnapAngle = 120;
+ }
+ //150 angle
+ if (rotateAngle >= 146 && rotateAngle <= 154) {
+ dc.DrawLine(guidelinePen4, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X + QuadrantFourLongest, ((Point)StrokesRotateSelectionBoundsCenterPoint).Y + QuadrantFourLongest * Math.Sqrt(3)));
+ guidelineSnapAngle = 150;
+ }
+ //180 angle
+ if (rotateAngle >= 176 && rotateAngle <= 184)
+ {
+ dc.DrawLine(guidelinePen4, (Point)StrokesRotateSelectionBoundsCenterPoint, new Point(((Point)StrokesRotateSelectionBoundsCenterPoint).X, ((Point)StrokesRotateSelectionBoundsCenterPoint).Y + QuadrantFourLongest));
+ guidelineSnapAngle = 180;
+ }
+ }
+
+ // preview
+ SelectedStrokesRotate(inkCanvas.GetSelectedStrokes(), guidelineSnapAngle!=0?guidelineSnapAngle:rotateAngle,
+ (Point)StrokesRotateSelectionBoundsCenterPoint, true);
+
+ // border rotate
+ StrokeSelectionBorderRotateTransform.Angle = guidelineSnapAngle != 0 ? guidelineSnapAngle : rotateAngle;
+ StrokeSelectionBorderRotateTransform.CenterX = StrokeSelectionBorder.Width / 2;
+ StrokeSelectionBorderRotateTransform.CenterY = StrokeSelectionBorder.Height / 2;
+
+ // display rotate toast
+ if (StrokeSelectionRotateToast.Visibility == Visibility.Collapsed) StrokeSelectionRotateToast.Visibility = Visibility.Visible;
+
+ // update rotate toast
+ ((TextBlock)StrokeSelectionRotateToast.Child).Text =
+ (guidelineSnapAngle != 0 ? guidelineSnapAngle : rotateAngle) == 360
+ ? "360° = 0°" : $"{(guidelineSnapAngle != 0 ? guidelineSnapAngle : rotateAngle)}°";
+
+
+ // hide selectionToolBar
+ if (BorderStrokeSelectionControl.Visibility != Visibility.Collapsed) BorderStrokeSelectionControl.Visibility = Visibility.Collapsed;
+ }
+
+ private void StrokeSelectionBorder_MouseEnter(object sender, MouseEventArgs e) {
+ StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(17, 96, 165, 250));
+ }
+
+ private void StrokeSelectionBorder_MouseLeave(object sender, MouseEventArgs e) {
+ StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(5, 96, 165, 250));
+ }
+
+ private void ApplyCursorToStrokeSelectionBorder() {
+ StrokeSelectionCursorArea.ForceCursor = true;
+ StreamResourceInfo sri_move = Application.GetResourceStream(
+ new Uri("Resources/Cursors/cursor-move.cur", UriKind.Relative));
+ StrokeSelectionCursorArea.Cursor = new Cursor(sri_move.Stream);
+
+ StreamResourceInfo sri_lr = Application.GetResourceStream(
+ new Uri("Resources/Cursors/cursor-resize-lr.cur", UriKind.Relative));
+ StreamResourceInfo sri_tb = Application.GetResourceStream(
+ new Uri("Resources/Cursors/cursor-resize-tb.cur", UriKind.Relative));
+ StreamResourceInfo sri_lt_rb = Application.GetResourceStream(
+ new Uri("Resources/Cursors/cursor-resize-lt-rb.cur", UriKind.Relative));
+ StreamResourceInfo sri_rt_lb = Application.GetResourceStream(
+ new Uri("Resources/Cursors/cursor-resize-rt-lb.cur", UriKind.Relative));
+
+ foreach (var bd in StrokeSelectionBorderHandles) {
+ bd.ForceCursor = true;
+ }
+ StrokeSelectionBorderHandles[0].Cursor = StrokeSelectionBorderHandles[3].Cursor = new Cursor(sri_lt_rb.Stream);
+ StrokeSelectionBorderHandles[1].Cursor = StrokeSelectionBorderHandles[2].Cursor = new Cursor(sri_rt_lb.Stream);
+ StrokeSelectionBorderHandles[4].Cursor = StrokeSelectionBorderHandles[5].Cursor = new Cursor(sri_lr.Stream);
+ StrokeSelectionBorderHandles[6].Cursor = StrokeSelectionBorderHandles[7].Cursor = new Cursor(sri_tb.Stream);
+
+ StreamResourceInfo sri_open_hand = Application.GetResourceStream(
+ new Uri("Resources/Cursors/open-hand-cursor.cur", UriKind.Relative));
+ StrokeSelectionBorderHandles[8].Cursor = new Cursor(sri_open_hand.Stream);
+ }
+
+ public enum StrokeSelectionBorderHandlesEnum {
+ LeftTop, RightTop, LeftBottom, RightBottom,
+ Left, Right, Top, Bottom,
+ Rotate
+ }
+
+ private void AddStrokeSelectionHandlesToArr() {
+ StrokeSelectionBorderHandles = new Border[] {
+ StrokeSelectionLTHandle,
+ StrokeSelectionRTHandle,
+ StrokeSelectionLBHandle,
+ StrokeSelectionRBHandle,
+ StrokeSelectionLHandle,
+ StrokeSelectionRHandle,
+ StrokeSelectionTHandle,
+ StrokeSelectionBHandle,
+ StrokeSelectionRotateHandle
+ };
+ foreach (var hd in StrokeSelectionBorderHandles) {
+ if (hd.Name== "StrokeSelectionRotateHandle") continue;
+ hd.MouseUp += StrokeSelectionBorderHandle_MouseUp;
+ hd.MouseDown += StrokeSelectionBorderHandle_MouseDown;
+ hd.MouseMove += StrokeSelectionBorderHandle_MouseMove;
+ }
+ StrokeSelectionRotateHandle.MouseUp += StrokeSelectionRotateHandle_MouseUp;
+ StrokeSelectionRotateHandle.MouseDown += StrokeSelectionRotateHandle_MouseDown;
+ StrokeSelectionRotateHandle.MouseMove += StrokeSelectionRotateHandle_MouseMove;
+
+ ApplyCursorToStrokeSelectionBorder();
+ }
+
+ private void SelectedStrokesRotate(StrokeCollection strokes, double angle, Point? centerPoint, bool isPreview = false) {
+ if (centerPoint == null) return;
+ var matrix = new Matrix();
+ matrix.RotateAt(angle, ((Point)centerPoint).X, ((Point)centerPoint).Y);
+
+ if (isPreview) {
+ InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix);
+ } else {
+ strokes.Transform(matrix, false);
+ }
+ }
+
+ private void SelectedStrokesMove(StrokeCollection strokes, Point firstPoint, Point lastPoint, bool isPreview = false) {
+
+ var matrix = new Matrix();
+ matrix.Translate(lastPoint.X-firstPoint.X, lastPoint.Y - firstPoint.Y);
+
+ if (isPreview) {
+ InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix);
+ } else {
+ strokes.Transform(matrix, false);
+ }
+ }
+
+ ///
+ /// 調整選中墨跡的大小
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ private Rect? SelectedStrokesResize(StrokeCollection strokes, StrokeSelectionBorderHandlesEnum handleType, Rect originalRect, Rect resizedRect, bool isPreview = false) {
+ if ((strokes?.Count ?? 0) == 0 || handleType == null || originalRect.Width == 0 || originalRect.Height == 0
+ || resizedRect.Width == 0 || resizedRect.Height == 0) return null;
+ Matrix matrix = new Matrix();
+
+ if ((int)handleType <= 3) {
+ var asidePt = (int)handleType == 0 ? originalRect.BottomRight :
+ (int)handleType == 1 ? originalRect.BottomLeft :
+ (int)handleType == 2 ? originalRect.TopRight : originalRect.TopLeft;
+ matrix.ScaleAt(Math.Round(resizedRect.Width / originalRect.Width, 2),
+ Math.Round(resizedRect.Height / originalRect.Height, 2),
+ asidePt.X, asidePt.Y);
+ } else if ((int)handleType == 4 || (int)handleType == 5) {
+ var asideX = (int)handleType == 5 ? originalRect.Left : originalRect.Right;
+ matrix.ScaleAt(Math.Round(resizedRect.Width / originalRect.Width, 2),1D,asideX, 0);
+ } else if ((int)handleType == 6 || (int)handleType == 7) {
+ var asideY = (int)handleType == 7 ? originalRect.Top : originalRect.Bottom;
+ matrix.ScaleAt(1D, Math.Round(resizedRect.Height / originalRect.Height, 2), 0, asideY);
+ }
+
+ if (isPreview) {
+ InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix);
+ } else {
+ strokes.Transform(matrix, false);
+ }
+
+ return strokes.GetBounds();
+ }
+
+ private void UpdateStrokeSelectionBorder(bool isDisplay, Rect? rect) {
+ if (isDisplay) {
+ if (rect == null) return;
+ var r = (Rect)rect;
+ if (r.Height == 0 || r.Width == 0) return;
+ InkCanvasSelectFakeAdornerCanvas.Visibility = Visibility.Visible;
+ System.Windows.Controls.Canvas.SetLeft(StrokeSelectionBorder,r.Left);
+ System.Windows.Controls.Canvas.SetTop(StrokeSelectionBorder,r.Top);
+ StrokeSelectionBorder.Width = r.Width;
+ StrokeSelectionBorder.Height = r.Height;
+ if (StrokeSelectionBorderHandles.Length == 0) AddStrokeSelectionHandlesToArr();
+ StrokeSelectionBorder.Visibility = Visibility.Visible;
+ } else {
+ InkCanvasSelectFakeAdornerCanvas.Visibility = Visibility.Collapsed;
+ StrokeSelectionBorder.Visibility = Visibility.Collapsed;
+ }
+ }
+
+ ///
+ /// 取消选中本次选中的墨迹或对象,准备继续进行矩形选框操作。
+ ///
+ private void CancelCurrentStrokesSelection() {
+ GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
+ inkCanvas.Select(new StrokeCollection());
+ UpdateStrokeSelectionBorder(false, null);
+ RectangleSelectionHitTestBorder.Visibility = Visibility.Visible;
+ var cm = this.FindResource("StrokesSelectionMoreMenuButtonContextMenu") as ContextMenu;
+ cm.IsOpen = false;
+ }
+
+ #endregion
private void inkCanvas_SelectionChanged(object sender, EventArgs e) {
- if (isProgramChangeStrokeSelection) return;
+ if (isProgramChangeStrokesSelection) return;
+ isStrokeSelectionCloneOn = false;
if (inkCanvas.GetSelectedStrokes().Count == 0) {
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
+ UpdateStrokeSelectionBorder(false,null);
+ inkCanvas.Opacity = 1;
+ InkSelectionStrokesOverlay.Visibility = Visibility.Collapsed;
+ InkSelectionStrokesBackgroundInkCanvas.Visibility = Visibility.Collapsed;
+ InkSelectionStrokesOverlay.DrawStrokes(new StrokeCollection(), new Matrix());
}
else {
+ var isAllStrokesLocked = false;
+ if (inkCanvas.GetSelectedStrokes().Count > 1) {
+ List lockedStrokes = new List();
+ var stks = inkCanvas.GetSelectedStrokes();
+ foreach (var stk in stks) {
+ if (stk.ContainsPropertyData(IsLockGuid)) lockedStrokes.Add(stk);
+ }
+
+ if (lockedStrokes.Count != stks.Count && lockedStrokes.Count!=0) {
+ stks.Remove(new StrokeCollection(lockedStrokes));
+ inkCanvas.Select(stks);
+ return;
+ } else if (lockedStrokes.Count == stks.Count) {
+ isAllStrokesLocked = true;
+ }
+ } else {
+ isAllStrokesLocked = inkCanvas.GetSelectedStrokes().Single().ContainsPropertyData(IsLockGuid);
+ }
+
GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
BorderStrokeSelectionClone.Background = Brushes.Transparent;
- isStrokeSelectionCloneOn = false;
+ RectangleSelectionHitTestBorder.Visibility = Visibility.Collapsed;
+ UpdateStrokeSelectionBorder(true, inkCanvas.GetSelectionBounds());
+ inkCanvas.Opacity = 0;
+ InkSelectionStrokesOverlay.Visibility = Visibility.Visible;
+ InkSelectionStrokesBackgroundInkCanvas.Visibility = Visibility.Visible;
+ InkSelectionStrokesBackgroundInkCanvas.Strokes.Clear();
+ InkSelectionStrokesBackgroundInkCanvas.Strokes.Add(inkCanvas.Strokes);
+ InkSelectionStrokesBackgroundInkCanvas.Strokes.Remove(inkCanvas.GetSelectedStrokes());
+ InkSelectionStrokesOverlay.DrawStrokes(inkCanvas.GetSelectedStrokes(), new Matrix());
+ UpdateStrokesSelectionCloneToolButtonLimitStatus();
updateBorderStrokeSelectionControlLocation();
+ UpdateSelectionToolbarOtherIconLockedStatus(isAllStrokesLocked);
+ UpdateSelectionToolBarLockIcon(isAllStrokesLocked);
+ UpdateSelectionBorderHandlesLockStatus(isAllStrokesLocked);
}
}
private void updateBorderStrokeSelectionControlLocation() {
- var borderLeft = (inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Right -
- BorderStrokeSelectionControlWidth) / 2;
- var borderTop = inkCanvas.GetSelectionBounds().Bottom + 1;
+
+ if (currentMode == 0) BorderStrokeSelectionCloneToNewBoardTextBlock.Text = "克隆到白板";
+ else BorderStrokeSelectionCloneToNewBoardTextBlock.Text = "克隆到新页";
+
+ var _w = 660;
+ BorderStrokeSelectionControl.Width = _w;
+
+ var borderLeft = (inkCanvas.GetSelectionBounds().Left + inkCanvas.GetSelectionBounds().Right - _w) / 2;
+ var borderTop = inkCanvas.GetSelectionBounds().Bottom + 24;
if (borderLeft < 0) borderLeft = 0;
if (borderTop < 0) borderTop = 0;
- if (Width - borderLeft < BorderStrokeSelectionControlWidth || double.IsNaN(borderLeft))
- borderLeft = Width - BorderStrokeSelectionControlWidth;
- if (Height - borderTop < BorderStrokeSelectionControlHeight || double.IsNaN(borderTop))
- borderTop = Height - BorderStrokeSelectionControlHeight;
+ if (Width - borderLeft < _w || double.IsNaN(borderLeft))
+ borderLeft = Width - _w;
+ if (Height - borderTop < 48 || double.IsNaN(borderTop))
+ borderTop = Height - 48;
- if (borderTop > 60) borderTop -= 60;
+ //if (borderTop > 60) borderTop -= 60;
BorderStrokeSelectionControl.Margin = new Thickness(borderLeft, borderTop, 0, 0);
}
+ #region Strokes Lock
+
+ public Guid IsLockGuid = new Guid("b701bb3f-16bf-43ce-a88f-30eab85cd77b");
+
+ private void UpdateSelectionToolBarLockIcon(bool isLocked) {
+ BorderStrokeSelectionLock_LockClose.Visibility = !isLocked ? Visibility.Visible : Visibility.Collapsed;
+ BorderStrokeSelectionLock_LockOpen.Visibility = isLocked ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ private void UpdateSelectionToolbarOtherIconLockedStatus(bool isLocked) {
+ var toolbtns = new Border[] {
+ BorderStrokeSelectionClone,
+ BorderStrokeSelectionCloneToNewBoard,
+ BorderImageRotate45,
+ BorderImageRotate90,
+ BorderImageFlipHorizontal,
+ BorderImageFlipVertical,
+ BorderStrokePaletteButton,
+ BorderStrokeSelectionDelete,
+ BorderImageRotateClockwise
+ };
+
+ foreach (var tb in toolbtns)
+ {
+ tb.IsHitTestVisible = !isLocked;
+ tb.Opacity = isLocked ? 0.5 : 1;
+ tb.IsEnabled = !isLocked;
+ }
+ }
+
+ private void UpdateSelectionBorderHandlesLockStatus(bool isLocked) {
+ var _v = !isLocked ? Visibility.Visible : Visibility.Collapsed;
+ foreach (var hd in StrokeSelectionBorderHandles) hd.Visibility = _v;
+ StrokeSelectionRotateHandleConnectLine.Visibility = _v;
+ StrokeSelectionBorder.IsHitTestVisible = !isLocked;
+ }
+
+ private void BorderStrokeSelectionLock_MouseUp(object sender, MouseButtonEventArgs e) {
+ if (BorderStrokeSelectionToolButtonMouseDown != (Border)sender) return;
+
+ var isAllStrokesLocked = BorderStrokeSelectionLock_LockOpen.Visibility == Visibility.Visible;
+
+ var stks = inkCanvas.GetSelectedStrokes();
+ if (isAllStrokesLocked) {
+ foreach (var stk in stks) {
+ stk.RemovePropertyData(IsLockGuid);
+ }
+ } else {
+ foreach (var stk in stks) {
+ stk.AddPropertyData(IsLockGuid, "Locked");
+ }
+ }
+
+ UpdateSelectionToolBarLockIcon(!isAllStrokesLocked);
+ UpdateSelectionToolbarOtherIconLockedStatus(!isAllStrokesLocked);
+ UpdateSelectionBorderHandlesLockStatus(!isAllStrokesLocked);
+
+ // toolbutton
+ BorderStrokeSelectionToolButton_MouseLeave(sender, e);
+ }
+
+ #endregion
+
private void GridInkCanvasSelectionCover_ManipulationStarting(object sender, ManipulationStartingEventArgs e) {
e.Mode = ManipulationModes.All;
}
@@ -356,53 +1265,5 @@ namespace Ink_Canvas {
}
catch { }
}
-
- private void GridInkCanvasSelectionCover_TouchDown(object sender, TouchEventArgs e) { }
-
- private void GridInkCanvasSelectionCover_TouchUp(object sender, TouchEventArgs e) { }
-
- private Point lastTouchPointOnGridInkCanvasCover = new Point(0, 0);
-
- private void GridInkCanvasSelectionCover_PreviewTouchDown(object sender, TouchEventArgs e) {
- dec.Add(e.TouchDevice.Id);
- //设备1个的时候,记录中心点
- if (dec.Count == 1) {
- var touchPoint = e.GetTouchPoint(null);
- centerPoint = touchPoint.Position;
- lastTouchPointOnGridInkCanvasCover = touchPoint.Position;
-
- if (isStrokeSelectionCloneOn) {
- var strokes = inkCanvas.GetSelectedStrokes();
- isProgramChangeStrokeSelection = true;
- inkCanvas.Select(new StrokeCollection());
- StrokesSelectionClone = strokes.Clone();
- inkCanvas.Select(strokes);
- isProgramChangeStrokeSelection = false;
- inkCanvas.Strokes.Add(StrokesSelectionClone);
- }
- }
- }
-
- private void GridInkCanvasSelectionCover_PreviewTouchUp(object sender, TouchEventArgs e) {
- dec.Remove(e.TouchDevice.Id);
- if (dec.Count >= 1) return;
- isProgramChangeStrokeSelection = false;
- if (lastTouchPointOnGridInkCanvasCover == e.GetTouchPoint(null).Position) {
- if (!(lastTouchPointOnGridInkCanvasCover.X < inkCanvas.GetSelectionBounds().Left) &&
- !(lastTouchPointOnGridInkCanvasCover.Y < inkCanvas.GetSelectionBounds().Top) &&
- !(lastTouchPointOnGridInkCanvasCover.X > inkCanvas.GetSelectionBounds().Right) &&
- !(lastTouchPointOnGridInkCanvasCover.Y > inkCanvas.GetSelectionBounds().Bottom)) return;
- inkCanvas.Select(new StrokeCollection());
- StrokesSelectionClone = new StrokeCollection();
- }
- else if (inkCanvas.GetSelectedStrokes().Count == 0) {
- GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
- StrokesSelectionClone = new StrokeCollection();
- }
- else {
- GridInkCanvasSelectionCover.Visibility = Visibility.Visible;
- StrokesSelectionClone = new StrokeCollection();
- }
- }
}
}
\ No newline at end of file
diff --git a/InkCanvasForClass/MainWindow_cs/MW_Settings.cs b/InkCanvasForClass/MainWindow_cs/MW_Settings.cs
index 310bc77..eb5ff9f 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_Settings.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_Settings.cs
@@ -20,6 +20,7 @@ using System.Security.Principal;
using System.IO;
using System.Reflection;
using System.Threading;
+using Ookii.Dialogs.Wpf;
namespace Ink_Canvas {
public partial class MainWindow : Window {
@@ -157,6 +158,12 @@ namespace Ink_Canvas {
SaveSettingsToFile();
}
+ private void ToggleSwitchEnableWindowChromeRendering_Toggled(object sender, RoutedEventArgs e) {
+ if (!isLoaded) return;
+ Settings.Startup.EnableWindowChromeRendering = ToggleSwitchEnableWindowChromeRendering.IsOn;
+ SaveSettingsToFile();
+ }
+
#endregion
#region Appearance
@@ -197,7 +204,7 @@ namespace Ink_Canvas {
ViewboxFloatingBarScaleTransform.ScaleY =
val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1;
// auto align
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible)
ViewboxFloatingBarMarginAnimation(60);
else
ViewboxFloatingBarMarginAnimation(100, true);
@@ -410,7 +417,7 @@ namespace Ink_Canvas {
if (!isLoaded) return;
Settings.PowerPointSettings.ShowPPTButton = ToggleSwitchShowPPTButton.IsOn;
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
UpdatePPTBtnPreview();
}
@@ -427,7 +434,7 @@ namespace Ink_Canvas {
c[0] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTButtonsDisplayOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
UpdatePPTBtnPreview();
}
@@ -439,7 +446,7 @@ namespace Ink_Canvas {
c[1] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTButtonsDisplayOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
UpdatePPTBtnPreview();
}
@@ -451,7 +458,7 @@ namespace Ink_Canvas {
c[2] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTButtonsDisplayOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
UpdatePPTBtnPreview();
}
@@ -463,7 +470,7 @@ namespace Ink_Canvas {
c[3] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTButtonsDisplayOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
UpdatePPTBtnPreview();
}
@@ -475,7 +482,7 @@ namespace Ink_Canvas {
c[0] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTSButtonsOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
UpdatePPTBtnPreview();
}
@@ -487,7 +494,7 @@ namespace Ink_Canvas {
c[1] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTSButtonsOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
UpdatePPTBtnPreview();
}
@@ -499,7 +506,7 @@ namespace Ink_Canvas {
c[2] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTSButtonsOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
UpdatePPTBtnPreview();
}
@@ -511,7 +518,7 @@ namespace Ink_Canvas {
c[0] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTBButtonsOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
UpdatePPTBtnPreview();
}
@@ -523,7 +530,7 @@ namespace Ink_Canvas {
c[1] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTBButtonsOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
UpdatePPTBtnPreview();
}
@@ -535,7 +542,7 @@ namespace Ink_Canvas {
c[2] = (bool)((CheckBox)sender).IsChecked ? '2' : '1';
Settings.PowerPointSettings.PPTBButtonsOption = int.Parse(new string(c));
SaveSettingsToFile();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnStyleSettingsStatus();
UpdatePPTBtnPreview();
}
@@ -543,7 +550,7 @@ namespace Ink_Canvas {
if (!isLoaded) return;
Settings.PowerPointSettings.PPTLSButtonPosition = (int)PPTButtonLeftPositionValueSlider.Value;
UpdatePPTBtnSlidersStatus();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
SliderDelayAction.DebounceAction(2000, null, SaveSettingsToFile);
UpdatePPTBtnPreview();
}
@@ -677,7 +684,7 @@ namespace Ink_Canvas {
if (!isLoaded) return;
Settings.PowerPointSettings.PPTRSButtonPosition = (int)PPTButtonRightPositionValueSlider.Value;
UpdatePPTBtnSlidersStatus();
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) UpdatePPTBtnDisplaySettingsStatus();
SliderDelayAction.DebounceAction(2000,null, SaveSettingsToFile);
UpdatePPTBtnPreview();
}
@@ -797,6 +804,7 @@ namespace Ink_Canvas {
private void ComboBoxEraserSize_SelectionChanged(object sender, SelectionChangedEventArgs e) {
if (!isLoaded) return;
Settings.Canvas.EraserSize = ComboBoxEraserSize.SelectedIndex;
+
SaveSettingsToFile();
}
@@ -812,46 +820,28 @@ namespace Ink_Canvas {
ComboBoxEraserSizeFloatingBar.SelectedIndex = s.SelectedIndex;
ComboBoxEraserSize.SelectedIndex = s.SelectedIndex;
}
- if (Settings.Canvas.EraserShapeType == 0) {
- double k = 1;
- switch (s.SelectedIndex) {
- case 0:
- k = 0.5;
- break;
- case 1:
- k = 0.8;
- break;
- case 3:
- k = 1.25;
- break;
- case 4:
- k = 1.8;
- break;
- }
-
- inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
- } else if (Settings.Canvas.EraserShapeType == 1) {
- double k = 1;
- switch (s.SelectedIndex) {
- case 0:
- k = 0.7;
- break;
- case 1:
- k = 0.9;
- break;
- case 3:
- k = 1.2;
- break;
- case 4:
- k = 1.6;
- break;
- }
-
- inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
+ double width = 24;
+ switch (Settings.Canvas.EraserSize)
+ {
+ case 0:
+ width = 24;
+ break;
+ case 1:
+ width = 38;
+ break;
+ case 2:
+ width = 46;
+ break;
+ case 3:
+ width = 62;
+ break;
+ case 4:
+ width = 78;
+ break;
}
- inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
- inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
+ eraserWidth = width;
+ isEraserCircleShape = Settings.Canvas.EraserShapeType == 0;
SaveSettingsToFile();
}
@@ -860,25 +850,7 @@ namespace Ink_Canvas {
Settings.Canvas.EraserShapeType = 0;
SaveSettingsToFile();
CheckEraserTypeTab();
- double k = 1;
- switch (ComboBoxEraserSizeFloatingBar.SelectedIndex) {
- case 0:
- k = 0.5;
- break;
- case 1:
- k = 0.8;
- break;
- case 3:
- k = 1.25;
- break;
- case 4:
- k = 1.8;
- break;
- }
-
- inkCanvas.EraserShape = new EllipseStylusShape(k * 90, k * 90);
- inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
- inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
+ isEraserCircleShape = true;
}
private void SwitchToRectangleEraser(object sender, MouseButtonEventArgs e) {
@@ -886,25 +858,7 @@ namespace Ink_Canvas {
Settings.Canvas.EraserShapeType = 1;
SaveSettingsToFile();
CheckEraserTypeTab();
- double k = 1;
- switch (ComboBoxEraserSizeFloatingBar.SelectedIndex) {
- case 0:
- k = 0.7;
- break;
- case 1:
- k = 0.9;
- break;
- case 3:
- k = 1.2;
- break;
- case 4:
- k = 1.6;
- break;
- }
-
- inkCanvas.EraserShape = new RectangleStylusShape(k * 90 * 0.6, k * 90);
- inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
- inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
+ isEraserCircleShape = false;
}
@@ -1369,17 +1323,25 @@ namespace Ink_Canvas {
SaveSettingsToFile();
}
+
+ private void ToggleSwitchLimitAutoSaveAmount_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!isLoaded) return;
+ Settings.Automation.IsEnableLimitAutoSaveAmount = ToggleSwitchLimitAutoSaveAmount.IsOn;
+ SaveSettingsToFile();
+ }
+
+ private void ComboBoxLimitAutoSaveAmount_SelectionChanged(object sender, RoutedEventArgs e)
+ {
+ if (!isLoaded) return;
+ Settings.Automation.LimitAutoSaveAmount = ComboBoxLimitAutoSaveAmount.SelectedIndex;
+ SaveSettingsToFile();
+ }
+
#endregion
#region Gesture
- private void ToggleSwitchEnableFingerGestureSlideShowControl_Toggled(object sender, RoutedEventArgs e) {
- if (!isLoaded) return;
- Settings.PowerPointSettings.IsEnableFingerGestureSlideShowControl =
- ToggleSwitchEnableFingerGestureSlideShowControl.IsOn;
- SaveSettingsToFile();
- }
-
private void ToggleSwitchAutoSwitchTwoFingerGesture_Toggled(object sender, RoutedEventArgs e) {
if (!isLoaded) return;
Settings.Gesture.AutoSwitchTwoFingerGesture = ToggleSwitchAutoSwitchTwoFingerGesture.IsOn;
@@ -1513,6 +1475,18 @@ namespace Ink_Canvas {
SaveSettingsToFile();
}
+ private void ComboBoxWindowsInkEraserButtonAction_SelectionChanged(object sender, SelectionChangedEventArgs e) {
+ if (!isLoaded) return;
+ Settings.Gesture.WindowsInkEraserButtonAction = ComboBoxWindowsInkEraserButtonAction.SelectedIndex;
+ SaveSettingsToFile();
+ }
+
+ private void ComboBoxWindowsInkBarrelButtonAction_SelectionChanged(object sender, SelectionChangedEventArgs e) {
+ if (!isLoaded) return;
+ Settings.Gesture.WindowsInkBarrelButtonAction = ComboBoxWindowsInkBarrelButtonAction.SelectedIndex;
+ SaveSettingsToFile();
+ }
+
#endregion
#region Reset
@@ -1555,6 +1529,7 @@ namespace Ink_Canvas {
Settings.Appearance.ViewboxFloatingBarOpacityInPPTValue = 1.0;
Settings.Appearance.EnableTrayIcon = true;
Settings.Appearance.FloatingBarButtonLabelVisibility = true;
+ Settings.Advanced.EnableForceTopMost = false;
Settings.Automation.IsAutoFoldInEasiNote = true;
Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno = true;
@@ -1588,6 +1563,8 @@ namespace Ink_Canvas {
Settings.Automation.MinimumAutomationStrokeNumber = 0;
Settings.Automation.AutoDelSavedFiles = AutoDelSavedFilesDays;
Settings.Automation.AutoDelSavedFilesDaysThreshold = AutoDelSavedFilesDaysThreshold;
+ Settings.Automation.IsEnableLimitAutoSaveAmount = false;
+ Settings.Automation.LimitAutoSaveAmount = 3;
//Settings.PowerPointSettings.IsShowPPTNavigation = true;
//Settings.PowerPointSettings.IsShowBottomPPTNavigationPanel = false;
@@ -1601,7 +1578,6 @@ namespace Ink_Canvas {
Settings.PowerPointSettings.IsNotifyPreviousPage = false;
Settings.PowerPointSettings.IsNotifyHiddenPage = false;
Settings.PowerPointSettings.IsEnableTwoFingerGestureInPresentationMode = false;
- Settings.PowerPointSettings.IsEnableFingerGestureSlideShowControl = false;
Settings.PowerPointSettings.IsSupportWPS = true;
Settings.PowerPointSettings.RegistryShowBlackScreenLastSlideShow = false;
Settings.PowerPointSettings.RegistryShowSlideShowToolbar = false;
@@ -1615,7 +1591,7 @@ namespace Ink_Canvas {
Settings.Canvas.EraserShapeType = 1;
Settings.Canvas.HideStrokeWhenSelecting = false;
Settings.Canvas.ClearCanvasAndClearTimeMachine = false;
- Settings.Canvas.FitToCurve = true;
+ Settings.Canvas.FitToCurve = false;
Settings.Canvas.UsingWhiteboard = false;
Settings.Canvas.HyperbolaAsymptoteOption = 0;
Settings.Canvas.BlackboardBackgroundColor = BlackboardBackgroundColorEnum.White;
@@ -1635,6 +1611,8 @@ namespace Ink_Canvas {
Settings.Gesture.EnableMouseGesture = true;
Settings.Gesture.EnableMouseRightBtnGesture = true;
Settings.Gesture.EnableMouseWheelGesture = true;
+ Settings.Gesture.WindowsInkEraserButtonAction = 2;
+ Settings.Gesture.WindowsInkBarrelButtonAction = 2;
Settings.InkToShape.IsInkToShapeEnabled = true;
Settings.InkToShape.IsInkToShapeNoFakePressureRectangle = false;
@@ -1650,6 +1628,8 @@ namespace Ink_Canvas {
Settings.Startup.AutoUpdateWithSilenceStartTime = "18:20";
Settings.Startup.AutoUpdateWithSilenceEndTime = "07:40";
Settings.Startup.IsFoldAtStartup = false;
+ Settings.Startup.EnableWindowChromeRendering = false;
+
}
private void BtnResetToSuggestion_Click(object sender, RoutedEventArgs e) {
@@ -1839,6 +1819,13 @@ namespace Ink_Canvas {
SaveSettingsToFile();
}
+ private void ToggleSwitchEnableForceTopMost_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!isLoaded) return;
+ Settings.Advanced.EnableForceTopMost = ToggleSwitchEnableForceTopMost.IsOn;
+ SaveSettingsToFile();
+ }
+
#endregion
#region RandSettings
@@ -2086,8 +2073,14 @@ namespace Ink_Canvas {
HideSubPanels();
}
+ private void HyperlinkSourceToICCGithubRepository_Click(object sender, RoutedEventArgs e)
+ {
+ Process.Start("https://github.com/InkCanvas/InkCanvasForClass");
+ HideSubPanels();
+ }
+
private void HyperlinkSourceToPresentRepository_Click(object sender, RoutedEventArgs e) {
- Process.Start("https://github.com/ChangSakura/Ink-Canvas");
+ Process.Start("https://github.com/InkCanvas/Ink-Canvas-Artistry");
HideSubPanels();
}
diff --git a/InkCanvasForClass/MainWindow_cs/MW_SettingsToLoad.cs b/InkCanvasForClass/MainWindow_cs/MW_SettingsToLoad.cs
index 6ef88a2..899b843 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_SettingsToLoad.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_SettingsToLoad.cs
@@ -111,6 +111,9 @@ namespace Ink_Canvas {
AutoUpdateWithSilenceEndTimeComboBox.SelectedItem = Settings.Startup.AutoUpdateWithSilenceEndTime;
ToggleSwitchFoldAtStartup.IsOn = Settings.Startup.IsFoldAtStartup;
+
+ ToggleSwitchEnableWindowChromeRendering.IsOn = Settings.Startup.EnableWindowChromeRendering;
+
} else {
Settings.Startup = new Startup();
}
@@ -220,17 +223,6 @@ namespace Ink_Canvas {
ToggleSwitchEnableViewboxBlackBoardScaleTransform.IsOn = false;
}
- if (Settings.Appearance.IsTransparentButtonBackground) {
- BtnExit.Background = new SolidColorBrush(StringToColor("#7F909090"));
- } else {
- //Light
- BtnExit.Background = BtnSwitchTheme.Content.ToString() == "深色"
- ? new SolidColorBrush(StringToColor("#FFCCCCCC"))
- :
- //Dark
- new SolidColorBrush(StringToColor("#FF555555"));
- }
-
ComboBoxFloatingBarImg.SelectedIndex = Settings.Appearance.FloatingBarImg;
if (ComboBoxFloatingBarImg.SelectedIndex == 0) {
FloatingbarHeadIconImg.Source =
@@ -300,9 +292,6 @@ namespace Ink_Canvas {
ToggleSwitchEnableTwoFingerGestureInPresentationMode.IsOn =
Settings.PowerPointSettings.IsEnableTwoFingerGestureInPresentationMode;
- ToggleSwitchEnableFingerGestureSlideShowControl.IsOn =
- Settings.PowerPointSettings.IsEnableFingerGestureSlideShowControl;
-
ToggleSwitchAutoSaveStrokesInPowerPoint.IsOn =
Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint;
@@ -449,6 +438,9 @@ namespace Ink_Canvas {
ToggleSwitchEnableMouseRightBtnGesture.IsOn = Settings.Gesture.EnableMouseRightBtnGesture;
ToggleSwitchEnableMouseWheelGesture.IsOn = Settings.Gesture.EnableMouseWheelGesture;
+ ComboBoxWindowsInkEraserButtonAction.SelectedIndex = Settings.Gesture.WindowsInkEraserButtonAction;
+ ComboBoxWindowsInkBarrelButtonAction.SelectedIndex = Settings.Gesture.WindowsInkBarrelButtonAction;
+
CheckEnableTwoFingerGestureBtnColorPrompt();
} else {
Settings.Gesture = new Gesture();
@@ -614,6 +606,7 @@ namespace Ink_Canvas {
Settings.Advanced.IsEnableResolutionChangeDetection;
ToggleSwitchIsDisableCloseWindow.IsOn = Settings.Advanced.IsDisableCloseWindow;
+ ToggleSwitchEnableForceTopMost.IsOn = Settings.Advanced.EnableForceTopMost;
} else {
Settings.Advanced = new Advanced();
}
@@ -730,12 +723,16 @@ namespace Ink_Canvas {
ToggleSwitchAutoDelSavedFiles.IsOn = Settings.Automation.AutoDelSavedFiles;
ComboBoxAutoDelSavedFilesDaysThreshold.Text =
Settings.Automation.AutoDelSavedFilesDaysThreshold.ToString();
+
+ ToggleSwitchLimitAutoSaveAmount.IsOn = Settings.Automation.IsEnableLimitAutoSaveAmount;
+ ComboBoxLimitAutoSaveAmount.SelectedIndex = Settings.Automation.LimitAutoSaveAmount;
+
} else {
Settings.Automation = new Automation();
}
// auto align
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) {
+ if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) {
ViewboxFloatingBarMarginAnimation(60);
} else {
ViewboxFloatingBarMarginAnimation(100, true);
diff --git a/InkCanvasForClass/MainWindow_cs/MW_ShapeDrawing.cs b/InkCanvasForClass/MainWindow_cs/MW_ShapeDrawing.cs
index c00b935..3a284f7 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_ShapeDrawing.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_ShapeDrawing.cs
@@ -98,7 +98,7 @@ namespace Ink_Canvas {
drawingShapeMode = 2;
else if (sender == ImageDrawParallelLine || sender == BoardImageDrawParallelLine) drawingShapeMode = 15;
isLongPressSelected = true;
- if (isSingleFingerDragMode) BtnFingerDragMode_Click(BtnFingerDragMode, null);
+ if (isSingleFingerDragMode) BtnFingerDragMode_Click(null, null);
}
}
diff --git a/InkCanvasForClass/MainWindow_cs/MW_TimeMachine.cs b/InkCanvasForClass/MainWindow_cs/MW_TimeMachine.cs
index 544f5c0..2711be7 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_TimeMachine.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_TimeMachine.cs
@@ -152,15 +152,11 @@ namespace Ink_Canvas {
}
private void TimeMachine_OnUndoStateChanged(bool status) {
- var result = status ? Visibility.Visible : Visibility.Collapsed;
- BtnUndo.Visibility = result;
- BtnUndo.IsEnabled = status;
+ SymbolIconUndo.IsEnabled = status;
}
private void TimeMachine_OnRedoStateChanged(bool status) {
- var result = status ? Visibility.Visible : Visibility.Collapsed;
- BtnRedo.Visibility = result;
- BtnRedo.IsEnabled = status;
+ SymbolIconRedo.IsEnabled = status;
}
private void StrokesOnStrokesChanged(object sender, StrokeCollectionChangedEventArgs e) {
diff --git a/InkCanvasForClass/MainWindow_cs/MW_TouchEvents.cs b/InkCanvasForClass/MainWindow_cs/MW_TouchEvents.cs
index 86ce0da..a2cd44a 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_TouchEvents.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_TouchEvents.cs
@@ -95,22 +95,21 @@ namespace Ink_Canvas {
}
private void MainWindow_StylusDown(object sender, StylusDownEventArgs e) {
+ if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Touch) {
+ if (!isCursorHidden && Settings.Gesture.HideCursorWhenUsingTouchDevice && e.StylusDevice.TabletDevice.Type == TabletDeviceType.Touch) {
+ System.Windows.Forms.Cursor.Hide();
+ isCursorHidden = true;
+ }
+
+ ViewboxFloatingBar.IsHitTestVisible = false;
+ BlackboardUIGridForInkReplay.IsHitTestVisible = false;
- if (!isCursorHidden && Settings.Gesture.HideCursorWhenUsingTouchDevice && e.StylusDevice.TabletDevice.Type == TabletDeviceType.Touch) {
- System.Windows.Forms.Cursor.Hide();
- isCursorHidden = true;
+ if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
+ || inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke
+ || inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
+
+ TouchDownPointsList[e.StylusDevice.Id] = InkCanvasEditingMode.None;
}
-
-
- inkCanvas.CaptureStylus();
- ViewboxFloatingBar.IsHitTestVisible = false;
- BlackboardUIGridForInkReplay.IsHitTestVisible = false;
-
- if (inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint
- || inkCanvas.EditingMode == InkCanvasEditingMode.EraseByStroke
- || inkCanvas.EditingMode == InkCanvasEditingMode.Select) return;
-
- TouchDownPointsList[e.StylusDevice.Id] = InkCanvasEditingMode.None;
}
private async void MainWindow_StylusUp(object sender, StylusEventArgs e) {
@@ -119,31 +118,27 @@ namespace Ink_Canvas {
inkCanvas.Strokes.Add(GetStrokeVisual(e.StylusDevice.Id).Stroke);
await Task.Delay(5); // 避免渲染墨迹完成前预览墨迹被删除导致墨迹闪烁
inkCanvas.Children.Remove(GetVisualCanvas(e.StylusDevice.Id));
-
- inkCanvas_StrokeCollected(inkCanvas,
- new InkCanvasStrokeCollectedEventArgs(GetStrokeVisual(e.StylusDevice.Id).Stroke));
- }
- catch (Exception ex) {
+ inkCanvas_StrokeCollected(inkCanvas, new InkCanvasStrokeCollectedEventArgs(GetStrokeVisual(e.StylusDevice.Id).Stroke));
+ } catch (Exception ex) {
Label.Content = ex.ToString();
}
- }
- try {
- StrokeVisualList.Remove(e.StylusDevice.Id);
- VisualCanvasList.Remove(e.StylusDevice.Id);
- TouchDownPointsList.Remove(e.StylusDevice.Id);
- if (StrokeVisualList.Count == 0 || VisualCanvasList.Count == 0 || TouchDownPointsList.Count == 0) {
- inkCanvas.Children.Clear();
- StrokeVisualList.Clear();
- VisualCanvasList.Clear();
- TouchDownPointsList.Clear();
+ try {
+ StrokeVisualList.Remove(e.StylusDevice.Id);
+ VisualCanvasList.Remove(e.StylusDevice.Id);
+ TouchDownPointsList.Remove(e.StylusDevice.Id);
+ if (StrokeVisualList.Count == 0 || VisualCanvasList.Count == 0 || TouchDownPointsList.Count == 0) {
+ inkCanvas.Children.Clear();
+ StrokeVisualList.Clear();
+ VisualCanvasList.Clear();
+ TouchDownPointsList.Clear();
+ }
}
- }
- catch { }
+ catch { }
- inkCanvas.ReleaseStylusCapture();
- ViewboxFloatingBar.IsHitTestVisible = true;
- BlackboardUIGridForInkReplay.IsHitTestVisible = true;
+ ViewboxFloatingBar.IsHitTestVisible = true;
+ BlackboardUIGridForInkReplay.IsHitTestVisible = true;
+ }
}
private void MainWindow_StylusMove(object sender, StylusEventArgs e) {
@@ -154,22 +149,21 @@ namespace Ink_Canvas {
isCursorHidden = true;
}
- Trace.WriteLine(e.Inverted);
-
- try {
- if (GetTouchDownPointsList(e.StylusDevice.Id) != InkCanvasEditingMode.None) return;
+ if (e.StylusDevice.TabletDevice.Type == TabletDeviceType.Touch) {
try {
- if (e.StylusDevice.StylusButtons[1].StylusButtonState == StylusButtonState.Down) return;
- }
- catch { }
+ if (GetTouchDownPointsList(e.StylusDevice.Id) != InkCanvasEditingMode.None) return;
+ try {
+ if (e.StylusDevice.StylusButtons[1].StylusButtonState == StylusButtonState.Down) return;
+ }
+ catch { }
- var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
- var stylusPointCollection = e.GetStylusPoints(this);
- foreach (var stylusPoint in stylusPointCollection)
- strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor));
- strokeVisual.Redraw();
+ var strokeVisual = GetStrokeVisual(e.StylusDevice.Id);
+ var stylusPointCollection = e.GetStylusPoints(this);
+ foreach (var stylusPoint in stylusPointCollection)
+ strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor));
+ strokeVisual.Redraw();
+ } catch { }
}
- catch { }
}
private StrokeVisual GetStrokeVisual(int id) {
@@ -277,16 +271,8 @@ namespace Ink_Canvas {
inkCanvas.EditingMode = InkCanvasEditingMode.EraseByPoint;
}
else {
- if (StackPanelPPTControls.Visibility == Visibility.Visible && inkCanvas.Strokes.Count == 0 &&
- Settings.PowerPointSettings.IsEnableFingerGestureSlideShowControl) {
- isLastTouchEraser = false;
- inkCanvas.EditingMode = InkCanvasEditingMode.GestureOnly;
- inkCanvas.Opacity = 0.1;
- }
- else {
- inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
- inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
- }
+ inkCanvas.EraserShape = new EllipseStylusShape(5, 5);
+ inkCanvas.EditingMode = InkCanvasEditingMode.EraseByStroke;
}
}
else {
@@ -396,8 +382,7 @@ namespace Ink_Canvas {
private void Main_Grid_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) {
if (isInMultiTouchMode || !Settings.Gesture.IsEnableTwoFingerGesture) return;
if ((dec.Count >= 2 && (Settings.PowerPointSettings.IsEnableTwoFingerGestureInPresentationMode ||
- StackPanelPPTControls.Visibility != Visibility.Visible ||
- StackPanelPPTButtons.Visibility == Visibility.Collapsed)) ||
+ BorderFloatingBarExitPPTBtn.Visibility != Visibility.Visible)) ||
isSingleFingerDragMode) {
var md = e.DeltaManipulation;
var trans = md.Translation; // 获得位移矢量
diff --git a/InkCanvasForClass/MainWindow_cs/MW_TrayIcon.cs b/InkCanvasForClass/MainWindow_cs/MW_TrayIcon.cs
index e4c943a..ccb52f3 100644
--- a/InkCanvasForClass/MainWindow_cs/MW_TrayIcon.cs
+++ b/InkCanvasForClass/MainWindow_cs/MW_TrayIcon.cs
@@ -85,7 +85,7 @@ namespace Ink_Canvas
if (mainWin.IsLoaded) {
var isInPPTPresentationMode = false;
Dispatcher.Invoke(() => {
- isInPPTPresentationMode = mainWin.BtnPPTSlideShowEnd.Visibility == Visibility.Visible;
+ isInPPTPresentationMode = mainWin.BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible;
});
if (!mainWin.isFloatingBarFolded) {
if (!isInPPTPresentationMode) mainWin.PureViewboxFloatingBarMarginAnimationInDesktopMode();
diff --git a/InkCanvasForClass/MainWindow_cs/MW_WindowsInk.cs b/InkCanvasForClass/MainWindow_cs/MW_WindowsInk.cs
new file mode 100644
index 0000000..da8a732
--- /dev/null
+++ b/InkCanvasForClass/MainWindow_cs/MW_WindowsInk.cs
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace Ink_Canvas
+{
+ public partial class MainWindow : Window {
+
+ private bool _stylusInverted = false;
+ private int _stylusInvertedInit = 0;
+
+ private bool IsStylusInverted {
+ get => _stylusInverted;
+ set {
+ if (value && !_stylusInverted) {
+ StylusInverted?.Invoke(this,new RoutedEventArgs());
+ } else if (!value && _stylusInverted) {
+ StylusUnInverted?.Invoke(this,new RoutedEventArgs());
+ }
+ _stylusInverted = value;
+ }
+ }
+
+ public event EventHandler StylusInverted;
+ public event EventHandler StylusUnInverted;
+
+ public void UpdateStylusPenInvertedStatus(bool isInverted) {
+ if (_stylusInvertedInit == 0) {
+ _stylusInverted = isInverted;
+ _stylusInvertedInit = 1;
+ } else {
+ IsStylusInverted = isInverted;
+ }
+ }
+
+ #region 托管StylusInAirMove和StylusMove事件
+
+ public void mainWin_StylusInAirMove(object sender, StylusEventArgs e) {
+ UpdateStylusPenInvertedStatus(e.Inverted);
+ }
+
+ public void mainWin_StylusMove(object sender, StylusEventArgs e) {
+ UpdateStylusPenInvertedStatus(e.Inverted);
+ }
+
+ #endregion
+
+ #region Windows Ink 橡皮按钮自定义适配
+
+ public void StylusInvertedListenerInit() {
+ StylusInverted += StylusInvertedEvent;
+ StylusUnInverted += StylusUnInvertedEvent;
+ }
+
+ private void StylusInvertedEvent(object sender, RoutedEventArgs e) {
+ if (Settings.Gesture.WindowsInkEraserButtonAction != 0) {
+ if (SelectedMode != ICCToolsEnum.EraseByGeometryMode &&
+ SelectedMode != ICCToolsEnum.EraseByStrokeMode) {
+ GridEraserOverlay.Visibility = Visibility.Visible;
+ isUsingStrokesEraser = Settings.Gesture.WindowsInkEraserButtonAction == 1;
+ } else if (SelectedMode == (Settings.Gesture.WindowsInkEraserButtonAction == 2
+ ? ICCToolsEnum.EraseByStrokeMode
+ : ICCToolsEnum.EraseByGeometryMode)) {
+ isUsingStrokesEraser = Settings.Gesture.WindowsInkEraserButtonAction == 1;
+ }
+ ForceUpdateToolSelection((Settings.Gesture.WindowsInkEraserButtonAction == 2
+ ? ICCToolsEnum.EraseByGeometryMode
+ : ICCToolsEnum.EraseByStrokeMode));
+ }
+ }
+
+ private void StylusUnInvertedEvent(object sender, RoutedEventArgs e) {
+ if (Settings.Gesture.WindowsInkEraserButtonAction != 0) {
+ if (SelectedMode != ICCToolsEnum.EraseByGeometryMode &&
+ SelectedMode != ICCToolsEnum.EraseByStrokeMode) {
+ GridEraserOverlay.Visibility = Visibility.Collapsed;
+ } else if (SelectedMode == (Settings.Gesture.WindowsInkEraserButtonAction == 2
+ ? ICCToolsEnum.EraseByStrokeMode
+ : ICCToolsEnum.EraseByGeometryMode)) {
+ isUsingStrokesEraser = Settings.Gesture.WindowsInkEraserButtonAction == 2;
+ }
+ }
+ ForceUpdateToolSelection(null);
+ }
+
+ #endregion
+
+ #region Windows Ink 筒形按钮自定义适配
+
+ private void mainWin_StylusButtonUp(object sender, StylusButtonEventArgs e) {
+ if (e.StylusButton.Guid == StylusPointProperties.BarrelButton.Id) {
+ if (Settings.Gesture.WindowsInkBarrelButtonAction == 0) return;
+ if (Settings.Gesture.WindowsInkBarrelButtonAction == 1) SelectIcon_MouseUp(null,null);
+ else if (Settings.Gesture.WindowsInkBarrelButtonAction == 2) {
+ SymbolIconSelect_MouseUp(null,null);
+ inkCanvas.Select(inkCanvas.Strokes);
+ }
+ else if (Settings.Gesture.WindowsInkBarrelButtonAction == 3) SymbolIconUndo_MouseUp(null,null);
+ }
+ }
+
+ private void mainWin_StylusButtonDown(object sender, StylusButtonEventArgs e) {
+ if (e.StylusButton.Guid == StylusPointProperties.BarrelButton.Id) {
+
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/InkCanvasForClass/Popups/ColorPalette.xaml b/InkCanvasForClass/Popups/ColorPalette.xaml
index c9f15a7..8726eab 100644
--- a/InkCanvasForClass/Popups/ColorPalette.xaml
+++ b/InkCanvasForClass/Popups/ColorPalette.xaml
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ink_Canvas.Popups"
xmlns:modern="http://schemas.inkore.net/lib/ui/wpf/modern"
+ xmlns:colorPicker="clr-namespace:ColorPicker;assembly=ColorPicker"
mc:Ignorable="d" Width="300" Height="450" UseLayoutRounding="True">
@@ -28,8 +29,6 @@
-
-
@@ -343,21 +342,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -381,9 +380,12 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/InkCanvasForClass/Popups/ColorPalette.xaml.cs b/InkCanvasForClass/Popups/ColorPalette.xaml.cs
index e396f21..821a835 100644
--- a/InkCanvasForClass/Popups/ColorPalette.xaml.cs
+++ b/InkCanvasForClass/Popups/ColorPalette.xaml.cs
@@ -16,8 +16,14 @@ using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using ColorPicker;
using iNKORE.UI.WPF.Helpers;
using static Ink_Canvas.Popups.ColorPalette;
+using System.Drawing;
+using Ink_Canvas.Helpers;
+using Color = System.Windows.Media.Color;
+using Point = System.Windows.Point;
+using Image = System.Windows.Controls.Image;
namespace Ink_Canvas.Popups {
public partial class ColorPalette : UserControl {
@@ -36,10 +42,11 @@ namespace Ink_Canvas.Popups {
ColorPurple,
ColorFuchsia,
ColorPink,
- ColorRose
+ ColorRose,
+ ColorCustom
};
- private Color[] _lightColors = new Color[] {
+ private Color[] _darkColors = new Color[] {
Color.FromRgb(9, 9, 11),
Color.FromRgb(250, 250, 250),
Color.FromRgb(220, 38, 38),
@@ -48,7 +55,7 @@ namespace Ink_Canvas.Popups {
Color.FromRgb(101, 163, 13),
Color.FromRgb(22, 163, 74),
Color.FromRgb(13, 148, 136),
- Color.FromRgb(2, 132, 199),
+ Color.FromRgb(8, 145, 178),
Color.FromRgb(37, 99, 235),
Color.FromRgb(79, 70, 229),
Color.FromRgb(124, 58, 237),
@@ -57,6 +64,24 @@ namespace Ink_Canvas.Popups {
Color.FromRgb(225, 29, 72),
};
+ private Color[] _lightColors = new Color[] {
+ Color.FromRgb(9, 9, 11),
+ Color.FromRgb(250, 250, 250),
+ Color.FromRgb(239, 68, 68),
+ Color.FromRgb(249, 115, 22),
+ Color.FromRgb(253, 224, 71),
+ Color.FromRgb(163, 230, 53),
+ Color.FromRgb(74, 222, 128),
+ Color.FromRgb(94, 234, 212),
+ Color.FromRgb(34, 211, 238),
+ Color.FromRgb(59, 130, 246),
+ Color.FromRgb(129, 140, 248),
+ Color.FromRgb(168, 85, 247),
+ Color.FromRgb(217, 70, 239),
+ Color.FromRgb(236, 72, 153),
+ Color.FromRgb(244, 63, 94),
+ };
+
public string[] ColorPaletteColorStrings = new[] {
"black", "white", "red", "orange", "yellow", "lime", "green", "teal", "cyan", "blue", "indigo", "purple",
"fuchsia", "pink", "rose"
@@ -68,6 +93,22 @@ namespace Ink_Canvas.Popups {
public GeometryDrawing[] PenModeTabButtonIcons;
public TextBlock[] PenModeTabButtonTexts;
+ private bool _usingDarkColors = true;
+
+ public bool UsingDarkColors {
+ get => _usingDarkColors;
+ set {
+ var pre = _usingDarkColors;
+ _usingDarkColors = value;
+ ColorModeChanged?.Invoke(this, new ColorModeChangedEventArgs()
+ {
+ IsPreviousUsedDarkColor = pre,
+ IsNowUsingDarkColor = value,
+ TriggerMode = TriggerMode.TriggeredByCode,
+ });
+ }
+ }
+
private ColorPaletteColor _colorSelected = ColorPaletteColor.ColorRed;
public ColorPaletteColor SelectedColor {
get => _colorSelected;
@@ -114,7 +155,6 @@ namespace Ink_Canvas.Popups {
var recogQua = ircm.Items[3] as MenuItem;
var recogEll = ircm.Items[4] as MenuItem;
var recogPlg = ircm.Items[5] as MenuItem;
- var ft2Curve = ircm.Items[7] as MenuItem;
var recogSub = new MenuItem[] {
recogTri, recogQua, recogEll, recogPlg,
};
@@ -233,11 +273,13 @@ namespace Ink_Canvas.Popups {
var pressSub = new MenuItem[] {
pointSP, velocitySP, noneSP
};
+ isSimulatePressureCheckedByUser = false;
foreach (var mi in pressSub) {
if (mi.Name=="PointSP") mi.IsChecked = _simulatePressure == PressureSimulation.PointSimulate;
else if (mi.Name == "VelocitySP") mi.IsChecked = _simulatePressure == PressureSimulation.VelocitySimulate;
else if (mi.Name == "NoneSP") mi.IsChecked = _simulatePressure == PressureSimulation.None;
}
+ isSimulatePressureCheckedByUser = true;
}
private void SimulatePressureContextMenu_Closed(object sender, RoutedEventArgs e) {
@@ -250,8 +292,23 @@ namespace Ink_Canvas.Popups {
UpdateSimulatePressureContextMenuDisplayStatus();
}
+ private bool isSimulatePressureCheckedByUser = true;
+
private void SimulatePressureContextMenuItem_Checked(object sender, RoutedEventArgs e) {
-
+ if (!isSimulatePressureCheckedByUser) return;
+ var mi = (MenuItem)sender;
+ var pre = _simulatePressure;
+ Trace.WriteLine(mi.Name);
+ _simulatePressure = mi.Name == "PointSP" ? PressureSimulation.PointSimulate : mi.Name == "VelocitySP" ? PressureSimulation.VelocitySimulate : PressureSimulation.None;
+ SimulatePressureToggleSwitchImage.Source =
+ this.FindResource(_simulatePressure != PressureSimulation.None ? "SwitchOnImage" : "SwitchOffImage") as DrawingImage;
+ UpdateSimulatePressureContextMenuDisplayStatus();
+ PressureSimulationChanged?.Invoke(this, new PressureSimulationChangedEventArgs()
+ {
+ PreviousMode = pre,
+ NowMode = _simulatePressure,
+ TriggerMode = TriggerMode.TriggeredByUser,
+ });
}
private void SimulatePressureToggleSwitchButton_Clicked(object sender, RoutedEventArgs e) {
@@ -284,6 +341,8 @@ namespace Ink_Canvas.Popups {
bd.Child = null;
}
+ UpdateCustomColorButtonDisplayStatus();
+ if (_colorSelected == ColorPaletteColor.ColorCustom) return;
var index = (int)_colorSelected;
var bdSel = ColorPaletteColorButtonBorders[index];
Image checkedImage = new Image();
@@ -291,8 +350,7 @@ namespace Ink_Canvas.Popups {
checkedImage.Height = 24;
var checkLight = this.FindResource("CheckedLightIcon");
var checkDark = this.FindResource("CheckedDarkIcon");
- if (_colorSelected == ColorPaletteColor.ColorWhite
- || _colorSelected == ColorPaletteColor.ColorYellow) checkedImage.Source = checkDark as DrawingImage;
+ if (ColorUtilities.GetReverseForegroundColor(ColorUtilities.GetGrayLevel((_usingDarkColors?_darkColors:_lightColors)[(int)_colorSelected])) == Colors.Black) checkedImage.Source = checkDark as DrawingImage;
else checkedImage.Source = checkLight as DrawingImage;
bdSel.Child = checkedImage;
}
@@ -355,6 +413,43 @@ namespace Ink_Canvas.Popups {
});
}
+ private void UpdateCustomColorPickerDisplayStatus() {
+ if (_customColor == null) {
+ CustomColorHexTextBox.Text = "请在上方选择一个颜色";
+ CustomColorHexBorder.Background = new SolidColorBrush(Colors.Transparent);
+ } else {
+ CustomColorHexTextBox.Text = "#" + CustomColorPicker.SelectedColor.R.ToString("X2") + CustomColorPicker.SelectedColor.G.ToString("X2") + CustomColorPicker.SelectedColor.B.ToString("X2");
+ CustomColorHexBorder.Background = new SolidColorBrush(CustomColorPicker.SelectedColor);
+ }
+ }
+
+ private void UpdateCustomColorButtonDisplayStatus() {
+ if (_customColor == null) {
+ CustomColorButtonColorBorder.Visibility = Visibility.Collapsed;
+ CustomColorButtonIcon.Visibility = Visibility.Visible;
+ } else {
+ CustomColorButtonColorBorder.Visibility = Visibility.Visible;
+ CustomColorButtonColorBorder.Background = new SolidColorBrush((Color)_customColor);
+ CustomColorButtonIcon.Visibility = Visibility.Collapsed;
+ if (_colorSelected == ColorPaletteColor.ColorCustom)
+ CustomColorButtonColorBorderCheckIcon.Visibility = Visibility.Visible;
+ else CustomColorButtonColorBorderCheckIcon.Visibility = Visibility.Collapsed;
+ CustomColorButtonColorBorderCheckIcon.Source =
+ this.FindResource(ColorUtilities.GetReverseForegroundColor(ColorUtilities.GetGrayLevel((Color)_customColor)) == Colors.White
+ ? "CheckedLightIcon"
+ : "CheckedDarkIcon") as DrawingImage;
+ }
+ }
+
+ private void CustomColorPicker_ColorChanged(object sender, RoutedEventArgs e) {
+ var cp = sender as SquarePicker;
+ _customColor = cp.SelectedColor;
+ if (_colorSelected != ColorPaletteColor.ColorCustom) _colorSelected = ColorPaletteColor.ColorCustom;
+ UpdateCustomColorPickerDisplayStatus();
+ UpdateCustomColorButtonDisplayStatus();
+ UpdateColorButtonsDisplayStatus();
+ }
+
private void ColorBtnStoryBoardScaleAnimation(object sender, double from, double to) {
var border = sender as Border;
@@ -403,6 +498,38 @@ namespace Ink_Canvas.Popups {
public ColorPaletteColor PreviousColor { get; set; }
public ColorPaletteColor NowColor { get; set; }
public TriggerMode TriggerMode { get; set; }
+ public Color CustomColor { get; set; }
+ }
+
+ public class ColorModeChangedEventArgs : EventArgs
+ {
+ public bool IsPreviousUsedDarkColor { get; set; }
+ public bool IsNowUsingDarkColor { get; set; }
+ public TriggerMode TriggerMode { get; set; }
+ }
+
+ private void UpdateColorPaletteColorsAndColorModeChangeButton() {
+ foreach (var bd in ColorPaletteColorButtonBorders) {
+ bd.Background =
+ new SolidColorBrush((_usingDarkColors ? _darkColors : _lightColors)[
+ Array.IndexOf(ColorPaletteColorStrings, bd.Name.ToLower())]);
+ }
+
+ var tb = ((SimpleStackPanel)ColorModeChangeButton.Content).Children.OfType().Single();
+ tb.Text = _usingDarkColors ? "亮色" : "暗色";
+ }
+
+ private void ColorModeChangeButton_Clicked(object sender, RoutedEventArgs e) {
+ var pre = _usingDarkColors;
+ _usingDarkColors = !_usingDarkColors;
+ UpdateColorPaletteColorsAndColorModeChangeButton();
+ UpdateColorButtonsDisplayStatus();
+ ColorModeChanged?.Invoke(this, new ColorModeChangedEventArgs()
+ {
+ IsPreviousUsedDarkColor = pre,
+ IsNowUsingDarkColor = _usingDarkColors,
+ TriggerMode = TriggerMode.TriggeredByUser,
+ });
}
public class PenModeChangedEventArgs : EventArgs
@@ -425,7 +552,26 @@ namespace Ink_Canvas.Popups {
public bool isRecognizeTriangle;
public bool isRecognizeQuadrilateral;
public bool isRecognizePolygon;
- public bool isFitToCurve;
+ }
+
+ private Color? _customColor = null;
+
+ private void CustomColorButton_Clicked(object sender, RoutedEventArgs e) {
+ if (_customColor == null) {
+ CustomColorPanel.Visibility = Visibility.Visible;
+ } else {
+ if (_colorSelected == ColorPaletteColor.ColorCustom) CustomColorPanel.Visibility = Visibility.Visible;
+ else {
+ _colorSelected = ColorPaletteColor.ColorCustom;
+ UpdateColorButtonsDisplayStatus();
+ UpdateCustomColorButtonDisplayStatus();
+ UpdateCustomColorPickerDisplayStatus();
+ }
+ }
+ }
+
+ private void BackToPaletteButton_Clicked(object sender, RoutedEventArgs e) {
+ CustomColorPanel.Visibility = Visibility.Collapsed;
}
public class InkRecognitionChangedEventArgs : EventArgs {
@@ -439,6 +585,7 @@ namespace Ink_Canvas.Popups {
public event EventHandler PenModeChanged;
public event EventHandler InkRecognitionChanged;
public event EventHandler PressureSimulationChanged;
+ public event EventHandler ColorModeChanged;
public ColorPalette() {
InitializeComponent();
@@ -464,6 +611,7 @@ namespace Ink_Canvas.Popups {
UpdatePenModeButtonsDisplayStatus();
UpdateColorButtonsDisplayStatus();
+ UpdateColorPaletteColorsAndColorModeChangeButton();
}
}
}
\ No newline at end of file
diff --git a/InkCanvasForClass/Popups/FloatingBarV2Resources.xaml b/InkCanvasForClass/Popups/FloatingBarV2Resources.xaml
new file mode 100644
index 0000000..cc1bd18
--- /dev/null
+++ b/InkCanvasForClass/Popups/FloatingBarV2Resources.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/InkCanvasForClass/Popups/FloatingBarWindowV2.xaml b/InkCanvasForClass/Popups/FloatingBarWindowV2.xaml
new file mode 100644
index 0000000..a5f0349
--- /dev/null
+++ b/InkCanvasForClass/Popups/FloatingBarWindowV2.xaml
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/InkCanvasForClass/Popups/FloatingBarWindowV2.xaml.cs b/InkCanvasForClass/Popups/FloatingBarWindowV2.xaml.cs
new file mode 100644
index 0000000..8bf2c2d
--- /dev/null
+++ b/InkCanvasForClass/Popups/FloatingBarWindowV2.xaml.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+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.Popups
+{
+ ///
+ /// FloatingBarWindowV2.xaml 的交互逻辑
+ ///
+ public partial class FloatingBarWindowV2 : Window
+ {
+ public FloatingBarWindowV2()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/InkCanvasForClass/Properties/AssemblyInfo.cs b/InkCanvasForClass/Properties/AssemblyInfo.cs
index c4d6a88..7624281 100644
--- a/InkCanvasForClass/Properties/AssemblyInfo.cs
+++ b/InkCanvasForClass/Properties/AssemblyInfo.cs
@@ -49,5 +49,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("5.0.5.1")]
-[assembly: AssemblyFileVersion("5.0.5.1")]
\ No newline at end of file
+[assembly: AssemblyVersion("6.0.0.0")]
+[assembly: AssemblyFileVersion("6.0.0.0")]
\ No newline at end of file
diff --git a/InkCanvasForClass/Resources/Cursors/Cursor.cur b/InkCanvasForClass/Resources/Cursors/Cursor.cur
deleted file mode 100644
index 95b0175..0000000
Binary files a/InkCanvasForClass/Resources/Cursors/Cursor.cur and /dev/null differ
diff --git a/InkCanvasForClass/Resources/Cursors/cursor-move.cur b/InkCanvasForClass/Resources/Cursors/cursor-move.cur
new file mode 100644
index 0000000..168593e
Binary files /dev/null and b/InkCanvasForClass/Resources/Cursors/cursor-move.cur differ
diff --git a/InkCanvasForClass/Resources/Cursors/cursor-resize-lr.cur b/InkCanvasForClass/Resources/Cursors/cursor-resize-lr.cur
new file mode 100644
index 0000000..a29801b
Binary files /dev/null and b/InkCanvasForClass/Resources/Cursors/cursor-resize-lr.cur differ
diff --git a/InkCanvasForClass/Resources/Cursors/cursor-resize-lt-rb.cur b/InkCanvasForClass/Resources/Cursors/cursor-resize-lt-rb.cur
new file mode 100644
index 0000000..01c3e19
Binary files /dev/null and b/InkCanvasForClass/Resources/Cursors/cursor-resize-lt-rb.cur differ
diff --git a/InkCanvasForClass/Resources/Cursors/cursor-resize-rt-lb.cur b/InkCanvasForClass/Resources/Cursors/cursor-resize-rt-lb.cur
new file mode 100644
index 0000000..a0e3126
Binary files /dev/null and b/InkCanvasForClass/Resources/Cursors/cursor-resize-rt-lb.cur differ
diff --git a/InkCanvasForClass/Resources/Cursors/cursor-resize-tb.cur b/InkCanvasForClass/Resources/Cursors/cursor-resize-tb.cur
new file mode 100644
index 0000000..b064995
Binary files /dev/null and b/InkCanvasForClass/Resources/Cursors/cursor-resize-tb.cur differ
diff --git a/InkCanvasForClass/Resources/GeometryIcons.xaml b/InkCanvasForClass/Resources/GeometryIcons.xaml
new file mode 100644
index 0000000..919eb51
--- /dev/null
+++ b/InkCanvasForClass/Resources/GeometryIcons.xaml
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/InkCanvasForClass/Resources/Icons-png/windows-ink.png b/InkCanvasForClass/Resources/Icons-png/windows-ink.png
new file mode 100644
index 0000000..1026b33
Binary files /dev/null and b/InkCanvasForClass/Resources/Icons-png/windows-ink.png differ
diff --git a/InkCanvasForClass/Resources/Settings.cs b/InkCanvasForClass/Resources/Settings.cs
index 90490d7..b5b2e5f 100644
--- a/InkCanvasForClass/Resources/Settings.cs
+++ b/InkCanvasForClass/Resources/Settings.cs
@@ -129,6 +129,10 @@ namespace Ink_Canvas
public bool EnableMouseRightBtnGesture { get; set; } = true;
[JsonProperty("enableMouseWheelGesture")]
public bool EnableMouseWheelGesture { get; set; } = true;
+ [JsonProperty("windowsInkEraserButtonAction")]
+ public int WindowsInkEraserButtonAction { get; set; } = 2;
+ [JsonProperty("windowsInkBarrelButtonAction")]
+ public int WindowsInkBarrelButtonAction { get; set; } = 0;
}
public class Startup
@@ -151,6 +155,8 @@ namespace Ink_Canvas
public bool IsAutoEnterModeFinger { get; set; } = false;*/
[JsonProperty("isFoldAtStartup")]
public bool IsFoldAtStartup { get; set; } = false;
+ [JsonProperty("enableWindowChromeRendering")]
+ public bool EnableWindowChromeRendering { get; set; } = false;
}
public class Appearance
@@ -252,8 +258,6 @@ namespace Ink_Canvas
public bool IsNotifyAutoPlayPresentation { get; set; } = true;
[JsonProperty("isEnableTwoFingerGestureInPresentationMode")]
public bool IsEnableTwoFingerGestureInPresentationMode { get; set; } = false;
- [JsonProperty("isEnableFingerGestureSlideShowControl")]
- public bool IsEnableFingerGestureSlideShowControl { get; set; } = true;
[JsonProperty("isSupportWPS")]
public bool IsSupportWPS { get; set; } = true;
@@ -390,6 +394,12 @@ namespace Ink_Canvas
[JsonProperty("autoDelSavedFilesDaysThreshold")]
public int AutoDelSavedFilesDaysThreshold = 15;
+
+ [JsonProperty("isEnableLimitAutoSaveAmount")]
+ public bool IsEnableLimitAutoSaveAmount { get; set; } = false;
+
+ [JsonProperty("limitAutoSaveAmount")]
+ public int LimitAutoSaveAmount { get; set; } = 3;
}
public class Advanced
@@ -435,6 +445,8 @@ namespace Ink_Canvas
[JsonProperty("isDisableCloseWindow")]
public bool IsDisableCloseWindow { get; set; } = true;
+ [JsonProperty("enableForceTopMost")]
+ public bool EnableForceTopMost { get; set; } = false;
}
public class InkToShape
diff --git a/InkCanvasForClass/Resources/Themes/DarkFloatingBarTheme.xaml b/InkCanvasForClass/Resources/Themes/DarkFloatingBarTheme.xaml
new file mode 100644
index 0000000..a60cfa1
--- /dev/null
+++ b/InkCanvasForClass/Resources/Themes/DarkFloatingBarTheme.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
\ No newline at end of file