代码清理
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using OSVersionExtension;
|
||||
using iNKORE.UI.WPF.Helpers;
|
||||
using OSVersionExtension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -13,31 +14,38 @@ using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using iNKORE.UI.WPF.Helpers;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews {
|
||||
namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
/// <summary>
|
||||
/// AboutPanel.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class AboutPanel : UserControl {
|
||||
public AboutPanel() {
|
||||
public partial class AboutPanel : UserControl
|
||||
{
|
||||
public AboutPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 关于页面图片横幅
|
||||
if (File.Exists(App.RootPath + "icc-about-illustrations.png")) {
|
||||
try {
|
||||
if (File.Exists(App.RootPath + "icc-about-illustrations.png"))
|
||||
{
|
||||
try
|
||||
{
|
||||
CopyrightBannerImage.Visibility = Visibility.Visible;
|
||||
CopyrightBannerImage.Source =
|
||||
new BitmapImage(new Uri($"file://{App.RootPath + "icc-about-illustrations.png"}"));
|
||||
}
|
||||
catch { }
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyrightBannerImage.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
// 关于页面构建时间
|
||||
var buildTime = FileBuildTimeHelper.GetBuildDateTime(Assembly.GetExecutingAssembly());
|
||||
if (buildTime != null) {
|
||||
if (buildTime != null)
|
||||
{
|
||||
var bt = ((DateTimeOffset)buildTime).LocalDateTime;
|
||||
var m = bt.Month.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}";
|
||||
|
||||
// 关于页面触摸设备
|
||||
var _t_touch = new Thread(() => {
|
||||
var _t_touch = new Thread(() =>
|
||||
{
|
||||
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
|
||||
var support = TouchTabletDetectHelper.IsTouchEnabled();
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
@@ -61,7 +70,8 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
||||
_t_touch.Start();
|
||||
}
|
||||
|
||||
public static class TouchTabletDetectHelper {
|
||||
public static class TouchTabletDetectHelper
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern int GetSystemMetrics(int nIndex);
|
||||
|
||||
@@ -92,9 +102,10 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
||||
|
||||
ManagementObjectCollection collection;
|
||||
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();
|
||||
if (!name.Contains("Pentablet")) continue;
|
||||
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 ushort Machine;
|
||||
@@ -146,46 +158,55 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
||||
pinnedBuffer.Free();
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
||||
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;
|
||||
if (scrollViewer.VerticalOffset >= 10) {
|
||||
if (scrollViewer.VerticalOffset >= 10)
|
||||
{
|
||||
IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
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 scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
|
||||
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;
|
||||
if (border.Child is Track track) {
|
||||
if (border.Child is Track track)
|
||||
{
|
||||
track.Width = 16;
|
||||
track.Margin = new Thickness(0, 0, -2, 0);
|
||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||
if (scrollbar != null) scrollbar.Width = 16;
|
||||
var grid = track.FindAscendant<Grid>();
|
||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||
{
|
||||
backgroundBorder.Width = 8;
|
||||
backgroundBorder.CornerRadius = new CornerRadius(4);
|
||||
backgroundBorder.Opacity = 1;
|
||||
}
|
||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
|
||||
if (thumb != null) {
|
||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||
if (thumb != null)
|
||||
{
|
||||
var _thumb = thumb as Border;
|
||||
_thumb.CornerRadius = new CornerRadius(4);
|
||||
_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;
|
||||
border.Background = new SolidColorBrush(Colors.Transparent);
|
||||
border.CornerRadius = new CornerRadius(0);
|
||||
if (border.Child is Track track) {
|
||||
if (border.Child is Track track)
|
||||
{
|
||||
track.Width = 6;
|
||||
track.Margin = new Thickness(0, 0, 0, 0);
|
||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||
if (scrollbar != null) scrollbar.Width = 6;
|
||||
var grid = track.FindAscendant<Grid>();
|
||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||
{
|
||||
backgroundBorder.Width = 3;
|
||||
backgroundBorder.CornerRadius = new CornerRadius(1.5);
|
||||
backgroundBorder.Opacity = 0;
|
||||
}
|
||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
|
||||
if (thumb != null) {
|
||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||
if (thumb != null)
|
||||
{
|
||||
var _thumb = thumb as Border;
|
||||
_thumb.CornerRadius = new CornerRadius(1.5);
|
||||
_thumb.Width = 3;
|
||||
@@ -221,15 +246,17 @@ 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 border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
|
||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||
((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 border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
|
||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,15 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews {
|
||||
public partial class AppearancePanel : UserControl {
|
||||
public AppearancePanel() {
|
||||
namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
public partial class AppearancePanel : UserControl
|
||||
{
|
||||
public AppearancePanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
BaseView.SettingsPanels.Add(new SettingsViewPanel() {
|
||||
BaseView.SettingsPanels.Add(new SettingsViewPanel()
|
||||
{
|
||||
Title = "新版设置测试",
|
||||
Items = new ObservableCollection<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;
|
||||
BaseView.SettingsPanels[0].Items[4].ToggleSwitchEnabled = item.ToggleSwitchToggled;
|
||||
};
|
||||
|
||||
+67
-36
@@ -1,93 +1,120 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using iNKORE.UI.WPF.DragDrop;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using iNKORE.UI.WPF.DragDrop;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews {
|
||||
|
||||
public class FloatingBarItem {
|
||||
namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
|
||||
public class FloatingBarItem
|
||||
{
|
||||
public DrawingImage IconSource { get; set; }
|
||||
}
|
||||
|
||||
public partial class FloatingBarDnDSettingsPanel : UserControl {
|
||||
|
||||
public class BarItemsDropTarget : IDropTarget {
|
||||
public partial class FloatingBarDnDSettingsPanel : UserControl
|
||||
{
|
||||
|
||||
public class BarItemsDropTarget : IDropTarget
|
||||
{
|
||||
public ObservableCollection<FloatingBarItem> BarItems { get; set; } =
|
||||
new ObservableCollection<FloatingBarItem>();
|
||||
|
||||
void IDropTarget.DragOver(IDropInfo info) {
|
||||
void IDropTarget.DragOver(IDropInfo info)
|
||||
{
|
||||
info.Effects = DragDropEffects.Move;
|
||||
info.DropTargetAdorner = DropTargetAdorners.Insert;
|
||||
}
|
||||
|
||||
void IDropTarget.Drop(IDropInfo info) {
|
||||
if (info.Data is FloatingBarItem draggedItem) {
|
||||
void IDropTarget.Drop(IDropInfo info)
|
||||
{
|
||||
if (info.Data is FloatingBarItem draggedItem)
|
||||
{
|
||||
var targetCollection = info.TargetCollection as ObservableCollection<FloatingBarItem>;
|
||||
var sourceCollection = info.DragInfo.SourceCollection as ObservableCollection<FloatingBarItem>;
|
||||
|
||||
Trace.WriteLine(info.InsertIndex);
|
||||
|
||||
// 在同一个 ObservableCollection 中移动
|
||||
if (targetCollection.Equals(sourceCollection)) {
|
||||
if (info.InsertIndex == 0) {
|
||||
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem),0);
|
||||
} else if (info.InsertIndex == targetCollection.Count) {
|
||||
if (targetCollection.Equals(sourceCollection))
|
||||
{
|
||||
if (info.InsertIndex == 0)
|
||||
{
|
||||
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem), 0);
|
||||
}
|
||||
else if (info.InsertIndex == targetCollection.Count)
|
||||
{
|
||||
targetCollection.Remove(info.Data as FloatingBarItem);
|
||||
targetCollection.Add(info.Data as FloatingBarItem);
|
||||
} else if ((info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 1 &&
|
||||
info.InsertPosition == RelativeInsertPosition.AfterTargetItem) ||
|
||||
(info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 0 &&
|
||||
info.InsertPosition == RelativeInsertPosition.BeforeTargetItem)) { } else {
|
||||
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem),info.InsertIndex - 1);
|
||||
}
|
||||
} else { // 跨 ObservableCollection 移动
|
||||
else if ((info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 1 &&
|
||||
info.InsertPosition == RelativeInsertPosition.AfterTargetItem) ||
|
||||
(info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 0 &&
|
||||
info.InsertPosition == RelativeInsertPosition.BeforeTargetItem)) { }
|
||||
else
|
||||
{
|
||||
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem), info.InsertIndex - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // 跨 ObservableCollection 移动
|
||||
sourceCollection.Remove(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; } =
|
||||
new ObservableCollection<FloatingBarItem>();
|
||||
|
||||
void IDropTarget.DragOver(IDropInfo info) {
|
||||
void IDropTarget.DragOver(IDropInfo info)
|
||||
{
|
||||
info.Effects = DragDropEffects.Move;
|
||||
info.DropTargetAdorner = DropTargetAdorners.Insert;
|
||||
}
|
||||
|
||||
void IDropTarget.Drop(IDropInfo info) {
|
||||
if (info.Data is FloatingBarItem draggedItem) {
|
||||
void IDropTarget.Drop(IDropInfo info)
|
||||
{
|
||||
if (info.Data is FloatingBarItem draggedItem)
|
||||
{
|
||||
var targetCollection = info.TargetCollection as ObservableCollection<FloatingBarItem>;
|
||||
var sourceCollection = info.DragInfo.SourceCollection as ObservableCollection<FloatingBarItem>;
|
||||
|
||||
// 在同一个 ObservableCollection 中移动
|
||||
if (targetCollection.Equals(sourceCollection)) {
|
||||
if (targetCollection.Equals(sourceCollection))
|
||||
{
|
||||
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
|
||||
} else { // 跨 ObservableCollection 移动
|
||||
}
|
||||
else
|
||||
{ // 跨 ObservableCollection 移动
|
||||
sourceCollection.Remove(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 BarDrawerItemsDropTarget barDrawerItems { get; set; } = new BarDrawerItemsDropTarget();
|
||||
|
||||
public FloatingBarDnDSettingsPanel() {
|
||||
public FloatingBarDnDSettingsPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ToolbarItemsControl.DataContext = barItems;
|
||||
ToolbarDrawerItemsControl.DataContext = barDrawerItems;
|
||||
|
||||
barItems.BarItems.Add(new FloatingBarItem() {
|
||||
barItems.BarItems.Add(new FloatingBarItem()
|
||||
{
|
||||
IconSource = FindResource("EraserIcon") as DrawingImage,
|
||||
});
|
||||
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem() {
|
||||
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem()
|
||||
{
|
||||
IconSource = FindResource("CursorIcon") as DrawingImage,
|
||||
});
|
||||
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem() {
|
||||
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem()
|
||||
{
|
||||
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.ComponentModel;
|
||||
using System.Windows;
|
||||
@@ -6,12 +8,12 @@ using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
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 Visibility _TitleVisibility => String.IsNullOrWhiteSpace(Title) ? Visibility.Collapsed : Visibility.Visible;
|
||||
public Thickness _PanelMargin =>
|
||||
@@ -19,14 +21,16 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
||||
public ObservableCollection<SettingsItem> Items { get; set; } = new ObservableCollection<SettingsItem>() { };
|
||||
}
|
||||
|
||||
public enum SettingsItemType {
|
||||
public enum SettingsItemType
|
||||
{
|
||||
Plain, // 只显示Title和Description
|
||||
SingleToggleSwtich,
|
||||
ToggleSwitchWithArrowButton,
|
||||
SelectionButtons,
|
||||
}
|
||||
|
||||
public class SettingsItem : INotifyPropertyChanged {
|
||||
public class SettingsItem : INotifyPropertyChanged
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public SettingsItemType Type { get; set; } = SettingsItemType.Plain;
|
||||
@@ -36,10 +40,13 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
||||
public Visibility _ToggleSwitchVisibility =>
|
||||
Type == SettingsItemType.SingleToggleSwtich || Type == SettingsItemType.ToggleSwitchWithArrowButton ? Visibility.Visible : Visibility.Collapsed;
|
||||
private bool _toggleSwitchToggled;
|
||||
public bool ToggleSwitchToggled {
|
||||
public bool ToggleSwitchToggled
|
||||
{
|
||||
get => _toggleSwitchToggled;
|
||||
set {
|
||||
if (_toggleSwitchToggled != value) {
|
||||
set
|
||||
{
|
||||
if (_toggleSwitchToggled != value)
|
||||
{
|
||||
_toggleSwitchToggled = value;
|
||||
OnPropertyChanged(nameof(ToggleSwitchToggled)); // 通知绑定控件属性变化
|
||||
OnToggleSwitchToggled?.Invoke(this, EventArgs.Empty); // 触发事件
|
||||
@@ -48,15 +55,19 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
||||
}
|
||||
public event EventHandler OnToggleSwitchToggled;
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName) {
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private SolidColorBrush _toggleSwitchBackground = new SolidColorBrush(Color.FromRgb(53, 132, 228));
|
||||
public SolidColorBrush ToggleSwitchBackground {
|
||||
public SolidColorBrush ToggleSwitchBackground
|
||||
{
|
||||
get => _toggleSwitchBackground;
|
||||
set {
|
||||
if (_toggleSwitchBackground != value) {
|
||||
set
|
||||
{
|
||||
if (_toggleSwitchBackground != value)
|
||||
{
|
||||
_toggleSwitchBackground = value;
|
||||
OnPropertyChanged(nameof(ToggleSwitchBackground)); // 通知绑定控件属性变化
|
||||
}
|
||||
@@ -64,19 +75,24 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
||||
}
|
||||
|
||||
private bool _toggleSwitchEnabled = true;
|
||||
public bool ToggleSwitchEnabled {
|
||||
public bool ToggleSwitchEnabled
|
||||
{
|
||||
get => _toggleSwitchEnabled;
|
||||
set {
|
||||
if (_toggleSwitchEnabled != value) {
|
||||
set
|
||||
{
|
||||
if (_toggleSwitchEnabled != value)
|
||||
{
|
||||
_toggleSwitchEnabled = value;
|
||||
OnPropertyChanged(nameof(ToggleSwitchEnabled)); // 通知绑定控件属性变化
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public partial class SettingsBaseView : UserControl {
|
||||
public SettingsBaseView() {
|
||||
|
||||
public partial class SettingsBaseView : UserControl
|
||||
{
|
||||
public SettingsBaseView()
|
||||
{
|
||||
InitializeComponent();
|
||||
SettingsViewBaseItemsControl.ItemsSource = SettingsPanels;
|
||||
}
|
||||
@@ -84,39 +100,48 @@ namespace Ink_Canvas.Windows.SettingsViews {
|
||||
public ObservableCollection<SettingsViewPanel> SettingsPanels { get; set; } =
|
||||
new ObservableCollection<SettingsViewPanel>() { };
|
||||
|
||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
||||
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
|
||||
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;
|
||||
if (scrollViewer.VerticalOffset >= 10) {
|
||||
if (scrollViewer.VerticalOffset >= 10)
|
||||
{
|
||||
IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
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 scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
|
||||
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;
|
||||
if (border.Child is Track track) {
|
||||
if (border.Child is Track track)
|
||||
{
|
||||
track.Width = 16;
|
||||
track.Margin = new Thickness(0, 0, -2, 0);
|
||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||
if (scrollbar != null) scrollbar.Width = 16;
|
||||
var grid = track.FindAscendant<Grid>();
|
||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||
{
|
||||
backgroundBorder.Width = 8;
|
||||
backgroundBorder.CornerRadius = new CornerRadius(4);
|
||||
backgroundBorder.Opacity = 1;
|
||||
}
|
||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
|
||||
if (thumb != null) {
|
||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||
if (thumb != null)
|
||||
{
|
||||
var _thumb = thumb as Border;
|
||||
_thumb.CornerRadius = new CornerRadius(4);
|
||||
_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 item = toggleswitch.Tag as SettingsItem;
|
||||
item.ToggleSwitchToggled = toggleswitch.IsOn;
|
||||
}
|
||||
|
||||
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e) {
|
||||
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
var border = (Border)sender;
|
||||
border.Background = new SolidColorBrush(Colors.Transparent);
|
||||
border.CornerRadius = new CornerRadius(0);
|
||||
if (border.Child is Track track) {
|
||||
if (border.Child is Track track)
|
||||
{
|
||||
track.Width = 6;
|
||||
track.Margin = new Thickness(0, 0, 0, 0);
|
||||
var scrollbar = track.FindAscendant<ScrollBar>();
|
||||
if (scrollbar != null) scrollbar.Width = 6;
|
||||
var grid = track.FindAscendant<Grid>();
|
||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
|
||||
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder)
|
||||
{
|
||||
backgroundBorder.Width = 3;
|
||||
backgroundBorder.CornerRadius = new CornerRadius(1.5);
|
||||
backgroundBorder.Opacity = 0;
|
||||
}
|
||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
|
||||
if (thumb != null) {
|
||||
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb);
|
||||
if (thumb != null)
|
||||
{
|
||||
var _thumb = thumb as Border;
|
||||
_thumb.CornerRadius = new CornerRadius(1.5);
|
||||
_thumb.Width = 3;
|
||||
@@ -158,15 +188,17 @@ 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 border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
|
||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||
((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 border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
|
||||
var border = thumb.Template.FindName("ScrollbarThumbEx", thumb);
|
||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user