diff --git a/InkCanvasForClass/Helpers/RectangleSelectionViewer.cs b/InkCanvasForClass/Helpers/RectangleSelectionViewer.cs index 79e70dc..44f97d7 100644 --- a/InkCanvasForClass/Helpers/RectangleSelectionViewer.cs +++ b/InkCanvasForClass/Helpers/RectangleSelectionViewer.cs @@ -15,6 +15,7 @@ namespace Ink_Canvas.Helpers private VisualCollection _children; private DrawingVisual _layer = new DrawingVisual(); private Pen defaultPen = new Pen(); + private Pen lassoPen = new Pen(); public RectangleSelectionViewer() { @@ -24,6 +25,13 @@ namespace Ink_Canvas.Helpers defaultPen.Thickness = 2; defaultPen.Brush = new SolidColorBrush(Color.FromRgb(37, 99, 235)); defaultPen.DashStyle = DashStyles.Dash; + + lassoPen.Thickness = 6; + lassoPen.Brush = new SolidColorBrush(Color.FromRgb(37, 99, 235)); + lassoPen.DashStyle = new DashStyle(new double[]{0,2},0); + lassoPen.DashCap = PenLineCap.Round; + lassoPen.StartLineCap = PenLineCap.Round; + lassoPen.EndLineCap = PenLineCap.Round; } protected override int VisualChildrenCount => _children.Count; @@ -40,6 +48,25 @@ namespace Ink_Canvas.Helpers context.Close(); } + public void DrawLassoLine(PointCollection pts) { + DrawingContext context = _layer.RenderOpen(); + if (pts.Count > 2) { + StreamGeometry geometry = new StreamGeometry(); + var _pts = pts.Clone(); + _pts.RemoveAt(0); + using (StreamGeometryContext ctx = geometry.Open()) { + ctx.BeginFigure(pts[0], true , false); + ctx.PolyLineTo(_pts,true, true); + } + context.DrawGeometry(new SolidColorBrush(Colors.Transparent), lassoPen, geometry); + } else if (pts.Count == 2) { + context.DrawLine(defaultPen, pts[0], pts[1]); + } else if (pts.Count == 1) { + context.DrawLine(defaultPen, pts[0], pts[0]); + } + context.Close(); + } + public void ClearDrawing() { DrawingContext context = _layer.RenderOpen(); context.Close(); diff --git a/InkCanvasForClass/InkCanvasForClass.csproj b/InkCanvasForClass/InkCanvasForClass.csproj index 6b9b6b6..10a855c 100644 --- a/InkCanvasForClass/InkCanvasForClass.csproj +++ b/InkCanvasForClass/InkCanvasForClass.csproj @@ -567,6 +567,7 @@ + @@ -579,6 +580,7 @@ + diff --git a/InkCanvasForClass/MainWindow.xaml b/InkCanvasForClass/MainWindow.xaml index 8daff08..6a1075d 100644 --- a/InkCanvasForClass/MainWindow.xaml +++ b/InkCanvasForClass/MainWindow.xaml @@ -22,7 +22,7 @@ Closed="Window_Closed" PreviewKeyDown="Main_Grid_PreviewKeyDown" PreviewKeyUp="Main_Grid_PreviewKeyUp" - Height="12000" Width="1440" + Height="18000" Width="1440" FontFamily="Microsoft YaHei UI" MouseWheel="Window_MouseWheel" Foreground="Black" @@ -6016,6 +6016,8 @@ StrokeThickness="1" Margin="0,4,0,4" /> + @@ -6041,11 +6043,92 @@ - + SelectedIndex="0" SelectionChanged="ComboBoxSelectionMethod_SelectionChanged"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -8416,6 +8499,22 @@ + + + + + + + + + + + + @@ -8831,6 +8930,23 @@ + + + + + + + + + + + + + + + diff --git a/InkCanvasForClass/MainWindow_cs/MW_SelectionGestures.cs b/InkCanvasForClass/MainWindow_cs/MW_SelectionGestures.cs index c875ba9..6409c81 100644 --- a/InkCanvasForClass/MainWindow_cs/MW_SelectionGestures.cs +++ b/InkCanvasForClass/MainWindow_cs/MW_SelectionGestures.cs @@ -1,4 +1,5 @@ using iNKORE.UI.WPF.Modern.Controls; +using Microsoft.Office.Interop.PowerPoint; using System; using System.Collections.Generic; using System.Diagnostics; @@ -14,7 +15,9 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Media.Media3D; using System.Windows.Resources; +using Ink_Canvas.Popups; using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel; +using Application = System.Windows.Application; using Matrix = System.Windows.Media.Matrix; using Point = System.Windows.Point; @@ -190,8 +193,6 @@ namespace Ink_Canvas { 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; @@ -282,8 +283,11 @@ namespace Ink_Canvas { 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 PointCollection rectangleSelection_LassoPoints = new PointCollection(); private void GridInkCanvasSelectionCover_MouseDown(object sender, MouseButtonEventArgs e) { isGridInkCanvasSelectionCoverMouseDown = true; @@ -297,39 +301,52 @@ namespace Ink_Canvas { private void RectangleSelectionHitTestBorder_MouseDown(object sender, MouseButtonEventArgs e) { var pt = e.GetPosition(Main_Grid); var nt = inkCanvas.Strokes.HitTest(pt, 8); - if (nt.Count > 0) { + if (nt.Count > 0 && !(e.RightButton == MouseButtonState.Pressed)) { if (nt.Count > 1) { var nodia = nt.HitTest(pt); if (nodia.Count > 0) { + if (nodia[nodia.Count - 1].ContainsPropertyData(IsLockGuid) && Settings.Canvas.AllowClickToSelectLockedStroke) return; inkCanvas.Select(new StrokeCollection() {nodia[nodia.Count-1]}); } else { + if (nt[0].ContainsPropertyData(IsLockGuid) && Settings.Canvas.AllowClickToSelectLockedStroke) return; inkCanvas.Select(new StrokeCollection() { nt[0] }); } } else if (nt.Count == 1) { + if (nt[0].ContainsPropertyData(IsLockGuid) && Settings.Canvas.AllowClickToSelectLockedStroke) return; inkCanvas.Select(nt); } } else { RectangleSelectionHitTestBorder.CaptureMouse(); isRectangleSelectionMouseDown = true; - rectangleSelection_FirstPoint = pt; + if (Settings.Canvas.SelectionMethod == 1) { + rectangleSelection_FirstPoint = pt; + } else { + rectangleSelection_LassoPoints.Clear(); + rectangleSelection_LassoPoints.Add(pt); + } + } } private void RectangleSelectionHitTestBorder_MouseMove(object sender, MouseEventArgs e) { var pt = e.GetPosition(Main_Grid); if (!isRectangleSelectionMouseDown) return; - rectangleSelection_LastPoint = pt; - RectangleSelection.DrawSelectionBox(new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint)); + if (Settings.Canvas.SelectionMethod == 1) { + rectangleSelection_LastPoint = pt; + RectangleSelection.DrawSelectionBox(new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint)); + } else { + rectangleSelection_LassoPoints.Add(pt); + RectangleSelection.DrawLassoLine(rectangleSelection_LassoPoints); + } } private void RectangleSelectionHitTestBorder_MouseUp(object sender, MouseButtonEventArgs e) { + if (!isRectangleSelectionMouseDown) return; 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); + var ilh = inkCanvas.Strokes.GetIncrementalLassoHitTester(Settings.Canvas.OnlyHitTestFullyContainedStrokes ? 100 : 1); void func(object s, LassoSelectionChangedEventArgs _e) { var _ilh = s as IncrementalLassoHitTester; @@ -339,13 +356,21 @@ namespace Ink_Canvas { } ilh.SelectionChanged += func; - ilh.AddPoints(new Point[] { - rct.TopLeft, - rct.TopRight, - rct.BottomRight, - rct.BottomLeft, - rct.TopLeft - }); + + if (Settings.Canvas.SelectionMethod == 1) { + rectangleSelection_LastPoint = pt; + var rct = new Rect(rectangleSelection_FirstPoint, rectangleSelection_LastPoint); + ilh.AddPoints(new Point[] { + rct.TopLeft, + rct.TopRight, + rct.BottomRight, + rct.BottomLeft, + rct.TopLeft + }); + } else { + rectangleSelection_LassoPoints.Add(pt); + ilh.AddPoints(rectangleSelection_LassoPoints); + } RectangleSelection.ClearDrawing(); } @@ -366,6 +391,7 @@ namespace Ink_Canvas { private Point? resizingLastPoint = null; private void StrokeSelectionBorderHandle_MouseDown(object sender, MouseButtonEventArgs e) { + if (isStrokeSelectionBorderLocked) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return; // lock isLockedStrokeSelectionHandle = true; @@ -416,6 +442,7 @@ namespace Ink_Canvas { } private void StrokeSelectionBorderHandle_MouseUp(object sender, MouseButtonEventArgs e) { + if (isStrokeSelectionBorderLocked) return; if (!isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return; // resize strokes and preview strokes @@ -448,7 +475,7 @@ namespace Ink_Canvas { } private void StrokeSelectionBorderHandle_MouseMove(object sender, MouseEventArgs e) { - + if (isStrokeSelectionBorderLocked) return; if (!isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return; var bd = (Border)sender; @@ -555,6 +582,7 @@ namespace Ink_Canvas { private bool isProgramChangeStrokesSelection = false; private void StrokeSelectionBorder_MouseUp(object sender, MouseButtonEventArgs e) { + if (isStrokeSelectionBorderLocked) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || !isLockedStrokeSelectionMove) return; // release capture @@ -620,6 +648,7 @@ namespace Ink_Canvas { } private void StrokeSelectionBorder_MouseDown(object sender, MouseButtonEventArgs e) { + if (isStrokeSelectionBorderLocked) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || isLockedStrokeSelectionMove) return; // record first move point @@ -643,6 +672,7 @@ namespace Ink_Canvas { private StrokeCollection clonedStrokes; private void StrokeSelectionBorder_MouseMove(object sender, MouseEventArgs e) { + if (isStrokeSelectionBorderLocked) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionRotate || !isLockedStrokeSelectionMove) return; // record last move point @@ -699,6 +729,7 @@ namespace Ink_Canvas { private bool isLockedStrokeSelectionRotate = false; private void StrokeSelectionRotateHandle_MouseUp(object sender, MouseButtonEventArgs e) { + if (isStrokeSelectionBorderLocked) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || !isLockedStrokeSelectionRotate) return; // unlock @@ -758,6 +789,7 @@ namespace Ink_Canvas { } private void StrokeSelectionRotateHandle_MouseDown(object sender, MouseButtonEventArgs e) { + if (isStrokeSelectionBorderLocked) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || isLockedStrokeSelectionRotate) return; // lock @@ -773,6 +805,7 @@ namespace Ink_Canvas { } private void StrokeSelectionRotateHandle_MouseMove(object sender, MouseEventArgs e) { + if (isStrokeSelectionBorderLocked) return; if (isLockedStrokeSelectionHandle || isLockedStrokeSelectionMove || !isLockedStrokeSelectionRotate) return; // record last point @@ -898,10 +931,18 @@ namespace Ink_Canvas { } private void StrokeSelectionBorder_MouseEnter(object sender, MouseEventArgs e) { + if (isStrokeSelectionBorderLocked) { + StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(5, 96, 165, 250)); + return; + }; StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(17, 96, 165, 250)); } private void StrokeSelectionBorder_MouseLeave(object sender, MouseEventArgs e) { + if (isStrokeSelectionBorderLocked) { + StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(5, 96, 165, 250)); + return; + }; StrokeSelectionCursorArea.Background = new SolidColorBrush(Color.FromArgb(5, 96, 165, 250)); } @@ -972,7 +1013,7 @@ namespace Ink_Canvas { if (isPreview) { InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix); } else { - strokes.Transform(matrix, false); + strokes.Transform(matrix, Settings.Canvas.ApplyScaleToStylusTip); } } @@ -984,7 +1025,7 @@ namespace Ink_Canvas { if (isPreview) { InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix); } else { - strokes.Transform(matrix, false); + strokes.Transform(matrix, Settings.Canvas.ApplyScaleToStylusTip); } } @@ -1020,7 +1061,7 @@ namespace Ink_Canvas { if (isPreview) { InkSelectionStrokesOverlay.DrawStrokes(strokes, matrix); } else { - strokes.Transform(matrix, false); + strokes.Transform(matrix, Settings.Canvas.ApplyScaleToStylusTip); } return strokes.GetBounds(); @@ -1109,7 +1150,6 @@ namespace Ink_Canvas { } private void updateBorderStrokeSelectionControlLocation() { - if (currentMode == 0) BorderStrokeSelectionCloneToNewBoardTextBlock.Text = "克隆到白板"; else BorderStrokeSelectionCloneToNewBoardTextBlock.Text = "克隆到新页"; @@ -1159,11 +1199,22 @@ namespace Ink_Canvas { } } + private bool isStrokeSelectionBorderLocked = false; + 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; + isStrokeSelectionBorderLocked = isLocked; + if (isLocked) { + StrokeSelectionCursorArea.ForceCursor = false; + StrokeSelectionCursorArea.Cursor = Cursors.Arrow; + } else { + StrokeSelectionCursorArea.ForceCursor = true; + StreamResourceInfo sri_move = Application.GetResourceStream( + new Uri("Resources/Cursors/cursor-move.cur", UriKind.Relative)); + StrokeSelectionCursorArea.Cursor = new Cursor(sri_move.Stream); + } } private void BorderStrokeSelectionLock_MouseUp(object sender, MouseButtonEventArgs e) { @@ -1280,6 +1331,37 @@ namespace Ink_Canvas { } SelectionPopupV2.IsOpen = false; }; + SelectionV2.ApplyScaleToStylusTip = Settings.Canvas.ApplyScaleToStylusTip; + SelectionV2.OnlyHitTestFullyContainedStrokes = Settings.Canvas.OnlyHitTestFullyContainedStrokes; + SelectionV2.AllowClickToSelectLockedStroke = Settings.Canvas.AllowClickToSelectLockedStroke; + SelectionV2.SelectionModeSelected = (SelectionPopup.SelectionMode)Settings.Canvas.SelectionMethod; + SelectionV2.ApplyScaleToStylusTipChanged += (sender, args) => { + if (!isLoaded) return; + Settings.Canvas.ApplyScaleToStylusTip = SelectionV2.ApplyScaleToStylusTip; + ToggleSwitchApplyScaleToStylusTip.IsOn = SelectionV2.ApplyScaleToStylusTip; + SaveSettingsToFile(); + }; + SelectionV2.OnlyHitTestFullyContainedStrokesChanged += (sender, args) => { + if (!isLoaded) return; + Settings.Canvas.OnlyHitTestFullyContainedStrokes = SelectionV2.OnlyHitTestFullyContainedStrokes; + ToggleSwitchOnlyHitTestFullyContainedStrokes.IsOn = SelectionV2.OnlyHitTestFullyContainedStrokes; + SaveSettingsToFile(); + }; + SelectionV2.AllowClickToSelectLockedStrokeChanged += (sender, args) => { + if (!isLoaded) return; + Settings.Canvas.AllowClickToSelectLockedStroke = SelectionV2.AllowClickToSelectLockedStroke; + ToggleSwitchAllowClickToSelectLockedStroke.IsOn = SelectionV2.AllowClickToSelectLockedStroke; + SaveSettingsToFile(); + }; + SelectionV2.SelectionModeChanged += (sender, args) => { + if (!isLoaded) return; + Settings.Canvas.SelectionMethod = (int)args.NowMode; + ComboBoxSelectionMethod.SelectedIndex = (int)args.NowMode; + SaveSettingsToFile(); + }; + SelectionV2.SelectionPopupShouldCloseEvent += (sender, args) => { + SelectionPopupV2.IsOpen = false; + }; } #endregion diff --git a/InkCanvasForClass/MainWindow_cs/MW_Settings.cs b/InkCanvasForClass/MainWindow_cs/MW_Settings.cs index 8961dff..4c4856e 100644 --- a/InkCanvasForClass/MainWindow_cs/MW_Settings.cs +++ b/InkCanvasForClass/MainWindow_cs/MW_Settings.cs @@ -23,6 +23,9 @@ using System.Threading; using System.Timers; using Ink_Canvas.Popups; using Ookii.Dialogs.Wpf; +using Microsoft.Office.Interop.PowerPoint; +using Application = System.Windows.Application; +using Point = System.Windows.Point; namespace Ink_Canvas { public partial class MainWindow : Window { @@ -936,14 +939,41 @@ namespace Ink_Canvas { } private void ToggleSwitchIsEnableAutoConvertInkColorWhenBackgroundChanged_Toggled(object sender, - RoutedEventArgs e) - { + RoutedEventArgs e) { if (!isLoaded) return; Settings.Canvas.IsEnableAutoConvertInkColorWhenBackgroundChanged = ToggleSwitchIsEnableAutoConvertInkColorWhenBackgroundChanged.IsOn; SaveSettingsToFile(); } + private void ToggleSwitchApplyScaleToStylusTip_OnToggled(object sender, RoutedEventArgs e) { + if (!isLoaded) return; + Settings.Canvas.ApplyScaleToStylusTip = ToggleSwitchApplyScaleToStylusTip.IsOn; + SelectionV2.ApplyScaleToStylusTip = ToggleSwitchApplyScaleToStylusTip.IsOn; + SaveSettingsToFile(); + } + + private void ToggleSwitchOnlyHitTestFullyContainedStrokes_OnToggled(object sender, RoutedEventArgs e) { + if (!isLoaded) return; + Settings.Canvas.OnlyHitTestFullyContainedStrokes = ToggleSwitchOnlyHitTestFullyContainedStrokes.IsOn; + SelectionV2.OnlyHitTestFullyContainedStrokes = ToggleSwitchOnlyHitTestFullyContainedStrokes.IsOn; + SaveSettingsToFile(); + } + + private void ToggleSwitchAllowClickToSelectLockedStroke_OnToggled(object sender, RoutedEventArgs e) { + if (!isLoaded) return; + Settings.Canvas.AllowClickToSelectLockedStroke = ToggleSwitchAllowClickToSelectLockedStroke.IsOn; + SelectionV2.AllowClickToSelectLockedStroke = ToggleSwitchAllowClickToSelectLockedStroke.IsOn; + SaveSettingsToFile(); + } + + private void ComboBoxSelectionMethod_SelectionChanged(object sender, RoutedEventArgs e) { + if (!isLoaded) return; + Settings.Canvas.SelectionMethod = ComboBoxSelectionMethod.SelectedIndex; + SelectionV2.SelectionModeSelected = (SelectionPopup.SelectionMode)ComboBoxSelectionMethod.SelectedIndex; + SaveSettingsToFile(); + } + #endregion #region Automation @@ -1580,6 +1610,10 @@ namespace Ink_Canvas { Settings.Canvas.IsEnableAutoConvertInkColorWhenBackgroundChanged = false; Settings.Canvas.UseDefaultBackgroundColorForEveryNewAddedBlackboardPage = false; Settings.Canvas.UseDefaultBackgroundPatternForEveryNewAddedBlackboardPage = false; + Settings.Canvas.SelectionMethod = 0; + Settings.Canvas.ApplyScaleToStylusTip = false; + Settings.Canvas.OnlyHitTestFullyContainedStrokes = false; + Settings.Canvas.AllowClickToSelectLockedStroke = false; Settings.Gesture.AutoSwitchTwoFingerGesture = true; Settings.Gesture.IsEnableTwoFingerTranslate = true; @@ -1967,6 +2001,7 @@ namespace Ink_Canvas { SettingsStorageGroupBox, SettingsSnapshotGroupBox, SettingsRandWindowGroupBox, + SettingsDonationGroupBox, SettingsAboutGroupBox }; @@ -1982,6 +2017,7 @@ namespace Ink_Canvas { SettingsStorageJumpToGroupBoxButton, SettingsSnapshotJumpToGroupBoxButton, SettingsRandWindowJumpToGroupBoxButton, + SettingsDonationJumpToGroupBoxButton, SettingsAboutJumpToGroupBoxButton }; } diff --git a/InkCanvasForClass/MainWindow_cs/MW_SettingsToLoad.cs b/InkCanvasForClass/MainWindow_cs/MW_SettingsToLoad.cs index 13138de..ede48b5 100644 --- a/InkCanvasForClass/MainWindow_cs/MW_SettingsToLoad.cs +++ b/InkCanvasForClass/MainWindow_cs/MW_SettingsToLoad.cs @@ -122,6 +122,8 @@ namespace Ink_Canvas { LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error); } + #region Startup + if (Settings.Startup != null) { if (isStartup) { if (Settings.Automation.AutoDelSavedFiles) { @@ -171,7 +173,10 @@ namespace Ink_Canvas { Settings.Startup = new Startup(); } - // Appearance + #endregion + + #region Appearance + if (Settings.Appearance != null) { if (!Settings.Appearance.IsEnableDisPlayNibModeToggler) { NibModeSimpleStackPanel.Visibility = Visibility.Collapsed; @@ -328,7 +333,10 @@ namespace Ink_Canvas { Settings.Appearance = new Appearance(); } - // PowerPointSettings + #endregion + + #region PowerPointSettings + if (Settings.PowerPointSettings != null) { @@ -431,7 +439,10 @@ namespace Ink_Canvas { Settings.PowerPointSettings = new PowerPointSettings(); } - // Gesture + #endregion + + #region Gesture + if (Settings.Gesture != null) { ToggleSwitchEnableMultiTouchMode.IsOn = Settings.Gesture.IsEnableMultiTouchMode; @@ -499,7 +510,10 @@ namespace Ink_Canvas { Settings.Gesture = new Gesture(); } - // Canvas + #endregion + + #region Canvas + if (Settings.Canvas != null) { drawingAttributes.Height = Settings.Canvas.InkWidth; drawingAttributes.Width = Settings.Canvas.InkWidth; @@ -621,7 +635,10 @@ namespace Ink_Canvas { Settings.Canvas = new Canvas(); } - // Advanced + #endregion + + #region Advanced + if (Settings.Advanced != null) { TouchMultiplierSlider.Value = Settings.Advanced.TouchMultiplier; FingerModeBoundsWidthSlider.Value = Settings.Advanced.FingerModeBoundsWidth; @@ -664,7 +681,10 @@ namespace Ink_Canvas { Settings.Advanced = new Advanced(); } - // InkToShape + #endregion + + #region Ink Recognition + if (Settings.InkToShape != null) { ToggleSwitchEnableInkToShape.IsOn = Settings.InkToShape.IsInkToShapeEnabled; @@ -683,15 +703,22 @@ namespace Ink_Canvas { Settings.InkToShape = new InkToShape(); } - // RandSettings - if (Settings.RandSettings != null) { } else { - Settings.RandSettings = new RandSettings(); + #endregion + + #region RandSettings + + if (Settings.RandSettings != null) { ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn; RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency; RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents; + } else { + Settings.RandSettings = new RandSettings(); } - // Automation + #endregion + + #region Automation + if (Settings.Automation != null) { StartOrStoptimerCheckAutoFold(); ToggleSwitchAutoFoldInEasiNote.IsOn = Settings.Automation.IsAutoFoldInEasiNote; @@ -783,6 +810,23 @@ namespace Ink_Canvas { Settings.Automation = new Automation(); } + #endregion + + #region Snapshot + + if (Settings.Snapshot != null) { + ToggleSwitchScreenshotUsingMagnificationAPI.IsOn = Settings.Snapshot.ScreenshotUsingMagnificationAPI; + ToggleSwitchCopyScreenshotToClipboard.IsOn = Settings.Snapshot.CopyScreenshotToClipboard; + ToggleSwitchHideMainWinWhenScreenshot.IsOn = Settings.Snapshot.HideMainWinWhenScreenshot; + ToggleSwitchAttachInkWhenScreenshot.IsOn = Settings.Snapshot.AttachInkWhenScreenshot; + ToggleSwitchOnlySnapshotMaximizeWindow.IsOn = Settings.Snapshot.OnlySnapshotMaximizeWindow; + ScreenshotFileName.Text = Settings.Snapshot.ScreenshotFileName; + } else { + Settings.Snapshot = new Snapshot(); + } + + #endregion + // auto align if (BorderFloatingBarExitPPTBtn.Visibility == Visibility.Visible) { ViewboxFloatingBarMarginAnimation(60); diff --git a/InkCanvasForClass/Popups/SelectionPopup.xaml b/InkCanvasForClass/Popups/SelectionPopup.xaml index e87204d..c8695cc 100644 --- a/InkCanvasForClass/Popups/SelectionPopup.xaml +++ b/InkCanvasForClass/Popups/SelectionPopup.xaml @@ -15,7 +15,7 @@ + CornerRadius="6" MouseDown="SelectionModeTabButton_MouseDown"> + CornerRadius="6" MouseDown="SelectionModeTabButton_MouseDown"> - - - + + + diff --git a/InkCanvasForClass/Popups/SelectionPopup.xaml.cs b/InkCanvasForClass/Popups/SelectionPopup.xaml.cs index fe3e78b..94e6ce9 100644 --- a/InkCanvasForClass/Popups/SelectionPopup.xaml.cs +++ b/InkCanvasForClass/Popups/SelectionPopup.xaml.cs @@ -1,4 +1,5 @@ -using System; +using iNKORE.UI.WPF.Modern.Controls; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -12,11 +13,25 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using static Ink_Canvas.Popups.ColorPalette; namespace Ink_Canvas.Popups { public partial class SelectionPopup : UserControl { public SelectionPopup() { InitializeComponent(); + SelectionModeTabButtonBorders = new Border[] { + LassoTabButton, RectangleTabButton + }; + SelectionModeTabButtonIndicators = new SimpleStackPanel[] { + LassoTabButtonIndicator, RectangleTabButtonIndicator + }; + SelectionModeTabButtonIcons = new GeometryDrawing[] { + LassoTabButtonIcon, RectangleTabButtonIcon + }; + SelectionModeTabButtonTexts = new TextBlock[] { + LassoTabButtonText, RectangleTabButtonText + }; + UpdateSelectionModeButtonsCheckedDisplayStatus(); } private bool isCloseButtonDown = false; @@ -24,6 +39,102 @@ namespace Ink_Canvas.Popups { public event EventHandler SelectAllEvent; public event EventHandler UnSelectEvent; public event EventHandler ReverseSelectEvent; + public event EventHandler ApplyScaleToStylusTipChanged; + public event EventHandler OnlyHitTestFullyContainedStrokesChanged; + public event EventHandler AllowClickToSelectLockedStrokeChanged; + + public bool ApplyScaleToStylusTip { + get => cb1.IsChecked??false; + set { + isProgramicallyChangeCheckBox = true; + cb1.IsChecked = value; + isProgramicallyChangeCheckBox = false; + } + } + + public bool OnlyHitTestFullyContainedStrokes { + get => cb2.IsChecked ?? false; + set { + isProgramicallyChangeCheckBox = true; + cb2.IsChecked = value; + isProgramicallyChangeCheckBox = false; + } + } + + public bool AllowClickToSelectLockedStroke { + get => cb3.IsChecked ?? false; + set { + isProgramicallyChangeCheckBox = true; + cb3.IsChecked = value; + isProgramicallyChangeCheckBox = false; + } + } + + public Border[] SelectionModeTabButtonBorders; + public SimpleStackPanel[] SelectionModeTabButtonIndicators; + public GeometryDrawing[] SelectionModeTabButtonIcons; + public TextBlock[] SelectionModeTabButtonTexts; + + public enum SelectionMode { + LassoMode, + RectangleMode + } + + private SelectionMode _selectionModeSelected = SelectionMode.LassoMode; + public SelectionMode SelectionModeSelected { + get => _selectionModeSelected; + set { + _selectionModeSelected = value; + UpdateSelectionModeButtonsCheckedDisplayStatus(); + } + } + + public event EventHandler SelectionModeChanged; + + public class SelectionModeChangedEventArgs : EventArgs + { + public SelectionMode PreviousMode { get; set; } + public SelectionMode NowMode { get; set; } + } + + private void UpdateSelectionModeButtonsCheckedDisplayStatus() { + foreach (var bd in SelectionModeTabButtonBorders) { + bd.Background = new SolidColorBrush(Colors.Transparent); + } + foreach (var indicator in SelectionModeTabButtonIndicators) { + indicator.Visibility = Visibility.Hidden; + } + foreach (var gd in SelectionModeTabButtonIcons) { + gd.Brush = new SolidColorBrush(Color.FromRgb(63, 63, 70)); + } + foreach (var text in SelectionModeTabButtonTexts) { + text.Foreground = new SolidColorBrush(Color.FromRgb(63, 63, 70)); + text.FontWeight = FontWeights.Normal; + } + + SelectionModeTabButtonBorders[(int)_selectionModeSelected].Background = new SolidColorBrush(Color.FromArgb(34, 59, 130, 246)); + SelectionModeTabButtonIndicators[(int)_selectionModeSelected].Visibility = Visibility.Visible; + SelectionModeTabButtonIcons[(int)_selectionModeSelected].Brush = new SolidColorBrush(Color.FromRgb(37, 99, 235)); + SelectionModeTabButtonTexts[(int)_selectionModeSelected].Foreground = new SolidColorBrush(Color.FromRgb(37, 99, 235)); + SelectionModeTabButtonTexts[(int)_selectionModeSelected].FontWeight = FontWeights.Bold; + } + + private bool isProgramicallyChangeCheckBox = false; + + private void cb1cked(object sender, RoutedEventArgs e) { + if (isProgramicallyChangeCheckBox) return; + ApplyScaleToStylusTipChanged?.Invoke(null,new RoutedEventArgs()); + } + + private void cb2cked(object sender, RoutedEventArgs e) { + if (isProgramicallyChangeCheckBox) return; + OnlyHitTestFullyContainedStrokesChanged?.Invoke(null,new RoutedEventArgs()); + } + + private void cb3cked(object sender, RoutedEventArgs e) { + if (isProgramicallyChangeCheckBox) return; + AllowClickToSelectLockedStrokeChanged?.Invoke(null,new RoutedEventArgs()); + } private void CloseButtonBorder_MouseDown(object sender, MouseButtonEventArgs e) { isCloseButtonDown = true; @@ -35,6 +146,17 @@ namespace Ink_Canvas.Popups { CloseButtonBorder.Background = new SolidColorBrush(Colors.Transparent); } + private void SelectionModeTabButton_MouseDown(object sender, MouseButtonEventArgs e) { + var pre = _selectionModeSelected; + _selectionModeSelected = (SelectionMode)Array.IndexOf(SelectionModeTabButtonBorders, (Border)sender); + UpdateSelectionModeButtonsCheckedDisplayStatus(); + + SelectionModeChanged?.Invoke(this, new SelectionModeChangedEventArgs() { + PreviousMode = pre, + NowMode = _selectionModeSelected, + }); + } + private void CloseButtonBorder_MouseUp(object sender, MouseButtonEventArgs e) { if (!isCloseButtonDown) return; diff --git a/InkCanvasForClass/Resources/Settings.cs b/InkCanvasForClass/Resources/Settings.cs index 8305249..ee46291 100644 --- a/InkCanvasForClass/Resources/Settings.cs +++ b/InkCanvasForClass/Resources/Settings.cs @@ -75,30 +75,31 @@ namespace Ink_Canvas public bool FitToCurve { get; set; } = true; [JsonProperty("clearCanvasAndClearTimeMachine")] public bool ClearCanvasAndClearTimeMachine { get; set; } = false; - [Obsolete("已经使用多背景色“blackboardBackgroundColor”替换该选项")] [JsonProperty("usingWhiteboard")] public bool UsingWhiteboard { get; set; } - [JsonProperty("hyperbolaAsymptoteOption")] public OptionalOperation HyperbolaAsymptoteOption { get; set; } = OptionalOperation.Ask; - [JsonProperty("blackboardBackgroundColor")] public BlackboardBackgroundColorEnum BlackboardBackgroundColor { get; set; } = BlackboardBackgroundColorEnum.White; - [JsonProperty("blackboardBackgroundPattern")] public BlackboardBackgroundPatternEnum BlackboardBackgroundPattern { get; set; } = BlackboardBackgroundPatternEnum.None; - [JsonProperty("useDefaultBackgroundColorForEveryNewAddedBlackboardPage")] public bool UseDefaultBackgroundColorForEveryNewAddedBlackboardPage { get; set; } = false; - [JsonProperty("useDefaultBackgroundPatternForEveryNewAddedBlackboardPage")] public bool UseDefaultBackgroundPatternForEveryNewAddedBlackboardPage { get; set; } = false; - [JsonProperty("isEnableAutoConvertInkColorWhenBackgroundChanged")] public bool IsEnableAutoConvertInkColorWhenBackgroundChanged { get; set; } = false; + [JsonProperty("ApplyScaleToStylusTip")] + public bool ApplyScaleToStylusTip { get; set; } = false; + [JsonProperty("onlyHitTestFullyContainedStrokes")] + public bool OnlyHitTestFullyContainedStrokes { get; set; } = false; + [JsonProperty("allowClickToSelectLockedStroke")] + public bool AllowClickToSelectLockedStroke { get; set; } = false; + [JsonProperty("selectionMethod")] + public int SelectionMethod { get; set; } = 0; } public enum OptionalOperation diff --git a/InkCanvasForClass/Resources/qrcodes.png b/InkCanvasForClass/Resources/qrcodes.png new file mode 100644 index 0000000..918dd1d Binary files /dev/null and b/InkCanvasForClass/Resources/qrcodes.png differ