diff --git a/Ink Canvas/Helpers/DeviceIdentifier.cs b/Ink Canvas/Helpers/DeviceIdentifier.cs index a78e1a4d..020d4e54 100644 --- a/Ink Canvas/Helpers/DeviceIdentifier.cs +++ b/Ink Canvas/Helpers/DeviceIdentifier.cs @@ -129,10 +129,10 @@ private static string GenerateHardwareFingerprint() { var searcherType = assembly.GetType("System.Management.ManagementObjectSearcher"); var searcher = Activator.CreateInstance(searcherType, "SELECT ProcessorId FROM Win32_Processor"); - var getMethod = searcherType.GetMethod("Get"); + var getMethod = GetPublicInstanceMethod(searcherType, "Get"); var enumerator = getMethod.Invoke(searcher, null); - var moveNextMethod = enumerator.GetType().GetMethod("MoveNext"); + var moveNextMethod = GetPublicInstanceMethod(enumerator.GetType(), "MoveNext"); var currentProperty = enumerator.GetType().GetProperty("Current"); if ((bool)moveNextMethod.Invoke(enumerator, null)) @@ -143,7 +143,7 @@ private static string GenerateHardwareFingerprint() hardwareInfo.Append(processorId?.ToString() ?? ""); } - var disposeMethod = searcher.GetType().GetMethod("Dispose"); + var disposeMethod = GetPublicInstanceMethod(searcher.GetType(), "Dispose"); disposeMethod?.Invoke(searcher, null); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } @@ -153,10 +153,10 @@ private static string GenerateHardwareFingerprint() { var searcherType = assembly.GetType("System.Management.ManagementObjectSearcher"); var searcher = Activator.CreateInstance(searcherType, "SELECT SerialNumber FROM Win32_BaseBoard"); - var getMethod = searcherType.GetMethod("Get"); + var getMethod = GetPublicInstanceMethod(searcherType, "Get"); var enumerator = getMethod.Invoke(searcher, null); - var moveNextMethod = enumerator.GetType().GetMethod("MoveNext"); + var moveNextMethod = GetPublicInstanceMethod(enumerator.GetType(), "MoveNext"); var currentProperty = enumerator.GetType().GetProperty("Current"); if ((bool)moveNextMethod.Invoke(enumerator, null)) @@ -167,7 +167,7 @@ private static string GenerateHardwareFingerprint() hardwareInfo.Append(serialNumber?.ToString() ?? ""); } - var disposeMethod = searcher.GetType().GetMethod("Dispose"); + var disposeMethod = GetPublicInstanceMethod(searcher.GetType(), "Dispose"); disposeMethod?.Invoke(searcher, null); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } @@ -177,10 +177,10 @@ private static string GenerateHardwareFingerprint() { var searcherType = assembly.GetType("System.Management.ManagementObjectSearcher"); var searcher = Activator.CreateInstance(searcherType, "SELECT SerialNumber FROM Win32_BIOS"); - var getMethod = searcherType.GetMethod("Get"); + var getMethod = GetPublicInstanceMethod(searcherType, "Get"); var enumerator = getMethod.Invoke(searcher, null); - var moveNextMethod = enumerator.GetType().GetMethod("MoveNext"); + var moveNextMethod = GetPublicInstanceMethod(enumerator.GetType(), "MoveNext"); var currentProperty = enumerator.GetType().GetProperty("Current"); if ((bool)moveNextMethod.Invoke(enumerator, null)) @@ -191,7 +191,7 @@ private static string GenerateHardwareFingerprint() hardwareInfo.Append(serialNumber?.ToString() ?? ""); } - var disposeMethod = searcher.GetType().GetMethod("Dispose"); + var disposeMethod = GetPublicInstanceMethod(searcher.GetType(), "Dispose"); disposeMethod?.Invoke(searcher, null); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } @@ -201,10 +201,10 @@ private static string GenerateHardwareFingerprint() { var searcherType = assembly.GetType("System.Management.ManagementObjectSearcher"); var searcher = Activator.CreateInstance(searcherType, "SELECT SerialNumber FROM Win32_DiskDrive WHERE MediaType='Fixed hard disk media'"); - var getMethod = searcherType.GetMethod("Get"); + var getMethod = GetPublicInstanceMethod(searcherType, "Get"); var enumerator = getMethod.Invoke(searcher, null); - var moveNextMethod = enumerator.GetType().GetMethod("MoveNext"); + var moveNextMethod = GetPublicInstanceMethod(enumerator.GetType(), "MoveNext"); var currentProperty = enumerator.GetType().GetProperty("Current"); if ((bool)moveNextMethod.Invoke(enumerator, null)) @@ -215,7 +215,7 @@ private static string GenerateHardwareFingerprint() hardwareInfo.Append(serialNumber?.ToString() ?? ""); } - var disposeMethod = searcher.GetType().GetMethod("Dispose"); + var disposeMethod = GetPublicInstanceMethod(searcher.GetType(), "Dispose"); disposeMethod?.Invoke(searcher, null); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } @@ -235,6 +235,12 @@ private static string GenerateHardwareFingerprint() return hardwareInfo.ToString(); } + private static MethodInfo GetPublicInstanceMethod(Type type, string methodName) + { + if (type == null || string.IsNullOrEmpty(methodName)) return null; + return type.GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null); + } + /// /// 基于硬件指纹生成25字符的设备ID /// diff --git a/Ink Canvas/Helpers/PPTUIManager.cs b/Ink Canvas/Helpers/PPTUIManager.cs index d500fd32..f6e0c525 100644 --- a/Ink Canvas/Helpers/PPTUIManager.cs +++ b/Ink Canvas/Helpers/PPTUIManager.cs @@ -89,14 +89,22 @@ public void UpdateSlideShowStatus(bool isInSlideShow, int currentSlide = 0, int // 只有在页数有效时才更新页码显示 if (currentSlide > 0 && totalSlides > 0) { - _mainWindow.PPTBtnPageNow.Text = currentSlide.ToString(); - _mainWindow.PPTBtnPageTotal.Text = $"/ {totalSlides}"; + _mainWindow.LeftSidePanelForPPTNavigation.SetPageDisplay(currentSlide.ToString(), totalSlides.ToString()); + _mainWindow.RightSidePanelForPPTNavigation.SetPageDisplay(currentSlide.ToString(), totalSlides.ToString()); + _mainWindow.BorderPPTNavBottomLeft.CurrentPage = currentSlide.ToString(); + _mainWindow.BorderPPTNavBottomLeft.TotalPages = totalSlides.ToString(); + _mainWindow.BorderPPTNavBottomRight.CurrentPage = currentSlide.ToString(); + _mainWindow.BorderPPTNavBottomRight.TotalPages = totalSlides.ToString(); } else { // 页数无效时清空页码显示 - _mainWindow.PPTBtnPageNow.Text = "?"; - _mainWindow.PPTBtnPageTotal.Text = "/ ?"; + _mainWindow.LeftSidePanelForPPTNavigation.SetPageDisplay("?", "?"); + _mainWindow.RightSidePanelForPPTNavigation.SetPageDisplay("?", "?"); + _mainWindow.BorderPPTNavBottomLeft.CurrentPage = "?"; + _mainWindow.BorderPPTNavBottomLeft.TotalPages = "?"; + _mainWindow.BorderPPTNavBottomRight.CurrentPage = "?"; + _mainWindow.BorderPPTNavBottomRight.TotalPages = "?"; } UpdateNavigationPanelsVisibility(); @@ -161,14 +169,22 @@ public void UpdateCurrentSlideNumber(int currentSlide, int totalSlides) // 只有在页数有效时才更新页码显示 if (currentSlide > 0 && totalSlides > 0) { - _mainWindow.PPTBtnPageNow.Text = currentSlide.ToString(); - _mainWindow.PPTBtnPageTotal.Text = $"/ {totalSlides}"; + _mainWindow.LeftSidePanelForPPTNavigation.SetPageDisplay(currentSlide.ToString(), totalSlides.ToString()); + _mainWindow.RightSidePanelForPPTNavigation.SetPageDisplay(currentSlide.ToString(), totalSlides.ToString()); + _mainWindow.BorderPPTNavBottomLeft.CurrentPage = currentSlide.ToString(); + _mainWindow.BorderPPTNavBottomLeft.TotalPages = totalSlides.ToString(); + _mainWindow.BorderPPTNavBottomRight.CurrentPage = currentSlide.ToString(); + _mainWindow.BorderPPTNavBottomRight.TotalPages = totalSlides.ToString(); } else { // 页数无效时清空页码显示 - _mainWindow.PPTBtnPageNow.Text = "?"; - _mainWindow.PPTBtnPageTotal.Text = "/ ?"; + _mainWindow.LeftSidePanelForPPTNavigation.SetPageDisplay("?", "?"); + _mainWindow.RightSidePanelForPPTNavigation.SetPageDisplay("?", "?"); + _mainWindow.BorderPPTNavBottomLeft.CurrentPage = "?"; + _mainWindow.BorderPPTNavBottomLeft.TotalPages = "?"; + _mainWindow.BorderPPTNavBottomRight.CurrentPage = "?"; + _mainWindow.BorderPPTNavBottomRight.TotalPages = "?"; } } catch (Exception ex) @@ -228,12 +244,12 @@ public void UpdateNavigationPanelsVisibility() } // 设置侧边按钮位置 - _mainWindow.LeftSidePanelForPPTNavigation.Margin = new Thickness(0, 0, 0, PPTLSButtonPosition * 2); - _mainWindow.RightSidePanelForPPTNavigation.Margin = new Thickness(0, 0, 0, PPTRSButtonPosition * 2); + _mainWindow.LeftSidePanelForPPTNavigation.ControlMargin = new Thickness(0, 0, 0, PPTLSButtonPosition * 2); + _mainWindow.RightSidePanelForPPTNavigation.ControlMargin = new Thickness(0, 0, 0, PPTRSButtonPosition * 2); // 设置底部按钮水平位置 - _mainWindow.LeftBottomPanelForPPTNavigation.Margin = new Thickness(6 + PPTLBButtonPosition, 0, 0, 6); - _mainWindow.RightBottomPanelForPPTNavigation.Margin = new Thickness(0, 0, 6 + PPTRBButtonPosition, 6); + _mainWindow.BorderPPTNavBottomLeft.ControlMargin = new Thickness(6 + PPTLBButtonPosition, 0, 0, 6); + _mainWindow.BorderPPTNavBottomRight.ControlMargin = new Thickness(0, 0, 6 + PPTRBButtonPosition, 6); // 根据显示选项设置面板可见性 var displayOption = PPTButtonsDisplayOption.ToString(); @@ -243,15 +259,15 @@ public void UpdateNavigationPanelsVisibility() // 左下角面板 if (options[0] == '2') - AnimationsHelper.ShowWithFadeIn(_mainWindow.LeftBottomPanelForPPTNavigation); + AnimationsHelper.ShowWithFadeIn(_mainWindow.BorderPPTNavBottomLeft); else - _mainWindow.LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; + _mainWindow.BorderPPTNavBottomLeft.Visibility = Visibility.Collapsed; // 右下角面板 if (options[1] == '2') - AnimationsHelper.ShowWithFadeIn(_mainWindow.RightBottomPanelForPPTNavigation); + AnimationsHelper.ShowWithFadeIn(_mainWindow.BorderPPTNavBottomRight); else - _mainWindow.RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; + _mainWindow.BorderPPTNavBottomRight.Visibility = Visibility.Collapsed; // 左侧面板 if (options[2] == '2') @@ -301,8 +317,8 @@ public void HideAllNavigationPanels() { try { - _mainWindow.LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; - _mainWindow.RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; + _mainWindow.BorderPPTNavBottomLeft.Visibility = Visibility.Collapsed; + _mainWindow.BorderPPTNavBottomRight.Visibility = Visibility.Collapsed; _mainWindow.LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; _mainWindow.RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; } @@ -386,16 +402,16 @@ private void UpdateSideButtonStyles() // 页码按钮显示 var pageButtonVisibility = options[0] == '2' ? Visibility.Visible : Visibility.Collapsed; - _mainWindow.PPTLSPageButton.Visibility = pageButtonVisibility; - _mainWindow.PPTRSPageButton.Visibility = pageButtonVisibility; + _mainWindow.LeftSidePanelForPPTNavigation.SetPageButtonVisibility(pageButtonVisibility); + _mainWindow.RightSidePanelForPPTNavigation.SetPageButtonVisibility(pageButtonVisibility); // 透明度设置 - 直接使用用户设置的透明度值 - _mainWindow.PPTBtnLSBorder.Opacity = PPTLSButtonOpacity; - _mainWindow.PPTBtnRSBorder.Opacity = PPTRSButtonOpacity; + _mainWindow.LeftSidePanelForPPTNavigation.SetContainerOpacity(PPTLSButtonOpacity); + _mainWindow.RightSidePanelForPPTNavigation.SetContainerOpacity(PPTRSButtonOpacity); // 颜色主题 bool isDarkTheme = options[2] == '2'; - ApplyButtonTheme(_mainWindow.PPTBtnLSBorder, _mainWindow.PPTBtnRSBorder, isDarkTheme, true); + ApplySideButtonTheme(isDarkTheme); } catch (Exception ex) { @@ -414,16 +430,16 @@ private void UpdateBottomButtonStyles() // 页码按钮显示 var pageButtonVisibility = options[0] == '2' ? Visibility.Visible : Visibility.Collapsed; - _mainWindow.PPTLBPageButton.Visibility = pageButtonVisibility; - _mainWindow.PPTRBPageButton.Visibility = pageButtonVisibility; + _mainWindow.BorderPPTNavBottomLeft.PPTLBPageButton.Visibility = pageButtonVisibility; + _mainWindow.BorderPPTNavBottomRight.PPTRBPageButton.Visibility = pageButtonVisibility; // 透明度设置 - 直接使用用户设置的透明度值 - _mainWindow.PPTBtnLBBorder.Opacity = PPTLBButtonOpacity; - _mainWindow.PPTBtnRBBorder.Opacity = PPTRBButtonOpacity; + _mainWindow.BorderPPTNavBottomLeft.PPTBtnLBBorder.Opacity = PPTLBButtonOpacity; + _mainWindow.BorderPPTNavBottomRight.PPTBtnRBBorder.Opacity = PPTRBButtonOpacity; // 颜色主题 bool isDarkTheme = options[2] == '2'; - ApplyButtonTheme(_mainWindow.PPTBtnLBBorder, _mainWindow.PPTBtnRBBorder, isDarkTheme, false); + ApplyBottomButtonTheme(isDarkTheme); } catch (Exception ex) { @@ -431,48 +447,14 @@ private void UpdateBottomButtonStyles() } } - private void ApplyButtonTheme(Border leftBorder, Border rightBorder, bool isDarkTheme, bool isSideButton) + private void ApplySideButtonTheme(bool isDarkTheme) { try { - Color backgroundColor, borderColor, foregroundColor, feedbackColor; + GetThemeBrushes(isDarkTheme, out var backgroundBrush, out var borderBrush, out var foregroundBrush, out var feedbackBrush); - if (isDarkTheme) - { - backgroundColor = Color.FromRgb(39, 39, 42); - borderColor = Color.FromRgb(82, 82, 91); - foregroundColor = Colors.White; - feedbackColor = Colors.White; - } - else - { - backgroundColor = Color.FromRgb(244, 244, 245); - borderColor = Color.FromRgb(161, 161, 170); - foregroundColor = Color.FromRgb(39, 39, 42); - feedbackColor = Color.FromRgb(24, 24, 27); - } - - // 应用背景和边框颜色 - var backgroundBrush = new SolidColorBrush(backgroundColor); - var borderBrush = new SolidColorBrush(borderColor); - - leftBorder.Background = backgroundBrush; - leftBorder.BorderBrush = borderBrush; - rightBorder.Background = backgroundBrush; - rightBorder.BorderBrush = borderBrush; - - // 应用图标和文字颜色 - var foregroundBrush = new SolidColorBrush(foregroundColor); - var feedbackBrush = new SolidColorBrush(feedbackColor); - - if (isSideButton) - { - ApplySideButtonColors(foregroundBrush, feedbackBrush); - } - else - { - ApplyBottomButtonColors(foregroundBrush, feedbackBrush); - } + _mainWindow.LeftSidePanelForPPTNavigation.ApplyTheme(backgroundBrush, borderBrush, foregroundBrush, feedbackBrush); + _mainWindow.RightSidePanelForPPTNavigation.ApplyTheme(backgroundBrush, borderBrush, foregroundBrush, feedbackBrush); } catch (Exception ex) { @@ -480,46 +462,68 @@ private void ApplyButtonTheme(Border leftBorder, Border rightBorder, bool isDark } } - private void ApplySideButtonColors(SolidColorBrush foregroundBrush, SolidColorBrush feedbackBrush) + private void ApplyBottomButtonTheme(bool isDarkTheme) { - // 图标颜色 - _mainWindow.PPTLSPreviousButtonGeometry.Brush = foregroundBrush; - _mainWindow.PPTRSPreviousButtonGeometry.Brush = foregroundBrush; - _mainWindow.PPTLSNextButtonGeometry.Brush = foregroundBrush; - _mainWindow.PPTRSNextButtonGeometry.Brush = foregroundBrush; - - // 反馈背景颜色 - _mainWindow.PPTLSPreviousButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTRSPreviousButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTLSPageButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTRSPageButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTLSNextButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTRSNextButtonFeedbackBorder.Background = feedbackBrush; - - // 文字颜色 - TextBlock.SetForeground(_mainWindow.PPTLSPageButton, foregroundBrush); - TextBlock.SetForeground(_mainWindow.PPTRSPageButton, foregroundBrush); + try + { + GetThemeBrushes(isDarkTheme, out var backgroundBrush, out var borderBrush, out var foregroundBrush, out var feedbackBrush); + + _mainWindow.BorderPPTNavBottomLeft.PPTBtnLBBorder.Background = backgroundBrush; + _mainWindow.BorderPPTNavBottomLeft.PPTBtnLBBorder.BorderBrush = borderBrush; + _mainWindow.BorderPPTNavBottomRight.PPTBtnRBBorder.Background = backgroundBrush; + _mainWindow.BorderPPTNavBottomRight.PPTBtnRBBorder.BorderBrush = borderBrush; + + _mainWindow.BorderPPTNavBottomLeft.PPTLBPreviousButtonGeometry.Brush = foregroundBrush; + _mainWindow.BorderPPTNavBottomRight.PPTRBPreviousButtonGeometry.Brush = foregroundBrush; + _mainWindow.BorderPPTNavBottomLeft.PPTLBNextButtonGeometry.Brush = foregroundBrush; + _mainWindow.BorderPPTNavBottomRight.PPTRBNextButtonGeometry.Brush = foregroundBrush; + + _mainWindow.BorderPPTNavBottomLeft.PPTLBPreviousButtonFeedbackBorder.Background = feedbackBrush; + _mainWindow.BorderPPTNavBottomRight.PPTRBPreviousButtonFeedbackBorder.Background = feedbackBrush; + _mainWindow.BorderPPTNavBottomLeft.PPTLBPageButtonFeedbackBorder.Background = feedbackBrush; + _mainWindow.BorderPPTNavBottomRight.PPTRBPageButtonFeedbackBorder.Background = feedbackBrush; + _mainWindow.BorderPPTNavBottomLeft.PPTLBNextButtonFeedbackBorder.Background = feedbackBrush; + _mainWindow.BorderPPTNavBottomRight.PPTRBNextButtonFeedbackBorder.Background = feedbackBrush; + + TextBlock.SetForeground(_mainWindow.BorderPPTNavBottomLeft.PPTLBPageButton, foregroundBrush); + TextBlock.SetForeground(_mainWindow.BorderPPTNavBottomRight.PPTRBPageButton, foregroundBrush); + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"应用按钮主题失败: {ex}", LogHelper.LogType.Error); + } } - private void ApplyBottomButtonColors(SolidColorBrush foregroundBrush, SolidColorBrush feedbackBrush) + private static void GetThemeBrushes(bool isDarkTheme, + out SolidColorBrush backgroundBrush, + out SolidColorBrush borderBrush, + out SolidColorBrush foregroundBrush, + out SolidColorBrush feedbackBrush) { - // 图标颜色 - _mainWindow.PPTLBPreviousButtonGeometry.Brush = foregroundBrush; - _mainWindow.PPTRBPreviousButtonGeometry.Brush = foregroundBrush; - _mainWindow.PPTLBNextButtonGeometry.Brush = foregroundBrush; - _mainWindow.PPTRBNextButtonGeometry.Brush = foregroundBrush; - - // 反馈背景颜色 - _mainWindow.PPTLBPreviousButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTRBPreviousButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTLBPageButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTRBPageButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTLBNextButtonFeedbackBorder.Background = feedbackBrush; - _mainWindow.PPTRBNextButtonFeedbackBorder.Background = feedbackBrush; - - // 文字颜色 - TextBlock.SetForeground(_mainWindow.PPTLBPageButton, foregroundBrush); - TextBlock.SetForeground(_mainWindow.PPTRBPageButton, foregroundBrush); + Color backgroundColor; + Color borderColor; + Color foregroundColor; + Color feedbackColor; + + if (isDarkTheme) + { + backgroundColor = Color.FromRgb(39, 39, 42); + borderColor = Color.FromRgb(82, 82, 91); + foregroundColor = Colors.White; + feedbackColor = Colors.White; + } + else + { + backgroundColor = Color.FromRgb(244, 244, 245); + borderColor = Color.FromRgb(161, 161, 170); + foregroundColor = Color.FromRgb(39, 39, 42); + feedbackColor = Color.FromRgb(24, 24, 27); + } + + backgroundBrush = new SolidColorBrush(backgroundColor); + borderBrush = new SolidColorBrush(borderColor); + foregroundBrush = new SolidColorBrush(foregroundColor); + feedbackBrush = new SolidColorBrush(feedbackColor); } #endregion } diff --git a/Ink Canvas/IBoardCanvasController.cs b/Ink Canvas/IBoardCanvasController.cs new file mode 100644 index 00000000..178e47a3 --- /dev/null +++ b/Ink Canvas/IBoardCanvasController.cs @@ -0,0 +1,47 @@ +using System.Windows.Controls; +using System.Windows.Ink; +using System.Windows.Media; + +namespace Ink_Canvas +{ + public interface IBoardCanvasController + { + StrokeCollection Strokes { get; } + System.Windows.Visibility Visibility { get; set; } + bool IsHitTestVisible { get; set; } + bool IsManipulationEnabled { get; set; } + InkCanvasEditingMode EditingMode { get; set; } + void SetInkMode(); + void SetEraserByPointMode(); + void SetEraserByStrokeMode(); + void SetSelectMode(); + Color StrokeColor { get; set; } + double StrokeWidth { get; set; } + double HighlighterWidth { get; set; } + bool IsHighlighterMode { get; set; } + StylusShape EraserShape { get; set; } + StrokeCollection GetSelectedStrokes(); + void Select(StrokeCollection strokes); + void ClearSelection(); + event System.EventHandler EditingModeChanged; + event System.EventHandler StrokeColorChanged; + event System.EventHandler StrokeCollected; + } + + public class EditingModeChangedEventArgs : System.EventArgs + { + public InkCanvasEditingMode OldMode { get; set; } + public InkCanvasEditingMode NewMode { get; set; } + } + + public class StrokeColorChangedEventArgs : System.EventArgs + { + public Color OldColor { get; set; } + public Color NewColor { get; set; } + } + + public class StrokeEventArgs : System.EventArgs + { + public StrokeCollection Strokes { get; set; } + } +} diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index cf129f5f..bf8d5fda 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -8,6 +8,7 @@ xmlns:c="clr-namespace:Ink_Canvas.Converter" xmlns:Controls="http://schemas.microsoft.com/netfx/2009/xaml/presentation" xmlns:controls="clr-namespace:Ink_Canvas.Controls" + xmlns:mwcontrols="clr-namespace:Ink_Canvas.MainWindow_controls" xmlns:Windows="clr-namespace:Ink_Canvas.Windows" xmlns:props="clr-namespace:Ink_Canvas.Properties" xmlns:i18n="clr-namespace:Ink_Canvas.MarkupExtensions" @@ -41,179 +42,10 @@ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -520,7 +352,7 @@ - @@ -624,7 +456,7 @@ - + @@ -643,7 +475,7 @@ - + @@ -656,7 +488,7 @@ - + @@ -797,7 +629,7 @@ --> - + @@ -1024,7 +856,7 @@ - + @@ -1042,7 +874,7 @@ - + @@ -1098,7 +930,7 @@ Visibility="{Binding ElementName=ToggleSwitchEnablePalmEraser, Path=IsOn, Converter={StaticResource BooleanToVisibilityConverter}}" /> - + @@ -1250,7 +1082,7 @@ - + @@ -4730,223 +4562,14 @@ TouchDown="SelectionHandle_TouchDown" TouchMove="SelectionHandle_TouchMove" TouchUp="SelectionHandle_TouchUp" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Visibility="{Binding ElementName=GridInkCanvasSelectionCover, Path=Visibility}" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Visibility="Collapsed" /> - - - - - - - - - - - - - + @@ -5360,7 +4910,7 @@ Geometry="F0 M24,24z M0,0z M7.82154,10.0753L7.82154,3.74613C7.82154,3.06603 8.08946,2.40655 8.57377,1.92224 9.05808,1.43793 9.70726,1.17001 10.3977,1.17001 11.0881,1.17001 11.7372,1.43793 12.2216,1.92224 12.7059,2.40655 12.9738,3.05573 12.9738,3.74613L12.9738,6.37308C13.1415,6.33947 13.3139,6.32225 13.489,6.32225 14.1794,6.32225 14.8286,6.59016 15.3129,7.07447 15.4484,7.21001 15.567,7.35845 15.6675,7.5171 15.9551,7.40916 16.2634,7.35269 16.5803,7.35269 17.2707,7.35269 17.9199,7.62061 18.4042,8.10492 18.5461,8.24683 18.6695,8.4029 18.7729,8.57001 19.6856,8.26338 20.7674,8.45871 21.4647,9.15599 21.949,9.6403 22.2169,10.2998 22.2169,10.9799L22.2169,15.6169C22.2169,17.5438 21.4647,19.3574 20.1045,20.7176 18.7443,22.0778 16.9307,22.83 15.0038,22.83L13.149,22.83 13.1799,22.8094 12.8398,22.8094C11.7682,22.7579 10.7068,22.4694 9.75878,21.9541 8.70773,21.3874 7.81124,20.563 7.15175,19.5738L6.94566,19.2647C6.60562,18.7494 5.49273,16.8019 3.52458,13.3087 3.19484,12.7213 3.1021,12.0412 3.27727,11.3818 3.45245,10.7326 3.86463,10.1761 4.44168,9.83608 5.00842,9.49604 5.66791,9.35177 6.31709,9.43421 6.86548,9.50385 7.39181,9.7279 7.82154,10.0753z M10.037,3.38547C10.1297,3.28243 10.2637,3.23091 10.3977,3.23091 10.5316,3.23091 10.6656,3.29273 10.7583,3.38547 10.8614,3.47821 10.9129,3.61217 10.9129,3.74613L10.9129,11.4745C10.9129,12.0412 11.3766,12.5049 11.9433,12.5049 12.5101,12.5049 12.9738,12.0412 12.9738,11.4745L12.9738,8.89836C12.9738,8.7644 13.0356,8.63045 13.1283,8.53771 13.2211,8.43466 13.355,8.38314 13.489,8.38314 13.623,8.38314 13.7569,8.44497 13.8497,8.53771 13.9527,8.63045 14.0042,8.7644 14.0042,8.89836L14.0042,11.4745C14.0042,12.0412 14.4679,12.5049 15.0347,12.5049 15.6014,12.5049 16.0651,12.0412 16.0651,11.4745L16.0651,9.92881C16.0651,9.79485 16.1269,9.66089 16.2197,9.56815 16.3124,9.46511 16.4464,9.41359 16.5803,9.41359 16.7143,9.41359 16.8483,9.47541 16.941,9.56815 17.044,9.66089 17.0956,9.79485 17.0956,9.92881L17.0956,10.5869C17.0752,10.7163 17.0646,10.8477 17.0646,10.9799 17.0646,11.0661 17.0754,11.1499 17.0956,11.2301L17.0956,11.4745C17.0956,12.0412 17.5593,12.5049 18.126,12.5049 18.6928,12.5049 19.1565,12.0412 19.1565,11.4745L19.1565,10.8128C19.1834,10.7399 19.2266,10.6727 19.2801,10.6192 19.4759,10.4234 19.8159,10.4234 20.0117,10.6192 20.1148,10.712 20.1663,10.8459 20.1663,10.9799L20.1663,15.6169C20.1663,16.9977 19.6408,18.296 18.6618,19.2647 17.6829,20.2333 16.3949,20.7691 15.0141,20.7691L13.1593,20.7691C12.3143,20.7691 11.4796,20.5527 10.7274,20.1509 9.98548,19.749 9.3363,19.1616 8.8726,18.4506L8.66651,18.1415C8.35737,17.6675 7.23419,15.7096 5.31756,12.2988 5.24543,12.1752 5.23512,12.0412 5.26604,11.9073 5.30725,11.7733 5.38969,11.6703 5.50304,11.5981 5.66791,11.4951 5.874,11.4539 6.06978,11.4745 6.26557,11.5054 6.45105,11.5878 6.59531,11.7321L8.11007,13.2469C8.49419,13.631 9.10425,13.648 9.50833,13.2978 9.73651,13.1084 9.88244,12.8229 9.88244,12.5049L9.88244,3.74613C9.88244,3.61217,9.94426,3.47821,10.037,3.38547z M2.99905,6.31195L1.78313,4.65293 2.61779,4.04497C3.46275,3.4267,4.37985,2.89087,5.33817,2.46838L6.27587,2.0459 7.12084,3.93162 6.18313,4.3541C5.35878,4.72506,4.56533,5.17846,3.83372,5.71429L2.99905,6.32225 2.99905,6.31195z M18.2806,5.20935L19.1565,5.75549 20.259,4.01404 19.3831,3.4679C18.1157,2.67446,16.7452,2.0768,15.3026,1.68523L14.303,1.41731 13.7672,3.40607 14.7667,3.67399C16.0033,4.00373,17.1883,4.51895,18.2806,5.20935z" /> + Geometry="{StaticResource BoardGestureGeometry2}" /> @@ -5373,7 +4923,7 @@ - - + Geometry="{StaticResource BoardSelectGeometry}" /> @@ -5579,7 +5129,7 @@ HorizontalAlignment="Center" FontSize="12" /> - @@ -5591,7 +5141,7 @@ + Geometry="{StaticResource BoardPenGeometry}" /> @@ -5619,876 +5169,33 @@ Opacity="1" BorderBrush="#2563eb" BorderThickness="1" CornerRadius="8"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - @@ -6500,7 +5207,7 @@ + Geometry="{StaticResource BoardEraserGeometry}" /> @@ -6522,7 +5229,7 @@ @@ -6576,7 +5283,7 @@ - @@ -6603,7 +5310,7 @@ - @@ -6745,7 +5452,7 @@ - @@ -7072,7 +5779,7 @@ - - @@ -7709,285 +6416,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -9560,7 +7259,7 @@ + Geometry="{StaticResource ShapesIconGeometry}" /> @@ -9572,7 +7271,7 @@ - @@ -9834,7 +7533,7 @@ + Geometry="{StaticResource UndoIconGeometry}" /> @@ -9863,7 +7562,7 @@ + Geometry="{StaticResource RedoIconGeometry}" /> @@ -9904,7 +7603,7 @@ - @@ -10114,7 +7813,7 @@ Style="{StaticResource AutoFitMainToolbarLabel8}" /> - @@ -10339,7 +8038,7 @@ - - @@ -11066,4 +8765,3 @@ - diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index af1e63d1..c1bfa605 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -119,6 +119,7 @@ public MainWindow() } InitializeComponent(); + InitializeBoardCanvasController(); BlackboardLeftSide.Visibility = Visibility.Collapsed; BlackboardCenterSide.Visibility = Visibility.Collapsed; @@ -747,10 +748,10 @@ private void SetBrushAttributesDirectly(Color color, double width, double height Settings.Canvas.InkAlpha = (int)color.A; } - if (InkWidthSlider != null) InkWidthSlider.Value = width * 2; - if (InkAlphaSlider != null) InkAlphaSlider.Value = color.A; - if (BoardInkWidthSlider != null) BoardInkWidthSlider.Value = width * 2; - if (BoardInkAlphaSlider != null) BoardInkAlphaSlider.Value = color.A; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.PenWidth = width * 2; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.PenAlpha = color.A; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.PenWidth = width * 2; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.PenAlpha = color.A; if (penType != 1) { @@ -786,7 +787,7 @@ private void BoardBrushModeButton_Click(object sender, RoutedEventArgs e) if (_isBoardBrushMode) { - _savedInkWidthBeforeBoardBrush = InkWidthSlider != null ? InkWidthSlider.Value / 2.0 : drawingAttributes.Width; + _savedInkWidthBeforeBoardBrush = BorderPenSettingsControl != null ? BorderPenSettingsControl.PenWidth / 2.0 : drawingAttributes.Width; if (_savedInkWidthBeforeBoardBrush < 0.5) _savedInkWidthBeforeBoardBrush = 2.5; drawingAttributes.Width = BoardBrushInkWidth; @@ -798,12 +799,11 @@ private void BoardBrushModeButton_Click(object sender, RoutedEventArgs e) drawingAttributes.IgnorePressure = true; inkCanvas.DefaultDrawingAttributes.IgnorePressure = true; - if (BoardBrushModeButton != null) - BoardBrushModeButton.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); + BorderPenSettingsControl?.SetBrushModeActive(true); } else { - double w = InkWidthSlider != null ? InkWidthSlider.Value / 2.0 : _savedInkWidthBeforeBoardBrush; + double w = BorderPenSettingsControl != null ? BorderPenSettingsControl.PenWidth / 2.0 : _savedInkWidthBeforeBoardBrush; if (w < 0.5) w = 2.5; drawingAttributes.Width = w; @@ -815,11 +815,10 @@ private void BoardBrushModeButton_Click(object sender, RoutedEventArgs e) drawingAttributes.IgnorePressure = Settings.Canvas.DisablePressure; inkCanvas.DefaultDrawingAttributes.IgnorePressure = Settings.Canvas.DisablePressure; - if (BoardInkWidthSlider != null) BoardInkWidthSlider.Value = w * 2; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.PenWidth = w * 2; if (Settings?.Canvas != null) Settings.Canvas.InkWidth = w; - if (BoardBrushModeButton != null) - BoardBrushModeButton.ClearValue(BackgroundProperty); + BorderPenSettingsControl?.SetBrushModeActive(false); } } catch (Exception ex) @@ -840,8 +839,8 @@ private void BoardBrushModeButton_Click(object sender, RoutedEventArgs e) /// private void BoardBrushModeButton_MouseUp(object sender, MouseButtonEventArgs e) { - if (sender != BoardBrushModeButton) return; - if (lastBorderMouseDownObject != BoardBrushModeButton) return; + if (sender != BorderPenSettingsControl) return; + if (lastBorderMouseDownObject != BorderPenSettingsControl) return; _isBoardBrushMode = !_isBoardBrushMode; @@ -854,7 +853,7 @@ private void BoardBrushModeButton_MouseUp(object sender, MouseButtonEventArgs e) if (_isBoardBrushMode) { - _savedInkWidthBeforeBoardBrush = InkWidthSlider != null ? InkWidthSlider.Value / 2.0 : drawingAttributes.Width; + _savedInkWidthBeforeBoardBrush = BorderPenSettingsControl != null ? BorderPenSettingsControl.PenWidth / 2.0 : drawingAttributes.Width; if (_savedInkWidthBeforeBoardBrush < 0.5) _savedInkWidthBeforeBoardBrush = 2.5; drawingAttributes.Width = BoardBrushInkWidth; @@ -866,12 +865,11 @@ private void BoardBrushModeButton_MouseUp(object sender, MouseButtonEventArgs e) drawingAttributes.IgnorePressure = true; inkCanvas.DefaultDrawingAttributes.IgnorePressure = true; - if (BoardBrushModeButton != null) - BoardBrushModeButton.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); + BorderPenSettingsControl?.SetBrushModeActive(true); } else { - double w = InkWidthSlider != null ? InkWidthSlider.Value / 2.0 : _savedInkWidthBeforeBoardBrush; + double w = BorderPenSettingsControl != null ? BorderPenSettingsControl.PenWidth / 2.0 : _savedInkWidthBeforeBoardBrush; if (w < 0.5) w = 2.5; drawingAttributes.Width = w; @@ -883,11 +881,10 @@ private void BoardBrushModeButton_MouseUp(object sender, MouseButtonEventArgs e) drawingAttributes.IgnorePressure = Settings.Canvas.DisablePressure; inkCanvas.DefaultDrawingAttributes.IgnorePressure = Settings.Canvas.DisablePressure; - if (BoardInkWidthSlider != null) BoardInkWidthSlider.Value = w * 2; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.PenWidth = w * 2; if (Settings?.Canvas != null) Settings.Canvas.InkWidth = w; - if (BoardBrushModeButton != null) - BoardBrushModeButton.ClearValue(BackgroundProperty); + BorderPenSettingsControl?.SetBrushModeActive(false); } } catch (Exception ex) @@ -3443,15 +3440,20 @@ private void ToggleSwitchEnableInkFade_Toggled(object sender, RoutedEventArgs e) _inkFadeManager.IsEnabled = Settings.Canvas.EnableInkFade; // 同步批注子面板中的开关状态 - if (ToggleSwitchInkFadeInPanel != null) + if (BoardPenSettingsControl != null) { - ToggleSwitchInkFadeInPanel.IsOn = Settings.Canvas.EnableInkFade; + BoardPenSettingsControl.IsInkFadeEnabled = Settings.Canvas.EnableInkFade; } // 同步普通画笔面板中的开关状态 - if (ToggleSwitchInkFadeInPanel2 != null) + if (BorderPenSettingsControl != null) { - ToggleSwitchInkFadeInPanel2.IsOn = Settings.Canvas.EnableInkFade; + BorderPenSettingsControl.IsInkFadeEnabled = Settings.Canvas.EnableInkFade; + } + + if (BoardPenSettingsControl != null) + { + BoardPenSettingsControl.IsInkFadeEnabled = Settings.Canvas.EnableInkFade; } } @@ -3490,7 +3492,11 @@ private void ToggleSwitchInkFadeInPanel_Toggled(object sender, RoutedEventArgs e { try { - Settings.Canvas.EnableInkFade = ToggleSwitchInkFadeInPanel.IsOn; + bool isInkFadeEnabled = sender == BorderPenSettingsControl + ? BorderPenSettingsControl.IsInkFadeEnabled + : BoardPenSettingsControl != null && BoardPenSettingsControl.IsInkFadeEnabled; + + Settings.Canvas.EnableInkFade = isInkFadeEnabled; _inkFadeManager.IsEnabled = Settings.Canvas.EnableInkFade; // 同步设置面板中的开关状态 @@ -3499,10 +3505,15 @@ private void ToggleSwitchInkFadeInPanel_Toggled(object sender, RoutedEventArgs e ToggleSwitchEnableInkFade.IsOn = Settings.Canvas.EnableInkFade; } + if (BoardPenSettingsControl != null) + { + BoardPenSettingsControl.IsInkFadeEnabled = Settings.Canvas.EnableInkFade; + } + // 同步普通画笔面板中的开关状态 - if (ToggleSwitchInkFadeInPanel2 != null) + if (BorderPenSettingsControl != null) { - ToggleSwitchInkFadeInPanel2.IsOn = Settings.Canvas.EnableInkFade; + BorderPenSettingsControl.IsInkFadeEnabled = Settings.Canvas.EnableInkFade; } } @@ -3726,16 +3737,14 @@ private void UpdateInkFadeControlVisibility() { bool isHidden = Settings.Canvas.HideInkFadeControlInPenMenu; - // 控制 InkFadeControlPanel1(批注子面板中)的可见性 - if (InkFadeControlPanel1 != null) + if (BoardPenSettingsControl != null) { - InkFadeControlPanel1.Visibility = isHidden ? Visibility.Collapsed : Visibility.Visible; + BoardPenSettingsControl.InkFadePanelVisibility = isHidden ? Visibility.Collapsed : Visibility.Visible; } - // 控制 InkFadeControlPanel2(普通画笔面板中)的可见性 - if (InkFadeControlPanel2 != null) + if (BorderPenSettingsControl != null) { - InkFadeControlPanel2.Visibility = isHidden ? Visibility.Collapsed : Visibility.Visible; + BorderPenSettingsControl.InkFadePanelVisibility = isHidden ? Visibility.Collapsed : Visibility.Visible; } } catch (Exception ex) @@ -3744,6 +3753,118 @@ private void UpdateInkFadeControlVisibility() } } + private void BoardPenSettingsControl_PenTypeChanged(object sender, RoutedEventArgs e) + { + if (BoardPenSettingsControl == null) return; + + if (BoardPenSettingsControl.SelectedPenType == 1) + SwitchToHighlighterPen(null, null); + else + SwitchToDefaultPen(null, null); + } + + private void BoardPenSettingsControl_PenStyleChanged(object sender, RoutedEventArgs e) + { + ComboBoxPenStyle_SelectionChanged(BoardPenSettingsControl, null); + } + + private void BoardPenSettingsControl_WidthChanged(object sender, RoutedEventArgs e) + { + if (BoardPenSettingsControl == null) return; + + if (BoardPenSettingsControl.SelectedPenType == 1) + HighlighterWidthSlider_ValueChanged(BoardPenSettingsControl.HighlighterWidthSliderControl, null); + else + InkWidthSlider_ValueChanged(BoardPenSettingsControl.InkWidthSliderControl, null); + } + + private void BoardPenSettingsControl_AlphaChanged(object sender, RoutedEventArgs e) + { + if (BoardPenSettingsControl == null) return; + InkAlphaSlider_ValueChanged(BoardPenSettingsControl.InkAlphaSliderControl, null); + } + + private void BoardPenSettingsControl_NibModeChanged(object sender, RoutedEventArgs e) + { + ToggleSwitchEnableNibMode_Toggled(BoardPenSettingsControl, e); + } + + private void BoardPenSettingsControl_InkFadeChanged(object sender, RoutedEventArgs e) + { + ToggleSwitchInkFadeInPanel_Toggled(BoardPenSettingsControl, e); + } + + private void BoardPenSettingsControl_InkToShapeChanged(object sender, RoutedEventArgs e) + { + ToggleSwitchEnableInkToShape_Toggled(BoardPenSettingsControl, e); + } + + private void BoardPenSettingsControl_BrushModeClicked(object sender, RoutedEventArgs e) + { + BoardBrushModeButton_Click(BoardPenSettingsControl, e); + } + + private void BoardPenSettingsControl_CloseRequested(object sender, RoutedEventArgs e) + { + HideSubPanels(); + } + + private void BorderPenSettingsControl_PenTypeChanged(object sender, RoutedEventArgs e) + { + if (BorderPenSettingsControl == null) return; + + if (BorderPenSettingsControl.SelectedPenType == 1) + SwitchToHighlighterPen(null, null); + else + SwitchToDefaultPen(null, null); + } + + private void BorderPenSettingsControl_PenStyleChanged(object sender, RoutedEventArgs e) + { + ComboBoxPenStyle_SelectionChanged(BorderPenSettingsControl, null); + } + + private void BorderPenSettingsControl_WidthChanged(object sender, RoutedEventArgs e) + { + if (BorderPenSettingsControl == null) return; + + if (BorderPenSettingsControl.SelectedPenType == 1) + HighlighterWidthSlider_ValueChanged(BorderPenSettingsControl.HighlighterWidthSliderControl, null); + else + InkWidthSlider_ValueChanged(BorderPenSettingsControl.InkWidthSliderControl, null); + } + + private void BorderPenSettingsControl_AlphaChanged(object sender, RoutedEventArgs e) + { + if (BorderPenSettingsControl == null) return; + InkAlphaSlider_ValueChanged(BorderPenSettingsControl.InkAlphaSliderControl, null); + } + + private void BorderPenSettingsControl_NibModeChanged(object sender, RoutedEventArgs e) + { + ToggleSwitchEnableNibMode_Toggled(BorderPenSettingsControl, e); + } + + private void BorderPenSettingsControl_InkFadeChanged(object sender, RoutedEventArgs e) + { + ToggleSwitchInkFadeInPanel_Toggled(BorderPenSettingsControl, e); + } + + private void BorderPenSettingsControl_InkToShapeChanged(object sender, RoutedEventArgs e) + { + ToggleSwitchEnableInkToShape_Toggled(BorderPenSettingsControl, e); + } + + private void BorderPenSettingsControl_BrushModeClicked(object sender, RoutedEventArgs e) + { + BoardBrushModeButton_Click(BorderPenSettingsControl, e); + } + + private void BorderPenSettingsControl_CloseRequested(object sender, RoutedEventArgs e) + { + HideSubPanels(); + } + /// /// PPT放映模式显示手势按钮开关切换事件处理 /// @@ -4085,12 +4206,12 @@ private void AddTouchSupportToSliders() RandWindowOnceMaxStudentsSlider, TimerVolumeSlider, ProgressiveReminderVolumeSlider, - BoardInkWidthSlider, - BoardInkAlphaSlider, - BoardHighlighterWidthSlider, - InkWidthSlider, - InkAlphaSlider, - HighlighterWidthSlider, + BoardPenSettingsControl?.InkWidthSliderControl, + BoardPenSettingsControl?.InkAlphaSliderControl, + BoardPenSettingsControl?.HighlighterWidthSliderControl, + BorderPenSettingsControl?.InkWidthSliderControl, + BorderPenSettingsControl?.InkAlphaSliderControl, + BorderPenSettingsControl?.HighlighterWidthSliderControl, MLAvoidanceHistorySlider, MLAvoidanceWeightSlider, BrushAutoRestoreWidthSlider, diff --git a/Ink Canvas/MainWindow_controls/HighlighterColorPalette.xaml b/Ink Canvas/MainWindow_controls/HighlighterColorPalette.xaml new file mode 100644 index 00000000..d2870220 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/HighlighterColorPalette.xaml @@ -0,0 +1,570 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/HighlighterColorPalette.xaml.cs b/Ink Canvas/MainWindow_controls/HighlighterColorPalette.xaml.cs new file mode 100644 index 00000000..535afa8b --- /dev/null +++ b/Ink Canvas/MainWindow_controls/HighlighterColorPalette.xaml.cs @@ -0,0 +1,203 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class HighlighterColorPalette : UserControl + { + public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register( + nameof(SelectedColor), typeof(Color), typeof(HighlighterColorPalette), new PropertyMetadata(Colors.Black)); + + public static readonly DependencyProperty SelectedColorCodeProperty = DependencyProperty.Register( + nameof(SelectedColorCode), typeof(int), typeof(HighlighterColorPalette), + new PropertyMetadata(100, OnSelectedColorCodeChanged)); + + public static readonly DependencyProperty IsBoardModeProperty = DependencyProperty.Register( + nameof(IsBoardMode), typeof(bool), typeof(HighlighterColorPalette), new PropertyMetadata(false)); + + public static readonly RoutedEvent ColorSelectedEvent = EventManager.RegisterRoutedEvent( + nameof(ColorSelected), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(HighlighterColorPalette)); + + public Color SelectedColor + { + get => (Color)GetValue(SelectedColorProperty); + set => SetValue(SelectedColorProperty, value); + } + + public bool IsBoardMode + { + get => (bool)GetValue(IsBoardModeProperty); + set => SetValue(IsBoardModeProperty, value); + } + + public int SelectedColorCode + { + get => (int)GetValue(SelectedColorCodeProperty); + set => SetValue(SelectedColorCodeProperty, value); + } + + public event RoutedEventHandler ColorSelected + { + add => AddHandler(ColorSelectedEvent, value); + remove => RemoveHandler(ColorSelectedEvent, value); + } + + public HighlighterColorPalette() + { + InitializeComponent(); + UpdateSelectionIndicators(SelectedColorCode); + } + + private void BtnHighlighterColorBlack_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(100, Colors.Black); + } + + private void BtnHighlighterColorWhite_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(101, Colors.White); + } + + private void BtnHighlighterColorRed_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(102, (Color)ColorConverter.ConvertFromString("#ef4444")); + } + + private void BtnHighlighterColorYellow_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(103, (Color)ColorConverter.ConvertFromString("#eab308")); + } + + private void BtnHighlighterColorGreen_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(104, (Color)ColorConverter.ConvertFromString("#22c55e")); + } + + private void BtnHighlighterColorZinc_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(105, (Color)ColorConverter.ConvertFromString("#71717a")); + } + + private void BtnHighlighterColorBlue_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(106, (Color)ColorConverter.ConvertFromString("#3b82f6")); + } + + private void BtnHighlighterColorPurple_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(107, (Color)ColorConverter.ConvertFromString("#a855f7")); + } + + private void BtnHighlighterColorTeal_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(108, (Color)ColorConverter.ConvertFromString("#14b8a6")); + } + + private void BtnHighlighterColorOrange_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(109, (Color)ColorConverter.ConvertFromString("#f97316")); + } + + public void SetSelectedColorCode(int colorCode) + { + SelectedColorCode = colorCode; + } + + private static void OnSelectedColorCodeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is HighlighterColorPalette palette) + { + palette.UpdateSelectionIndicators((int)e.NewValue); + } + } + + private void SelectColor(int colorCode, Color color) + { + SelectedColor = color; + SelectedColorCode = colorCode; + RaiseEvent(new RoutedEventArgs(ColorSelectedEvent, this)); + } + + private void UpdateSelectionIndicators(int colorCode) + { + foreach (var indicator in GetAllIndicators()) + { + indicator.Visibility = Visibility.Collapsed; + } + + switch (colorCode) + { + case 100: + HighlighterPenViewboxBtnColorBlackContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorBlackContent.Visibility = Visibility.Visible; + break; + case 101: + HighlighterPenViewboxBtnColorWhiteContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorWhiteContent.Visibility = Visibility.Visible; + break; + case 102: + HighlighterPenViewboxBtnColorRedContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorRedContent.Visibility = Visibility.Visible; + break; + case 103: + HighlighterPenViewboxBtnColorYellowContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorYellowContent.Visibility = Visibility.Visible; + break; + case 104: + HighlighterPenViewboxBtnColorGreenContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorGreenContent.Visibility = Visibility.Visible; + break; + case 105: + HighlighterPenViewboxBtnColorZincContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorZincContent.Visibility = Visibility.Visible; + break; + case 106: + HighlighterPenViewboxBtnColorBlueContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorBlueContent.Visibility = Visibility.Visible; + break; + case 107: + HighlighterPenViewboxBtnColorPurpleContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorPurpleContent.Visibility = Visibility.Visible; + break; + case 108: + HighlighterPenViewboxBtnColorTealContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorTealContent.Visibility = Visibility.Visible; + break; + case 109: + HighlighterPenViewboxBtnColorOrangeContent.Visibility = Visibility.Visible; + BoardHighlighterPenViewboxBtnColorOrangeContent.Visibility = Visibility.Visible; + break; + } + } + + private Viewbox[] GetAllIndicators() + { + return new[] + { + HighlighterPenViewboxBtnColorBlackContent, + HighlighterPenViewboxBtnColorWhiteContent, + HighlighterPenViewboxBtnColorRedContent, + HighlighterPenViewboxBtnColorYellowContent, + HighlighterPenViewboxBtnColorGreenContent, + HighlighterPenViewboxBtnColorZincContent, + HighlighterPenViewboxBtnColorBlueContent, + HighlighterPenViewboxBtnColorPurpleContent, + HighlighterPenViewboxBtnColorTealContent, + HighlighterPenViewboxBtnColorOrangeContent, + BoardHighlighterPenViewboxBtnColorBlackContent, + BoardHighlighterPenViewboxBtnColorWhiteContent, + BoardHighlighterPenViewboxBtnColorRedContent, + BoardHighlighterPenViewboxBtnColorYellowContent, + BoardHighlighterPenViewboxBtnColorGreenContent, + BoardHighlighterPenViewboxBtnColorZincContent, + BoardHighlighterPenViewboxBtnColorBlueContent, + BoardHighlighterPenViewboxBtnColorPurpleContent, + BoardHighlighterPenViewboxBtnColorTealContent, + BoardHighlighterPenViewboxBtnColorOrangeContent, + }; + } + } +} diff --git a/Ink Canvas/MainWindow_controls/ImageResizeHandles.xaml b/Ink Canvas/MainWindow_controls/ImageResizeHandles.xaml new file mode 100644 index 00000000..a9555796 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/ImageResizeHandles.xaml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/ImageResizeHandles.xaml.cs b/Ink Canvas/MainWindow_controls/ImageResizeHandles.xaml.cs new file mode 100644 index 00000000..57042f48 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/ImageResizeHandles.xaml.cs @@ -0,0 +1,91 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Shapes; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class ImageResizeHandles : UserControl + { + private const double HandleOffset = 4d; + + private FrameworkElement ResizeHandlesCanvasElement => (FrameworkElement)FindName("ImageResizeHandlesCanvas"); + private Ellipse TopLeftHandle => (Ellipse)FindName("ImageTopLeftHandle"); + private Ellipse TopRightHandle => (Ellipse)FindName("ImageTopRightHandle"); + private Ellipse BottomLeftHandle => (Ellipse)FindName("ImageBottomLeftHandle"); + private Ellipse BottomRightHandle => (Ellipse)FindName("ImageBottomRightHandle"); + private Ellipse TopHandle => (Ellipse)FindName("ImageTopHandle"); + private Ellipse BottomHandle => (Ellipse)FindName("ImageBottomHandle"); + private Ellipse LeftHandle => (Ellipse)FindName("ImageLeftHandle"); + private Ellipse RightHandle => (Ellipse)FindName("ImageRightHandle"); + + public static new readonly DependencyProperty VisibilityProperty = DependencyProperty.Register( + nameof(Visibility), + typeof(Visibility), + typeof(ImageResizeHandles), + new FrameworkPropertyMetadata(Visibility.Collapsed, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVisibilityChanged)); + + public new Visibility Visibility + { + get => (Visibility)GetValue(VisibilityProperty); + set => SetValue(VisibilityProperty, value); + } + + public Thickness ControlMargin + { + get => ResizeHandlesCanvasElement.Margin; + set => ResizeHandlesCanvasElement.Margin = value; + } + + public ImageResizeHandles() + { + InitializeComponent(); + } + + public void UpdateHandlePositions(Rect elementBounds) + { + ControlMargin = new Thickness(elementBounds.Left, elementBounds.Top, 0, 0); + + System.Windows.Controls.Canvas.SetLeft(TopLeftHandle, -HandleOffset); + System.Windows.Controls.Canvas.SetTop(TopLeftHandle, -HandleOffset); + + System.Windows.Controls.Canvas.SetLeft(TopRightHandle, elementBounds.Width - HandleOffset); + System.Windows.Controls.Canvas.SetTop(TopRightHandle, -HandleOffset); + + System.Windows.Controls.Canvas.SetLeft(BottomLeftHandle, -HandleOffset); + System.Windows.Controls.Canvas.SetTop(BottomLeftHandle, elementBounds.Height - HandleOffset); + + System.Windows.Controls.Canvas.SetLeft(BottomRightHandle, elementBounds.Width - HandleOffset); + System.Windows.Controls.Canvas.SetTop(BottomRightHandle, elementBounds.Height - HandleOffset); + + System.Windows.Controls.Canvas.SetLeft(TopHandle, elementBounds.Width / 2 - HandleOffset); + System.Windows.Controls.Canvas.SetTop(TopHandle, -HandleOffset); + + System.Windows.Controls.Canvas.SetLeft(BottomHandle, elementBounds.Width / 2 - HandleOffset); + System.Windows.Controls.Canvas.SetTop(BottomHandle, elementBounds.Height - HandleOffset); + + System.Windows.Controls.Canvas.SetLeft(LeftHandle, -HandleOffset); + System.Windows.Controls.Canvas.SetTop(LeftHandle, elementBounds.Height / 2 - HandleOffset); + + System.Windows.Controls.Canvas.SetLeft(RightHandle, elementBounds.Width - HandleOffset); + System.Windows.Controls.Canvas.SetTop(RightHandle, elementBounds.Height / 2 - HandleOffset); + } + + private static void OnVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is ImageResizeHandles handles) + { + var visibility = (Visibility)e.NewValue; + handles.SetCurrentValue(UIElement.VisibilityProperty, visibility); + ResizeHandlesVisibility(handles, visibility); + } + } + + private static void ResizeHandlesVisibility(ImageResizeHandles handles, Visibility visibility) + { + if (handles.ResizeHandlesCanvasElement is UIElement resizeHandlesCanvas) + { + resizeHandlesCanvas.Visibility = visibility; + } + } + } +} diff --git a/Ink Canvas/MainWindow_controls/ImageSelectionToolbar.xaml b/Ink Canvas/MainWindow_controls/ImageSelectionToolbar.xaml new file mode 100644 index 00000000..95220b42 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/ImageSelectionToolbar.xaml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/ImageSelectionToolbar.xaml.cs b/Ink Canvas/MainWindow_controls/ImageSelectionToolbar.xaml.cs new file mode 100644 index 00000000..01168b55 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/ImageSelectionToolbar.xaml.cs @@ -0,0 +1,148 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class ImageSelectionToolbar : UserControl + { + public static readonly DependencyProperty SelectedImageProperty = DependencyProperty.Register( + nameof(SelectedImage), typeof(object), typeof(ImageSelectionToolbar), new PropertyMetadata(null)); + + public static new readonly DependencyProperty VisibilityProperty = DependencyProperty.Register( + nameof(Visibility), typeof(Visibility), typeof(ImageSelectionToolbar), + new FrameworkPropertyMetadata(Visibility.Collapsed, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVisibilityChanged)); + + public static readonly RoutedEvent CloneRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(CloneRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ImageSelectionToolbar)); + + public static readonly RoutedEvent CloneToNewBoardRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(CloneToNewBoardRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ImageSelectionToolbar)); + + public static readonly RoutedEvent DeleteRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(DeleteRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ImageSelectionToolbar)); + + public static readonly RoutedEvent RotateRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(RotateRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ImageSelectionToolbar)); + + public static readonly RoutedEvent ScaleChangedEvent = EventManager.RegisterRoutedEvent( + nameof(ScaleChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ImageSelectionToolbar)); + + // 用于向后兼容 - 暴露内部 Border 以便 partial class 访问 + public Border BorderSelectionControl => BorderImageSelectionControl; + + // 暴露 Margin 属性以便 MW_ElementsControls.cs 设置位置 + public Thickness ControlMargin + { + get => BorderImageSelectionControl.Margin; + set => BorderImageSelectionControl.Margin = value; + } + + // 暴露 Child 属性以便 MW_AutoTheme.cs 访问 + public UIElement ControlChild + { + get => BorderImageSelectionControl.Child; + } + + // 暴露 InvalidateVisual 方法以便 MW_AutoTheme.cs 调用 + public void InvalidateVisualOnControl() + { + BorderImageSelectionControl.InvalidateVisual(); + } + + public object SelectedImage + { + get => GetValue(SelectedImageProperty); + set => SetValue(SelectedImageProperty, value); + } + + public new Visibility Visibility + { + get => (Visibility)GetValue(VisibilityProperty); + set => SetValue(VisibilityProperty, value); + } + + private static void OnVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is ImageSelectionToolbar toolbar) + { + toolbar.BorderImageSelectionControl.Visibility = (Visibility)e.NewValue; + } + } + + public event RoutedEventHandler CloneRequested + { + add => AddHandler(CloneRequestedEvent, value); + remove => RemoveHandler(CloneRequestedEvent, value); + } + + public event RoutedEventHandler CloneToNewBoardRequested + { + add => AddHandler(CloneToNewBoardRequestedEvent, value); + remove => RemoveHandler(CloneToNewBoardRequestedEvent, value); + } + + public event RoutedEventHandler DeleteRequested + { + add => AddHandler(DeleteRequestedEvent, value); + remove => RemoveHandler(DeleteRequestedEvent, value); + } + + public event RoutedEventHandler RotateRequested + { + add => AddHandler(RotateRequestedEvent, value); + remove => RemoveHandler(RotateRequestedEvent, value); + } + + public event RoutedEventHandler ScaleChanged + { + add => AddHandler(ScaleChangedEvent, value); + remove => RemoveHandler(ScaleChangedEvent, value); + } + + public ImageSelectionToolbar() + { + InitializeComponent(); + } + + private void Border_MouseDown(object sender, MouseButtonEventArgs e) + { + } + + private void BorderImageClone_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(CloneRequestedEvent, this)); + } + + private void BorderImageCloneToNewBoard_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(CloneToNewBoardRequestedEvent, this)); + } + + private void BorderImageDelete_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(DeleteRequestedEvent, this)); + } + + private void BorderImageRotateLeft_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(RotateRequestedEvent, this)); + } + + private void BorderImageRotateRight_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(RotateRequestedEvent, this)); + } + + private void GridImageScaleDecrease_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(ScaleChangedEvent, this)); + } + + private void GridImageScaleIncrease_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(ScaleChangedEvent, this)); + } + } +} diff --git a/Ink Canvas/MainWindow_controls/PPTNavigationBottomLeft.xaml b/Ink Canvas/MainWindow_controls/PPTNavigationBottomLeft.xaml new file mode 100644 index 00000000..47d79971 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PPTNavigationBottomLeft.xaml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/PPTNavigationBottomLeft.xaml.cs b/Ink Canvas/MainWindow_controls/PPTNavigationBottomLeft.xaml.cs new file mode 100644 index 00000000..56149b6f --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PPTNavigationBottomLeft.xaml.cs @@ -0,0 +1,149 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class PPTNavigationBottomLeft : UserControl + { + public static readonly DependencyProperty CurrentPageProperty = DependencyProperty.Register( + nameof(CurrentPage), typeof(string), typeof(PPTNavigationBottomLeft), new PropertyMetadata("1")); + + public static readonly DependencyProperty TotalPagesProperty = DependencyProperty.Register( + nameof(TotalPages), typeof(string), typeof(PPTNavigationBottomLeft), new PropertyMetadata("1")); + + public static readonly DependencyProperty IsVisibleProperty = DependencyProperty.Register( + nameof(IsVisible), typeof(bool), typeof(PPTNavigationBottomLeft), new PropertyMetadata(true)); + + public static readonly RoutedEvent PreviousClickedEvent = EventManager.RegisterRoutedEvent( + nameof(PreviousClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationBottomLeft)); + + public static readonly RoutedEvent NextClickedEvent = EventManager.RegisterRoutedEvent( + nameof(NextClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationBottomLeft)); + + public static readonly RoutedEvent PageClickedEvent = EventManager.RegisterRoutedEvent( + nameof(PageClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationBottomLeft)); + + public Border BorderSelectionControl => PPTBtnLBBorderElement; + + public Thickness ControlMargin + { + get => Margin; + set => Margin = value; + } + + public UIElement ControlChild => ViewboxPPTNavigationBottomLeft; + + public void InvalidateVisualOnControl() + { + PPTBtnLBBorderElement.InvalidateVisual(); + } + + public new Visibility Visibility + { + get => base.Visibility; + set => base.Visibility = value; + } + + public Border PPTBtnLBBorder => PPTBtnLBBorderElement; + public Border PPTLBPreviousButtonBorder => PPTLBPreviousButtonBorderElement; + public Border PPTLBPreviousButtonFeedbackBorder => PPTLBPreviousButtonFeedbackBorderElement; + public GeometryDrawing PPTLBPreviousButtonGeometry => PPTLBPreviousButtonGeometryElement; + public Border PPTLBPageButton => PPTLBPageButtonElement; + public Border PPTLBPageButtonFeedbackBorder => PPTLBPageButtonFeedbackBorderElement; + public Border PPTLBNextButtonBorder => PPTLBNextButtonBorderElement; + public Border PPTLBNextButtonFeedbackBorder => PPTLBNextButtonFeedbackBorderElement; + public GeometryDrawing PPTLBNextButtonGeometry => PPTLBNextButtonGeometryElement; + + public string CurrentPage + { + get => (string)GetValue(CurrentPageProperty); + set => SetValue(CurrentPageProperty, value); + } + + public string TotalPages + { + get => (string)GetValue(TotalPagesProperty); + set => SetValue(TotalPagesProperty, value); + } + + public bool IsVisible + { + get => (bool)GetValue(IsVisibleProperty); + set => SetValue(IsVisibleProperty, value); + } + + public event RoutedEventHandler PreviousClicked + { + add => AddHandler(PreviousClickedEvent, value); + remove => RemoveHandler(PreviousClickedEvent, value); + } + + public event RoutedEventHandler NextClicked + { + add => AddHandler(NextClickedEvent, value); + remove => RemoveHandler(NextClickedEvent, value); + } + + public event RoutedEventHandler PageClicked + { + add => AddHandler(PageClickedEvent, value); + remove => RemoveHandler(PageClickedEvent, value); + } + + public PPTNavigationBottomLeft() + { + InitializeComponent(); + } + + private void GridPPTControlPrevious_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTLBPreviousButtonFeedbackBorderElement.Opacity = 1; + } + + private void GridPPTControlPrevious_MouseLeave(object sender, MouseEventArgs e) + { + PPTLBPreviousButtonFeedbackBorderElement.Opacity = 0; + } + + private void GridPPTControlPrevious_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTLBPreviousButtonFeedbackBorderElement.Opacity = 0; + RaiseEvent(new RoutedEventArgs(PreviousClickedEvent, this)); + } + + private void PPTNavigationBtn_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTLBPageButtonFeedbackBorderElement.Opacity = 1; + } + + private void PPTNavigationBtn_MouseLeave(object sender, MouseEventArgs e) + { + PPTLBPageButtonFeedbackBorderElement.Opacity = 0; + } + + private void PPTNavigationBtn_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTLBPageButtonFeedbackBorderElement.Opacity = 0; + RaiseEvent(new RoutedEventArgs(PageClickedEvent, this)); + } + + private void GridPPTControlNext_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTLBNextButtonFeedbackBorderElement.Opacity = 1; + } + + private void GridPPTControlNext_MouseLeave(object sender, MouseEventArgs e) + { + PPTLBNextButtonFeedbackBorderElement.Opacity = 0; + } + + private void GridPPTControlNext_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTLBNextButtonFeedbackBorderElement.Opacity = 0; + RaiseEvent(new RoutedEventArgs(NextClickedEvent, this)); + } + } +} diff --git a/Ink Canvas/MainWindow_controls/PPTNavigationBottomRight.xaml b/Ink Canvas/MainWindow_controls/PPTNavigationBottomRight.xaml new file mode 100644 index 00000000..e4ae0b92 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PPTNavigationBottomRight.xaml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/PPTNavigationBottomRight.xaml.cs b/Ink Canvas/MainWindow_controls/PPTNavigationBottomRight.xaml.cs new file mode 100644 index 00000000..f0dd6907 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PPTNavigationBottomRight.xaml.cs @@ -0,0 +1,149 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class PPTNavigationBottomRight : UserControl + { + public static readonly DependencyProperty CurrentPageProperty = DependencyProperty.Register( + nameof(CurrentPage), typeof(string), typeof(PPTNavigationBottomRight), new PropertyMetadata("1")); + + public static readonly DependencyProperty TotalPagesProperty = DependencyProperty.Register( + nameof(TotalPages), typeof(string), typeof(PPTNavigationBottomRight), new PropertyMetadata("1")); + + public static readonly DependencyProperty IsVisibleProperty = DependencyProperty.Register( + nameof(IsVisible), typeof(bool), typeof(PPTNavigationBottomRight), new PropertyMetadata(true)); + + public static readonly RoutedEvent PreviousClickedEvent = EventManager.RegisterRoutedEvent( + nameof(PreviousClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationBottomRight)); + + public static readonly RoutedEvent NextClickedEvent = EventManager.RegisterRoutedEvent( + nameof(NextClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationBottomRight)); + + public static readonly RoutedEvent PageClickedEvent = EventManager.RegisterRoutedEvent( + nameof(PageClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationBottomRight)); + + public Border BorderSelectionControl => PPTBtnRBBorderElement; + + public Thickness ControlMargin + { + get => Margin; + set => Margin = value; + } + + public UIElement ControlChild => ViewboxPPTNavigationBottomRight; + + public void InvalidateVisualOnControl() + { + PPTBtnRBBorderElement.InvalidateVisual(); + } + + public new Visibility Visibility + { + get => base.Visibility; + set => base.Visibility = value; + } + + public Border PPTBtnRBBorder => PPTBtnRBBorderElement; + public Border PPTRBPreviousButtonBorder => PPTRBPreviousButtonBorderElement; + public Border PPTRBPreviousButtonFeedbackBorder => PPTRBPreviousButtonFeedbackBorderElement; + public GeometryDrawing PPTRBPreviousButtonGeometry => PPTRBPreviousButtonGeometryElement; + public Border PPTRBPageButton => PPTRBPageButtonElement; + public Border PPTRBPageButtonFeedbackBorder => PPTRBPageButtonFeedbackBorderElement; + public Border PPTRBNextButtonBorder => PPTRBNextButtonBorderElement; + public Border PPTRBNextButtonFeedbackBorder => PPTRBNextButtonFeedbackBorderElement; + public GeometryDrawing PPTRBNextButtonGeometry => PPTRBNextButtonGeometryElement; + + public string CurrentPage + { + get => (string)GetValue(CurrentPageProperty); + set => SetValue(CurrentPageProperty, value); + } + + public string TotalPages + { + get => (string)GetValue(TotalPagesProperty); + set => SetValue(TotalPagesProperty, value); + } + + public bool IsVisible + { + get => (bool)GetValue(IsVisibleProperty); + set => SetValue(IsVisibleProperty, value); + } + + public event RoutedEventHandler PreviousClicked + { + add => AddHandler(PreviousClickedEvent, value); + remove => RemoveHandler(PreviousClickedEvent, value); + } + + public event RoutedEventHandler NextClicked + { + add => AddHandler(NextClickedEvent, value); + remove => RemoveHandler(NextClickedEvent, value); + } + + public event RoutedEventHandler PageClicked + { + add => AddHandler(PageClickedEvent, value); + remove => RemoveHandler(PageClickedEvent, value); + } + + public PPTNavigationBottomRight() + { + InitializeComponent(); + } + + private void GridPPTControlPrevious_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTRBPreviousButtonFeedbackBorderElement.Opacity = 1; + } + + private void GridPPTControlPrevious_MouseLeave(object sender, MouseEventArgs e) + { + PPTRBPreviousButtonFeedbackBorderElement.Opacity = 0; + } + + private void GridPPTControlPrevious_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTRBPreviousButtonFeedbackBorderElement.Opacity = 0; + RaiseEvent(new RoutedEventArgs(PreviousClickedEvent, this)); + } + + private void PPTNavigationBtn_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTRBPageButtonFeedbackBorderElement.Opacity = 1; + } + + private void PPTNavigationBtn_MouseLeave(object sender, MouseEventArgs e) + { + PPTRBPageButtonFeedbackBorderElement.Opacity = 0; + } + + private void PPTNavigationBtn_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTRBPageButtonFeedbackBorderElement.Opacity = 0; + RaiseEvent(new RoutedEventArgs(PageClickedEvent, this)); + } + + private void GridPPTControlNext_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTRBNextButtonFeedbackBorderElement.Opacity = 1; + } + + private void GridPPTControlNext_MouseLeave(object sender, MouseEventArgs e) + { + PPTRBNextButtonFeedbackBorderElement.Opacity = 0; + } + + private void GridPPTControlNext_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTRBNextButtonFeedbackBorderElement.Opacity = 0; + RaiseEvent(new RoutedEventArgs(NextClickedEvent, this)); + } + } +} diff --git a/Ink Canvas/MainWindow_controls/PPTNavigationSideLeft.xaml b/Ink Canvas/MainWindow_controls/PPTNavigationSideLeft.xaml new file mode 100644 index 00000000..0b46cd6d --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PPTNavigationSideLeft.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/PPTNavigationSideLeft.xaml.cs b/Ink Canvas/MainWindow_controls/PPTNavigationSideLeft.xaml.cs new file mode 100644 index 00000000..2b1c84e0 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PPTNavigationSideLeft.xaml.cs @@ -0,0 +1,165 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class PPTNavigationSideLeft : UserControl + { + public static readonly DependencyProperty CurrentPageProperty = DependencyProperty.Register( + nameof(CurrentPage), typeof(int), typeof(PPTNavigationSideLeft), new PropertyMetadata(1)); + + public static readonly DependencyProperty TotalPagesProperty = DependencyProperty.Register( + nameof(TotalPages), typeof(int), typeof(PPTNavigationSideLeft), new PropertyMetadata(1)); + + public static readonly DependencyProperty IsVisibleProperty = DependencyProperty.Register( + nameof(IsVisible), typeof(bool), typeof(PPTNavigationSideLeft), new PropertyMetadata(true)); + + public static readonly RoutedEvent PreviousClickedEvent = EventManager.RegisterRoutedEvent( + nameof(PreviousClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationSideLeft)); + + public static readonly RoutedEvent NextClickedEvent = EventManager.RegisterRoutedEvent( + nameof(NextClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationSideLeft)); + + public static readonly RoutedEvent PageClickedEvent = EventManager.RegisterRoutedEvent( + nameof(PageClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationSideLeft)); + + public int CurrentPage + { + get => (int)GetValue(CurrentPageProperty); + set => SetValue(CurrentPageProperty, value); + } + + public int TotalPages + { + get => (int)GetValue(TotalPagesProperty); + set => SetValue(TotalPagesProperty, value); + } + + public bool IsVisible + { + get => (bool)GetValue(IsVisibleProperty); + set => SetValue(IsVisibleProperty, value); + } + + public event RoutedEventHandler PreviousClicked + { + add => AddHandler(PreviousClickedEvent, value); + remove => RemoveHandler(PreviousClickedEvent, value); + } + + public event RoutedEventHandler NextClicked + { + add => AddHandler(NextClickedEvent, value); + remove => RemoveHandler(NextClickedEvent, value); + } + + public event RoutedEventHandler PageClicked + { + add => AddHandler(PageClickedEvent, value); + remove => RemoveHandler(PageClickedEvent, value); + } + + public PPTNavigationSideLeft() + { + InitializeComponent(); + } + + private Border ContainerBorderElement => (Border)FindName("PPTBtnLSBorder"); + private Border PreviousButtonFeedbackBorderElement => (Border)FindName("PPTLSPreviousButtonFeedbackBorder"); + private GeometryDrawing PreviousButtonGeometryElement => (GeometryDrawing)FindName("PPTLSPreviousButtonGeometry"); + private Border PageButtonElement => (Border)FindName("PPTLSPageButton"); + private Border PageButtonFeedbackBorderElement => (Border)FindName("PPTLSPageButtonFeedbackBorder"); + private Border NextButtonFeedbackBorderElement => (Border)FindName("PPTLSNextButtonFeedbackBorder"); + private GeometryDrawing NextButtonGeometryElement => (GeometryDrawing)FindName("PPTLSNextButtonGeometry"); + private TextBlock CurrentPageTextElement => (TextBlock)FindName("PPTBtnPageNow"); + private TextBlock TotalPagesTextElement => (TextBlock)FindName("PPTBtnPageTotal"); + + public Thickness ControlMargin + { + get => Margin; + set => Margin = value; + } + + public void SetPageDisplay(string currentPage, string totalPages) + { + CurrentPageTextElement.Text = currentPage; + TotalPagesTextElement.Text = $"/ {totalPages}"; + } + + public void SetPageButtonVisibility(Visibility visibility) + { + PageButtonElement.Visibility = visibility; + } + + public void SetContainerOpacity(double opacity) + { + ContainerBorderElement.Opacity = opacity; + } + + public void ApplyTheme(Brush backgroundBrush, Brush borderBrush, Brush foregroundBrush, Brush feedbackBrush) + { + ContainerBorderElement.Background = backgroundBrush; + ContainerBorderElement.BorderBrush = borderBrush; + + PreviousButtonGeometryElement.Brush = foregroundBrush; + NextButtonGeometryElement.Brush = foregroundBrush; + + PreviousButtonFeedbackBorderElement.Background = feedbackBrush; + PageButtonFeedbackBorderElement.Background = feedbackBrush; + NextButtonFeedbackBorderElement.Background = feedbackBrush; + + TextBlock.SetForeground(PageButtonElement, foregroundBrush); + } + + private void GridPPTControlPrevious_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTLSPreviousButtonFeedbackBorder.Opacity = 1; + } + + private void GridPPTControlPrevious_MouseLeave(object sender, MouseEventArgs e) + { + PPTLSPreviousButtonFeedbackBorder.Opacity = 0; + } + + private void GridPPTControlPrevious_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTLSPreviousButtonFeedbackBorder.Opacity = 0; + RaiseEvent(new RoutedEventArgs(PreviousClickedEvent, this)); + } + + private void PPTNavigationBtn_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTLSPageButtonFeedbackBorder.Opacity = 1; + } + + private void PPTNavigationBtn_MouseLeave(object sender, MouseEventArgs e) + { + PPTLSPageButtonFeedbackBorder.Opacity = 0; + } + + private void PPTNavigationBtn_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTLSPageButtonFeedbackBorder.Opacity = 0; + RaiseEvent(new RoutedEventArgs(PageClickedEvent, this)); + } + + private void GridPPTControlNext_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTLSNextButtonFeedbackBorder.Opacity = 1; + } + + private void GridPPTControlNext_MouseLeave(object sender, MouseEventArgs e) + { + PPTLSNextButtonFeedbackBorder.Opacity = 0; + } + + private void GridPPTControlNext_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTLSNextButtonFeedbackBorder.Opacity = 0; + RaiseEvent(new RoutedEventArgs(NextClickedEvent, this)); + } + } +} diff --git a/Ink Canvas/MainWindow_controls/PPTNavigationSideRight.xaml b/Ink Canvas/MainWindow_controls/PPTNavigationSideRight.xaml new file mode 100644 index 00000000..a61f33bb --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PPTNavigationSideRight.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/PPTNavigationSideRight.xaml.cs b/Ink Canvas/MainWindow_controls/PPTNavigationSideRight.xaml.cs new file mode 100644 index 00000000..0d28644d --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PPTNavigationSideRight.xaml.cs @@ -0,0 +1,171 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class PPTNavigationSideRight : UserControl + { + public static readonly DependencyProperty CurrentPageProperty = DependencyProperty.Register( + nameof(CurrentPage), typeof(string), typeof(PPTNavigationSideRight), new PropertyMetadata("1")); + + public static readonly DependencyProperty TotalPagesProperty = DependencyProperty.Register( + nameof(TotalPages), typeof(string), typeof(PPTNavigationSideRight), new PropertyMetadata("1")); + + public static readonly DependencyProperty IsVisibleProperty = DependencyProperty.Register( + nameof(IsVisible), typeof(bool), typeof(PPTNavigationSideRight), new PropertyMetadata(true)); + + public static readonly RoutedEvent PreviousClickedEvent = EventManager.RegisterRoutedEvent( + nameof(PreviousClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationSideRight)); + + public static readonly RoutedEvent NextClickedEvent = EventManager.RegisterRoutedEvent( + nameof(NextClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationSideRight)); + + public static readonly RoutedEvent PageClickedEvent = EventManager.RegisterRoutedEvent( + nameof(PageClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PPTNavigationSideRight)); + + private Border ContainerBorderElement => (Border)FindName("PPTBtnRSBorder"); + private Border PreviousButtonFeedbackBorderElement => (Border)FindName("PPTRSPreviousButtonFeedbackBorder"); + private GeometryDrawing PreviousButtonGeometryElement => (GeometryDrawing)FindName("PPTRSPreviousButtonGeometry"); + private Border PageButtonElement => (Border)FindName("PPTRSPageButton"); + private Border PageButtonFeedbackBorderElement => (Border)FindName("PPTRSPageButtonFeedbackBorder"); + private Border NextButtonFeedbackBorderElement => (Border)FindName("PPTRSNextButtonFeedbackBorder"); + private GeometryDrawing NextButtonGeometryElement => (GeometryDrawing)FindName("PPTRSNextButtonGeometry"); + + public Border ContainerBorder => ContainerBorderElement; + public Border PreviousButtonFeedbackBorder => PreviousButtonFeedbackBorderElement; + public GeometryDrawing PreviousButtonGeometry => PreviousButtonGeometryElement; + public Border PageButton => PageButtonElement; + public Border PageButtonFeedbackBorder => PageButtonFeedbackBorderElement; + public Border NextButtonFeedbackBorder => NextButtonFeedbackBorderElement; + public GeometryDrawing NextButtonGeometry => NextButtonGeometryElement; + + public Thickness ControlMargin + { + get => Margin; + set => Margin = value; + } + + public void SetPageDisplay(string currentPage, string totalPages) + { + CurrentPage = currentPage; + TotalPages = totalPages; + } + + public void SetPageButtonVisibility(Visibility visibility) + { + PageButtonElement.Visibility = visibility; + } + + public void SetContainerOpacity(double opacity) + { + ContainerBorderElement.Opacity = opacity; + } + + public void ApplyTheme(Brush backgroundBrush, Brush borderBrush, Brush foregroundBrush, Brush feedbackBrush) + { + ContainerBorderElement.Background = backgroundBrush; + ContainerBorderElement.BorderBrush = borderBrush; + + PreviousButtonGeometryElement.Brush = foregroundBrush; + NextButtonGeometryElement.Brush = foregroundBrush; + + PreviousButtonFeedbackBorderElement.Background = feedbackBrush; + PageButtonFeedbackBorderElement.Background = feedbackBrush; + NextButtonFeedbackBorderElement.Background = feedbackBrush; + + TextBlock.SetForeground(PageButtonElement, foregroundBrush); + } + + public string CurrentPage + { + get => (string)GetValue(CurrentPageProperty); + set => SetValue(CurrentPageProperty, value); + } + + public string TotalPages + { + get => (string)GetValue(TotalPagesProperty); + set => SetValue(TotalPagesProperty, value); + } + + public bool IsVisible + { + get => (bool)GetValue(IsVisibleProperty); + set => SetValue(IsVisibleProperty, value); + } + + public event RoutedEventHandler PreviousClicked + { + add => AddHandler(PreviousClickedEvent, value); + remove => RemoveHandler(PreviousClickedEvent, value); + } + + public event RoutedEventHandler NextClicked + { + add => AddHandler(NextClickedEvent, value); + remove => RemoveHandler(NextClickedEvent, value); + } + + public event RoutedEventHandler PageClicked + { + add => AddHandler(PageClickedEvent, value); + remove => RemoveHandler(PageClickedEvent, value); + } + + public PPTNavigationSideRight() + { + InitializeComponent(); + } + + private void GridPPTControlPrevious_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTRSPreviousButtonFeedbackBorder.Opacity = 1; + } + + private void GridPPTControlPrevious_MouseLeave(object sender, MouseEventArgs e) + { + PPTRSPreviousButtonFeedbackBorder.Opacity = 0; + } + + private void GridPPTControlPrevious_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTRSPreviousButtonFeedbackBorder.Opacity = 0; + RaiseEvent(new RoutedEventArgs(PreviousClickedEvent, this)); + } + + private void PPTNavigationBtn_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTRSPageButtonFeedbackBorder.Opacity = 1; + } + + private void PPTNavigationBtn_MouseLeave(object sender, MouseEventArgs e) + { + PPTRSPageButtonFeedbackBorder.Opacity = 0; + } + + private void PPTNavigationBtn_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTRSPageButtonFeedbackBorder.Opacity = 0; + RaiseEvent(new RoutedEventArgs(PageClickedEvent, this)); + } + + private void GridPPTControlNext_MouseDown(object sender, MouseButtonEventArgs e) + { + PPTRSNextButtonFeedbackBorder.Opacity = 1; + } + + private void GridPPTControlNext_MouseLeave(object sender, MouseEventArgs e) + { + PPTRSNextButtonFeedbackBorder.Opacity = 0; + } + + private void GridPPTControlNext_MouseUp(object sender, MouseButtonEventArgs e) + { + PPTRSNextButtonFeedbackBorder.Opacity = 0; + RaiseEvent(new RoutedEventArgs(NextClickedEvent, this)); + } + } +} diff --git a/Ink Canvas/MainWindow_controls/PenColorPalette.xaml b/Ink Canvas/MainWindow_controls/PenColorPalette.xaml new file mode 100644 index 00000000..d31f14c8 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PenColorPalette.xaml @@ -0,0 +1,409 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/PenColorPalette.xaml.cs b/Ink Canvas/MainWindow_controls/PenColorPalette.xaml.cs new file mode 100644 index 00000000..05c460e7 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PenColorPalette.xaml.cs @@ -0,0 +1,354 @@ +using System; +using System.Collections.ObjectModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class PenColorPalette : UserControl + { + public static readonly DependencyProperty SelectedColorProperty = DependencyProperty.Register( + nameof(SelectedColor), typeof(Color), typeof(PenColorPalette), new PropertyMetadata(Colors.Black)); + + public static readonly DependencyProperty SelectedColorCodeProperty = DependencyProperty.Register( + nameof(SelectedColorCode), typeof(int), typeof(PenColorPalette), new PropertyMetadata(0, OnSelectedColorCodeChanged)); + + public static readonly DependencyProperty ColorPaletteProperty = DependencyProperty.Register( + nameof(ColorPalette), typeof(ObservableCollection), typeof(PenColorPalette), + new PropertyMetadata(new ObservableCollection())); + + public static readonly DependencyProperty IsBoardModeProperty = DependencyProperty.Register( + nameof(IsBoardMode), typeof(bool), typeof(PenColorPalette), new PropertyMetadata(false)); + + public static readonly DependencyProperty UseLightThemeColorsProperty = DependencyProperty.Register( + nameof(UseLightThemeColors), typeof(bool), typeof(PenColorPalette), new PropertyMetadata(false, OnUseLightThemeColorsChanged)); + + public static new readonly DependencyProperty VisibilityProperty = DependencyProperty.Register( + nameof(Visibility), typeof(Visibility), typeof(PenColorPalette), + new FrameworkPropertyMetadata(Visibility.Visible, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVisibilityChanged)); + + public static readonly RoutedEvent ColorSelectedEvent = EventManager.RegisterRoutedEvent( + nameof(ColorSelected), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenColorPalette)); + + public static readonly RoutedEvent ThemeSwitchClickedEvent = EventManager.RegisterRoutedEvent( + nameof(ThemeSwitchClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenColorPalette)); + + public Color SelectedColor + { + get => (Color)GetValue(SelectedColorProperty); + set => SetValue(SelectedColorProperty, value); + } + + public int SelectedColorCode + { + get => (int)GetValue(SelectedColorCodeProperty); + set => SetValue(SelectedColorCodeProperty, value); + } + + public ObservableCollection ColorPalette + { + get => (ObservableCollection)GetValue(ColorPaletteProperty); + set => SetValue(ColorPaletteProperty, value); + } + + public bool IsBoardMode + { + get => (bool)GetValue(IsBoardModeProperty); + set => SetValue(IsBoardModeProperty, value); + } + + public bool UseLightThemeColors + { + get => (bool)GetValue(UseLightThemeColorsProperty); + set => SetValue(UseLightThemeColorsProperty, value); + } + + public Border BorderSelectionControl => BorderPenColorPaletteSelectionControl; + + public Thickness ControlMargin + { + get => BorderPenColorPaletteSelectionControl.Margin; + set => BorderPenColorPaletteSelectionControl.Margin = value; + } + + public UIElement ControlChild => BorderPenColorPaletteSelectionControl.Child; + + public new Visibility Visibility + { + get => (Visibility)GetValue(VisibilityProperty); + set => SetValue(VisibilityProperty, value); + } + + public event RoutedEventHandler ColorSelected + { + add => AddHandler(ColorSelectedEvent, value); + remove => RemoveHandler(ColorSelectedEvent, value); + } + + public event RoutedEventHandler ThemeSwitchClicked + { + add => AddHandler(ThemeSwitchClickedEvent, value); + remove => RemoveHandler(ThemeSwitchClickedEvent, value); + } + + public PenColorPalette() + { + InitializeComponent(); + UpdateThemeVisuals(UseLightThemeColors); + UpdateSelectionIndicators(SelectedColorCode); + } + + public void InvalidateVisualOnControl() + { + BorderPenColorPaletteSelectionControl.InvalidateVisual(); + } + + public void SetSelectedColorCode(int colorCode) + { + SelectedColorCode = colorCode; + } + + public void SetUseLightThemeColors(bool useLightThemeColors) + { + UseLightThemeColors = useLightThemeColors; + } + + private static void OnSelectedColorCodeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenColorPalette palette) + { + palette.UpdateSelectionIndicators((int)e.NewValue); + } + } + + private static void OnUseLightThemeColorsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenColorPalette palette) + { + palette.UpdateThemeVisuals((bool)e.NewValue); + } + } + + private static void OnVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenColorPalette palette) + { + palette.BorderPenColorPaletteSelectionControl.Visibility = (Visibility)e.NewValue; + } + } + + private void Border_MouseDown(object sender, MouseButtonEventArgs e) + { + } + + private void ColorThemeSwitch_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(ThemeSwitchClickedEvent, this)); + } + + private void BtnColorBlack_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(0, Colors.Black); + } + + private void BtnColorWhite_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(5, Colors.White); + } + + private void BtnColorRed_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(1, GetCurrentPaletteColor(PaletteColor.Red)); + } + + private void BtnColorYellow_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(4, GetCurrentPaletteColor(PaletteColor.Yellow)); + } + + private void BtnColorGreen_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(2, GetCurrentPaletteColor(PaletteColor.Green)); + } + + private void BtnColorBlue_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(3, GetCurrentPaletteColor(PaletteColor.Blue)); + } + + private void BtnColorPink_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(6, GetCurrentPaletteColor(PaletteColor.Pink)); + } + + private void BtnColorTeal_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(7, GetCurrentPaletteColor(PaletteColor.Teal)); + } + + private void BtnColorOrange_Click(object sender, MouseButtonEventArgs e) + { + SelectColor(8, GetCurrentPaletteColor(PaletteColor.Orange)); + } + + private void SelectColor(int colorCode, Color color) + { + SelectedColor = color; + SelectedColorCode = colorCode; + RaiseEvent(new RoutedEventArgs(ColorSelectedEvent, this)); + } + + private void UpdateThemeVisuals(bool useLightThemeColors) + { + ColorThemeSwitchIcon.Source = CreateThemeIcon(useLightThemeColors); + BoardColorThemeSwitchIcon.Source = CreateThemeIcon(useLightThemeColors); + + string switchText = useLightThemeColors ? "暗系" : "亮系"; + ColorThemeSwitchTextBlock.Text = switchText; + BoardColorThemeSwitchTextBlock.Text = switchText; + + ApplyPaletteColor(BorderPenColorRed, BoardBorderPenColorRed, PaletteColor.Red, useLightThemeColors); + ApplyPaletteColor(BorderPenColorGreen, BoardBorderPenColorGreen, PaletteColor.Green, useLightThemeColors); + ApplyPaletteColor(BorderPenColorBlue, BoardBorderPenColorBlue, PaletteColor.Blue, useLightThemeColors); + ApplyPaletteColor(BorderPenColorYellow, BoardBorderPenColorYellow, PaletteColor.Yellow, useLightThemeColors); + ApplyPaletteColor(BorderPenColorPink, BoardBorderPenColorPink, PaletteColor.Pink, useLightThemeColors); + ApplyPaletteColor(BorderPenColorTeal, BoardBorderPenColorTeal, PaletteColor.Teal, useLightThemeColors); + ApplyPaletteColor(BorderPenColorOrange, BoardBorderPenColorOrange, PaletteColor.Orange, useLightThemeColors); + } + + private void UpdateSelectionIndicators(int colorCode) + { + foreach (var indicator in GetAllIndicators()) + { + indicator.Visibility = Visibility.Collapsed; + } + + switch (colorCode) + { + case 0: + ViewboxBtnColorBlackContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorBlackContent.Visibility = Visibility.Visible; + break; + case 1: + ViewboxBtnColorRedContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorRedContent.Visibility = Visibility.Visible; + break; + case 2: + ViewboxBtnColorGreenContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorGreenContent.Visibility = Visibility.Visible; + break; + case 3: + ViewboxBtnColorBlueContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorBlueContent.Visibility = Visibility.Visible; + break; + case 4: + ViewboxBtnColorYellowContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorYellowContent.Visibility = Visibility.Visible; + break; + case 5: + ViewboxBtnColorWhiteContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorWhiteContent.Visibility = Visibility.Visible; + break; + case 6: + ViewboxBtnColorPinkContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorPinkContent.Visibility = Visibility.Visible; + break; + case 7: + ViewboxBtnColorTealContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorTealContent.Visibility = Visibility.Visible; + break; + case 8: + ViewboxBtnColorOrangeContent.Visibility = Visibility.Visible; + BoardViewboxBtnColorOrangeContent.Visibility = Visibility.Visible; + break; + } + } + + private Viewbox[] GetAllIndicators() + { + return new[] + { + ViewboxBtnColorBlackContent, + ViewboxBtnColorWhiteContent, + ViewboxBtnColorRedContent, + ViewboxBtnColorYellowContent, + ViewboxBtnColorGreenContent, + ViewboxBtnColorBlueContent, + ViewboxBtnColorPinkContent, + ViewboxBtnColorTealContent, + ViewboxBtnColorOrangeContent, + BoardViewboxBtnColorBlackContent, + BoardViewboxBtnColorWhiteContent, + BoardViewboxBtnColorRedContent, + BoardViewboxBtnColorYellowContent, + BoardViewboxBtnColorGreenContent, + BoardViewboxBtnColorBlueContent, + BoardViewboxBtnColorPinkContent, + BoardViewboxBtnColorTealContent, + BoardViewboxBtnColorOrangeContent, + }; + } + + private static ImageSource CreateThemeIcon(bool useLightThemeColors) + { + string uri = useLightThemeColors + ? "/Resources/Icons-Fluent/ic_fluent_weather_moon_24_regular.png" + : "/Resources/Icons-Fluent/ic_fluent_weather_sunny_24_regular.png"; + + var imageSource = new System.Windows.Media.Imaging.BitmapImage(); + imageSource.BeginInit(); + imageSource.UriSource = new Uri(uri, UriKind.RelativeOrAbsolute); + imageSource.EndInit(); + return imageSource; + } + + private void ApplyPaletteColor(Border desktopBorder, Border boardBorder, PaletteColor paletteColor, bool useLightThemeColors) + { + Color color = GetPaletteColor(paletteColor, useLightThemeColors); + var brush = new SolidColorBrush(color); + desktopBorder.Background = brush; + boardBorder.Background = brush.Clone(); + } + + private Color GetCurrentPaletteColor(PaletteColor paletteColor) + { + return GetPaletteColor(paletteColor, UseLightThemeColors); + } + + private static Color GetPaletteColor(PaletteColor paletteColor, bool useLightThemeColors) + { + switch (paletteColor) + { + case PaletteColor.Red: + return useLightThemeColors ? Color.FromRgb(239, 68, 68) : Color.FromRgb(220, 38, 38); + case PaletteColor.Green: + return useLightThemeColors ? Color.FromRgb(34, 197, 94) : Color.FromRgb(22, 163, 74); + case PaletteColor.Blue: + return useLightThemeColors ? Color.FromRgb(59, 130, 246) : Color.FromRgb(37, 99, 235); + case PaletteColor.Yellow: + return useLightThemeColors ? Color.FromRgb(250, 204, 21) : Color.FromRgb(234, 179, 8); + case PaletteColor.Pink: + return useLightThemeColors ? Color.FromRgb(236, 72, 153) : Color.FromRgb(147, 51, 234); + case PaletteColor.Teal: + return useLightThemeColors ? Color.FromRgb(20, 184, 166) : Color.FromRgb(13, 148, 136); + case PaletteColor.Orange: + return useLightThemeColors ? Color.FromRgb(249, 115, 22) : Color.FromRgb(234, 88, 12); + default: + return Colors.Black; + } + } + + private enum PaletteColor + { + Red, + Green, + Blue, + Yellow, + Pink, + Teal, + Orange, + } + } +} diff --git a/Ink Canvas/MainWindow_controls/PenSettingsPanel.xaml b/Ink Canvas/MainWindow_controls/PenSettingsPanel.xaml new file mode 100644 index 00000000..8c4f192c --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PenSettingsPanel.xaml @@ -0,0 +1,227 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/PenSettingsPanel.xaml.cs b/Ink Canvas/MainWindow_controls/PenSettingsPanel.xaml.cs new file mode 100644 index 00000000..c2074c53 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/PenSettingsPanel.xaml.cs @@ -0,0 +1,496 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class PenSettingsPanel : UserControl + { + private bool _isSynchronizingControls; + + public static readonly DependencyProperty PenWidthProperty = DependencyProperty.Register( + nameof(PenWidth), typeof(double), typeof(PenSettingsPanel), new PropertyMetadata(5.0, OnPenWidthChanged)); + + public static readonly DependencyProperty PenAlphaProperty = DependencyProperty.Register( + nameof(PenAlpha), typeof(double), typeof(PenSettingsPanel), new PropertyMetadata(255.0, OnPenAlphaChanged)); + + public static readonly DependencyProperty HighlighterWidthProperty = DependencyProperty.Register( + nameof(HighlighterWidth), typeof(double), typeof(PenSettingsPanel), new PropertyMetadata(20.0, OnHighlighterWidthChanged)); + + public static readonly DependencyProperty IsNibModeEnabledProperty = DependencyProperty.Register( + nameof(IsNibModeEnabled), typeof(bool), typeof(PenSettingsPanel), new PropertyMetadata(true, OnIsNibModeEnabledChanged)); + + public static readonly DependencyProperty IsInkFadeEnabledProperty = DependencyProperty.Register( + nameof(IsInkFadeEnabled), typeof(bool), typeof(PenSettingsPanel), new PropertyMetadata(false, OnIsInkFadeEnabledChanged)); + + public static readonly DependencyProperty IsBoardModeProperty = DependencyProperty.Register( + nameof(IsBoardMode), typeof(bool), typeof(PenSettingsPanel), new PropertyMetadata(false)); + + public static readonly DependencyProperty SelectedPenTypeProperty = DependencyProperty.Register( + nameof(SelectedPenType), typeof(int), typeof(PenSettingsPanel), new PropertyMetadata(0, OnSelectedPenTypeChanged)); + + public static readonly RoutedEvent PenTypeChangedEvent = EventManager.RegisterRoutedEvent( + nameof(PenTypeChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public static readonly RoutedEvent PenStyleChangedEvent = EventManager.RegisterRoutedEvent( + nameof(PenStyleChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public static readonly RoutedEvent WidthChangedEvent = EventManager.RegisterRoutedEvent( + nameof(WidthChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public static readonly RoutedEvent AlphaChangedEvent = EventManager.RegisterRoutedEvent( + nameof(AlphaChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public static readonly RoutedEvent NibModeChangedEvent = EventManager.RegisterRoutedEvent( + nameof(NibModeChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public static readonly RoutedEvent InkFadeChangedEvent = EventManager.RegisterRoutedEvent( + nameof(InkFadeChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public static readonly RoutedEvent InkToShapeChangedEvent = EventManager.RegisterRoutedEvent( + nameof(InkToShapeChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public static readonly RoutedEvent BrushModeClickedEvent = EventManager.RegisterRoutedEvent( + nameof(BrushModeClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public static readonly RoutedEvent CloseRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(CloseRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PenSettingsPanel)); + + public double PenWidth + { + get => (double)GetValue(PenWidthProperty); + set => SetValue(PenWidthProperty, value); + } + + public double PenAlpha + { + get => (double)GetValue(PenAlphaProperty); + set => SetValue(PenAlphaProperty, value); + } + + public double HighlighterWidth + { + get => (double)GetValue(HighlighterWidthProperty); + set => SetValue(HighlighterWidthProperty, value); + } + + public bool IsNibModeEnabled + { + get => (bool)GetValue(IsNibModeEnabledProperty); + set => SetValue(IsNibModeEnabledProperty, value); + } + + public bool IsInkFadeEnabled + { + get => (bool)GetValue(IsInkFadeEnabledProperty); + set => SetValue(IsInkFadeEnabledProperty, value); + } + + public bool IsBoardMode + { + get => (bool)GetValue(IsBoardModeProperty); + set => SetValue(IsBoardModeProperty, value); + } + + public int SelectedPenType + { + get => (int)GetValue(SelectedPenTypeProperty); + set => SetValue(SelectedPenTypeProperty, value); + } + + public event RoutedEventHandler PenTypeChanged + { + add => AddHandler(PenTypeChangedEvent, value); + remove => RemoveHandler(PenTypeChangedEvent, value); + } + + public event RoutedEventHandler PenStyleChanged + { + add => AddHandler(PenStyleChangedEvent, value); + remove => RemoveHandler(PenStyleChangedEvent, value); + } + + public event RoutedEventHandler WidthChanged + { + add => AddHandler(WidthChangedEvent, value); + remove => RemoveHandler(WidthChangedEvent, value); + } + + public event RoutedEventHandler AlphaChanged + { + add => AddHandler(AlphaChangedEvent, value); + remove => RemoveHandler(AlphaChangedEvent, value); + } + + public event RoutedEventHandler NibModeChanged + { + add => AddHandler(NibModeChangedEvent, value); + remove => RemoveHandler(NibModeChangedEvent, value); + } + + public event RoutedEventHandler InkFadeChanged + { + add => AddHandler(InkFadeChangedEvent, value); + remove => RemoveHandler(InkFadeChangedEvent, value); + } + + public event RoutedEventHandler InkToShapeChanged + { + add => AddHandler(InkToShapeChangedEvent, value); + remove => RemoveHandler(InkToShapeChangedEvent, value); + } + + public event RoutedEventHandler BrushModeClicked + { + add => AddHandler(BrushModeClickedEvent, value); + remove => RemoveHandler(BrushModeClickedEvent, value); + } + + public event RoutedEventHandler CloseRequested + { + add => AddHandler(CloseRequestedEvent, value); + remove => RemoveHandler(CloseRequestedEvent, value); + } + + public Slider InkWidthSliderControl => InkWidthSlider; + + public Slider InkAlphaSliderControl => InkAlphaSlider; + + public Slider HighlighterWidthSliderControl => HighlighterWidthSlider; + + public FrameworkElement NibModePanel => NibModeSimpleStackPanel; + + public FrameworkElement InkFadePanel => InkFadeControlPanel; + + public int PenStyleSelectedIndex + { + get => ComboBoxPenStyle?.SelectedIndex ?? -1; + set + { + if (ComboBoxPenStyle != null && ComboBoxPenStyle.SelectedIndex != value) + { + SynchronizeControls(() => ComboBoxPenStyle.SelectedIndex = value); + } + } + } + + public bool IsInkToShapeEnabled + { + get => ToggleSwitchEnableInkToShape?.IsOn ?? false; + set + { + if (ToggleSwitchEnableInkToShape != null && ToggleSwitchEnableInkToShape.IsOn != value) + { + SynchronizeControls(() => ToggleSwitchEnableInkToShape.IsOn = value); + } + } + } + + public Visibility NibModePanelVisibility + { + get => NibModeSimpleStackPanel.Visibility; + set => NibModeSimpleStackPanel.Visibility = value; + } + + public Visibility InkFadePanelVisibility + { + get => InkFadeControlPanel.Visibility; + set => InkFadeControlPanel.Visibility = value; + } + + public PenSettingsPanel() + { + InitializeComponent(); + ApplyStateToControls(); + } + + public void SetPenTypeVisualState(int penType) + { + if (SelectedPenType != penType) + { + SelectedPenType = penType; + return; + } + + UpdatePenTypeVisualState(); + } + + public void SetBrushModeActive(bool isActive) + { + if (BrushModeButton == null) + { + return; + } + + if (isActive) + { + BrushModeButton.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); + } + else + { + BrushModeButton.ClearValue(BackgroundProperty); + } + } + + private static void OnPenWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenSettingsPanel panel) + { + panel.ApplyPenWidthToControl((double)e.NewValue); + } + } + + private static void OnPenAlphaChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenSettingsPanel panel) + { + panel.ApplyPenAlphaToControl((double)e.NewValue); + } + } + + private static void OnHighlighterWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenSettingsPanel panel) + { + panel.ApplyHighlighterWidthToControl((double)e.NewValue); + } + } + + private static void OnIsNibModeEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenSettingsPanel panel) + { + panel.ApplyNibModeToControl((bool)e.NewValue); + } + } + + private static void OnIsInkFadeEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenSettingsPanel panel) + { + panel.ApplyInkFadeToControl((bool)e.NewValue); + } + } + + private static void OnSelectedPenTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PenSettingsPanel panel) + { + panel.UpdatePenTypeVisualState(); + } + } + + private void ApplyStateToControls() + { + ApplyPenWidthToControl(PenWidth); + ApplyPenAlphaToControl(PenAlpha); + ApplyHighlighterWidthToControl(HighlighterWidth); + ApplyNibModeToControl(IsNibModeEnabled); + ApplyInkFadeToControl(IsInkFadeEnabled); + UpdatePenTypeVisualState(); + } + + private void ApplyPenWidthToControl(double value) + { + if (InkWidthSlider == null || AreClose(InkWidthSlider.Value, value)) + { + return; + } + + SynchronizeControls(() => InkWidthSlider.Value = value); + } + + private void ApplyPenAlphaToControl(double value) + { + if (InkAlphaSlider == null || AreClose(InkAlphaSlider.Value, value)) + { + return; + } + + SynchronizeControls(() => InkAlphaSlider.Value = value); + } + + private void ApplyHighlighterWidthToControl(double value) + { + if (HighlighterWidthSlider == null || AreClose(HighlighterWidthSlider.Value, value)) + { + return; + } + + SynchronizeControls(() => HighlighterWidthSlider.Value = value); + } + + private void ApplyNibModeToControl(bool value) + { + if (ToggleSwitchEnableNibMode == null || ToggleSwitchEnableNibMode.IsOn == value) + { + return; + } + + SynchronizeControls(() => ToggleSwitchEnableNibMode.IsOn = value); + } + + private void ApplyInkFadeToControl(bool value) + { + if (ToggleSwitchInkFade == null || ToggleSwitchInkFade.IsOn == value) + { + return; + } + + SynchronizeControls(() => ToggleSwitchInkFade.IsOn = value); + } + + private void UpdatePenTypeVisualState() + { + bool isDefaultPen = SelectedPenType != 1; + + DefaultPenPropsPanel.Visibility = isDefaultPen ? Visibility.Visible : Visibility.Collapsed; + HighlighterPenPropsPanel.Visibility = isDefaultPen ? Visibility.Collapsed : Visibility.Visible; + + DefaultPenTabButton.Opacity = isDefaultPen ? 1 : 0.9; + DefaultPenTabButtonText.FontWeight = isDefaultPen ? FontWeights.Bold : FontWeights.Normal; + DefaultPenTabButtonText.FontSize = isDefaultPen ? 9.5 : 9; + DefaultPenTabButtonText.Margin = isDefaultPen ? new Thickness(2, 0.5, 0, 0) : new Thickness(2, 1, 0, 0); + DefaultPenTabButton.Background = isDefaultPen + ? new SolidColorBrush(Color.FromArgb(72, 219, 234, 254)) + : new SolidColorBrush(Colors.Transparent); + DefaultPenTabButtonIndicator.Visibility = isDefaultPen ? Visibility.Visible : Visibility.Collapsed; + + HighlightPenTabButton.Opacity = isDefaultPen ? 0.9 : 1; + HighlightPenTabButtonText.FontWeight = isDefaultPen ? FontWeights.Normal : FontWeights.Bold; + HighlightPenTabButtonText.FontSize = isDefaultPen ? 9 : 9.5; + HighlightPenTabButtonText.Margin = isDefaultPen ? new Thickness(2, 1, 0, 0) : new Thickness(2, 0.5, 0, 0); + HighlightPenTabButton.Background = isDefaultPen + ? new SolidColorBrush(Colors.Transparent) + : new SolidColorBrush(Color.FromArgb(72, 219, 234, 254)); + HighlightPenTabButtonIndicator.Visibility = isDefaultPen ? Visibility.Collapsed : Visibility.Visible; + } + + private void SynchronizeControls(Action action) + { + _isSynchronizingControls = true; + try + { + action(); + } + finally + { + _isSynchronizingControls = false; + } + } + + private static bool AreClose(double left, double right) + { + return Math.Abs(left - right) < 0.001; + } + + private void Border_MouseDown(object sender, MouseButtonEventArgs e) + { + } + + private void CloseBordertools_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(CloseRequestedEvent, this)); + } + + private void SwitchToDefaultPen(object sender, MouseButtonEventArgs e) + { + SelectedPenType = 0; + RaiseEvent(new RoutedEventArgs(PenTypeChangedEvent, this)); + } + + private void SwitchToHighlighterPen(object sender, MouseButtonEventArgs e) + { + SelectedPenType = 1; + RaiseEvent(new RoutedEventArgs(PenTypeChangedEvent, this)); + } + + private void ComboBoxPenStyle_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (_isSynchronizingControls) + { + return; + } + + RaiseEvent(new RoutedEventArgs(PenStyleChangedEvent, this)); + } + + private void ToggleSwitchEnableNibMode_Toggled(object sender, RoutedEventArgs e) + { + IsNibModeEnabled = ToggleSwitchEnableNibMode.IsOn; + + if (_isSynchronizingControls) + { + return; + } + + RaiseEvent(new RoutedEventArgs(NibModeChangedEvent, this)); + } + + private void ToggleSwitchEnableInkToShape_Toggled(object sender, RoutedEventArgs e) + { + if (_isSynchronizingControls) + { + return; + } + + RaiseEvent(new RoutedEventArgs(InkToShapeChangedEvent, this)); + } + + private void ToggleSwitchInkFade_Toggled(object sender, RoutedEventArgs e) + { + IsInkFadeEnabled = ToggleSwitchInkFade.IsOn; + + if (_isSynchronizingControls) + { + return; + } + + RaiseEvent(new RoutedEventArgs(InkFadeChangedEvent, this)); + } + + private void InkWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + PenWidth = InkWidthSlider.Value; + + if (_isSynchronizingControls) + { + return; + } + + RaiseEvent(new RoutedEventArgs(WidthChangedEvent, this)); + } + + private void InkAlphaSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + PenAlpha = InkAlphaSlider.Value; + + if (_isSynchronizingControls) + { + return; + } + + RaiseEvent(new RoutedEventArgs(AlphaChangedEvent, this)); + } + + private void HighlighterWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + HighlighterWidth = HighlighterWidthSlider.Value; + + if (_isSynchronizingControls) + { + return; + } + + RaiseEvent(new RoutedEventArgs(WidthChangedEvent, this)); + } + + private void BrushModeButton_Click(object sender, RoutedEventArgs e) + { + RaiseEvent(new RoutedEventArgs(BrushModeClickedEvent, this)); + } + } +} diff --git a/Ink Canvas/MainWindow_controls/ResourceDictionaryStyles.xaml b/Ink Canvas/MainWindow_controls/ResourceDictionaryStyles.xaml new file mode 100644 index 00000000..fd8a173e --- /dev/null +++ b/Ink Canvas/MainWindow_controls/ResourceDictionaryStyles.xaml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/StrokeSelectionToolbar.xaml b/Ink Canvas/MainWindow_controls/StrokeSelectionToolbar.xaml new file mode 100644 index 00000000..f0b09b36 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/StrokeSelectionToolbar.xaml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_controls/StrokeSelectionToolbar.xaml.cs b/Ink Canvas/MainWindow_controls/StrokeSelectionToolbar.xaml.cs new file mode 100644 index 00000000..e820be66 --- /dev/null +++ b/Ink Canvas/MainWindow_controls/StrokeSelectionToolbar.xaml.cs @@ -0,0 +1,180 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; + +namespace Ink_Canvas.MainWindow_controls +{ + public partial class StrokeSelectionToolbar : UserControl + { + public static readonly DependencyProperty SelectedStrokesProperty = DependencyProperty.Register( + nameof(SelectedStrokes), typeof(object), typeof(StrokeSelectionToolbar), new PropertyMetadata(null)); + + public static new readonly DependencyProperty VisibilityProperty = DependencyProperty.Register( + nameof(Visibility), typeof(Visibility), typeof(StrokeSelectionToolbar), + new FrameworkPropertyMetadata(Visibility.Collapsed, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVisibilityChanged)); + + public static readonly RoutedEvent CloneRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(CloneRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(StrokeSelectionToolbar)); + + public static readonly RoutedEvent CloneToNewBoardRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(CloneToNewBoardRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(StrokeSelectionToolbar)); + + public static readonly RoutedEvent DeleteRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(DeleteRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(StrokeSelectionToolbar)); + + public static readonly RoutedEvent RotateRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(RotateRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(StrokeSelectionToolbar)); + + public static readonly RoutedEvent FlipRequestedEvent = EventManager.RegisterRoutedEvent( + nameof(FlipRequested), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(StrokeSelectionToolbar)); + + public static readonly RoutedEvent WidthChangedEvent = EventManager.RegisterRoutedEvent( + nameof(WidthChanged), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(StrokeSelectionToolbar)); + + // 用于向后兼容 - 暴露内部 Border 以便 partial class 访问 + public Border BorderSelectionControl => BorderStrokeSelectionControl; + + public object SelectedStrokes + { + get => GetValue(SelectedStrokesProperty); + set => SetValue(SelectedStrokesProperty, value); + } + + public new Visibility Visibility + { + get => (Visibility)GetValue(VisibilityProperty); + set => SetValue(VisibilityProperty, value); + } + + // 暴露 Margin 属性以便 MW_SelectionGestures.cs 设置位置 + public Thickness ControlMargin + { + get => BorderStrokeSelectionControl.Margin; + set => BorderStrokeSelectionControl.Margin = value; + } + + // 暴露 Child 属性以便 MW_AutoTheme.cs 访问 + public UIElement ControlChild + { + get => BorderStrokeSelectionControl.Child; + } + + // 暴露 InvalidateVisual 方法以便 MW_AutoTheme.cs 调用 + public void InvalidateVisualOnControl() + { + BorderStrokeSelectionControl.InvalidateVisual(); + } + + // 暴露克隆按钮背景设置方法 + public void SetCloneButtonBackground(Brush brush) + { + BorderStrokeSelectionClone.Background = brush; + } + + public event RoutedEventHandler CloneRequested + { + add => AddHandler(CloneRequestedEvent, value); + remove => RemoveHandler(CloneRequestedEvent, value); + } + + public event RoutedEventHandler CloneToNewBoardRequested + { + add => AddHandler(CloneToNewBoardRequestedEvent, value); + remove => RemoveHandler(CloneToNewBoardRequestedEvent, value); + } + + public event RoutedEventHandler DeleteRequested + { + add => AddHandler(DeleteRequestedEvent, value); + remove => RemoveHandler(DeleteRequestedEvent, value); + } + + public event RoutedEventHandler RotateRequested + { + add => AddHandler(RotateRequestedEvent, value); + remove => RemoveHandler(RotateRequestedEvent, value); + } + + public event RoutedEventHandler FlipRequested + { + add => AddHandler(FlipRequestedEvent, value); + remove => RemoveHandler(FlipRequestedEvent, value); + } + + public event RoutedEventHandler WidthChanged + { + add => AddHandler(WidthChangedEvent, value); + remove => RemoveHandler(WidthChangedEvent, value); + } + + public StrokeSelectionToolbar() + { + InitializeComponent(); + } + + private static void OnVisibilityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is StrokeSelectionToolbar toolbar) + { + toolbar.BorderStrokeSelectionControl.Visibility = (Visibility)e.NewValue; + } + } + + private void Border_MouseDown(object sender, MouseButtonEventArgs e) + { + // 空处理 - 让事件冒泡以便 MW_SelectionGestures.cs 处理 lastBorderMouseDownObject + } + + private void BorderStrokeSelectionClone_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(CloneRequestedEvent, this)); + } + + private void BorderStrokeSelectionCloneToNewBoard_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(CloneToNewBoardRequestedEvent, this)); + } + + private void BorderStrokeSelectionDelete_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(DeleteRequestedEvent, this)); + } + + private void ImageRotate45_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(RotateRequestedEvent, this)); + } + + private void ImageRotate90_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(RotateRequestedEvent, this)); + } + + private void ImageFlipHorizontal_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(FlipRequestedEvent, this)); + } + + private void ImageFlipVertical_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(FlipRequestedEvent, this)); + } + + private void GridPenWidthDecrease_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(WidthChangedEvent, this)); + } + + private void GridPenWidthIncrease_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(WidthChangedEvent, this)); + } + + private void GridPenWidthRestore_MouseUp(object sender, MouseButtonEventArgs e) + { + RaiseEvent(new RoutedEventArgs(WidthChangedEvent, this)); + } + } +} diff --git a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs index 0d7de4fe..e8ce63ce 100644 --- a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs +++ b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs @@ -148,8 +148,8 @@ await Dispatcher.InvokeAsync(() => await Dispatcher.InvokeAsync(() => { - LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; - RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; + BorderPPTNavBottomLeft.Visibility = Visibility.Collapsed; + BorderPPTNavBottomRight.Visibility = Visibility.Collapsed; LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; GridForFloatingBarDraging.Visibility = Visibility.Collapsed; @@ -415,16 +415,16 @@ await Dispatcher.InvokeAsync(() => { var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString(); var dopsc = dops.ToCharArray(); - if (dopsc[0] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftBottomPanelForPPTNavigation); - if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation); + if (dopsc[0] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(BorderPPTNavBottomLeft); + if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(BorderPPTNavBottomRight); if (dopsc[2] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation); if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation); } else { // 如果条件不满足,确保隐藏翻页按钮 - LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; - RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; + BorderPPTNavBottomLeft.Visibility = Visibility.Collapsed; + BorderPPTNavBottomRight.Visibility = Visibility.Collapsed; LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; } diff --git a/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs b/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs index 06131fc5..03923728 100644 --- a/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs +++ b/Ink Canvas/MainWindow_cs/MW_AutoTheme.cs @@ -443,11 +443,9 @@ private void RefreshStrokeSelectionIcons() { if (BorderStrokeSelectionControl != null) { - // 强制刷新墨迹选中栏的视觉状态 - BorderStrokeSelectionControl.InvalidateVisual(); + BorderStrokeSelectionControl.InvalidateVisualOnControl(); - // 刷新墨迹选中栏内的所有图标 - var viewbox = BorderStrokeSelectionControl.Child as Viewbox; + var viewbox = BorderStrokeSelectionControl.ControlChild as Viewbox; if (viewbox?.Child is ui.SimpleStackPanel stackPanel) { RefreshStrokeSelectionIconsRecursive(stackPanel); @@ -501,11 +499,9 @@ private void RefreshImageSelectionIcons() { if (BorderImageSelectionControl != null) { - // 强制刷新图片选中栏的视觉状态 - BorderImageSelectionControl.InvalidateVisual(); + BorderImageSelectionControl.InvalidateVisualOnControl(); - // 刷新图片选中栏内的所有图标 - var viewbox = BorderImageSelectionControl.Child as Viewbox; + var viewbox = BorderImageSelectionControl.ControlChild as Viewbox; if (viewbox?.Child is ui.SimpleStackPanel stackPanel) { RefreshImageSelectionIconsRecursive(stackPanel); diff --git a/Ink Canvas/MainWindow_cs/MW_BoardCanvasController.cs b/Ink Canvas/MainWindow_cs/MW_BoardCanvasController.cs new file mode 100644 index 00000000..40f05ae7 --- /dev/null +++ b/Ink Canvas/MainWindow_cs/MW_BoardCanvasController.cs @@ -0,0 +1,151 @@ +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Ink; +using System.Windows.Media; + +namespace Ink_Canvas +{ + public partial class MainWindow + { + private IBoardCanvasController _boardCanvasController; + + public IBoardCanvasController BoardCanvasController => _boardCanvasController; + + private void InitializeBoardCanvasController() + { + if (_boardCanvasController == null) + { + _boardCanvasController = new MainWindowBoardCanvasController(this); + } + } + } + + internal sealed class MainWindowBoardCanvasController : IBoardCanvasController + { + private readonly MainWindow _window; + private InkCanvasEditingMode _lastEditingMode; + + public MainWindowBoardCanvasController(MainWindow window) + { + _window = window; + _lastEditingMode = _window.inkCanvas.EditingMode; + _window.inkCanvas.EditingModeChanged += InkCanvasOnEditingModeChanged; + _window.inkCanvas.StrokeCollected += InkCanvasOnStrokeCollected; + } + + public StrokeCollection Strokes => _window.inkCanvas.Strokes; + + public System.Windows.Visibility Visibility + { + get => _window.inkCanvas.Visibility; + set => _window.inkCanvas.Visibility = value; + } + + public bool IsHitTestVisible + { + get => _window.inkCanvas.IsHitTestVisible; + set => _window.inkCanvas.IsHitTestVisible = value; + } + + public bool IsManipulationEnabled + { + get => _window.inkCanvas.IsManipulationEnabled; + set => _window.inkCanvas.IsManipulationEnabled = value; + } + + public InkCanvasEditingMode EditingMode + { + get => _window.inkCanvas.EditingMode; + set + { + if (_window.inkCanvas.EditingMode == value) + { + return; + } + + var oldMode = _window.inkCanvas.EditingMode; + _window.inkCanvas.EditingMode = value; + EditingModeChanged?.Invoke(this, new EditingModeChangedEventArgs { OldMode = oldMode, NewMode = value }); + } + } + + public void SetInkMode() => EditingMode = InkCanvasEditingMode.Ink; + + public void SetEraserByPointMode() => EditingMode = InkCanvasEditingMode.EraseByPoint; + + public void SetEraserByStrokeMode() => EditingMode = InkCanvasEditingMode.EraseByStroke; + + public void SetSelectMode() => EditingMode = InkCanvasEditingMode.Select; + + public Color StrokeColor + { + get => _window.inkCanvas.DefaultDrawingAttributes.Color; + set + { + if (_window.inkCanvas.DefaultDrawingAttributes.Color == value) + { + return; + } + + var oldColor = _window.inkCanvas.DefaultDrawingAttributes.Color; + _window.inkCanvas.DefaultDrawingAttributes.Color = value; + StrokeColorChanged?.Invoke(this, new StrokeColorChangedEventArgs { OldColor = oldColor, NewColor = value }); + } + } + + public double StrokeWidth + { + get => _window.inkCanvas.DefaultDrawingAttributes.Width; + set => _window.inkCanvas.DefaultDrawingAttributes.Width = value; + } + + public double HighlighterWidth + { + get => _window.inkCanvas.DefaultDrawingAttributes.Height; + set => _window.inkCanvas.DefaultDrawingAttributes.Height = value; + } + + public bool IsHighlighterMode + { + get => _window.inkCanvas.DefaultDrawingAttributes.IsHighlighter; + set => _window.inkCanvas.DefaultDrawingAttributes.IsHighlighter = value; + } + + public StylusShape EraserShape + { + get => _window.inkCanvas.EraserShape; + set => _window.inkCanvas.EraserShape = value; + } + + public StrokeCollection GetSelectedStrokes() => _window.inkCanvas.GetSelectedStrokes(); + + public void Select(StrokeCollection strokes) => _window.inkCanvas.Select(strokes); + + public void ClearSelection() => _window.inkCanvas.Select(new StrokeCollection()); + + public event EventHandler EditingModeChanged; + + public event EventHandler StrokeColorChanged; + + public event EventHandler StrokeCollected; + + private void InkCanvasOnEditingModeChanged(object sender, RoutedEventArgs e) + { + var newMode = _window.inkCanvas.EditingMode; + var oldMode = _lastEditingMode; + _lastEditingMode = newMode; + EditingModeChanged?.Invoke(this, new EditingModeChangedEventArgs { OldMode = oldMode, NewMode = newMode }); + } + + private void InkCanvasOnStrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e) + { + if (e?.Stroke == null) + { + return; + } + + StrokeCollected?.Invoke(this, new StrokeEventArgs { Strokes = new StrokeCollection { e.Stroke } }); + } + } +} diff --git a/Ink Canvas/MainWindow_cs/MW_Colors.cs b/Ink Canvas/MainWindow_cs/MW_Colors.cs index 133d23c9..8eff8ac2 100644 --- a/Ink Canvas/MainWindow_cs/MW_Colors.cs +++ b/Ink Canvas/MainWindow_cs/MW_Colors.cs @@ -64,7 +64,7 @@ private void ColorSwitchCheck(bool hidePanels = true) foreach (var stroke in strokes) try { - stroke.DrawingAttributes.Color = inkCanvas.DefaultDrawingAttributes.Color; + stroke.DrawingAttributes.Color = BoardCanvasController.StrokeColor; } catch { @@ -176,7 +176,7 @@ private void CheckColorTheme(bool changeColorTheme = false) inkColor = lastBoardInkColor; } - double alpha = inkCanvas.DefaultDrawingAttributes.Color.A; + double alpha = BoardCanvasController.StrokeColor.A; if (penType == 0 && Settings?.Canvas != null) { double settingAlpha = Settings.Canvas.InkAlpha; @@ -189,298 +189,112 @@ private void CheckColorTheme(bool changeColorTheme = false) if (inkColor == 0) { // Black - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 0, 0, 0); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 0, 0, 0); } else if (inkColor == 5) { // White - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 255, 255, 255); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 255, 255, 255); } else if (isUselightThemeColor) { if (inkColor == 1) // Red - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 239, 68, 68); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 239, 68, 68); else if (inkColor == 2) // Green - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 34, 197, 94); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 34, 197, 94); else if (inkColor == 3) // Blue - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 59, 130, 246); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 59, 130, 246); else if (inkColor == 4) // Yellow - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 250, 204, 21); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 250, 204, 21); else if (inkColor == 6) // Pink - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 236, 72, 153); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 236, 72, 153); else if (inkColor == 7) // Teal (亮色) - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 20, 184, 166); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 20, 184, 166); else if (inkColor == 8) // Orange (亮色) - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 249, 115, 22); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 249, 115, 22); } else { if (inkColor == 1) // Red - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 220, 38, 38); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 220, 38, 38); else if (inkColor == 2) // Green - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 22, 163, 74); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 22, 163, 74); else if (inkColor == 3) // Blue - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 37, 99, 235); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 37, 99, 235); else if (inkColor == 4) // Yellow - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 234, 179, 8); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 234, 179, 8); else if (inkColor == 6) // Pink ( Purple ) - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 147, 51, 234); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 147, 51, 234); else if (inkColor == 7) // Teal (暗色) - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 13, 148, 136); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 13, 148, 136); else if (inkColor == 8) // Orange (暗色) - inkCanvas.DefaultDrawingAttributes.Color = Color.FromArgb((byte)alpha, 234, 88, 12); + BoardCanvasController.StrokeColor = Color.FromArgb((byte)alpha, 234, 88, 12); } } else if (penType == 1) { if (highlighterColor == 100) // Black - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(0, 0, 0); + BoardCanvasController.StrokeColor = Color.FromRgb(0, 0, 0); else if (highlighterColor == 101) // White - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(250, 250, 250); + BoardCanvasController.StrokeColor = Color.FromRgb(250, 250, 250); else if (highlighterColor == 102) // Red - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(239, 68, 68); + BoardCanvasController.StrokeColor = Color.FromRgb(239, 68, 68); else if (highlighterColor == 103) // Yellow - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(253, 224, 71); + BoardCanvasController.StrokeColor = Color.FromRgb(253, 224, 71); else if (highlighterColor == 104) // Green - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(74, 222, 128); + BoardCanvasController.StrokeColor = Color.FromRgb(74, 222, 128); else if (highlighterColor == 105) // Zinc - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(113, 113, 122); + BoardCanvasController.StrokeColor = Color.FromRgb(113, 113, 122); else if (highlighterColor == 106) // Blue - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(59, 130, 246); + BoardCanvasController.StrokeColor = Color.FromRgb(59, 130, 246); else if (highlighterColor == 107) // Purple - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(168, 85, 247); + BoardCanvasController.StrokeColor = Color.FromRgb(168, 85, 247); else if (highlighterColor == 108) // teal - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(45, 212, 191); + BoardCanvasController.StrokeColor = Color.FromRgb(45, 212, 191); else if (highlighterColor == 109) // Orange - inkCanvas.DefaultDrawingAttributes.Color = Color.FromRgb(249, 115, 22); + BoardCanvasController.StrokeColor = Color.FromRgb(249, 115, 22); } - if (isUselightThemeColor) - { - // 亮系 - // 亮色的红色 - BorderPenColorRed.Background = new SolidColorBrush(Color.FromRgb(239, 68, 68)); - BoardBorderPenColorRed.Background = new SolidColorBrush(Color.FromRgb(239, 68, 68)); - // 亮色的绿色 - BorderPenColorGreen.Background = new SolidColorBrush(Color.FromRgb(34, 197, 94)); - BoardBorderPenColorGreen.Background = new SolidColorBrush(Color.FromRgb(34, 197, 94)); - // 亮色的蓝色 - BorderPenColorBlue.Background = new SolidColorBrush(Color.FromRgb(59, 130, 246)); - BoardBorderPenColorBlue.Background = new SolidColorBrush(Color.FromRgb(59, 130, 246)); - // 亮色的黄色 - BorderPenColorYellow.Background = new SolidColorBrush(Color.FromRgb(250, 204, 21)); - BoardBorderPenColorYellow.Background = new SolidColorBrush(Color.FromRgb(250, 204, 21)); - // 亮色的粉色 - BorderPenColorPink.Background = new SolidColorBrush(Color.FromRgb(236, 72, 153)); - BoardBorderPenColorPink.Background = new SolidColorBrush(Color.FromRgb(236, 72, 153)); - // 亮色的Teal - BorderPenColorTeal.Background = new SolidColorBrush(Color.FromRgb(20, 184, 166)); - BoardBorderPenColorTeal.Background = new SolidColorBrush(Color.FromRgb(20, 184, 166)); - // 亮色的Orange - BorderPenColorOrange.Background = new SolidColorBrush(Color.FromRgb(249, 115, 22)); - BoardBorderPenColorOrange.Background = new SolidColorBrush(Color.FromRgb(249, 115, 22)); - - var newImageSource = new BitmapImage(); - newImageSource.BeginInit(); - newImageSource.UriSource = new Uri("/Resources/Icons-Fluent/ic_fluent_weather_moon_24_regular.png", - UriKind.RelativeOrAbsolute); - newImageSource.EndInit(); - ColorThemeSwitchIcon.Source = newImageSource; - BoardColorThemeSwitchIcon.Source = newImageSource; - - ColorThemeSwitchTextBlock.Text = "暗系"; - BoardColorThemeSwitchTextBlock.Text = "暗系"; - } - else - { - // 暗系 - // 暗色的红色 - BorderPenColorRed.Background = new SolidColorBrush(Color.FromRgb(220, 38, 38)); - BoardBorderPenColorRed.Background = new SolidColorBrush(Color.FromRgb(220, 38, 38)); - // 暗色的绿色 - BorderPenColorGreen.Background = new SolidColorBrush(Color.FromRgb(22, 163, 74)); - BoardBorderPenColorGreen.Background = new SolidColorBrush(Color.FromRgb(22, 163, 74)); - // 暗色的蓝色 - BorderPenColorBlue.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); - BoardBorderPenColorBlue.Background = new SolidColorBrush(Color.FromRgb(37, 99, 235)); - // 暗色的黄色 - BorderPenColorYellow.Background = new SolidColorBrush(Color.FromRgb(234, 179, 8)); - BoardBorderPenColorYellow.Background = new SolidColorBrush(Color.FromRgb(234, 179, 8)); - // 暗色的紫色对应亮色的粉色 - BorderPenColorPink.Background = new SolidColorBrush(Color.FromRgb(147, 51, 234)); - BoardBorderPenColorPink.Background = new SolidColorBrush(Color.FromRgb(147, 51, 234)); - // 暗色的Teal - BorderPenColorTeal.Background = new SolidColorBrush(Color.FromRgb(13, 148, 136)); - BoardBorderPenColorTeal.Background = new SolidColorBrush(Color.FromRgb(13, 148, 136)); - // 暗色的Orange - BorderPenColorOrange.Background = new SolidColorBrush(Color.FromRgb(234, 88, 12)); - BoardBorderPenColorOrange.Background = new SolidColorBrush(Color.FromRgb(234, 88, 12)); - - var newImageSource = new BitmapImage(); - newImageSource.BeginInit(); - newImageSource.UriSource = new Uri("/Resources/Icons-Fluent/ic_fluent_weather_sunny_24_regular.png", - UriKind.RelativeOrAbsolute); - newImageSource.EndInit(); - ColorThemeSwitchIcon.Source = newImageSource; - BoardColorThemeSwitchIcon.Source = newImageSource; - - ColorThemeSwitchTextBlock.Text = "亮系"; - BoardColorThemeSwitchTextBlock.Text = "亮系"; - } - - // 改变选中提示 - ViewboxBtnColorBlackContent.Visibility = Visibility.Collapsed; - ViewboxBtnColorBlueContent.Visibility = Visibility.Collapsed; - ViewboxBtnColorGreenContent.Visibility = Visibility.Collapsed; - ViewboxBtnColorRedContent.Visibility = Visibility.Collapsed; - ViewboxBtnColorYellowContent.Visibility = Visibility.Collapsed; - ViewboxBtnColorWhiteContent.Visibility = Visibility.Collapsed; - ViewboxBtnColorPinkContent.Visibility = Visibility.Collapsed; - ViewboxBtnColorTealContent.Visibility = Visibility.Collapsed; - ViewboxBtnColorOrangeContent.Visibility = Visibility.Collapsed; - - BoardViewboxBtnColorBlackContent.Visibility = Visibility.Collapsed; - BoardViewboxBtnColorBlueContent.Visibility = Visibility.Collapsed; - BoardViewboxBtnColorGreenContent.Visibility = Visibility.Collapsed; - BoardViewboxBtnColorRedContent.Visibility = Visibility.Collapsed; - BoardViewboxBtnColorYellowContent.Visibility = Visibility.Collapsed; - BoardViewboxBtnColorWhiteContent.Visibility = Visibility.Collapsed; - BoardViewboxBtnColorPinkContent.Visibility = Visibility.Collapsed; - BoardViewboxBtnColorTealContent.Visibility = Visibility.Collapsed; - BoardViewboxBtnColorOrangeContent.Visibility = Visibility.Collapsed; - - HighlighterPenViewboxBtnColorBlackContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorBlueContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorGreenContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorOrangeContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorPurpleContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorRedContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorTealContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorWhiteContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorYellowContent.Visibility = Visibility.Collapsed; - HighlighterPenViewboxBtnColorZincContent.Visibility = Visibility.Collapsed; - - BoardHighlighterPenViewboxBtnColorBlackContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorBlueContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorGreenContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorOrangeContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorPurpleContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorRedContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorTealContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorWhiteContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorYellowContent.Visibility = Visibility.Collapsed; - BoardHighlighterPenViewboxBtnColorZincContent.Visibility = Visibility.Collapsed; - - switch (inkColor) - { - case 0: - ViewboxBtnColorBlackContent.Visibility = Visibility.Visible; - BoardViewboxBtnColorBlackContent.Visibility = Visibility.Visible; - break; - case 1: - ViewboxBtnColorRedContent.Visibility = Visibility.Visible; - BoardViewboxBtnColorRedContent.Visibility = Visibility.Visible; - break; - case 2: - ViewboxBtnColorGreenContent.Visibility = Visibility.Visible; - BoardViewboxBtnColorGreenContent.Visibility = Visibility.Visible; - break; - case 3: - ViewboxBtnColorBlueContent.Visibility = Visibility.Visible; - BoardViewboxBtnColorBlueContent.Visibility = Visibility.Visible; - break; - case 4: - ViewboxBtnColorYellowContent.Visibility = Visibility.Visible; - BoardViewboxBtnColorYellowContent.Visibility = Visibility.Visible; - break; - case 5: - ViewboxBtnColorWhiteContent.Visibility = Visibility.Visible; - BoardViewboxBtnColorWhiteContent.Visibility = Visibility.Visible; - break; - case 6: - ViewboxBtnColorPinkContent.Visibility = Visibility.Visible; - BoardViewboxBtnColorPinkContent.Visibility = Visibility.Visible; - break; - case 7: - ViewboxBtnColorTealContent.Visibility = Visibility.Visible; - break; - case 8: - ViewboxBtnColorOrangeContent.Visibility = Visibility.Visible; - break; - } + var penPalette = BorderPenColorPaletteControl as MainWindow_controls.PenColorPalette; + var boardPenPalette = BoardBorderPenColorPaletteControl as MainWindow_controls.PenColorPalette; + penPalette?.SetUseLightThemeColors(isUselightThemeColor); + boardPenPalette?.SetUseLightThemeColors(isUselightThemeColor); + penPalette?.SetSelectedColorCode(inkColor); + boardPenPalette?.SetSelectedColorCode(inkColor); - switch (highlighterColor) - { - case 100: - HighlighterPenViewboxBtnColorBlackContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorBlackContent.Visibility = Visibility.Visible; - break; - case 101: - HighlighterPenViewboxBtnColorWhiteContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorWhiteContent.Visibility = Visibility.Visible; - break; - case 102: - HighlighterPenViewboxBtnColorRedContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorRedContent.Visibility = Visibility.Visible; - break; - case 103: - HighlighterPenViewboxBtnColorYellowContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorYellowContent.Visibility = Visibility.Visible; - break; - case 104: - HighlighterPenViewboxBtnColorGreenContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorGreenContent.Visibility = Visibility.Visible; - break; - case 105: - HighlighterPenViewboxBtnColorZincContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorZincContent.Visibility = Visibility.Visible; - break; - case 106: - HighlighterPenViewboxBtnColorBlueContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorBlueContent.Visibility = Visibility.Visible; - break; - case 107: - HighlighterPenViewboxBtnColorPurpleContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorPurpleContent.Visibility = Visibility.Visible; - break; - case 108: - HighlighterPenViewboxBtnColorTealContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorTealContent.Visibility = Visibility.Visible; - break; - case 109: - HighlighterPenViewboxBtnColorOrangeContent.Visibility = Visibility.Visible; - BoardHighlighterPenViewboxBtnColorOrangeContent.Visibility = Visibility.Visible; - break; - } + var highlighterPalette = (object)HighlighterPenColorsPanel as MainWindow_controls.HighlighterColorPalette; + var boardHighlighterPalette = (object)BoardHighlighterPenColorsPanel as MainWindow_controls.HighlighterColorPalette; + highlighterPalette?.SetSelectedColorCode(highlighterColor); + boardHighlighterPalette?.SetSelectedColorCode(highlighterColor); // 更新快捷调色盘选择指示器 if (penType == 0) { - UpdateQuickColorPaletteIndicator(inkCanvas.DefaultDrawingAttributes.Color); + UpdateQuickColorPaletteIndicator(BoardCanvasController.StrokeColor); } } @@ -520,39 +334,13 @@ private async void CheckPenTypeUIState() { if (penType == 0) { - DefaultPenPropsPanel.Visibility = Visibility.Visible; - DefaultPenColorsPanel.Visibility = Visibility.Visible; + BorderPenSettingsControl?.SetPenTypeVisualState(0); + BoardPenSettingsControl?.SetPenTypeVisualState(0); + BorderPenColorPaletteControl.Visibility = Visibility.Visible; HighlighterPenColorsPanel.Visibility = Visibility.Collapsed; - HighlighterPenPropsPanel.Visibility = Visibility.Collapsed; - DefaultPenTabButton.Opacity = 1; - DefaultPenTabButtonText.FontWeight = FontWeights.Bold; - DefaultPenTabButtonText.Margin = new Thickness(2, 0.5, 0, 0); - DefaultPenTabButtonText.FontSize = 9.5; - DefaultPenTabButton.Background = new SolidColorBrush(Color.FromArgb(72, 219, 234, 254)); - DefaultPenTabButtonIndicator.Visibility = Visibility.Visible; - HighlightPenTabButton.Opacity = 0.9; - HighlightPenTabButtonText.FontWeight = FontWeights.Normal; - HighlightPenTabButtonText.FontSize = 9; - HighlightPenTabButtonText.Margin = new Thickness(2, 1, 0, 0); - HighlightPenTabButton.Background = new SolidColorBrush(Colors.Transparent); - HighlightPenTabButtonIndicator.Visibility = Visibility.Collapsed; - - BoardDefaultPenPropsPanel.Visibility = Visibility.Visible; - BoardDefaultPenColorsPanel.Visibility = Visibility.Visible; + + BoardBorderPenColorPaletteControl.Visibility = Visibility.Visible; BoardHighlighterPenColorsPanel.Visibility = Visibility.Collapsed; - BoardHighlighterPenPropsPanel.Visibility = Visibility.Collapsed; - BoardDefaultPenTabButton.Opacity = 1; - BoardDefaultPenTabButtonText.FontWeight = FontWeights.Bold; - BoardDefaultPenTabButtonText.Margin = new Thickness(2, 0.5, 0, 0); - BoardDefaultPenTabButtonText.FontSize = 9.5; - BoardDefaultPenTabButton.Background = new SolidColorBrush(Color.FromArgb(72, 219, 234, 254)); - BoardDefaultPenTabButtonIndicator.Visibility = Visibility.Visible; - BoardHighlightPenTabButton.Opacity = 0.9; - BoardHighlightPenTabButtonText.FontWeight = FontWeights.Normal; - BoardHighlightPenTabButtonText.FontSize = 9; - BoardHighlightPenTabButtonText.Margin = new Thickness(2, 1, 0, 0); - BoardHighlightPenTabButton.Background = new SolidColorBrush(Colors.Transparent); - BoardHighlightPenTabButtonIndicator.Visibility = Visibility.Collapsed; // PenPalette.Margin = new Thickness(-160, -200, -33, 32); await Dispatcher.InvokeAsync(() => @@ -588,39 +376,13 @@ await Dispatcher.InvokeAsync(() => } else if (penType == 1) { - DefaultPenPropsPanel.Visibility = Visibility.Collapsed; - DefaultPenColorsPanel.Visibility = Visibility.Collapsed; + BorderPenSettingsControl?.SetPenTypeVisualState(1); + BoardPenSettingsControl?.SetPenTypeVisualState(1); + BorderPenColorPaletteControl.Visibility = Visibility.Collapsed; HighlighterPenColorsPanel.Visibility = Visibility.Visible; - HighlighterPenPropsPanel.Visibility = Visibility.Visible; - DefaultPenTabButton.Opacity = 0.9; - DefaultPenTabButtonText.FontWeight = FontWeights.Normal; - DefaultPenTabButtonText.FontSize = 9; - DefaultPenTabButtonText.Margin = new Thickness(2, 1, 0, 0); - DefaultPenTabButton.Background = new SolidColorBrush(Colors.Transparent); - DefaultPenTabButtonIndicator.Visibility = Visibility.Collapsed; - HighlightPenTabButton.Opacity = 1; - HighlightPenTabButtonText.FontWeight = FontWeights.Bold; - HighlightPenTabButtonText.FontSize = 9.5; - HighlightPenTabButtonText.Margin = new Thickness(2, 0.5, 0, 0); - HighlightPenTabButton.Background = new SolidColorBrush(Color.FromArgb(72, 219, 234, 254)); - HighlightPenTabButtonIndicator.Visibility = Visibility.Visible; - - BoardDefaultPenPropsPanel.Visibility = Visibility.Collapsed; - BoardDefaultPenColorsPanel.Visibility = Visibility.Collapsed; + + BoardBorderPenColorPaletteControl.Visibility = Visibility.Collapsed; BoardHighlighterPenColorsPanel.Visibility = Visibility.Visible; - BoardHighlighterPenPropsPanel.Visibility = Visibility.Visible; - BoardDefaultPenTabButton.Opacity = 0.9; - BoardDefaultPenTabButtonText.FontWeight = FontWeights.Normal; - BoardDefaultPenTabButtonText.FontSize = 9; - BoardDefaultPenTabButtonText.Margin = new Thickness(2, 1, 0, 0); - BoardDefaultPenTabButton.Background = new SolidColorBrush(Colors.Transparent); - BoardDefaultPenTabButtonIndicator.Visibility = Visibility.Collapsed; - BoardHighlightPenTabButton.Opacity = 1; - BoardHighlightPenTabButtonText.FontWeight = FontWeights.Bold; - BoardHighlightPenTabButtonText.FontSize = 9.5; - BoardHighlightPenTabButtonText.Margin = new Thickness(2, 0.5, 0, 0); - BoardHighlightPenTabButton.Background = new SolidColorBrush(Color.FromArgb(72, 219, 234, 254)); - BoardHighlightPenTabButtonIndicator.Visibility = Visibility.Visible; // PenPalette.Margin = new Thickness(-160, -157, -33, 32); await Dispatcher.InvokeAsync(() => @@ -932,6 +694,32 @@ private void BtnHighlighterColorOrange_Click(object sender, RoutedEventArgs e) ColorSwitchCheck(); } + private void HighlighterColorPalette_ColorSelected(object sender, RoutedEventArgs e) + { + var palette = sender as MainWindow_controls.HighlighterColorPalette; + if (palette == null) + { + return; + } + + CheckLastColor(palette.SelectedColorCode, true); + penType = 1; + CheckPenTypeUIState(); + ColorSwitchCheck(); + } + + private void PenColorPalette_ColorSelected(object sender, RoutedEventArgs e) + { + var palette = sender as MainWindow_controls.PenColorPalette; + if (palette == null) + { + return; + } + + CheckLastColor(palette.SelectedColorCode); + ColorSwitchCheck(); + } + /// /// 将字符串转换为颜色对象 /// @@ -970,4 +758,4 @@ private static byte toByte(char c) return b; } } -} \ No newline at end of file +} diff --git a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs index e91bcb73..0349acf5 100644 --- a/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs +++ b/Ink Canvas/MainWindow_cs/MW_ElementsControls.cs @@ -1556,7 +1556,10 @@ private void UpdateImageSelectionToolbarPosition(FrameworkElement element) toolbarTop = Math.Max(0, Math.Min(toolbarTop, maxTop)); // 设置工具栏位置 - BorderImageSelectionControl.Margin = new Thickness(toolbarLeft, toolbarTop, 0, 0); + if ((object)BorderImageSelectionControl is MainWindow_controls.ImageSelectionToolbar imageSelectionToolbar) + { + imageSelectionToolbar.ControlMargin = new Thickness(toolbarLeft, toolbarTop, 0, 0); + } var pdfTarget = GetPdfSidebarTargetElement(); if (pdfTarget != null && BorderPdfPageSidebar != null && BorderPdfPageSidebar.Visibility == Visibility.Visible) @@ -2431,33 +2434,10 @@ private void UpdateImageResizeHandlesPosition(Rect elementBounds) { if (ImageResizeHandlesCanvas == null) return; - ImageResizeHandlesCanvas.Margin = new Thickness(elementBounds.Left, elementBounds.Top, 0, 0); - - // 四个角控制点 - System.Windows.Controls.Canvas.SetLeft(ImageTopLeftHandle, -4); - System.Windows.Controls.Canvas.SetTop(ImageTopLeftHandle, -4); - - System.Windows.Controls.Canvas.SetLeft(ImageTopRightHandle, elementBounds.Width - 4); - System.Windows.Controls.Canvas.SetTop(ImageTopRightHandle, -4); - - System.Windows.Controls.Canvas.SetLeft(ImageBottomLeftHandle, -4); - System.Windows.Controls.Canvas.SetTop(ImageBottomLeftHandle, elementBounds.Height - 4); - - System.Windows.Controls.Canvas.SetLeft(ImageBottomRightHandle, elementBounds.Width - 4); - System.Windows.Controls.Canvas.SetTop(ImageBottomRightHandle, elementBounds.Height - 4); - - // 四个边控制点 - System.Windows.Controls.Canvas.SetLeft(ImageTopHandle, elementBounds.Width / 2 - 4); - System.Windows.Controls.Canvas.SetTop(ImageTopHandle, -4); - - System.Windows.Controls.Canvas.SetLeft(ImageBottomHandle, elementBounds.Width / 2 - 4); - System.Windows.Controls.Canvas.SetTop(ImageBottomHandle, elementBounds.Height - 4); - - System.Windows.Controls.Canvas.SetLeft(ImageLeftHandle, -4); - System.Windows.Controls.Canvas.SetTop(ImageLeftHandle, elementBounds.Height / 2 - 4); - - System.Windows.Controls.Canvas.SetLeft(ImageRightHandle, elementBounds.Width - 4); - System.Windows.Controls.Canvas.SetTop(ImageRightHandle, elementBounds.Height / 2 - 4); + if ((object)ImageResizeHandlesCanvas is MainWindow_controls.ImageResizeHandles resizeHandles) + { + resizeHandles.UpdateHandlePositions(elementBounds); + } } catch (Exception ex) { @@ -2470,7 +2450,7 @@ private void ImageResizeHandle_MouseLeftButtonDown(object sender, MouseButtonEve { try { - if (IsBitmapLikeCanvasElement(currentSelectedElement) && sender is Ellipse ellipse) + if (IsBitmapLikeCanvasElement(currentSelectedElement) && e.OriginalSource is Ellipse ellipse) { isResizingImage = true; imageResizeStartPoint = e.GetPosition(inkCanvas); @@ -2494,7 +2474,7 @@ private void ImageResizeHandle_MouseLeftButtonUp(object sender, MouseButtonEvent { try { - if (isResizingImage && sender is Ellipse ellipse) + if (isResizingImage && e.OriginalSource is Ellipse ellipse) { isResizingImage = false; ellipse.ReleaseMouseCapture(); @@ -2513,7 +2493,7 @@ private void ImageResizeHandle_MouseMove(object sender, MouseEventArgs e) { try { - if (isResizingImage && IsBitmapLikeCanvasElement(currentSelectedElement) && sender is Ellipse ellipse) + if (isResizingImage && IsBitmapLikeCanvasElement(currentSelectedElement) && e.OriginalSource is Ellipse ellipse) { var currentPoint = e.GetPosition(inkCanvas); ResizeImageByHandle(currentSelectedElement, imageResizeStartPoint, currentPoint, activeResizeHandle); diff --git a/Ink Canvas/MainWindow_cs/MW_Eraser.cs b/Ink Canvas/MainWindow_cs/MW_Eraser.cs index 0b1e203c..16c1f244 100644 --- a/Ink Canvas/MainWindow_cs/MW_Eraser.cs +++ b/Ink Canvas/MainWindow_cs/MW_Eraser.cs @@ -122,7 +122,7 @@ private void EraserOverlay_PointerDown(object sender) eraserShape = new RectangleStylusShape(eraserWidth, _h); } - hitTester = inkCanvas.Strokes.GetIncrementalStrokeHitTester(eraserShape); + hitTester = BoardCanvasController.Strokes.GetIncrementalStrokeHitTester(eraserShape); hitTester.StrokeHit += EraserGeometry_StrokeHit; // 计算缩放矩阵 @@ -189,10 +189,10 @@ private void EraserOverlay_PointerMove(object sender, Point pt) if (isUsingStrokesEraser) { // 笔画橡皮擦模式 - var _filtered = inkCanvas.Strokes.HitTest(pt).Where(stroke => !stroke.ContainsPropertyData(IsLockGuid)); + var _filtered = BoardCanvasController.Strokes.HitTest(pt).Where(stroke => !stroke.ContainsPropertyData(IsLockGuid)); var filtered = _filtered as Stroke[] ?? _filtered.ToArray(); if (!filtered.Any()) return; - inkCanvas.Strokes.Remove(new StrokeCollection(filtered)); + BoardCanvasController.Strokes.Remove(new StrokeCollection(filtered)); } else { @@ -237,11 +237,11 @@ private void EraserGeometry_StrokeHit(object sender, StrokeHitEventArgs args) // 替换或删除笔画 if (filteredResult.Any()) { - inkCanvas.Strokes.Replace(new StrokeCollection(filtered2Replace), new StrokeCollection(filteredResult)); + BoardCanvasController.Strokes.Replace(new StrokeCollection(filtered2Replace), new StrokeCollection(filteredResult)); } else { - inkCanvas.Strokes.Remove(new StrokeCollection(filtered2Replace)); + BoardCanvasController.Strokes.Remove(new StrokeCollection(filtered2Replace)); } } @@ -360,7 +360,7 @@ public void ApplyAdvancedEraserShape() } // 应用到InkCanvas - inkCanvas.EraserShape = eraserShape; + BoardCanvasController.EraserShape = eraserShape; Trace.WriteLine($"Eraser: Applied shape - Size: {eraserWidth}, Circle: {isEraserCircleShape}"); } @@ -382,4 +382,4 @@ public string GetEraserStatusInfo() $"- 模式: {(isUsingStrokesEraser ? "笔画" : "几何")}"; } } -} \ No newline at end of file +} diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 2788a77f..9022fcba 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -688,8 +688,8 @@ internal void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e) if (currentMode == 0) { - LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; - RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; + BorderPPTNavBottomLeft.Visibility = Visibility.Collapsed; + BorderPPTNavBottomRight.Visibility = Visibility.Collapsed; LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; //進入黑板 @@ -820,16 +820,16 @@ internal void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e) { var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString(); var dopsc = dops.ToCharArray(); - if (dopsc[0] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftBottomPanelForPPTNavigation); - if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation); + if (dopsc[0] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(BorderPPTNavBottomLeft); + if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(BorderPPTNavBottomRight); if (dopsc[2] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation); if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation); } else { // 如果不在放映模式或页数无效,隐藏所有翻页按钮 - LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; - RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed; + BorderPPTNavBottomLeft.Visibility = Visibility.Collapsed; + BorderPPTNavBottomRight.Visibility = Visibility.Collapsed; LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed; } @@ -1559,7 +1559,7 @@ private void GridInkReplayButton_MouseUp(object sender, MouseButtonEventArgs e) FloatingbarUIForInkReplay.IsHitTestVisible = true; BlackboardUIGridForInkReplay.Visibility = Visibility.Visible; BlackboardUIGridForInkReplay.IsHitTestVisible = true; - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; inkCanvas.IsManipulationEnabled = true; if (inkCanvas.EditingMode == InkCanvasEditingMode.None) @@ -1607,7 +1607,7 @@ private void InkCanvasForInkReplay_MouseDown(object sender, MouseButtonEventArgs BlackboardUIGridForInkReplay.IsHitTestVisible = true; AnimationsHelper.HideWithFadeOut(BorderInkReplayToolBox); isStopInkReplay = true; - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; inkCanvas.IsManipulationEnabled = true; if (inkCanvas.EditingMode == InkCanvasEditingMode.None) @@ -2177,7 +2177,7 @@ internal async void CursorIcon_Click(object sender, RoutedEventArgs e) } else { - inkCanvas.IsHitTestVisible = false; + BoardCanvasController.IsHitTestVisible = false; inkCanvas.Visibility = Visibility.Visible; } } @@ -2186,7 +2186,7 @@ internal async void CursorIcon_Click(object sender, RoutedEventArgs e) if (Settings.PowerPointSettings.IsShowStrokeOnSelectInPowerPoint) { inkCanvas.Visibility = Visibility.Visible; - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; } else { @@ -2196,7 +2196,7 @@ internal async void CursorIcon_Click(object sender, RoutedEventArgs e) } else { - inkCanvas.IsHitTestVisible = false; + BoardCanvasController.IsHitTestVisible = false; inkCanvas.Visibility = Visibility.Visible; } } @@ -2306,7 +2306,7 @@ internal void PenIcon_Click(object sender, RoutedEventArgs e) GridTransparencyFakeBackground.Opacity = 1; GridTransparencyFakeBackground.Background = new SolidColorBrush(StringToColor("#01FFFFFF")); - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; inkCanvas.Visibility = Visibility.Visible; GridBackgroundCoverHolder.Visibility = Visibility.Visible; @@ -2757,7 +2757,7 @@ private void SetQuickColor(Color color) // 设置画笔颜色 drawingAttributes.Color = color; - inkCanvas.DefaultDrawingAttributes.Color = color; + BoardCanvasController.StrokeColor = color; // 如果当前是荧光笔模式,同时更新荧光笔颜色和属性 if (penType == 1) @@ -2814,7 +2814,7 @@ private void SetQuickColor(Color color) inkCanvas.DefaultDrawingAttributes.IsHighlighter = true; // 确保荧光笔颜色索引正确更新 - inkCanvas.DefaultDrawingAttributes.Color = drawingAttributes.Color; + BoardCanvasController.StrokeColor = drawingAttributes.Color; } // 更新颜色状态 @@ -3302,7 +3302,7 @@ private void ResetTouchStates() isPalmEraserActive = false; // 确保触摸事件能正常响应 - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; inkCanvas.IsManipulationEnabled = true; // 释放所有触摸捕获 @@ -3583,7 +3583,7 @@ private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e) // 进入批注模式 GridTransparencyFakeBackground.Opacity = 1; GridTransparencyFakeBackground.Background = new SolidColorBrush(StringToColor("#01FFFFFF")); - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; inkCanvas.Visibility = Visibility.Visible; GridBackgroundCoverHolder.Visibility = Visibility.Visible; @@ -3636,7 +3636,7 @@ private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e) //BtnClear_Click(null, null); } - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; inkCanvas.Visibility = Visibility.Visible; } else @@ -3656,11 +3656,11 @@ private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e) if (Settings.PowerPointSettings.IsShowStrokeOnSelectInPowerPoint) { inkCanvas.Visibility = Visibility.Visible; - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; } else { - inkCanvas.IsHitTestVisible = true; + BoardCanvasController.IsHitTestVisible = true; inkCanvas.Visibility = Visibility.Visible; } } diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index e9fd850f..e6f4f79a 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -2217,22 +2217,6 @@ private void PPTNavigationBtn_MouseDown(object sender, MouseButtonEventArgs e) { lastBorderMouseDownObject = sender; if (!Settings.PowerPointSettings.EnablePPTButtonPageClickable) return; - if (sender == PPTLSPageButton) - { - PPTLSPageButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTRSPageButton) - { - PPTRSPageButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTLBPageButton) - { - PPTLBPageButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTRBPageButton) - { - PPTRBPageButtonFeedbackBorder.Opacity = 0.15; - } } /// @@ -2248,22 +2232,6 @@ private void PPTNavigationBtn_MouseDown(object sender, MouseButtonEventArgs e) private void PPTNavigationBtn_MouseLeave(object sender, MouseEventArgs e) { lastBorderMouseDownObject = null; - if (sender == PPTLSPageButton) - { - PPTLSPageButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRSPageButton) - { - PPTRSPageButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTLBPageButton) - { - PPTLBPageButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRBPageButton) - { - PPTRBPageButtonFeedbackBorder.Opacity = 0; - } } /// @@ -2286,24 +2254,11 @@ private void PPTNavigationBtn_MouseLeave(object sender, MouseEventArgs e) private async void PPTNavigationBtn_MouseUp(object sender, MouseButtonEventArgs e) { if (lastBorderMouseDownObject != sender) return; + await HandlePptNavigationPageClickAsync(); + } - if (sender == PPTLSPageButton) - { - PPTLSPageButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRSPageButton) - { - PPTRSPageButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTLBPageButton) - { - PPTLBPageButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRBPageButton) - { - PPTRBPageButtonFeedbackBorder.Opacity = 0; - } - + private async Task HandlePptNavigationPageClickAsync() + { if (!Settings.PowerPointSettings.EnablePPTButtonPageClickable) return; // 使用新的PPT管理器检查连接状态 @@ -2500,23 +2455,6 @@ private async Task HandleManualSlideShowEnd() private void GridPPTControlPrevious_MouseDown(object sender, MouseButtonEventArgs e) { lastBorderMouseDownObject = sender; - if (sender == PPTLSPreviousButtonBorder) - { - PPTLSPreviousButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTRSPreviousButtonBorder) - { - PPTRSPreviousButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTLBPreviousButtonBorder) - { - PPTLBPreviousButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTRBPreviousButtonBorder) - { - PPTRBPreviousButtonFeedbackBorder.Opacity = 0.15; - } - // 启动长按检测 if (Settings.PowerPointSettings.EnablePPTButtonLongPressPageTurn) { @@ -2537,23 +2475,6 @@ private void GridPPTControlPrevious_MouseDown(object sender, MouseButtonEventArg private void GridPPTControlPrevious_MouseLeave(object sender, MouseEventArgs e) { lastBorderMouseDownObject = null; - if (sender == PPTLSPreviousButtonBorder) - { - PPTLSPreviousButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRSPreviousButtonBorder) - { - PPTRSPreviousButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTLBPreviousButtonBorder) - { - PPTLBPreviousButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRBPreviousButtonBorder) - { - PPTRBPreviousButtonFeedbackBorder.Opacity = 0; - } - // 停止长按检测 StopLongPressDetection(); } @@ -2572,23 +2493,6 @@ private void GridPPTControlPrevious_MouseLeave(object sender, MouseEventArgs e) private void GridPPTControlPrevious_MouseUp(object sender, MouseButtonEventArgs e) { if (lastBorderMouseDownObject != sender) return; - if (sender == PPTLSPreviousButtonBorder) - { - PPTLSPreviousButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRSPreviousButtonBorder) - { - PPTRSPreviousButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTLBPreviousButtonBorder) - { - PPTLBPreviousButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRBPreviousButtonBorder) - { - PPTRBPreviousButtonFeedbackBorder.Opacity = 0; - } - // 停止长按检测 StopLongPressDetection(); @@ -2610,23 +2514,6 @@ private void GridPPTControlPrevious_MouseUp(object sender, MouseButtonEventArgs private void GridPPTControlNext_MouseDown(object sender, MouseButtonEventArgs e) { lastBorderMouseDownObject = sender; - if (sender == PPTLSNextButtonBorder) - { - PPTLSNextButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTRSNextButtonBorder) - { - PPTRSNextButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTLBNextButtonBorder) - { - PPTLBNextButtonFeedbackBorder.Opacity = 0.15; - } - else if (sender == PPTRBNextButtonBorder) - { - PPTRBNextButtonFeedbackBorder.Opacity = 0.15; - } - // 启动长按检测 if (Settings.PowerPointSettings.EnablePPTButtonLongPressPageTurn) { @@ -2647,23 +2534,6 @@ private void GridPPTControlNext_MouseDown(object sender, MouseButtonEventArgs e) private void GridPPTControlNext_MouseLeave(object sender, MouseEventArgs e) { lastBorderMouseDownObject = null; - if (sender == PPTLSNextButtonBorder) - { - PPTLSNextButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRSNextButtonBorder) - { - PPTRSNextButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTLBNextButtonBorder) - { - PPTLBNextButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRBNextButtonBorder) - { - PPTRBNextButtonFeedbackBorder.Opacity = 0; - } - // 停止长按检测 StopLongPressDetection(); } @@ -2682,29 +2552,72 @@ private void GridPPTControlNext_MouseLeave(object sender, MouseEventArgs e) private void GridPPTControlNext_MouseUp(object sender, MouseButtonEventArgs e) { if (lastBorderMouseDownObject != sender) return; - if (sender == PPTLSNextButtonBorder) - { - PPTLSNextButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRSNextButtonBorder) - { - PPTRSNextButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTLBNextButtonBorder) - { - PPTLBNextButtonFeedbackBorder.Opacity = 0; - } - else if (sender == PPTRBNextButtonBorder) - { - PPTRBNextButtonFeedbackBorder.Opacity = 0; - } - // 停止长按检测 StopLongPressDetection(); BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null); } + private void PPTNavigationBottomLeft_PreviousClicked(object sender, RoutedEventArgs e) + { + BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null); + } + + private void PPTNavigationBottomRight_PreviousClicked(object sender, RoutedEventArgs e) + { + BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null); + } + + private void PPTNavigationSideLeft_PreviousClicked(object sender, RoutedEventArgs e) + { + BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null); + } + + private void PPTNavigationSideRight_PreviousClicked(object sender, RoutedEventArgs e) + { + BtnPPTSlidesUp_Click(BtnPPTSlidesUp, null); + } + + private void PPTNavigationBottomLeft_NextClicked(object sender, RoutedEventArgs e) + { + BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null); + } + + private void PPTNavigationBottomRight_NextClicked(object sender, RoutedEventArgs e) + { + BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null); + } + + private void PPTNavigationSideLeft_NextClicked(object sender, RoutedEventArgs e) + { + BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null); + } + + private void PPTNavigationSideRight_NextClicked(object sender, RoutedEventArgs e) + { + BtnPPTSlidesDown_Click(BtnPPTSlidesDown, null); + } + + private async void PPTNavigationBottomLeft_PageClicked(object sender, RoutedEventArgs e) + { + await HandlePptNavigationPageClickAsync(); + } + + private async void PPTNavigationBottomRight_PageClicked(object sender, RoutedEventArgs e) + { + await HandlePptNavigationPageClickAsync(); + } + + private async void PPTNavigationSideLeft_PageClicked(object sender, RoutedEventArgs e) + { + await HandlePptNavigationPageClickAsync(); + } + + private async void PPTNavigationSideRight_PageClicked(object sender, RoutedEventArgs e) + { + await HandlePptNavigationPageClickAsync(); + } + /// /// 处理PPT结束控制按钮的鼠标释放事件 /// diff --git a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs index 92ee533c..da06f76a 100644 --- a/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs +++ b/Ink Canvas/MainWindow_cs/MW_SelectionGestures.cs @@ -603,7 +603,7 @@ private void inkCanvas_SelectionChanged(object sender, EventArgs e) // 显示墨迹选择栏和选择框 GridInkCanvasSelectionCover.Visibility = Visibility.Visible; - BorderStrokeSelectionClone.Background = Brushes.Transparent; + BorderStrokeSelectionControl.SetCloneButtonBackground(Brushes.Transparent); updateBorderStrokeSelectionControlLocation(); UpdateSelectionDisplay(); return; @@ -664,7 +664,7 @@ private void updateBorderStrokeSelectionControlLocation() if (borderTop < 0) borderTop = 10; // 如果上方也没有空间,则显示在顶部 } - BorderStrokeSelectionControl.Margin = new Thickness(borderLeft, borderTop, 0, 0); + BorderStrokeSelectionControl.ControlMargin = new Thickness(borderLeft, borderTop, 0, 0); } /// diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs index acacfedc..51d3bf12 100644 --- a/Ink Canvas/MainWindow_cs/MW_Settings.cs +++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs @@ -868,11 +868,28 @@ private void ToggleSwitchShowCanvasAtNewSlideShow_Toggled(object sender, RoutedE private void ToggleSwitchEnableNibMode_Toggled(object sender, RoutedEventArgs e) { if (!isLoaded) return; - if (sender == ToggleSwitchEnableNibMode) - BoardToggleSwitchEnableNibMode.IsOn = ToggleSwitchEnableNibMode.IsOn; + + bool isNibModeEnabled; + if (sender == BoardPenSettingsControl) + { + isNibModeEnabled = BoardPenSettingsControl.IsNibModeEnabled; + if (BorderPenSettingsControl != null) + BorderPenSettingsControl.IsNibModeEnabled = isNibModeEnabled; + } + else if (sender == BorderPenSettingsControl) + { + isNibModeEnabled = BorderPenSettingsControl != null && BorderPenSettingsControl.IsNibModeEnabled; + if (BoardPenSettingsControl != null) + BoardPenSettingsControl.IsNibModeEnabled = isNibModeEnabled; + } else - ToggleSwitchEnableNibMode.IsOn = BoardToggleSwitchEnableNibMode.IsOn; - Settings.Startup.IsEnableNibMode = ToggleSwitchEnableNibMode.IsOn; + { + isNibModeEnabled = BorderPenSettingsControl != null && BorderPenSettingsControl.IsNibModeEnabled; + if (BoardPenSettingsControl != null) + BoardPenSettingsControl.IsNibModeEnabled = isNibModeEnabled; + } + + Settings.Startup.IsEnableNibMode = isNibModeEnabled; if (Settings.Startup.IsEnableNibMode) BoundsWidth = Settings.Advanced.NibModeBoundsWidth; @@ -902,13 +919,17 @@ private void ToggleSwitchEnableDisPlayNibModeToggle_Toggled(object sender, Route SaveSettingsToFile(); if (!ToggleSwitchEnableDisPlayNibModeToggle.IsOn) { - NibModeSimpleStackPanel.Visibility = Visibility.Collapsed; - BoardNibModeSimpleStackPanel.Visibility = Visibility.Collapsed; + if (BorderPenSettingsControl != null) + BorderPenSettingsControl.NibModePanelVisibility = Visibility.Collapsed; + if (BoardPenSettingsControl != null) + BoardPenSettingsControl.NibModePanelVisibility = Visibility.Collapsed; } else { - NibModeSimpleStackPanel.Visibility = Visibility.Visible; - BoardNibModeSimpleStackPanel.Visibility = Visibility.Visible; + if (BorderPenSettingsControl != null) + BorderPenSettingsControl.NibModePanelVisibility = Visibility.Visible; + if (BoardPenSettingsControl != null) + BoardPenSettingsControl.NibModePanelVisibility = Visibility.Visible; } } @@ -2804,16 +2825,23 @@ private static int InkStyleFromPenStyleUiIndex(int uiIndex) private void ComboBoxPenStyle_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!isLoaded) return; - int uiIndex = sender == ComboBoxPenStyle - ? ComboBoxPenStyle.SelectedIndex - : BoardComboBoxPenStyle.SelectedIndex; + + int uiIndex = sender == BoardPenSettingsControl + ? BoardPenSettingsControl?.PenStyleSelectedIndex ?? -1 + : BorderPenSettingsControl?.PenStyleSelectedIndex ?? -1; if (uiIndex < 0) return; Settings.Canvas.InkStyle = InkStyleFromPenStyleUiIndex(uiIndex); - if (sender == ComboBoxPenStyle) - BoardComboBoxPenStyle.SelectedIndex = uiIndex; + if (sender == BoardPenSettingsControl) + { + if (BorderPenSettingsControl != null) + BorderPenSettingsControl.PenStyleSelectedIndex = uiIndex; + } else - ComboBoxPenStyle.SelectedIndex = uiIndex; + { + if (BoardPenSettingsControl != null) + BoardPenSettingsControl.PenStyleSelectedIndex = uiIndex; + } SaveSettingsToFile(); } @@ -2895,22 +2923,46 @@ private void SwitchToRectangleEraser(object sender, MouseButtonEventArgs e) private void InkWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { if (!isLoaded) return; - if (sender == BoardInkWidthSlider) InkWidthSlider.Value = ((Slider)sender).Value; - if (sender == InkWidthSlider) BoardInkWidthSlider.Value = ((Slider)sender).Value; - drawingAttributes.Height = ((Slider)sender).Value / 2; - drawingAttributes.Width = ((Slider)sender).Value / 2; - Settings.Canvas.InkWidth = ((Slider)sender).Value / 2; + + if (!(sender is Slider slider)) return; + + if (sender == BoardPenSettingsControl?.InkWidthSliderControl) + { + if (BorderPenSettingsControl != null && Math.Abs(BorderPenSettingsControl.PenWidth - slider.Value) > 0.001) + BorderPenSettingsControl.PenWidth = slider.Value; + } + else if (sender == BorderPenSettingsControl?.InkWidthSliderControl) + { + if (BoardPenSettingsControl != null && Math.Abs(BoardPenSettingsControl.PenWidth - slider.Value) > 0.001) + BoardPenSettingsControl.PenWidth = slider.Value; + } + + drawingAttributes.Height = slider.Value / 2; + drawingAttributes.Width = slider.Value / 2; + Settings.Canvas.InkWidth = slider.Value / 2; SaveSettingsToFile(); } private void HighlighterWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { if (!isLoaded) return; - // if (sender == BoardInkWidthSlider) InkWidthSlider.Value = ((Slider)sender).Value; - // if (sender == InkWidthSlider) BoardInkWidthSlider.Value = ((Slider)sender).Value; - drawingAttributes.Height = ((Slider)sender).Value; - drawingAttributes.Width = ((Slider)sender).Value / 2; - Settings.Canvas.HighlighterWidth = ((Slider)sender).Value; + + if (!(sender is Slider slider)) return; + + if (sender == BoardPenSettingsControl?.HighlighterWidthSliderControl) + { + if (BorderPenSettingsControl != null && Math.Abs(BorderPenSettingsControl.HighlighterWidth - slider.Value) > 0.001) + BorderPenSettingsControl.HighlighterWidth = slider.Value; + } + else if (sender == BorderPenSettingsControl?.HighlighterWidthSliderControl) + { + if (BoardPenSettingsControl != null && Math.Abs(BoardPenSettingsControl.HighlighterWidth - slider.Value) > 0.001) + BoardPenSettingsControl.HighlighterWidth = slider.Value; + } + + drawingAttributes.Height = slider.Value; + drawingAttributes.Width = slider.Value / 2; + Settings.Canvas.HighlighterWidth = slider.Value; SaveSettingsToFile(); } @@ -2923,14 +2975,25 @@ private void HighlighterWidthSlider_ValueChanged(object sender, RoutedPropertyCh private void InkAlphaSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { if (!isLoaded) return; - // if (sender == BoardInkWidthSlider) InkWidthSlider.Value = ((Slider)sender).Value; - // if (sender == InkWidthSlider) BoardInkWidthSlider.Value = ((Slider)sender).Value; + + if (!(sender is Slider slider)) return; + + if (sender == BoardPenSettingsControl?.InkAlphaSliderControl) + { + if (BorderPenSettingsControl != null && Math.Abs(BorderPenSettingsControl.PenAlpha - slider.Value) > 0.001) + BorderPenSettingsControl.PenAlpha = slider.Value; + } + else if (sender == BorderPenSettingsControl?.InkAlphaSliderControl) + { + if (BoardPenSettingsControl != null && Math.Abs(BoardPenSettingsControl.PenAlpha - slider.Value) > 0.001) + BoardPenSettingsControl.PenAlpha = slider.Value; + } + var NowR = drawingAttributes.Color.R; var NowG = drawingAttributes.Color.G; var NowB = drawingAttributes.Color.B; - // Trace.WriteLine(BitConverter.GetBytes(((Slider)sender).Value)); - drawingAttributes.Color = Color.FromArgb((byte)((Slider)sender).Value, NowR, NowG, NowB); - Settings.Canvas.InkAlpha = ((Slider)sender).Value; + drawingAttributes.Color = Color.FromArgb((byte)slider.Value, NowR, NowG, NowB); + Settings.Canvas.InkAlpha = slider.Value; SaveSettingsToFile(); } @@ -3953,7 +4016,32 @@ private async void SpecialVersionResetToSuggestion_Click() private void ToggleSwitchEnableInkToShape_Toggled(object sender, RoutedEventArgs e) { if (!isLoaded) return; - Settings.InkToShape.IsInkToShapeEnabled = ToggleSwitchEnableInkToShape.IsOn; + + bool isEnabled; + if (sender == BorderPenSettingsControl) + { + isEnabled = BorderPenSettingsControl.IsInkToShapeEnabled; + ToggleSwitchEnableInkToShape.IsOn = isEnabled; + if (BoardPenSettingsControl != null) + BoardPenSettingsControl.IsInkToShapeEnabled = isEnabled; + } + else if (sender == BoardPenSettingsControl) + { + isEnabled = BoardPenSettingsControl.IsInkToShapeEnabled; + ToggleSwitchEnableInkToShape.IsOn = isEnabled; + if (BorderPenSettingsControl != null) + BorderPenSettingsControl.IsInkToShapeEnabled = isEnabled; + } + else + { + isEnabled = ToggleSwitchEnableInkToShape.IsOn; + if (BorderPenSettingsControl != null) + BorderPenSettingsControl.IsInkToShapeEnabled = isEnabled; + if (BoardPenSettingsControl != null) + BoardPenSettingsControl.IsInkToShapeEnabled = isEnabled; + } + + Settings.InkToShape.IsInkToShapeEnabled = isEnabled; SaveSettingsToFile(); } @@ -5878,4 +5966,4 @@ private void BtnRegisterFileAssociation_Click(object sender, RoutedEventArgs e) #endregion } -} \ No newline at end of file +} diff --git a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs index 9fbca2bc..6e0f5e87 100644 --- a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs +++ b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs @@ -252,14 +252,14 @@ private void LoadSettings(bool isStartup = false, bool skipAutoUpdateCheck = fal if (Settings.Startup.IsEnableNibMode) { - ToggleSwitchEnableNibMode.IsOn = true; - BoardToggleSwitchEnableNibMode.IsOn = true; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.IsNibModeEnabled = true; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.IsNibModeEnabled = true; BoundsWidth = Settings.Advanced.NibModeBoundsWidth; } else { - ToggleSwitchEnableNibMode.IsOn = false; - BoardToggleSwitchEnableNibMode.IsOn = false; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.IsNibModeEnabled = false; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.IsNibModeEnabled = false; BoundsWidth = Settings.Advanced.FingerModeBoundsWidth; } @@ -339,8 +339,8 @@ private void LoadSettings(bool isStartup = false, bool skipAutoUpdateCheck = fal { Settings.Startup = new Startup(); Settings.Startup.IsEnableNibMode = false; // 默认关闭笔尖模式 - ToggleSwitchEnableNibMode.IsOn = false; // 默认关闭笔尖模式 - BoardToggleSwitchEnableNibMode.IsOn = false; // 默认关闭笔尖模式 + if (BorderPenSettingsControl != null) BorderPenSettingsControl.IsNibModeEnabled = false; // 默认关闭笔尖模式 + if (BoardPenSettingsControl != null) BoardPenSettingsControl.IsNibModeEnabled = false; // 默认关闭笔尖模式 BoundsWidth = Settings.Advanced.FingerModeBoundsWidth; // 使用手指模式边界宽度 } @@ -365,13 +365,13 @@ private void LoadSettings(bool isStartup = false, bool skipAutoUpdateCheck = fal { if (!Settings.Appearance.IsEnableDisPlayNibModeToggler) { - NibModeSimpleStackPanel.Visibility = Visibility.Collapsed; - BoardNibModeSimpleStackPanel.Visibility = Visibility.Collapsed; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.NibModePanelVisibility = Visibility.Collapsed; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.NibModePanelVisibility = Visibility.Collapsed; } else { - NibModeSimpleStackPanel.Visibility = Visibility.Visible; - BoardNibModeSimpleStackPanel.Visibility = Visibility.Visible; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.NibModePanelVisibility = Visibility.Visible; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.NibModePanelVisibility = Visibility.Visible; } //if (Settings.Appearance.IsColorfulViewboxFloatingBar) // 浮动工具栏背景色 @@ -803,16 +803,18 @@ private void LoadSettings(bool isStartup = false, bool skipAutoUpdateCheck = fal drawingAttributes.Height = Settings.Canvas.InkWidth; drawingAttributes.Width = Settings.Canvas.InkWidth; - InkWidthSlider.Value = Settings.Canvas.InkWidth * 2; - HighlighterWidthSlider.Value = Settings.Canvas.HighlighterWidth; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.PenWidth = Settings.Canvas.InkWidth * 2; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.PenWidth = Settings.Canvas.InkWidth * 2; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.HighlighterWidth = Settings.Canvas.HighlighterWidth; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.HighlighterWidth = Settings.Canvas.HighlighterWidth; int alpha = (int)Settings.Canvas.InkAlpha; if (alpha < 0) alpha = 0; if (alpha > 255) alpha = 255; var inkColor = drawingAttributes.Color; drawingAttributes.Color = Color.FromArgb((byte)alpha, inkColor.R, inkColor.G, inkColor.B); inkCanvas.DefaultDrawingAttributes.Color = drawingAttributes.Color; - if (InkAlphaSlider != null) InkAlphaSlider.Value = alpha; - if (BoardInkAlphaSlider != null) BoardInkAlphaSlider.Value = alpha; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.PenAlpha = alpha; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.PenAlpha = alpha; ComboBoxHyperbolaAsymptoteOption.SelectedIndex = (int)Settings.Canvas.HyperbolaAsymptoteOption; @@ -865,8 +867,8 @@ private void LoadSettings(bool isStartup = false, bool skipAutoUpdateCheck = fal Settings.Canvas.InkStyle = 0; int penStyleUi = PenStyleUiIndexFromInkStyle(Settings.Canvas.InkStyle); - ComboBoxPenStyle.SelectedIndex = penStyleUi; - BoardComboBoxPenStyle.SelectedIndex = penStyleUi; + if (BorderPenSettingsControl != null) BorderPenSettingsControl.PenStyleSelectedIndex = penStyleUi; + if (BoardPenSettingsControl != null) BoardPenSettingsControl.PenStyleSelectedIndex = penStyleUi; ComboBoxEraserSize.SelectedIndex = Settings.Canvas.EraserSize; ComboBoxEraserSizeFloatingBar.SelectedIndex = Settings.Canvas.EraserSize; @@ -1060,6 +1062,10 @@ private void LoadSettings(bool isStartup = false, bool skipAutoUpdateCheck = fal if (Settings.InkToShape != null) { ToggleSwitchEnableInkToShape.IsOn = Settings.InkToShape.IsInkToShapeEnabled; + if (BorderPenSettingsControl != null) + BorderPenSettingsControl.IsInkToShapeEnabled = Settings.InkToShape.IsInkToShapeEnabled; + if (BoardPenSettingsControl != null) + BoardPenSettingsControl.IsInkToShapeEnabled = Settings.InkToShape.IsInkToShapeEnabled; if (ComboBoxShapeRecognitionEngine != null) { @@ -1439,15 +1445,15 @@ private void LoadInkFadeSettings() } // 同步批注子面板中的开关状态 - if (ToggleSwitchInkFadeInPanel != null) + if (BoardPenSettingsControl != null) { - ToggleSwitchInkFadeInPanel.IsOn = Settings.Canvas.EnableInkFade; + BoardPenSettingsControl.IsInkFadeEnabled = Settings.Canvas.EnableInkFade; } // 同步普通画笔面板中的开关状态 - if (ToggleSwitchInkFadeInPanel2 != null) + if (BorderPenSettingsControl != null) { - ToggleSwitchInkFadeInPanel2.IsOn = Settings.Canvas.EnableInkFade; + BorderPenSettingsControl.IsInkFadeEnabled = Settings.Canvas.EnableInkFade; } // 同步滑块值 @@ -1611,4 +1617,4 @@ private void RemoveObsoleteProperties(JObject userObj, JObject defaultObj, ref b } } } -} \ No newline at end of file +} diff --git a/Ink Canvas/MainWindow_cs/MW_Styles.xaml b/Ink Canvas/MainWindow_cs/MW_Styles.xaml new file mode 100644 index 00000000..dcf4d739 --- /dev/null +++ b/Ink Canvas/MainWindow_cs/MW_Styles.xaml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow_cs/MW_Timer.cs b/Ink Canvas/MainWindow_cs/MW_Timer.cs index 0190d673..2568be9c 100644 --- a/Ink Canvas/MainWindow_cs/MW_Timer.cs +++ b/Ink Canvas/MainWindow_cs/MW_Timer.cs @@ -323,7 +323,7 @@ private void AutoSaveStrokesTimer_Tick(object sender, EventArgs e) try { // 只有在画布可见且有墨迹时才保存 - if (inkCanvas.Visibility == Visibility.Visible && inkCanvas.Strokes.Count > 0) + if (BoardCanvasController.Visibility == Visibility.Visible && BoardCanvasController.Strokes.Count > 0) { // 静默保存 SaveInkCanvasStrokes(false, false); @@ -1221,7 +1221,7 @@ private void timerCheckAutoUpdateWithSilence_Elapsed(object sender, ElapsedEvent { // 判断是否处于批注模式(inkCanvas.EditingMode == InkCanvasEditingMode.Ink) // 判断是否处于画板模式(!Topmost) - if (inkCanvas.EditingMode != InkCanvasEditingMode.Ink && Topmost) + if (BoardCanvasController.EditingMode != InkCanvasEditingMode.Ink && Topmost) { // 检查是否有未保存的内容或正在进行的操作 if (!isHidingSubPanelsWhenInking) @@ -1455,8 +1455,8 @@ private void EraserAutoSwitchBackTimer_Tick(object sender, EventArgs e) try { // 检查是否仍然在橡皮擦模式 - if (inkCanvas.EditingMode != InkCanvasEditingMode.EraseByPoint && - inkCanvas.EditingMode != InkCanvasEditingMode.EraseByStroke) + if (BoardCanvasController.EditingMode != InkCanvasEditingMode.EraseByPoint && + BoardCanvasController.EditingMode != InkCanvasEditingMode.EraseByStroke) { StopEraserAutoSwitchBackTimer(); return; diff --git a/Ink Canvas/MainWindow_cs/MW_ToolbarIcons.xaml b/Ink Canvas/MainWindow_cs/MW_ToolbarIcons.xaml new file mode 100644 index 00000000..350eaa3a --- /dev/null +++ b/Ink Canvas/MainWindow_cs/MW_ToolbarIcons.xaml @@ -0,0 +1,63 @@ + + F0 M24,24z M0,0z M7.82154,10.0753L7.82154,3.74613C7.82154,3.06603 8.08946,2.40655 8.57377,1.92224 9.05808,1.43793 9.70726,1.17001 10.3977,1.17001 11.0881,1.17001 11.7372,1.43793 12.2216,1.92224 12.7059,2.40655 12.9738,3.05573 12.9738,3.74613L12.9738,6.37308C13.1415,6.33947 13.3139,6.32225 13.489,6.32225 14.1794,6.32225 14.8286,6.59016 15.3129,7.07447 15.4484,7.21001 15.567,7.35845 15.6675,7.5171 15.9551,7.40916 16.2634,7.35269 16.5803,7.35269 17.2707,7.35269 17.9199,7.62061 18.4042,8.10492 18.5461,8.24683 18.6695,8.4029 18.7729,8.57001 19.6856,8.26338 20.7674,8.45871 21.4647,9.15599 21.949,9.6403 22.2169,10.2998 22.2169,10.9799L22.2169,15.6169C22.2169,17.5438 21.4647,19.3574 20.1045,20.7176 18.7443,22.0778 16.9307,22.83 15.0038,22.83L13.149,22.83 13.1799,22.8094 12.8398,22.8094C11.7682,22.7579 10.7068,22.4694 9.75878,21.9541 8.70773,21.3874 7.81124,20.563 7.15175,19.5738L6.94566,19.2647C6.60562,18.7494 5.49273,16.8019 3.52458,13.3087 3.19484,12.7213 3.1021,12.0412 3.27727,11.3818 3.45245,10.7326 3.86463,10.1761 4.44168,9.83608 5.00842,9.49604 5.66791,9.35177 6.31709,9.43421 6.86548,9.50385 7.39181,9.7279 7.82154,10.0753z + F0 M24,24z M0,0z + F1 M24,24z M0,0z M22.7989,10.1653L1.14304,1.14304 10.1653,22.7989 12.8305,14.9518 19.6892,21.8105 21.8105,19.6892 14.9518,12.8305 22.7989,10.1653z + F1 M24,24z M0,0z M20.4786,1.42438C19.9985,1.23743 19.4847,1.15194 18.9698,1.17319 18.4549,1.19444 17.9499,1.32197 17.4869,1.54789 17.0368,1.76752 16.6358,2.07554 16.3083,2.45361L3.85516,14.9067 9.08243,20.134 21.5311,7.68529C21.9113,7.36382 22.223,6.96912 22.447,6.52438 22.6786,6.06462 22.8113,5.56167 22.8365,5.04763 22.8616,4.5336 22.7787,4.02012 22.593,3.54002 22.4073,3.05994 22.1232,2.62403 21.759,2.25988 21.3949,1.89574 20.9587,1.61132 20.4786,1.42438z M7.28056,21.1605L2.8286,16.7086 1.15912,22.83 7.28056,21.1605z + F1 M24,24z M0,0z M15.6314,20.7262L22.7921,13.5655C24.3494,12.141,24.2819,9.81776,22.8105,8.34633L16.7793,2.31508C15.3547,0.757753,13.0315,0.825236,11.5601,2.29666L4.38099,9.47574 15.6314,20.7262z M14.2172,22.1404L2.96677,10.89 1.20761,12.6491C-0.34971,14.0737,-0.281711,16.3974,1.18971,17.8688L6.15089,22.83 13.5276,22.83 14.2172,22.1404z + + F0 M24,24z M0,0z + F0 M24,24z M0,0z + F0 M24,24z M0,0z + F0 M24,24z M0,0z + F0 M24,24z M0,0z + F1 M24,24z M0,0z M8.7269,2.9067C8.84872,2.70875 9.00852,2.57931 9.20647,2.5184 9.41966,2.44227 9.62541,2.43465 9.82337,2.49556 10.0365,2.55647 10.2039,2.67829 10.3257,2.86102L13.9118,8.13731C12.9068,8.47231 12.0084,8.99766 11.2165,9.71334 10.4247,10.4138 9.8157,11.2513 9.38933,12.2259 8.93251,13.2156 8.70413,14.2587 8.70413,15.3551L8.7269,15.9946 2.46851,15.9946C2.22487,15.9946 2.01158,15.9185 1.82885,15.7662 1.66135,15.614 1.55481,15.4236 1.50913,15.1952 1.47868,14.9668 1.5244,14.746 1.64622,14.5328L8.7269,2.9067z + F1 M24,24z M0,0z M10.3344,5.02734L10.3605,8.62849C12.2431,8.87029 14.0305,9.44026 15.7232,10.3384 17.4676,11.2538 18.9187,12.4196 20.0759,13.8359 21.3367,15.3731 22.1398,17.0657 22.4852,18.9138 22.5197,19.1211 22.4938,19.3197 22.4075,19.5097 22.3211,19.6997 22.2003,19.8292 22.0448,19.8983 21.8894,19.9501 21.7423,19.9069 21.6042,19.7687 20.7579,18.8361 19.6268,17.9984 18.2105,17.2557 16.9324,16.5821 15.5591,16.0553 14.091,15.6754 12.7093,15.3126 11.4659,15.1313 10.3605,15.1313L10.3344,18.862C10.3344,19.2938 10.2395,19.6047 10.0495,19.7947 9.8941,19.9501 9.69547,20.0106 9.45367,19.976 9.21187,19.9242 8.99586,19.8119 8.80587,19.6392 8.14955,18.9829 6.90606,17.7739 5.07526,16.0121 3.46899,14.475 2.41544,13.4559 1.91456,12.9551 1.63821,12.6787 1.5,12.3678 1.5,12.0224 1.51727,11.6769 1.67272,11.3574 1.96634,11.0638 4.02168,9.00847 6.3103,6.73724 8.83197,4.25011 9.00468,4.07739 9.20331,3.99967 9.42784,4.01694 9.66965,4.01694 9.87683,4.11194 10.0495,4.30193 10.2395,4.47464 10.3344,4.71645 10.3344,5.02734z + F1 M24,24z M0,0z M13.6656,5.02734L13.6395,8.62849C11.7569,8.87029 9.96948,9.44026 8.27685,10.3384 6.5324,11.2538 5.08134,12.4196 3.92413,13.8359 2.6633,15.3731 1.86023,17.0657 1.5148,18.9138 1.48026,19.1211 1.50619,19.3197 1.59255,19.5097 1.6789,19.6997 1.79974,19.8292 1.95518,19.8983 2.11063,19.9501 2.25766,19.9069 2.39583,19.7687 3.24215,18.8361 4.37323,17.9984 5.78951,17.2557 7.06761,16.5821 8.44089,16.0553 9.90899,15.6754 11.2907,15.3126 12.5341,15.1313 13.6395,15.1313L13.6656,18.862C13.6656,19.2938 13.7605,19.6047 13.9505,19.7947 14.1059,19.9501 14.3045,20.0106 14.5463,19.976 14.7881,19.9242 15.0041,19.8119 15.1941,19.6392 15.8505,18.9829 17.0939,17.7739 18.9247,16.0121 20.531,14.475 21.5846,13.4559 22.0854,12.9551 22.3618,12.6787 22.5,12.3678 22.5,12.0224 22.4827,11.6769 22.3273,11.3574 22.0337,11.0638 19.9783,9.00847 17.6897,6.73724 15.168,4.25011 14.9953,4.07739 14.7967,3.99967 14.5722,4.01694 14.3304,4.01694 14.1232,4.11194 13.9505,4.30193 13.7605,4.47464 13.6656,4.71645 13.6656,5.02734z + + F0 M24,24z M0,0z M3.3994,12.9642C2.86687,12.4317,2.86687,11.5683,3.3994,11.0358L9.94485,4.49031C10.4774,3.95777 11.3408,3.95777 11.8733,4.49031 12.4059,5.02284 12.4059,5.88625 11.8733,6.41878L7.65575,10.6364 19.6364,10.6364C20.3895,10.6364 21,11.2469 21,12 21,12.7531 20.3895,13.3636 19.6364,13.3636L7.65575,13.3636 11.8733,17.5812C12.4059,18.1137 12.4059,18.9772 11.8733,19.5097 11.3408,20.0422 10.4774,20.0422 9.94485,19.5097L3.3994,12.9642z + F0 M24,24z M0,0z M20.6006,12.9642C21.1331,12.4317,21.1331,11.5683,20.6006,11.0358L14.0551,4.49031C13.5226,3.95777 12.6592,3.95777 12.1267,4.49031 11.5941,5.02284 11.5941,5.88625 12.1267,6.41878L16.3443,10.6364 4.36364,10.6364C3.61052,10.6364 3,11.2469 3,12 3,12.7531 3.61052,13.3636 4.36364,13.3636L16.3443,13.3636 12.1267,17.5812C11.5941,18.1137 11.5941,18.9772 12.1267,19.5097 12.6592,20.0422 13.5226,20.0422 14.0551,19.5097L20.6006,12.9642z + F0 M24,24z M0,0z M3.3994,12.9642C2.86687,12.4317,2.86687,11.5683,3.3994,11.0358L9.94485,4.49031C10.4774,3.95777 11.3408,3.95777 11.8733,4.49031 12.4059,5.02284 12.4059,5.88625 11.8733,6.41878L7.65575,10.6364 19.6364,10.6364C20.3895,10.6364 21,11.2469 21,12 21,12.7531 20.3895,13.3636 19.6364,13.3636L7.65575,13.3636 11.8733,17.5812C12.4059,18.1137 12.4059,18.9772 11.8733,19.5097 11.3408,20.0422 10.4774,20.0422 9.94485,19.5097L3.3994,12.9642z + F0 M24,24z M0,0z M20.6006,12.9642C21.1331,12.4317,21.1331,11.5683,20.6006,11.0358L14.0551,4.49031C13.5226,3.95777 12.6592,3.95777 12.1267,4.49031 11.5941,5.02284 11.5941,5.88625 12.1267,6.41878L16.3443,10.6364 4.36364,10.6364C3.61052,10.6364 3,11.2469 3,12 3,12.7531 3.61052,13.3636 4.36364,13.3636L16.3443,13.3636 12.1267,17.5812C11.5941,18.1137 11.5941,18.9772 12.1267,19.5097 12.6592,20.0422 13.5226,20.0422 14.0551,19.5097L20.6006,12.9642z + F0 M24,24z M0,0z M11.0357,3.3994C11.5682,2.86687,12.4316,2.86687,12.9641,3.3994L19.5096,9.94485C20.0421,10.4774 20.0421,11.3408 19.5096,11.8733 18.9771,12.4059 18.1137,12.4059 17.5811,11.8733L13.3635,7.65575 13.3635,19.6364C13.3635,20.3895 12.753,21 11.9999,21 11.2468,21 10.6363,20.3895 10.6363,19.6364L10.6363,7.65575 6.41869,11.8733C5.88616,12.4059 5.02275,12.4059 4.49022,11.8733 3.95769,11.3408 3.95769,10.4774 4.49022,9.94485L11.0357,3.3994z + F0 M24,24z M0,0z M11.0357,20.6006C11.5682,21.1331,12.4316,21.1331,12.9641,20.6006L19.5096,14.0551C20.0421,13.5226 20.0421,12.6592 19.5096,12.1267 18.9771,11.5941 18.1137,11.5941 17.5811,12.1267L13.3635,16.3443 13.3635,4.36364C13.3635,3.61052 12.753,3 11.9999,3 11.2468,3 10.6363,3.61052 10.6363,4.36364L10.6363,16.3443 6.41869,12.1267C5.88616,11.5941 5.02275,11.5941 4.49022,12.1267 3.95769,12.6592 3.95769,13.5226 4.49022,14.0551L11.0357,20.6006z + F0 M24,24z M0,0z M11.0357,3.3994C11.5682,2.86687,12.4316,2.86687,12.9641,3.3994L19.5096,9.94485C20.0421,10.4774 20.0421,11.3408 19.5096,11.8733 18.9771,12.4059 18.1137,12.4059 17.5811,11.8733L13.3635,7.65575 13.3635,19.6364C13.3635,20.3895 12.753,21 11.9999,21 11.2468,21 10.6363,20.3895 10.6363,19.6364L10.6363,7.65575 6.41869,11.8733C5.88616,12.4059 5.02275,12.4059 4.49022,11.8733 3.95769,11.3408 3.95769,10.4774 4.49022,9.94485L11.0357,3.3994z + F0 M24,24z M0,0z M11.0357,20.6006C11.5682,21.1331,12.4316,21.1331,12.9641,20.6006L19.5096,14.0551C20.0421,13.5226 20.0421,12.6592 19.5096,12.1267 18.9771,11.5941 18.1137,11.5941 17.5811,12.1267L13.3635,16.3443 13.3635,4.36364C13.3635,3.61052 12.753,3 11.9999,3 11.2468,3 10.6363,3.61052 10.6363,4.36364L10.6363,16.3443 6.41869,12.1267C5.88616,11.5941 5.02275,11.5941 4.49022,12.1267 3.95769,12.6592 3.95769,13.5226 4.49022,14.0551L11.0357,20.6006z + + + + + + + + + + + + + + + + + + + + + + + +