代码清理
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Windows;
|
|
||||||
using Microsoft.Win32;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
namespace Ink_Canvas.Helpers
|
namespace Ink_Canvas.Helpers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Ink_Canvas.Helpers;
|
||||||
using iNKORE.UI.WPF.Modern.Controls;
|
using iNKORE.UI.WPF.Modern.Controls;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -8,7 +9,6 @@ using System.Windows.Ink;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using Ink_Canvas.Helpers;
|
|
||||||
using Point = System.Windows.Point;
|
using Point = System.Windows.Point;
|
||||||
|
|
||||||
namespace Ink_Canvas
|
namespace Ink_Canvas
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace Ink_Canvas.Resources.ICCConfiguration {
|
namespace Ink_Canvas.Resources.ICCConfiguration
|
||||||
public enum InitialPositionTypes {
|
{
|
||||||
|
public enum InitialPositionTypes
|
||||||
|
{
|
||||||
TopLeft, TopRight, BottomLeft, BottomRight, TopCenter, BottomCenter, Custom
|
TopLeft, TopRight, BottomLeft, BottomRight, TopCenter, BottomCenter, Custom
|
||||||
}
|
}
|
||||||
public enum ElementCornerRadiusTypes {
|
public enum ElementCornerRadiusTypes
|
||||||
|
{
|
||||||
SuperEllipse, Circle, Custom, None
|
SuperEllipse, Circle, Custom, None
|
||||||
}
|
}
|
||||||
public class NearSnapAreaSize {
|
public class NearSnapAreaSize
|
||||||
|
{
|
||||||
public double[] TopLeft { get; set; } = { 24, 24 };
|
public double[] TopLeft { get; set; } = { 24, 24 };
|
||||||
public double[] TopRight { get; set; } = { 24, 24 };
|
public double[] TopRight { get; set; } = { 24, 24 };
|
||||||
public double[] BottomLeft { get; set; } = { 24, 24 };
|
public double[] BottomLeft { get; set; } = { 24, 24 };
|
||||||
@@ -16,7 +20,8 @@ namespace Ink_Canvas.Resources.ICCConfiguration {
|
|||||||
public double TopCenter { get; set; } = 24;
|
public double TopCenter { get; set; } = 24;
|
||||||
public double BottomCenter { get; set; } = 24;
|
public double BottomCenter { get; set; } = 24;
|
||||||
}
|
}
|
||||||
public class ICCFloatingBarConfiguration {
|
public class ICCFloatingBarConfiguration
|
||||||
|
{
|
||||||
public bool SemiTransparent { get; set; } = false;
|
public bool SemiTransparent { get; set; } = false;
|
||||||
public bool NearSnap { get; set; } = true;
|
public bool NearSnap { get; set; } = true;
|
||||||
public InitialPositionTypes InitialPosition { get; set; } = InitialPositionTypes.BottomCenter;
|
public InitialPositionTypes InitialPosition { get; set; } = InitialPositionTypes.BottomCenter;
|
||||||
@@ -32,7 +37,8 @@ namespace Ink_Canvas.Resources.ICCConfiguration {
|
|||||||
public double MovingLimitationNoSnap { get; set; } = 12;
|
public double MovingLimitationNoSnap { get; set; } = 12;
|
||||||
public double MovingLimitationSnapped { get; set; } = 24;
|
public double MovingLimitationSnapped { get; set; } = 24;
|
||||||
|
|
||||||
public NearSnapAreaSize NearSnapAreaSize { get; set; } = new NearSnapAreaSize() {
|
public NearSnapAreaSize NearSnapAreaSize { get; set; } = new NearSnapAreaSize()
|
||||||
|
{
|
||||||
TopLeft = new double[] { 24, 24 },
|
TopLeft = new double[] { 24, 24 },
|
||||||
TopRight = new double[] { 24, 24 },
|
TopRight = new double[] { 24, 24 },
|
||||||
BottomLeft = new double[] { 24, 24 },
|
BottomLeft = new double[] { 24, 24 },
|
||||||
@@ -50,7 +56,8 @@ namespace Ink_Canvas.Resources.ICCConfiguration {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ICCConfiguration {
|
public class ICCConfiguration
|
||||||
|
{
|
||||||
public ICCFloatingBarConfiguration FloatingBar { get; set; } = new ICCFloatingBarConfiguration();
|
public ICCFloatingBarConfiguration FloatingBar { get; set; } = new ICCFloatingBarConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -359,7 +359,8 @@ namespace Ink_Canvas
|
|||||||
// Set to center
|
// Set to center
|
||||||
double dpiScaleX = 1, dpiScaleY = 1;
|
double dpiScaleX = 1, dpiScaleY = 1;
|
||||||
PresentationSource source = PresentationSource.FromVisual(this);
|
PresentationSource source = PresentationSource.FromVisual(this);
|
||||||
if (source != null) {
|
if (source != null)
|
||||||
|
{
|
||||||
dpiScaleX = source.CompositionTarget.TransformToDevice.M11;
|
dpiScaleX = source.CompositionTarget.TransformToDevice.M11;
|
||||||
dpiScaleY = source.CompositionTarget.TransformToDevice.M22;
|
dpiScaleY = source.CompositionTarget.TransformToDevice.M22;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,22 @@ namespace Ink_Canvas
|
|||||||
if (e.LeftButton == MouseButtonState.Pressed) DragMove();
|
if (e.LeftButton == MouseButtonState.Pressed) DragMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnFullscreen_MouseUp(object sender, MouseButtonEventArgs e) {
|
private void BtnFullscreen_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
if (WindowState == WindowState.Normal) {
|
{
|
||||||
|
if (WindowState == WindowState.Normal)
|
||||||
|
{
|
||||||
WindowState = WindowState.Maximized;
|
WindowState = WindowState.Maximized;
|
||||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.BackToWindow;
|
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.BackToWindow;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
WindowState = WindowState.Normal;
|
WindowState = WindowState.Normal;
|
||||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.FullScreen;
|
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.FullScreen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SCManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e) {
|
private void SCManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
|
||||||
|
{
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using OSVersionExtension;
|
using iNKORE.UI.WPF.Helpers;
|
||||||
|
using OSVersionExtension;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -13,31 +14,38 @@ using System.Windows.Controls.Primitives;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using iNKORE.UI.WPF.Helpers;
|
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows.SettingsViews {
|
namespace Ink_Canvas.Windows.SettingsViews
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// AboutPanel.xaml 的交互逻辑
|
/// AboutPanel.xaml 的交互逻辑
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class AboutPanel : UserControl {
|
public partial class AboutPanel : UserControl
|
||||||
public AboutPanel() {
|
{
|
||||||
|
public AboutPanel()
|
||||||
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
// 关于页面图片横幅
|
// 关于页面图片横幅
|
||||||
if (File.Exists(App.RootPath + "icc-about-illustrations.png")) {
|
if (File.Exists(App.RootPath + "icc-about-illustrations.png"))
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
CopyrightBannerImage.Visibility = Visibility.Visible;
|
CopyrightBannerImage.Visibility = Visibility.Visible;
|
||||||
CopyrightBannerImage.Source =
|
CopyrightBannerImage.Source =
|
||||||
new BitmapImage(new Uri($"file://{App.RootPath + "icc-about-illustrations.png"}"));
|
new BitmapImage(new Uri($"file://{App.RootPath + "icc-about-illustrations.png"}"));
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
CopyrightBannerImage.Visibility = Visibility.Collapsed;
|
CopyrightBannerImage.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关于页面构建时间
|
// 关于页面构建时间
|
||||||
var buildTime = FileBuildTimeHelper.GetBuildDateTime(Assembly.GetExecutingAssembly());
|
var buildTime = FileBuildTimeHelper.GetBuildDateTime(Assembly.GetExecutingAssembly());
|
||||||
if (buildTime != null) {
|
if (buildTime != null)
|
||||||
|
{
|
||||||
var bt = ((DateTimeOffset)buildTime).LocalDateTime;
|
var bt = ((DateTimeOffset)buildTime).LocalDateTime;
|
||||||
var m = bt.Month.ToString().PadLeft(2, '0');
|
var m = bt.Month.ToString().PadLeft(2, '0');
|
||||||
var d = bt.Day.ToString().PadLeft(2, '0');
|
var d = bt.Day.ToString().PadLeft(2, '0');
|
||||||
@@ -52,7 +60,8 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
AboutSystemVersion.Text = $"{OSVersion.GetOperatingSystem()} {OSVersion.GetOSVersion().Version}";
|
AboutSystemVersion.Text = $"{OSVersion.GetOperatingSystem()} {OSVersion.GetOSVersion().Version}";
|
||||||
|
|
||||||
// 关于页面触摸设备
|
// 关于页面触摸设备
|
||||||
var _t_touch = new Thread(() => {
|
var _t_touch = new Thread(() =>
|
||||||
|
{
|
||||||
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
|
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
|
||||||
var support = TouchTabletDetectHelper.IsTouchEnabled();
|
var support = TouchTabletDetectHelper.IsTouchEnabled();
|
||||||
Dispatcher.BeginInvoke(() =>
|
Dispatcher.BeginInvoke(() =>
|
||||||
@@ -61,7 +70,8 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
_t_touch.Start();
|
_t_touch.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TouchTabletDetectHelper {
|
public static class TouchTabletDetectHelper
|
||||||
|
{
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern int GetSystemMetrics(int nIndex);
|
public static extern int GetSystemMetrics(int nIndex);
|
||||||
|
|
||||||
@@ -94,7 +104,8 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
|
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
|
||||||
collection = searcher.Get();
|
collection = searcher.Get();
|
||||||
|
|
||||||
foreach (var device in collection) {
|
foreach (var device in collection)
|
||||||
|
{
|
||||||
var name = new StringBuilder((string)device.GetPropertyValue("Name")).ToString();
|
var name = new StringBuilder((string)device.GetPropertyValue("Name")).ToString();
|
||||||
if (!name.Contains("Pentablet")) continue;
|
if (!name.Contains("Pentablet")) continue;
|
||||||
devices.Add(new USBDeviceInfo(
|
devices.Add(new USBDeviceInfo(
|
||||||
@@ -109,7 +120,8 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FileBuildTimeHelper {
|
public static class FileBuildTimeHelper
|
||||||
|
{
|
||||||
public struct _IMAGE_FILE_HEADER
|
public struct _IMAGE_FILE_HEADER
|
||||||
{
|
{
|
||||||
public ushort Machine;
|
public ushort Machine;
|
||||||
@@ -156,36 +168,45 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
||||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedNoShadowEffect;
|
public event EventHandler<RoutedEventArgs> IsTopBarNeedNoShadowEffect;
|
||||||
|
|
||||||
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e) {
|
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||||
|
{
|
||||||
var scrollViewer = (ScrollViewer)sender;
|
var scrollViewer = (ScrollViewer)sender;
|
||||||
if (scrollViewer.VerticalOffset >= 10) {
|
if (scrollViewer.VerticalOffset >= 10)
|
||||||
|
{
|
||||||
IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
|
IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
|
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBar_Scroll(object sender, RoutedEventArgs e) {
|
private void ScrollBar_Scroll(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
var scrollbar = (ScrollBar)sender;
|
var scrollbar = (ScrollBar)sender;
|
||||||
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
|
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
|
||||||
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
|
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e) {
|
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
var border = (Border)sender;
|
var border = (Border)sender;
|
||||||
if (border.Child is Track track) {
|
if (border.Child is Track track)
|
||||||
|
{
|
||||||
track.Width = 16;
|
track.Width = 16;
|
||||||
track.Margin = new Thickness(0, 0, -2, 0);
|
track.Margin = new Thickness(0, 0, -2, 0);
|
||||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||||
if (scrollbar != null) scrollbar.Width = 16;
|
if (scrollbar != null) scrollbar.Width = 16;
|
||||||
var grid = track.FindAscendant<Grid>();
|
var grid = track.FindAscendant<Grid>();
|
||||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||||
|
{
|
||||||
backgroundBorder.Width = 8;
|
backgroundBorder.Width = 8;
|
||||||
backgroundBorder.CornerRadius = new CornerRadius(4);
|
backgroundBorder.CornerRadius = new CornerRadius(4);
|
||||||
backgroundBorder.Opacity = 1;
|
backgroundBorder.Opacity = 1;
|
||||||
}
|
}
|
||||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||||
if (thumb != null) {
|
if (thumb != null)
|
||||||
|
{
|
||||||
var _thumb = thumb as Border;
|
var _thumb = thumb as Border;
|
||||||
_thumb.CornerRadius = new CornerRadius(4);
|
_thumb.CornerRadius = new CornerRadius(4);
|
||||||
_thumb.Width = 8;
|
_thumb.Width = 8;
|
||||||
@@ -195,23 +216,27 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e) {
|
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
var border = (Border)sender;
|
var border = (Border)sender;
|
||||||
border.Background = new SolidColorBrush(Colors.Transparent);
|
border.Background = new SolidColorBrush(Colors.Transparent);
|
||||||
border.CornerRadius = new CornerRadius(0);
|
border.CornerRadius = new CornerRadius(0);
|
||||||
if (border.Child is Track track) {
|
if (border.Child is Track track)
|
||||||
|
{
|
||||||
track.Width = 6;
|
track.Width = 6;
|
||||||
track.Margin = new Thickness(0, 0, 0, 0);
|
track.Margin = new Thickness(0, 0, 0, 0);
|
||||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||||
if (scrollbar != null) scrollbar.Width = 6;
|
if (scrollbar != null) scrollbar.Width = 6;
|
||||||
var grid = track.FindAscendant<Grid>();
|
var grid = track.FindAscendant<Grid>();
|
||||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||||
|
{
|
||||||
backgroundBorder.Width = 3;
|
backgroundBorder.Width = 3;
|
||||||
backgroundBorder.CornerRadius = new CornerRadius(1.5);
|
backgroundBorder.CornerRadius = new CornerRadius(1.5);
|
||||||
backgroundBorder.Opacity = 0;
|
backgroundBorder.Opacity = 0;
|
||||||
}
|
}
|
||||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||||
if (thumb != null) {
|
if (thumb != null)
|
||||||
|
{
|
||||||
var _thumb = thumb as Border;
|
var _thumb = thumb as Border;
|
||||||
_thumb.CornerRadius = new CornerRadius(1.5);
|
_thumb.CornerRadius = new CornerRadius(1.5);
|
||||||
_thumb.Width = 3;
|
_thumb.Width = 3;
|
||||||
@@ -221,13 +246,15 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e) {
|
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
var thumb = (Thumb)sender;
|
var thumb = (Thumb)sender;
|
||||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
|
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e) {
|
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
var thumb = (Thumb)sender;
|
var thumb = (Thumb)sender;
|
||||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
||||||
|
|||||||
@@ -2,11 +2,15 @@
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows.SettingsViews {
|
namespace Ink_Canvas.Windows.SettingsViews
|
||||||
public partial class AppearancePanel : UserControl {
|
{
|
||||||
public AppearancePanel() {
|
public partial class AppearancePanel : UserControl
|
||||||
|
{
|
||||||
|
public AppearancePanel()
|
||||||
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
BaseView.SettingsPanels.Add(new SettingsViewPanel() {
|
BaseView.SettingsPanels.Add(new SettingsViewPanel()
|
||||||
|
{
|
||||||
Title = "新版设置测试",
|
Title = "新版设置测试",
|
||||||
Items = new ObservableCollection<SettingsItem>(new SettingsItem[] {
|
Items = new ObservableCollection<SettingsItem>(new SettingsItem[] {
|
||||||
new SettingsItem() {
|
new SettingsItem() {
|
||||||
@@ -55,7 +59,8 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
BaseView.SettingsPanels[0].Items[5].OnToggleSwitchToggled += (sender, args) => {
|
BaseView.SettingsPanels[0].Items[5].OnToggleSwitchToggled += (sender, args) =>
|
||||||
|
{
|
||||||
var item = (SettingsItem)sender;
|
var item = (SettingsItem)sender;
|
||||||
BaseView.SettingsPanels[0].Items[4].ToggleSwitchEnabled = item.ToggleSwitchToggled;
|
BaseView.SettingsPanels[0].Items[4].ToggleSwitchEnabled = item.ToggleSwitchToggled;
|
||||||
};
|
};
|
||||||
|
|||||||
+60
-29
@@ -1,93 +1,120 @@
|
|||||||
using System.Collections.ObjectModel;
|
using iNKORE.UI.WPF.DragDrop;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using iNKORE.UI.WPF.DragDrop;
|
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows.SettingsViews {
|
namespace Ink_Canvas.Windows.SettingsViews
|
||||||
|
{
|
||||||
|
|
||||||
public class FloatingBarItem {
|
public class FloatingBarItem
|
||||||
|
{
|
||||||
public DrawingImage IconSource { get; set; }
|
public DrawingImage IconSource { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class FloatingBarDnDSettingsPanel : UserControl {
|
public partial class FloatingBarDnDSettingsPanel : UserControl
|
||||||
|
{
|
||||||
|
|
||||||
public class BarItemsDropTarget : IDropTarget {
|
public class BarItemsDropTarget : IDropTarget
|
||||||
|
{
|
||||||
public ObservableCollection<FloatingBarItem> BarItems { get; set; } =
|
public ObservableCollection<FloatingBarItem> BarItems { get; set; } =
|
||||||
new ObservableCollection<FloatingBarItem>();
|
new ObservableCollection<FloatingBarItem>();
|
||||||
|
|
||||||
void IDropTarget.DragOver(IDropInfo info) {
|
void IDropTarget.DragOver(IDropInfo info)
|
||||||
|
{
|
||||||
info.Effects = DragDropEffects.Move;
|
info.Effects = DragDropEffects.Move;
|
||||||
info.DropTargetAdorner = DropTargetAdorners.Insert;
|
info.DropTargetAdorner = DropTargetAdorners.Insert;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDropTarget.Drop(IDropInfo info) {
|
void IDropTarget.Drop(IDropInfo info)
|
||||||
if (info.Data is FloatingBarItem draggedItem) {
|
{
|
||||||
|
if (info.Data is FloatingBarItem draggedItem)
|
||||||
|
{
|
||||||
var targetCollection = info.TargetCollection as ObservableCollection<FloatingBarItem>;
|
var targetCollection = info.TargetCollection as ObservableCollection<FloatingBarItem>;
|
||||||
var sourceCollection = info.DragInfo.SourceCollection as ObservableCollection<FloatingBarItem>;
|
var sourceCollection = info.DragInfo.SourceCollection as ObservableCollection<FloatingBarItem>;
|
||||||
|
|
||||||
Trace.WriteLine(info.InsertIndex);
|
Trace.WriteLine(info.InsertIndex);
|
||||||
|
|
||||||
// 在同一个 ObservableCollection 中移动
|
// 在同一个 ObservableCollection 中移动
|
||||||
if (targetCollection.Equals(sourceCollection)) {
|
if (targetCollection.Equals(sourceCollection))
|
||||||
if (info.InsertIndex == 0) {
|
{
|
||||||
|
if (info.InsertIndex == 0)
|
||||||
|
{
|
||||||
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem), 0);
|
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem), 0);
|
||||||
} else if (info.InsertIndex == targetCollection.Count) {
|
}
|
||||||
|
else if (info.InsertIndex == targetCollection.Count)
|
||||||
|
{
|
||||||
targetCollection.Remove(info.Data as FloatingBarItem);
|
targetCollection.Remove(info.Data as FloatingBarItem);
|
||||||
targetCollection.Add(info.Data as FloatingBarItem);
|
targetCollection.Add(info.Data as FloatingBarItem);
|
||||||
} else if ((info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 1 &&
|
}
|
||||||
|
else if ((info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 1 &&
|
||||||
info.InsertPosition == RelativeInsertPosition.AfterTargetItem) ||
|
info.InsertPosition == RelativeInsertPosition.AfterTargetItem) ||
|
||||||
(info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 0 &&
|
(info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 0 &&
|
||||||
info.InsertPosition == RelativeInsertPosition.BeforeTargetItem)) { } else {
|
info.InsertPosition == RelativeInsertPosition.BeforeTargetItem)) { }
|
||||||
|
else
|
||||||
|
{
|
||||||
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem), info.InsertIndex - 1);
|
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem), info.InsertIndex - 1);
|
||||||
}
|
}
|
||||||
} else { // 跨 ObservableCollection 移动
|
}
|
||||||
|
else
|
||||||
|
{ // 跨 ObservableCollection 移动
|
||||||
sourceCollection.Remove(info.Data as FloatingBarItem);
|
sourceCollection.Remove(info.Data as FloatingBarItem);
|
||||||
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
|
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDropTarget.DragEnter(IDropInfo info) {
|
void IDropTarget.DragEnter(IDropInfo info)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDropTarget.DragLeave(IDropInfo info) {
|
void IDropTarget.DragLeave(IDropInfo info)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BarDrawerItemsDropTarget : IDropTarget {
|
public class BarDrawerItemsDropTarget : IDropTarget
|
||||||
|
{
|
||||||
public ObservableCollection<FloatingBarItem> BarDrawerItems { get; set; } =
|
public ObservableCollection<FloatingBarItem> BarDrawerItems { get; set; } =
|
||||||
new ObservableCollection<FloatingBarItem>();
|
new ObservableCollection<FloatingBarItem>();
|
||||||
|
|
||||||
void IDropTarget.DragOver(IDropInfo info) {
|
void IDropTarget.DragOver(IDropInfo info)
|
||||||
|
{
|
||||||
info.Effects = DragDropEffects.Move;
|
info.Effects = DragDropEffects.Move;
|
||||||
info.DropTargetAdorner = DropTargetAdorners.Insert;
|
info.DropTargetAdorner = DropTargetAdorners.Insert;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDropTarget.Drop(IDropInfo info) {
|
void IDropTarget.Drop(IDropInfo info)
|
||||||
if (info.Data is FloatingBarItem draggedItem) {
|
{
|
||||||
|
if (info.Data is FloatingBarItem draggedItem)
|
||||||
|
{
|
||||||
var targetCollection = info.TargetCollection as ObservableCollection<FloatingBarItem>;
|
var targetCollection = info.TargetCollection as ObservableCollection<FloatingBarItem>;
|
||||||
var sourceCollection = info.DragInfo.SourceCollection as ObservableCollection<FloatingBarItem>;
|
var sourceCollection = info.DragInfo.SourceCollection as ObservableCollection<FloatingBarItem>;
|
||||||
|
|
||||||
// 在同一个 ObservableCollection 中移动
|
// 在同一个 ObservableCollection 中移动
|
||||||
if (targetCollection.Equals(sourceCollection)) {
|
if (targetCollection.Equals(sourceCollection))
|
||||||
|
{
|
||||||
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
|
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
|
||||||
} else { // 跨 ObservableCollection 移动
|
}
|
||||||
|
else
|
||||||
|
{ // 跨 ObservableCollection 移动
|
||||||
sourceCollection.Remove(info.Data as FloatingBarItem);
|
sourceCollection.Remove(info.Data as FloatingBarItem);
|
||||||
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
|
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDropTarget.DragEnter(IDropInfo info) {
|
void IDropTarget.DragEnter(IDropInfo info)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDropTarget.DragLeave(IDropInfo info) {
|
void IDropTarget.DragLeave(IDropInfo info)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,19 +123,23 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
public BarItemsDropTarget barItems { get; set; } = new BarItemsDropTarget();
|
public BarItemsDropTarget barItems { get; set; } = new BarItemsDropTarget();
|
||||||
public BarDrawerItemsDropTarget barDrawerItems { get; set; } = new BarDrawerItemsDropTarget();
|
public BarDrawerItemsDropTarget barDrawerItems { get; set; } = new BarDrawerItemsDropTarget();
|
||||||
|
|
||||||
public FloatingBarDnDSettingsPanel() {
|
public FloatingBarDnDSettingsPanel()
|
||||||
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
ToolbarItemsControl.DataContext = barItems;
|
ToolbarItemsControl.DataContext = barItems;
|
||||||
ToolbarDrawerItemsControl.DataContext = barDrawerItems;
|
ToolbarDrawerItemsControl.DataContext = barDrawerItems;
|
||||||
|
|
||||||
barItems.BarItems.Add(new FloatingBarItem() {
|
barItems.BarItems.Add(new FloatingBarItem()
|
||||||
|
{
|
||||||
IconSource = FindResource("EraserIcon") as DrawingImage,
|
IconSource = FindResource("EraserIcon") as DrawingImage,
|
||||||
});
|
});
|
||||||
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem() {
|
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem()
|
||||||
|
{
|
||||||
IconSource = FindResource("CursorIcon") as DrawingImage,
|
IconSource = FindResource("CursorIcon") as DrawingImage,
|
||||||
});
|
});
|
||||||
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem() {
|
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem()
|
||||||
|
{
|
||||||
IconSource = FindResource("PenIcon") as DrawingImage,
|
IconSource = FindResource("PenIcon") as DrawingImage,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using System;
|
using iNKORE.UI.WPF.Helpers;
|
||||||
|
using iNKORE.UI.WPF.Modern.Controls;
|
||||||
|
using System;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -6,12 +8,12 @@ using System.Windows.Controls;
|
|||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using iNKORE.UI.WPF.Helpers;
|
|
||||||
using iNKORE.UI.WPF.Modern.Controls;
|
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows.SettingsViews {
|
namespace Ink_Canvas.Windows.SettingsViews
|
||||||
|
{
|
||||||
|
|
||||||
public class SettingsViewPanel {
|
public class SettingsViewPanel
|
||||||
|
{
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public Visibility _TitleVisibility => String.IsNullOrWhiteSpace(Title) ? Visibility.Collapsed : Visibility.Visible;
|
public Visibility _TitleVisibility => String.IsNullOrWhiteSpace(Title) ? Visibility.Collapsed : Visibility.Visible;
|
||||||
public Thickness _PanelMargin =>
|
public Thickness _PanelMargin =>
|
||||||
@@ -19,14 +21,16 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
public ObservableCollection<SettingsItem> Items { get; set; } = new ObservableCollection<SettingsItem>() { };
|
public ObservableCollection<SettingsItem> Items { get; set; } = new ObservableCollection<SettingsItem>() { };
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SettingsItemType {
|
public enum SettingsItemType
|
||||||
|
{
|
||||||
Plain, // 只显示Title和Description
|
Plain, // 只显示Title和Description
|
||||||
SingleToggleSwtich,
|
SingleToggleSwtich,
|
||||||
ToggleSwitchWithArrowButton,
|
ToggleSwitchWithArrowButton,
|
||||||
SelectionButtons,
|
SelectionButtons,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SettingsItem : INotifyPropertyChanged {
|
public class SettingsItem : INotifyPropertyChanged
|
||||||
|
{
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public SettingsItemType Type { get; set; } = SettingsItemType.Plain;
|
public SettingsItemType Type { get; set; } = SettingsItemType.Plain;
|
||||||
@@ -36,10 +40,13 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
public Visibility _ToggleSwitchVisibility =>
|
public Visibility _ToggleSwitchVisibility =>
|
||||||
Type == SettingsItemType.SingleToggleSwtich || Type == SettingsItemType.ToggleSwitchWithArrowButton ? Visibility.Visible : Visibility.Collapsed;
|
Type == SettingsItemType.SingleToggleSwtich || Type == SettingsItemType.ToggleSwitchWithArrowButton ? Visibility.Visible : Visibility.Collapsed;
|
||||||
private bool _toggleSwitchToggled;
|
private bool _toggleSwitchToggled;
|
||||||
public bool ToggleSwitchToggled {
|
public bool ToggleSwitchToggled
|
||||||
|
{
|
||||||
get => _toggleSwitchToggled;
|
get => _toggleSwitchToggled;
|
||||||
set {
|
set
|
||||||
if (_toggleSwitchToggled != value) {
|
{
|
||||||
|
if (_toggleSwitchToggled != value)
|
||||||
|
{
|
||||||
_toggleSwitchToggled = value;
|
_toggleSwitchToggled = value;
|
||||||
OnPropertyChanged(nameof(ToggleSwitchToggled)); // 通知绑定控件属性变化
|
OnPropertyChanged(nameof(ToggleSwitchToggled)); // 通知绑定控件属性变化
|
||||||
OnToggleSwitchToggled?.Invoke(this, EventArgs.Empty); // 触发事件
|
OnToggleSwitchToggled?.Invoke(this, EventArgs.Empty); // 触发事件
|
||||||
@@ -48,15 +55,19 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
}
|
}
|
||||||
public event EventHandler OnToggleSwitchToggled;
|
public event EventHandler OnToggleSwitchToggled;
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
protected virtual void OnPropertyChanged(string propertyName) {
|
protected virtual void OnPropertyChanged(string propertyName)
|
||||||
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private SolidColorBrush _toggleSwitchBackground = new SolidColorBrush(Color.FromRgb(53, 132, 228));
|
private SolidColorBrush _toggleSwitchBackground = new SolidColorBrush(Color.FromRgb(53, 132, 228));
|
||||||
public SolidColorBrush ToggleSwitchBackground {
|
public SolidColorBrush ToggleSwitchBackground
|
||||||
|
{
|
||||||
get => _toggleSwitchBackground;
|
get => _toggleSwitchBackground;
|
||||||
set {
|
set
|
||||||
if (_toggleSwitchBackground != value) {
|
{
|
||||||
|
if (_toggleSwitchBackground != value)
|
||||||
|
{
|
||||||
_toggleSwitchBackground = value;
|
_toggleSwitchBackground = value;
|
||||||
OnPropertyChanged(nameof(ToggleSwitchBackground)); // 通知绑定控件属性变化
|
OnPropertyChanged(nameof(ToggleSwitchBackground)); // 通知绑定控件属性变化
|
||||||
}
|
}
|
||||||
@@ -64,10 +75,13 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool _toggleSwitchEnabled = true;
|
private bool _toggleSwitchEnabled = true;
|
||||||
public bool ToggleSwitchEnabled {
|
public bool ToggleSwitchEnabled
|
||||||
|
{
|
||||||
get => _toggleSwitchEnabled;
|
get => _toggleSwitchEnabled;
|
||||||
set {
|
set
|
||||||
if (_toggleSwitchEnabled != value) {
|
{
|
||||||
|
if (_toggleSwitchEnabled != value)
|
||||||
|
{
|
||||||
_toggleSwitchEnabled = value;
|
_toggleSwitchEnabled = value;
|
||||||
OnPropertyChanged(nameof(ToggleSwitchEnabled)); // 通知绑定控件属性变化
|
OnPropertyChanged(nameof(ToggleSwitchEnabled)); // 通知绑定控件属性变化
|
||||||
}
|
}
|
||||||
@@ -75,8 +89,10 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class SettingsBaseView : UserControl {
|
public partial class SettingsBaseView : UserControl
|
||||||
public SettingsBaseView() {
|
{
|
||||||
|
public SettingsBaseView()
|
||||||
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
SettingsViewBaseItemsControl.ItemsSource = SettingsPanels;
|
SettingsViewBaseItemsControl.ItemsSource = SettingsPanels;
|
||||||
}
|
}
|
||||||
@@ -87,36 +103,45 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
||||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedNoShadowEffect;
|
public event EventHandler<RoutedEventArgs> IsTopBarNeedNoShadowEffect;
|
||||||
|
|
||||||
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e) {
|
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||||
|
{
|
||||||
var scrollViewer = (ScrollViewer)sender;
|
var scrollViewer = (ScrollViewer)sender;
|
||||||
if (scrollViewer.VerticalOffset >= 10) {
|
if (scrollViewer.VerticalOffset >= 10)
|
||||||
|
{
|
||||||
IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
|
IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
|
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBar_Scroll(object sender, RoutedEventArgs e) {
|
private void ScrollBar_Scroll(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
var scrollbar = (ScrollBar)sender;
|
var scrollbar = (ScrollBar)sender;
|
||||||
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
|
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
|
||||||
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
|
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e) {
|
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
var border = (Border)sender;
|
var border = (Border)sender;
|
||||||
if (border.Child is Track track) {
|
if (border.Child is Track track)
|
||||||
|
{
|
||||||
track.Width = 16;
|
track.Width = 16;
|
||||||
track.Margin = new Thickness(0, 0, -2, 0);
|
track.Margin = new Thickness(0, 0, -2, 0);
|
||||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||||
if (scrollbar != null) scrollbar.Width = 16;
|
if (scrollbar != null) scrollbar.Width = 16;
|
||||||
var grid = track.FindAscendant<Grid>();
|
var grid = track.FindAscendant<Grid>();
|
||||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||||
|
{
|
||||||
backgroundBorder.Width = 8;
|
backgroundBorder.Width = 8;
|
||||||
backgroundBorder.CornerRadius = new CornerRadius(4);
|
backgroundBorder.CornerRadius = new CornerRadius(4);
|
||||||
backgroundBorder.Opacity = 1;
|
backgroundBorder.Opacity = 1;
|
||||||
}
|
}
|
||||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||||
if (thumb != null) {
|
if (thumb != null)
|
||||||
|
{
|
||||||
var _thumb = thumb as Border;
|
var _thumb = thumb as Border;
|
||||||
_thumb.CornerRadius = new CornerRadius(4);
|
_thumb.CornerRadius = new CornerRadius(4);
|
||||||
_thumb.Width = 8;
|
_thumb.Width = 8;
|
||||||
@@ -126,29 +151,34 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleSwitch_OnToggled(object sender, RoutedEventArgs e) {
|
private void ToggleSwitch_OnToggled(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
var toggleswitch = sender as ToggleSwitch;
|
var toggleswitch = sender as ToggleSwitch;
|
||||||
var item = toggleswitch.Tag as SettingsItem;
|
var item = toggleswitch.Tag as SettingsItem;
|
||||||
item.ToggleSwitchToggled = toggleswitch.IsOn;
|
item.ToggleSwitchToggled = toggleswitch.IsOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e) {
|
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
var border = (Border)sender;
|
var border = (Border)sender;
|
||||||
border.Background = new SolidColorBrush(Colors.Transparent);
|
border.Background = new SolidColorBrush(Colors.Transparent);
|
||||||
border.CornerRadius = new CornerRadius(0);
|
border.CornerRadius = new CornerRadius(0);
|
||||||
if (border.Child is Track track) {
|
if (border.Child is Track track)
|
||||||
|
{
|
||||||
track.Width = 6;
|
track.Width = 6;
|
||||||
track.Margin = new Thickness(0, 0, 0, 0);
|
track.Margin = new Thickness(0, 0, 0, 0);
|
||||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||||
if (scrollbar != null) scrollbar.Width = 6;
|
if (scrollbar != null) scrollbar.Width = 6;
|
||||||
var grid = track.FindAscendant<Grid>();
|
var grid = track.FindAscendant<Grid>();
|
||||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||||
|
{
|
||||||
backgroundBorder.Width = 3;
|
backgroundBorder.Width = 3;
|
||||||
backgroundBorder.CornerRadius = new CornerRadius(1.5);
|
backgroundBorder.CornerRadius = new CornerRadius(1.5);
|
||||||
backgroundBorder.Opacity = 0;
|
backgroundBorder.Opacity = 0;
|
||||||
}
|
}
|
||||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||||
if (thumb != null) {
|
if (thumb != null)
|
||||||
|
{
|
||||||
var _thumb = thumb as Border;
|
var _thumb = thumb as Border;
|
||||||
_thumb.CornerRadius = new CornerRadius(1.5);
|
_thumb.CornerRadius = new CornerRadius(1.5);
|
||||||
_thumb.Width = 3;
|
_thumb.Width = 3;
|
||||||
@@ -158,13 +188,15 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e) {
|
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
var thumb = (Thumb)sender;
|
var thumb = (Thumb)sender;
|
||||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
|
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e) {
|
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
var thumb = (Thumb)sender;
|
var thumb = (Thumb)sender;
|
||||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using iNKORE.UI.WPF.Helpers;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -8,72 +9,84 @@ using System.Windows.Controls.Primitives;
|
|||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using iNKORE.UI.WPF.Helpers;
|
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows {
|
namespace Ink_Canvas.Windows
|
||||||
public partial class SettingsWindow : Window {
|
{
|
||||||
|
public partial class SettingsWindow : Window
|
||||||
|
{
|
||||||
|
|
||||||
public SettingsWindow() {
|
public SettingsWindow()
|
||||||
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
// 初始化侧边栏项目
|
// 初始化侧边栏项目
|
||||||
SidebarItemsControl.ItemsSource = SidebarItems;
|
SidebarItemsControl.ItemsSource = SidebarItems;
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "启动时行为",
|
Title = "启动时行为",
|
||||||
Name = "StartupItem",
|
Name = "StartupItem",
|
||||||
IconSource = FindResource("StartupIcon") as DrawingImage,
|
IconSource = FindResource("StartupIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "画板和墨迹",
|
Title = "画板和墨迹",
|
||||||
Name = "CanvasAndInkItem",
|
Name = "CanvasAndInkItem",
|
||||||
IconSource = FindResource("CanvasAndInkIcon") as DrawingImage,
|
IconSource = FindResource("CanvasAndInkIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "手势操作",
|
Title = "手势操作",
|
||||||
Name = "GesturesItem",
|
Name = "GesturesItem",
|
||||||
IconSource = FindResource("GesturesIcon") as DrawingImage,
|
IconSource = FindResource("GesturesIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "墨迹纠正",
|
Title = "墨迹纠正",
|
||||||
Name = "InkRecognitionItem",
|
Name = "InkRecognitionItem",
|
||||||
IconSource = FindResource("InkRecognitionIcon") as DrawingImage,
|
IconSource = FindResource("InkRecognitionIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Separator
|
Type = SidebarItemType.Separator
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "个性化设置",
|
Title = "个性化设置",
|
||||||
Name = "ThemeItem",
|
Name = "ThemeItem",
|
||||||
IconSource = FindResource("AppearanceIcon") as DrawingImage,
|
IconSource = FindResource("AppearanceIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "快捷键设置",
|
Title = "快捷键设置",
|
||||||
Name = "ShortcutsItem",
|
Name = "ShortcutsItem",
|
||||||
IconSource = FindResource("AppearanceIcon") as DrawingImage,
|
IconSource = FindResource("AppearanceIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "崩溃处理",
|
Title = "崩溃处理",
|
||||||
Name = "CrashActionItem",
|
Name = "CrashActionItem",
|
||||||
IconSource = FindResource("AppearanceIcon") as DrawingImage,
|
IconSource = FindResource("AppearanceIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Separator
|
Type = SidebarItemType.Separator
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "PowerPoint 支持",
|
Title = "PowerPoint 支持",
|
||||||
Name = "PowerPointItem",
|
Name = "PowerPointItem",
|
||||||
@@ -81,48 +94,56 @@ namespace Ink_Canvas.Windows {
|
|||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "自动化行为",
|
Title = "自动化行为",
|
||||||
Name = "AutomationItem",
|
Name = "AutomationItem",
|
||||||
IconSource = FindResource("AutomationIcon") as DrawingImage,
|
IconSource = FindResource("AutomationIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "随机点名",
|
Title = "随机点名",
|
||||||
Name = "LuckyRandomItem",
|
Name = "LuckyRandomItem",
|
||||||
IconSource = FindResource("LuckyRandomIcon") as DrawingImage,
|
IconSource = FindResource("LuckyRandomIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Separator
|
Type = SidebarItemType.Separator
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "存储空间",
|
Title = "存储空间",
|
||||||
Name = "StorageItem",
|
Name = "StorageItem",
|
||||||
IconSource = FindResource("StorageIcon") as DrawingImage,
|
IconSource = FindResource("StorageIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "截图和屏幕捕捉",
|
Title = "截图和屏幕捕捉",
|
||||||
Name = "SnapshotItem",
|
Name = "SnapshotItem",
|
||||||
IconSource = FindResource("SnapshotIcon") as DrawingImage,
|
IconSource = FindResource("SnapshotIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Separator
|
Type = SidebarItemType.Separator
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "高级选项",
|
Title = "高级选项",
|
||||||
Name = "AdvancedItem",
|
Name = "AdvancedItem",
|
||||||
IconSource = FindResource("AdvancedIcon") as DrawingImage,
|
IconSource = FindResource("AdvancedIcon") as DrawingImage,
|
||||||
Selected = false,
|
Selected = false,
|
||||||
});
|
});
|
||||||
SidebarItems.Add(new SidebarItem() {
|
SidebarItems.Add(new SidebarItem()
|
||||||
|
{
|
||||||
Type = SidebarItemType.Item,
|
Type = SidebarItemType.Item,
|
||||||
Title = "关于 InkCanvasForClass",
|
Title = "关于 InkCanvasForClass",
|
||||||
Name = "AboutItem",
|
Name = "AboutItem",
|
||||||
@@ -209,25 +230,30 @@ namespace Ink_Canvas.Windows {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum SidebarItemType {
|
public enum SidebarItemType
|
||||||
|
{
|
||||||
Item,
|
Item,
|
||||||
Separator
|
Separator
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SidebarItem {
|
public class SidebarItem
|
||||||
|
{
|
||||||
public SidebarItemType Type { get; set; }
|
public SidebarItemType Type { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public ImageSource IconSource { get; set; }
|
public ImageSource IconSource { get; set; }
|
||||||
public bool Selected { get; set; }
|
public bool Selected { get; set; }
|
||||||
public Visibility _spVisibility {
|
public Visibility _spVisibility
|
||||||
|
{
|
||||||
get => Type == SidebarItemType.Separator ? Visibility.Visible : Visibility.Collapsed;
|
get => Type == SidebarItemType.Separator ? Visibility.Visible : Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
public Visibility _siVisibility {
|
public Visibility _siVisibility
|
||||||
|
{
|
||||||
get => Type == SidebarItemType.Item ? Visibility.Visible : Visibility.Collapsed;
|
get => Type == SidebarItemType.Item ? Visibility.Visible : Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SolidColorBrush _siBackground {
|
public SolidColorBrush _siBackground
|
||||||
|
{
|
||||||
get => Selected
|
get => Selected
|
||||||
? new SolidColorBrush(Color.FromRgb(217, 217, 217))
|
? new SolidColorBrush(Color.FromRgb(217, 217, 217))
|
||||||
: new SolidColorBrush(Colors.Transparent);
|
: new SolidColorBrush(Colors.Transparent);
|
||||||
@@ -242,10 +268,13 @@ namespace Ink_Canvas.Windows {
|
|||||||
public string[] SettingsPaneTitles;
|
public string[] SettingsPaneTitles;
|
||||||
public string[] SettingsPaneNames;
|
public string[] SettingsPaneNames;
|
||||||
|
|
||||||
public void UpdateSidebarItemsSelection() {
|
public void UpdateSidebarItemsSelection()
|
||||||
foreach (var si in SidebarItems) {
|
{
|
||||||
|
foreach (var si in SidebarItems)
|
||||||
|
{
|
||||||
si.Selected = si.Name == _selectedSidebarItemName;
|
si.Selected = si.Name == _selectedSidebarItemName;
|
||||||
if (si.Selected && SettingsWindowTitle != null) {
|
if (si.Selected && SettingsWindowTitle != null)
|
||||||
|
{
|
||||||
SettingsWindowTitle.Text = si.Title;
|
SettingsWindowTitle.Text = si.Title;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,45 +294,57 @@ namespace Ink_Canvas.Windows {
|
|||||||
if (StoragePane != null) StoragePane.Visibility = _selectedSidebarItemName == "StorageItem" ? Visibility.Visible : Visibility.Collapsed;
|
if (StoragePane != null) StoragePane.Visibility = _selectedSidebarItemName == "StorageItem" ? Visibility.Visible : Visibility.Collapsed;
|
||||||
if (SnapshotPane != null) SnapshotPane.Visibility = _selectedSidebarItemName == "SnapshotItem" ? Visibility.Visible : Visibility.Collapsed;
|
if (SnapshotPane != null) SnapshotPane.Visibility = _selectedSidebarItemName == "SnapshotItem" ? Visibility.Visible : Visibility.Collapsed;
|
||||||
if (AdvancedPane != null) AdvancedPane.Visibility = _selectedSidebarItemName == "AdvancedItem" ? Visibility.Visible : Visibility.Collapsed;
|
if (AdvancedPane != null) AdvancedPane.Visibility = _selectedSidebarItemName == "AdvancedItem" ? Visibility.Visible : Visibility.Collapsed;
|
||||||
if (SettingsPaneScrollViewers != null) {
|
if (SettingsPaneScrollViewers != null)
|
||||||
foreach (var sv in SettingsPaneScrollViewers) {
|
{
|
||||||
if (sv != null) {
|
foreach (var sv in SettingsPaneScrollViewers)
|
||||||
|
{
|
||||||
|
if (sv != null)
|
||||||
|
{
|
||||||
sv.ScrollToTop();
|
sv.ScrollToTop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e) {
|
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||||
|
{
|
||||||
var scrollViewer = (ScrollViewer)sender;
|
var scrollViewer = (ScrollViewer)sender;
|
||||||
if (scrollViewer.VerticalOffset >= 10) {
|
if (scrollViewer.VerticalOffset >= 10)
|
||||||
|
{
|
||||||
DropShadowEffectTopBar.Opacity = 0.25;
|
DropShadowEffectTopBar.Opacity = 0.25;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DropShadowEffectTopBar.Opacity = 0;
|
DropShadowEffectTopBar.Opacity = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBar_Scroll(object sender, RoutedEventArgs e) {
|
private void ScrollBar_Scroll(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
var scrollbar = (ScrollBar)sender;
|
var scrollbar = (ScrollBar)sender;
|
||||||
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
|
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
|
||||||
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
|
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e) {
|
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
var border = (Border)sender;
|
var border = (Border)sender;
|
||||||
if (border.Child is Track track) {
|
if (border.Child is Track track)
|
||||||
|
{
|
||||||
track.Width = 16;
|
track.Width = 16;
|
||||||
track.Margin = new Thickness(0, 0, -2, 0);
|
track.Margin = new Thickness(0, 0, -2, 0);
|
||||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||||
if (scrollbar != null) scrollbar.Width = 16;
|
if (scrollbar != null) scrollbar.Width = 16;
|
||||||
var grid = track.FindAscendant<Grid>();
|
var grid = track.FindAscendant<Grid>();
|
||||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||||
|
{
|
||||||
backgroundBorder.Width = 8;
|
backgroundBorder.Width = 8;
|
||||||
backgroundBorder.CornerRadius = new CornerRadius(4);
|
backgroundBorder.CornerRadius = new CornerRadius(4);
|
||||||
backgroundBorder.Opacity = 1;
|
backgroundBorder.Opacity = 1;
|
||||||
}
|
}
|
||||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||||
if (thumb != null) {
|
if (thumb != null)
|
||||||
|
{
|
||||||
var _thumb = thumb as Border;
|
var _thumb = thumb as Border;
|
||||||
_thumb.CornerRadius = new CornerRadius(4);
|
_thumb.CornerRadius = new CornerRadius(4);
|
||||||
_thumb.Width = 8;
|
_thumb.Width = 8;
|
||||||
@@ -313,23 +354,27 @@ namespace Ink_Canvas.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e) {
|
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
var border = (Border)sender;
|
var border = (Border)sender;
|
||||||
border.Background = new SolidColorBrush(Colors.Transparent);
|
border.Background = new SolidColorBrush(Colors.Transparent);
|
||||||
border.CornerRadius = new CornerRadius(0);
|
border.CornerRadius = new CornerRadius(0);
|
||||||
if (border.Child is Track track) {
|
if (border.Child is Track track)
|
||||||
|
{
|
||||||
track.Width = 6;
|
track.Width = 6;
|
||||||
track.Margin = new Thickness(0, 0, 0, 0);
|
track.Margin = new Thickness(0, 0, 0, 0);
|
||||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||||
if (scrollbar != null) scrollbar.Width = 6;
|
if (scrollbar != null) scrollbar.Width = 6;
|
||||||
var grid = track.FindAscendant<Grid>();
|
var grid = track.FindAscendant<Grid>();
|
||||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||||
|
{
|
||||||
backgroundBorder.Width = 3;
|
backgroundBorder.Width = 3;
|
||||||
backgroundBorder.CornerRadius = new CornerRadius(1.5);
|
backgroundBorder.CornerRadius = new CornerRadius(1.5);
|
||||||
backgroundBorder.Opacity = 0;
|
backgroundBorder.Opacity = 0;
|
||||||
}
|
}
|
||||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||||
if (thumb != null) {
|
if (thumb != null)
|
||||||
|
{
|
||||||
var _thumb = thumb as Border;
|
var _thumb = thumb as Border;
|
||||||
_thumb.CornerRadius = new CornerRadius(1.5);
|
_thumb.CornerRadius = new CornerRadius(1.5);
|
||||||
_thumb.Width = 3;
|
_thumb.Width = 3;
|
||||||
@@ -339,13 +384,15 @@ namespace Ink_Canvas.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e) {
|
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
var thumb = (Thumb)sender;
|
var thumb = (Thumb)sender;
|
||||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
|
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e) {
|
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
var thumb = (Thumb)sender;
|
var thumb = (Thumb)sender;
|
||||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
||||||
@@ -353,62 +400,74 @@ namespace Ink_Canvas.Windows {
|
|||||||
|
|
||||||
private Border _sidebarItemMouseDownBorder = null;
|
private Border _sidebarItemMouseDownBorder = null;
|
||||||
|
|
||||||
private void SidebarItem_MouseDown(object sender, MouseButtonEventArgs e) {
|
private void SidebarItem_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
if (_sidebarItemMouseDownBorder != null || _sidebarItemMouseDownBorder == sender) return;
|
if (_sidebarItemMouseDownBorder != null || _sidebarItemMouseDownBorder == sender) return;
|
||||||
_sidebarItemMouseDownBorder = (Border)sender;
|
_sidebarItemMouseDownBorder = (Border)sender;
|
||||||
var bd = sender as Border;
|
var bd = sender as Border;
|
||||||
if (bd.FindDescendantByName("MouseFeedbackBorder") is Border feedbackBd) feedbackBd.Opacity = 0.12;
|
if (bd.FindDescendantByName("MouseFeedbackBorder") is Border feedbackBd) feedbackBd.Opacity = 0.12;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SidebarItem_MouseUp(object sender, MouseButtonEventArgs e) {
|
private void SidebarItem_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
if (_sidebarItemMouseDownBorder == null || _sidebarItemMouseDownBorder != sender) return;
|
if (_sidebarItemMouseDownBorder == null || _sidebarItemMouseDownBorder != sender) return;
|
||||||
if (_sidebarItemMouseDownBorder.Tag is SidebarItem data) _selectedSidebarItemName = data.Name;
|
if (_sidebarItemMouseDownBorder.Tag is SidebarItem data) _selectedSidebarItemName = data.Name;
|
||||||
SidebarItem_MouseLeave(sender, null);
|
SidebarItem_MouseLeave(sender, null);
|
||||||
UpdateSidebarItemsSelection();
|
UpdateSidebarItemsSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SidebarItem_MouseLeave(object sender, MouseEventArgs e) {
|
private void SidebarItem_MouseLeave(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
if (_sidebarItemMouseDownBorder == null || _sidebarItemMouseDownBorder != sender) return;
|
if (_sidebarItemMouseDownBorder == null || _sidebarItemMouseDownBorder != sender) return;
|
||||||
if (_sidebarItemMouseDownBorder.FindDescendantByName("MouseFeedbackBorder") is Border feedbackBd) feedbackBd.Opacity = 0;
|
if (_sidebarItemMouseDownBorder.FindDescendantByName("MouseFeedbackBorder") is Border feedbackBd) feedbackBd.Opacity = 0;
|
||||||
_sidebarItemMouseDownBorder = null;
|
_sidebarItemMouseDownBorder = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CloseButton_Click(object sender, MouseButtonEventArgs e) {
|
private void CloseButton_Click(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchButton_Click(object sender, MouseButtonEventArgs e) {
|
private void SearchButton_Click(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
// 搜索功能 - 可以显示搜索框或搜索对话框
|
// 搜索功能 - 可以显示搜索框或搜索对话框
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MenuButton_Click(object sender, MouseButtonEventArgs e) {
|
private void MenuButton_Click(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
// 菜单功能 - 可以显示上下文菜单或选项菜单
|
// 菜单功能 - 可以显示上下文菜单或选项菜单
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleSwitch_Click(object sender, MouseButtonEventArgs e) {
|
private void ToggleSwitch_Click(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
var border = sender as Border;
|
var border = sender as Border;
|
||||||
if (border != null) {
|
if (border != null)
|
||||||
|
{
|
||||||
// 切换开关状态
|
// 切换开关状态
|
||||||
bool isOn = border.Background.ToString() == "#FF3584E4";
|
bool isOn = border.Background.ToString() == "#FF3584E4";
|
||||||
border.Background = isOn ? new SolidColorBrush(Color.FromRgb(225, 225, 225)) : new SolidColorBrush(Color.FromRgb(53, 132, 228));
|
border.Background = isOn ? new SolidColorBrush(Color.FromRgb(225, 225, 225)) : new SolidColorBrush(Color.FromRgb(53, 132, 228));
|
||||||
|
|
||||||
// 切换内部圆点的位置
|
// 切换内部圆点的位置
|
||||||
var innerBorder = border.Child as Border;
|
var innerBorder = border.Child as Border;
|
||||||
if (innerBorder != null) {
|
if (innerBorder != null)
|
||||||
|
{
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Left : HorizontalAlignment.Right;
|
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Left : HorizontalAlignment.Right;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据Tag处理不同的设置项
|
// 根据Tag处理不同的设置项
|
||||||
string tag = border.Tag?.ToString();
|
string tag = border.Tag?.ToString();
|
||||||
if (!string.IsNullOrEmpty(tag)) {
|
if (!string.IsNullOrEmpty(tag))
|
||||||
|
{
|
||||||
HandleSettingChange(tag, !isOn);
|
HandleSettingChange(tag, !isOn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleSettingChange(string settingName, bool value) {
|
private void HandleSettingChange(string settingName, bool value)
|
||||||
|
{
|
||||||
// 根据设置名称处理不同的设置项
|
// 根据设置名称处理不同的设置项
|
||||||
switch (settingName) {
|
switch (settingName)
|
||||||
|
{
|
||||||
case "UseObviousCursor":
|
case "UseObviousCursor":
|
||||||
// 处理使用更加明显的画笔光标设置
|
// 处理使用更加明显的画笔光标设置
|
||||||
break;
|
break;
|
||||||
@@ -496,18 +555,22 @@ namespace Ink_Canvas.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OptionButton_Click(object sender, MouseButtonEventArgs e) {
|
private void OptionButton_Click(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
var border = sender as Border;
|
var border = sender as Border;
|
||||||
if (border != null) {
|
if (border != null)
|
||||||
|
{
|
||||||
string tag = border.Tag?.ToString();
|
string tag = border.Tag?.ToString();
|
||||||
if (!string.IsNullOrEmpty(tag)) {
|
if (!string.IsNullOrEmpty(tag))
|
||||||
|
{
|
||||||
// 清除同组其他按钮的选中状态
|
// 清除同组其他按钮的选中状态
|
||||||
ClearOtherOptionsInGroup(border, tag);
|
ClearOtherOptionsInGroup(border, tag);
|
||||||
|
|
||||||
// 设置当前按钮为选中状态
|
// 设置当前按钮为选中状态
|
||||||
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
||||||
var textBlock = border.Child as TextBlock;
|
var textBlock = border.Child as TextBlock;
|
||||||
if (textBlock != null) {
|
if (textBlock != null)
|
||||||
|
{
|
||||||
textBlock.FontWeight = FontWeights.Bold;
|
textBlock.FontWeight = FontWeights.Bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,21 +580,27 @@ namespace Ink_Canvas.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearOtherOptionsInGroup(Border currentBorder, string currentTag) {
|
private void ClearOtherOptionsInGroup(Border currentBorder, string currentTag)
|
||||||
|
{
|
||||||
// 获取当前按钮所在的父容器
|
// 获取当前按钮所在的父容器
|
||||||
var parent = currentBorder.Parent as StackPanel;
|
var parent = currentBorder.Parent as StackPanel;
|
||||||
if (parent != null) {
|
if (parent != null)
|
||||||
|
{
|
||||||
// 获取组名(Tag中下划线前的部分)
|
// 获取组名(Tag中下划线前的部分)
|
||||||
string groupName = currentTag.Split('_')[0];
|
string groupName = currentTag.Split('_')[0];
|
||||||
|
|
||||||
// 清除同组其他按钮的选中状态
|
// 清除同组其他按钮的选中状态
|
||||||
foreach (var child in parent.Children) {
|
foreach (var child in parent.Children)
|
||||||
if (child is Border border && border != currentBorder) {
|
{
|
||||||
|
if (child is Border border && border != currentBorder)
|
||||||
|
{
|
||||||
string childTag = border.Tag?.ToString();
|
string childTag = border.Tag?.ToString();
|
||||||
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(groupName + "_")) {
|
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(groupName + "_"))
|
||||||
|
{
|
||||||
border.Background = new SolidColorBrush(Colors.Transparent);
|
border.Background = new SolidColorBrush(Colors.Transparent);
|
||||||
var textBlock = border.Child as TextBlock;
|
var textBlock = border.Child as TextBlock;
|
||||||
if (textBlock != null) {
|
if (textBlock != null)
|
||||||
|
{
|
||||||
textBlock.FontWeight = FontWeights.Normal;
|
textBlock.FontWeight = FontWeights.Normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,14 +609,17 @@ namespace Ink_Canvas.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleOptionChange(string optionTag) {
|
private void HandleOptionChange(string optionTag)
|
||||||
|
{
|
||||||
// 根据选项标签处理不同的选项变化
|
// 根据选项标签处理不同的选项变化
|
||||||
string[] parts = optionTag.Split('_');
|
string[] parts = optionTag.Split('_');
|
||||||
if (parts.Length >= 2) {
|
if (parts.Length >= 2)
|
||||||
|
{
|
||||||
string group = parts[0];
|
string group = parts[0];
|
||||||
string value = parts[1];
|
string value = parts[1];
|
||||||
|
|
||||||
switch (group) {
|
switch (group)
|
||||||
|
{
|
||||||
case "EraserSize":
|
case "EraserSize":
|
||||||
// 处理板擦橡皮大小设置
|
// 处理板擦橡皮大小设置
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user