diff --git a/Ink Canvas/App.xaml b/Ink Canvas/App.xaml index 1af86f5..4113188 100644 --- a/Ink Canvas/App.xaml +++ b/Ink Canvas/App.xaml @@ -2,20 +2,235 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Ink_Canvas" - StartupUri="MainWindow.xaml" - xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"> + xmlns:tb="http://www.hardcodet.net/taskbar" + xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern" + StartupUri="MainWindow.xaml"> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ink Canvas/App.xaml.cs b/Ink Canvas/App.xaml.cs index a3ec2b5..57e7300 100644 --- a/Ink Canvas/App.xaml.cs +++ b/Ink Canvas/App.xaml.cs @@ -1,10 +1,13 @@ -using Ink_Canvas.Helpers; +using Hardcodet.Wpf.TaskbarNotification; +using Ink_Canvas.Helpers; using iNKORE.UI.WPF.Modern.Controls; using System; using System.Linq; using System.Reflection; using System.Windows; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; using MessageBox = System.Windows.MessageBox; +using Window = System.Windows.Window; namespace Ink_Canvas { @@ -31,6 +34,8 @@ namespace Ink_Canvas e.Handled = true; } + private TaskbarIcon _taskbar; + void App_Startup(object sender, StartupEventArgs e) { /*if (!StoreHelper.IsStoreApp) */RootPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; @@ -48,6 +53,8 @@ namespace Ink_Canvas Environment.Exit(0); } + _taskbar = (TaskbarIcon)FindResource("Taskbar"); + StartArgs = e.Args; } diff --git a/Ink Canvas/Helpers/DelayActionHelper.cs b/Ink Canvas/Helpers/DelayActionHelper.cs index 3c27e38..bcf1fd5 100644 --- a/Ink Canvas/Helpers/DelayActionHelper.cs +++ b/Ink Canvas/Helpers/DelayActionHelper.cs @@ -8,7 +8,7 @@ using System.Timers; namespace Ink_Canvas.Helpers { - internal class DelayAction + public class DelayAction { Timer _timerDebounce; diff --git a/Ink Canvas/InkCanvasForClass.csproj b/Ink Canvas/InkCanvasForClass.csproj index 591a5b0..d5d6129 100644 --- a/Ink Canvas/InkCanvasForClass.csproj +++ b/Ink Canvas/InkCanvasForClass.csproj @@ -22,27 +22,27 @@ 2.0.2.%2a false false - false + False true Debug;Release;x86 Debug - full + embedded bin\$(Configuration)\ True - full + embedded bin\$(Configuration)\ True - full + embedded bin\$(Configuration)\ True - icc.ico + Resources\icc.ico bin\$(Platform)\$(Configuration)\ @@ -138,6 +138,7 @@ + @@ -189,6 +190,7 @@ + @@ -464,10 +466,6 @@ - - - - @@ -475,6 +473,7 @@ + @@ -484,6 +483,7 @@ + diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index b21950f..c0028eb 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -596,14 +596,46 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1461,7 +1493,7 @@ + FontWeight="Bold" Toggled="ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled" /> @@ -1471,7 +1503,7 @@ @@ -1485,6 +1517,7 @@ FontSize="14" Margin="0,0,16,0" /> - + + + + + + + + + + + @@ -5819,9 +5861,18 @@ MouseUp="ImageBlackboard_MouseUp" Background="Transparent" Orientation="Vertical" HorizontalAlignment="Center" Width="28" Margin="0,-2"> - + + + + + + + + + + + @@ -5832,9 +5883,18 @@ MouseUp="SymbolIconTools_MouseUp" Background="Transparent" Orientation="Vertical" HorizontalAlignment="Center" Width="28" Margin="0,-2"> - + + + + + + + + + + + @@ -5846,9 +5906,18 @@ MouseUp="FoldFloatingBar_MouseUp" Background="Transparent" Orientation="Vertical" HorizontalAlignment="Center" Width="28" Margin="0,-2"> - + + + + + + + + + + + diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index 2bf449f..8b80f4f 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -211,7 +211,7 @@ namespace Ink_Canvas { }).Start(); } - private DelayAction dpiChangedDelayAction = new DelayAction(); + public DelayAction dpiChangedDelayAction = new DelayAction(); private void MainWindow_OnDpiChanged(object sender, DpiChangedEventArgs e) { @@ -254,7 +254,7 @@ namespace Ink_Canvas { } [DllImport("user32.dll", SetLastError = true)] - internal static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); + public static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint); private void MainWindow_OnSizeChanged(object sender, SizeChangedEventArgs e) { if (Settings.Advanced.IsEnableForceFullScreen) { diff --git a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs index 4ea3e18..1b3bcbd 100644 --- a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs +++ b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs @@ -13,7 +13,8 @@ using System.Windows.Media.Imaging; namespace Ink_Canvas { public partial class MainWindow : Window { - private bool isFloatingBarFolded = false, isFloatingBarChangingHideMode = false; + public bool isFloatingBarFolded = false; + private bool isFloatingBarChangingHideMode = false; private void CloseWhiteboardImmediately() { if (isDisplayingOrHidingBlackboard) return; @@ -35,11 +36,16 @@ namespace Ink_Canvas { })).Start(); } - private async void FoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e) { + public async void FoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e) { + var isShouldRejectAction = false; - if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel) - ((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent); - if (sender == Fold_Icon && lastBorderMouseDownObject != Fold_Icon) return; + await Dispatcher.InvokeAsync(() => { + if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel) + ((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent); + if (sender == Fold_Icon && lastBorderMouseDownObject != Fold_Icon) isShouldRejectAction = true; + }); + + if (isShouldRejectAction) return; // FloatingBarIcons_MouseUp_New(sender); if (sender == null) @@ -179,7 +185,7 @@ namespace Ink_Canvas { HideRightQuickPanel(); } - private async void UnFoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e) { + public async void UnFoldFloatingBar_MouseUp(object sender, MouseButtonEventArgs e) { await Dispatcher.InvokeAsync(() => { LeftUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed; RightUnFoldButtonQuickPanel.Visibility = Visibility.Collapsed; diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 08ded5f..d246f47 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -732,7 +732,7 @@ namespace Ink_Canvas { AnimationsHelper.HideWithSlideAndFade(BorderTools); AnimationsHelper.HideWithSlideAndFade(BoardBorderTools); - new RandWindow().Show(); + new RandWindow(Settings).Show(); } public void CheckEraserTypeTab() { @@ -800,7 +800,7 @@ namespace Ink_Canvas { AnimationsHelper.HideWithSlideAndFade(BorderTools); AnimationsHelper.HideWithSlideAndFade(BoardBorderTools); - new RandWindow(true).ShowDialog(); + new RandWindow(Settings,true).ShowDialog(); } private void GridInkReplayButton_MouseUp(object sender, MouseButtonEventArgs e) { @@ -1039,7 +1039,7 @@ namespace Ink_Canvas { private bool isViewboxFloatingBarMarginAnimationRunning = false; - private async void ViewboxFloatingBarMarginAnimation(int MarginFromEdge, + public async void ViewboxFloatingBarMarginAnimation(int MarginFromEdge, bool PosXCaculatedWithTaskbarHeight = false) { if (MarginFromEdge == 60) MarginFromEdge = 55; await Dispatcher.InvokeAsync(() => { @@ -1105,6 +1105,94 @@ namespace Ink_Canvas { }); } + public async void PureViewboxFloatingBarMarginAnimationInDesktopMode() + { + await Dispatcher.InvokeAsync(() => { + ViewboxFloatingBar.Visibility = Visibility.Visible; + isViewboxFloatingBarMarginAnimationRunning = true; + + double dpiScaleX = 1, dpiScaleY = 1; + var source = PresentationSource.FromVisual(this); + if (source != null) + { + dpiScaleX = source.CompositionTarget.TransformToDevice.M11; + dpiScaleY = source.CompositionTarget.TransformToDevice.M22; + } + + var windowHandle = new WindowInteropHelper(this).Handle; + var screen = System.Windows.Forms.Screen.FromHandle(windowHandle); + double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY; + var toolbarHeight = SystemParameters.PrimaryScreenHeight - SystemParameters.FullPrimaryScreenHeight - + SystemParameters.WindowCaptionHeight; + pos.X = (screenWidth - ViewboxFloatingBar.ActualWidth * ViewboxFloatingBarScaleTransform.ScaleX) / 2; + + pos.Y = screenHeight - ViewboxFloatingBar.ActualHeight * ViewboxFloatingBarScaleTransform.ScaleY - + toolbarHeight - ViewboxFloatingBarScaleTransform.ScaleY * 3; + + if (pointDesktop.X != -1 || pointDesktop.Y != -1) pointDesktop = pos; + + var marginAnimation = new ThicknessAnimation + { + Duration = TimeSpan.FromSeconds(0.35), + From = ViewboxFloatingBar.Margin, + To = new Thickness(pos.X, pos.Y, 0, -20) + }; + marginAnimation.EasingFunction = new CircleEase(); + ViewboxFloatingBar.BeginAnimation(MarginProperty, marginAnimation); + }); + + await Task.Delay(349); + + await Dispatcher.InvokeAsync(() => { + ViewboxFloatingBar.Margin = new Thickness(pos.X, pos.Y, -2000, -200); + }); + } + + public async void PureViewboxFloatingBarMarginAnimationInPPTMode() + { + await Dispatcher.InvokeAsync(() => { + ViewboxFloatingBar.Visibility = Visibility.Visible; + isViewboxFloatingBarMarginAnimationRunning = true; + + double dpiScaleX = 1, dpiScaleY = 1; + var source = PresentationSource.FromVisual(this); + if (source != null) + { + dpiScaleX = source.CompositionTarget.TransformToDevice.M11; + dpiScaleY = source.CompositionTarget.TransformToDevice.M22; + } + + var windowHandle = new WindowInteropHelper(this).Handle; + var screen = System.Windows.Forms.Screen.FromHandle(windowHandle); + double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY; + var toolbarHeight = SystemParameters.PrimaryScreenHeight - SystemParameters.FullPrimaryScreenHeight - + SystemParameters.WindowCaptionHeight; + pos.X = (screenWidth - ViewboxFloatingBar.ActualWidth * ViewboxFloatingBarScaleTransform.ScaleX) / 2; + + pos.Y = screenHeight - 55 * ViewboxFloatingBarScaleTransform.ScaleY; + + if (pointPPT.X != -1 || pointPPT.Y != -1) + { + pointPPT = pos; + } + + var marginAnimation = new ThicknessAnimation + { + Duration = TimeSpan.FromSeconds(0.35), + From = ViewboxFloatingBar.Margin, + To = new Thickness(pos.X, pos.Y, 0, -20) + }; + marginAnimation.EasingFunction = new CircleEase(); + ViewboxFloatingBar.BeginAnimation(MarginProperty, marginAnimation); + }); + + await Task.Delay(349); + + await Dispatcher.InvokeAsync(() => { + ViewboxFloatingBar.Margin = new Thickness(pos.X, pos.Y, -2000, -200); + }); + } + private async void CursorIcon_Click(object sender, RoutedEventArgs e) { if (lastBorderMouseDownObject != null && lastBorderMouseDownObject is Panel) ((Panel)lastBorderMouseDownObject).Background = new SolidColorBrush(Colors.Transparent); @@ -1473,12 +1561,12 @@ namespace Ink_Canvas { public static bool CloseIsFromButton = false; - private void BtnExit_Click(object sender, RoutedEventArgs e) { + public void BtnExit_Click(object sender, RoutedEventArgs e) { CloseIsFromButton = true; Close(); } - private void BtnRestart_Click(object sender, RoutedEventArgs e) { + public void BtnRestart_Click(object sender, RoutedEventArgs e) { Process.Start(System.Windows.Forms.Application.ExecutablePath, "-m"); CloseIsFromButton = true; diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs index ad90231..62112dd 100644 --- a/Ink Canvas/MainWindow_cs/MW_Settings.cs +++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs @@ -11,6 +11,7 @@ using System.Windows.Media; using System.Windows.Ink; using System.Windows.Media.Imaging; using System.Windows.Interop; +using Hardcodet.Wpf.TaskbarNotification; using OSVersionExtension; namespace Ink_Canvas { @@ -160,6 +161,15 @@ namespace Ink_Canvas { SaveSettingsToFile(); } + private void ToggleSwitchEnableTrayIcon_Toggled(object sender, RoutedEventArgs e) { + if (!isLoaded) return; + Settings.Appearance.EnableTrayIcon = ToggleSwitchEnableTrayIcon.IsOn; + ICCTrayIconExampleImage.Visibility = Settings.Appearance.EnableTrayIcon ? Visibility.Visible : Visibility.Collapsed; + var _taskbar = (TaskbarIcon)Application.Current.Resources["TaskbarTrayIcon"]; + _taskbar.Visibility = ToggleSwitchEnableTrayIcon.IsOn? Visibility.Visible : Visibility.Collapsed; + SaveSettingsToFile(); + } + private void ComboBoxUnFoldBtnImg_SelectionChanged(object sender, RoutedEventArgs e) { if (!isLoaded) return; Settings.Appearance.UnFoldButtonImageType = ComboBoxUnFoldBtnImg.SelectedIndex; @@ -939,6 +949,7 @@ namespace Ink_Canvas { Settings.Appearance.ChickenSoupSource = 1; Settings.Appearance.ViewboxFloatingBarOpacityValue = 1.0; Settings.Appearance.ViewboxFloatingBarOpacityInPPTValue = 1.0; + Settings.Appearance.EnableTrayIcon = true; Settings.Automation.IsAutoFoldInEasiNote = true; Settings.Automation.IsAutoFoldInEasiNoteIgnoreDesktopAnno = true; @@ -1200,6 +1211,30 @@ namespace Ink_Canvas { #endregion + #region RandSettings + + private void ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled(object sender, RoutedEventArgs e) { + if (!isLoaded) return; + Settings.RandSettings.DisplayRandWindowNamesInputBtn = ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn; + SaveSettingsToFile(); + } + + private void RandWindowOnceCloseLatencySlider_ValueChanged(object sender, RoutedEventArgs e) + { + if (!isLoaded) return; + Settings.RandSettings.RandWindowOnceCloseLatency = RandWindowOnceCloseLatencySlider.Value; + SaveSettingsToFile(); + } + + private void RandWindowOnceMaxStudentsSlider_ValueChanged(object sender, RoutedEventArgs e) + { + if (!isLoaded) return; + Settings.RandSettings.RandWindowOnceMaxStudents = (int)RandWindowOnceMaxStudentsSlider.Value; + SaveSettingsToFile(); + } + + #endregion + public static void SaveSettingsToFile() { var text = JsonConvert.SerializeObject(Settings, Formatting.Indented); try { diff --git a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs index cb6374d..4e55d92 100644 --- a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs +++ b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs @@ -1,4 +1,5 @@ -using Ink_Canvas.Helpers; +using Hardcodet.Wpf.TaskbarNotification; +using Ink_Canvas.Helpers; using Newtonsoft.Json; using OSVersionExtension; using System; @@ -9,11 +10,12 @@ using System.Windows.Ink; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; using File = System.IO.File; using OperatingSystem = OSVersionExtension.OperatingSystem; namespace Ink_Canvas { - public partial class MainWindow : Window { + public partial class MainWindow : System.Windows.Window { private void LoadSettings(bool isStartup = false) { AppVersionTextBlock.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString(); try { @@ -168,6 +170,11 @@ namespace Ink_Canvas { ToggleSwitchEnableQuickPanel.IsOn = Settings.Appearance.IsShowQuickPanel; + ToggleSwitchEnableTrayIcon.IsOn = Settings.Appearance.EnableTrayIcon; + ICCTrayIconExampleImage.Visibility = Settings.Appearance.EnableTrayIcon ? Visibility.Visible : Visibility.Collapsed; + var _taskbar = (TaskbarIcon)Application.Current.Resources["TaskbarTrayIcon"]; + _taskbar.Visibility = Settings.Appearance.EnableTrayIcon ? Visibility.Visible : Visibility.Collapsed; + ViewboxFloatingBar.Opacity = Settings.Appearance.ViewboxFloatingBarOpacityValue; if (Settings.Appearance.EnableViewboxBlackBoardScaleTransform) // 画板 UI 缩放 80% @@ -506,6 +513,9 @@ namespace Ink_Canvas { // RandSettings if (Settings.RandSettings != null) { } else { Settings.RandSettings = new RandSettings(); + ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn; + RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency; + RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents; } // Automation diff --git a/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs b/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs new file mode 100644 index 0000000..a1fff75 --- /dev/null +++ b/Ink Canvas/MainWindow_cs/MW_TrayIcon.cs @@ -0,0 +1,128 @@ +using Ink_Canvas.Helpers; +using iNKORE.UI.WPF.Modern.Controls; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Forms.VisualStyles; +using System.Windows.Interop; +using System.Windows.Media.Animation; + +namespace Ink_Canvas +{ + public partial class App : Application { + + private void SysTrayMenu_Opened(object sender, RoutedEventArgs e) { + var s = (ContextMenu)sender; + var FoldFloatingBarTrayIconMenuItemIconEyeOff = + (Image)((Grid)((MenuItem)s.Items[s.Items.Count-5]).Icon).Children[0]; + var FoldFloatingBarTrayIconMenuItemIconEyeOn = + (Image)((Grid)((MenuItem)s.Items[s.Items.Count - 5]).Icon).Children[1]; + var FoldFloatingBarTrayIconMenuItemHeaderText = + (TextBlock)((SimpleStackPanel)((MenuItem)s.Items[s.Items.Count - 5]).Header).Children[0]; + var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4]; + var HideICCMainWindowTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 9]; + var mainWin = (MainWindow)Application.Current.MainWindow; + if (mainWin.IsLoaded) { + // 判斷是否在收納模式中 + if (mainWin.isFloatingBarFolded) { + FoldFloatingBarTrayIconMenuItemIconEyeOff.Visibility = Visibility.Hidden; + FoldFloatingBarTrayIconMenuItemIconEyeOn.Visibility = Visibility.Visible; + FoldFloatingBarTrayIconMenuItemHeaderText.Text = "退出收纳模式"; + if (!HideICCMainWindowTrayIconMenuItem.IsChecked) { + ResetFloatingBarPositionTrayIconMenuItem.IsEnabled = false; + ResetFloatingBarPositionTrayIconMenuItem.Opacity = 0.5; + } + } else { + FoldFloatingBarTrayIconMenuItemIconEyeOff.Visibility = Visibility.Visible; + FoldFloatingBarTrayIconMenuItemIconEyeOn.Visibility = Visibility.Hidden; + FoldFloatingBarTrayIconMenuItemHeaderText.Text = "切换为收纳模式"; + if (!HideICCMainWindowTrayIconMenuItem.IsChecked) { + ResetFloatingBarPositionTrayIconMenuItem.IsEnabled = true; + ResetFloatingBarPositionTrayIconMenuItem.Opacity = 1; + } + + } + } + } + + private void CloseAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) { + var mainWin = (MainWindow)Application.Current.MainWindow; + if (mainWin.IsLoaded) mainWin.BtnExit_Click(null,null); + } + + private void RestartAppTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) { + var mainWin = (MainWindow)Application.Current.MainWindow; + if (mainWin.IsLoaded) mainWin.BtnRestart_Click(null,null); + } + + private void ForceFullScreenTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) { + var mainWin = (MainWindow)Application.Current.MainWindow; + if (mainWin.IsLoaded) { + Ink_Canvas.MainWindow.MoveWindow(new WindowInteropHelper(mainWin).Handle, 0, 0, + System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, true); + Ink_Canvas.MainWindow.ShowNewMessage($"已强制全屏化:{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height}(缩放比例为{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth}x{System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight})"); + } + } + + private void FoldFloatingBarTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) + { + var mainWin = (MainWindow)Application.Current.MainWindow; + if (mainWin.IsLoaded) + if (mainWin.isFloatingBarFolded) mainWin.UnFoldFloatingBar_MouseUp(new object(),null); + else mainWin.FoldFloatingBar_MouseUp(new object(),null); + } + + private void ResetFloatingBarPositionTrayIconMenuItem_Clicked(object sender, RoutedEventArgs e) + { + var mainWin = (MainWindow)Application.Current.MainWindow; + if (mainWin.IsLoaded) { + var isInPPTPresentationMode = false; + Dispatcher.Invoke(() => { + isInPPTPresentationMode = mainWin.BtnPPTSlideShowEnd.Visibility == Visibility.Visible; + }); + if (!mainWin.isFloatingBarFolded) { + if (!isInPPTPresentationMode) mainWin.PureViewboxFloatingBarMarginAnimationInDesktopMode(); + else mainWin.PureViewboxFloatingBarMarginAnimationInPPTMode(); + } + } + } + + private void HideICCMainWindowTrayIconMenuItem_Checked(object sender, RoutedEventArgs e) { + var mainWin = (MainWindow)Application.Current.MainWindow; + mainWin.Hide(); + var s = (ContextMenu)_taskbar.ContextMenu; + var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4]; + var FoldFloatingBarTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 5]; + var ForceFullScreenTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 6]; + ResetFloatingBarPositionTrayIconMenuItem.IsEnabled = false; + FoldFloatingBarTrayIconMenuItem.IsEnabled = false; + ForceFullScreenTrayIconMenuItem.IsEnabled = false; + ResetFloatingBarPositionTrayIconMenuItem.Opacity = 0.5; + FoldFloatingBarTrayIconMenuItem.Opacity = 0.5; + ForceFullScreenTrayIconMenuItem.Opacity = 0.5; + } + + private void HideICCMainWindowTrayIconMenuItem_UnChecked(object sender, RoutedEventArgs e) + { + var mainWin = (MainWindow)Application.Current.MainWindow; + mainWin.Show(); + var s = (ContextMenu)_taskbar.ContextMenu; + var ResetFloatingBarPositionTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 4]; + var FoldFloatingBarTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 5]; + var ForceFullScreenTrayIconMenuItem = (MenuItem)s.Items[s.Items.Count - 6]; + ResetFloatingBarPositionTrayIconMenuItem.IsEnabled = true; + FoldFloatingBarTrayIconMenuItem.IsEnabled = true; + ForceFullScreenTrayIconMenuItem.IsEnabled = true; + ResetFloatingBarPositionTrayIconMenuItem.Opacity = 1; + FoldFloatingBarTrayIconMenuItem.Opacity = 1; + ForceFullScreenTrayIconMenuItem.Opacity = 1; + } + + } +} diff --git a/Ink Canvas/Resources/Settings.cs b/Ink Canvas/Resources/Settings.cs index 1a00d26..d4a009b 100644 --- a/Ink Canvas/Resources/Settings.cs +++ b/Ink Canvas/Resources/Settings.cs @@ -119,6 +119,8 @@ namespace Ink_Canvas public int FloatingBarImg { get; set; } = 0; [JsonProperty("viewboxFloatingBarOpacityValue")] public double ViewboxFloatingBarOpacityValue { get; set; } = 1.0; + [JsonProperty("enableTrayIcon")] + public bool EnableTrayIcon { get; set; } = true; [JsonProperty("viewboxFloatingBarOpacityInPPTValue")] public double ViewboxFloatingBarOpacityInPPTValue { get; set; } = 0.5; [JsonProperty("enableViewboxBlackBoardScaleTransform")] @@ -354,9 +356,11 @@ namespace Ink_Canvas } public class RandSettings { - [JsonProperty("peopleCount")] - public int PeopleCount { get; set; } = 60; - [JsonProperty("isNotRepeatName")] - public bool IsNotRepeatName { get; set; } = false; + [JsonProperty("displayRandWindowNamesInputBtn")] + public bool DisplayRandWindowNamesInputBtn { get; set; } = false; + [JsonProperty("randWindowOnceCloseLatency")] + public double RandWindowOnceCloseLatency { get; set; } = 2.5; + [JsonProperty("randWindowOnceMaxStudents")] + public int RandWindowOnceMaxStudents { get; set; } = 10; } } \ No newline at end of file diff --git a/Ink Canvas/Resources/icc.ico b/Ink Canvas/Resources/icc.ico index 200daa4..5cf30b0 100644 Binary files a/Ink Canvas/Resources/icc.ico and b/Ink Canvas/Resources/icc.ico differ diff --git a/Ink Canvas/Windows/RandWindow.xaml b/Ink Canvas/Windows/RandWindow.xaml index f5de16f..8d42864 100644 --- a/Ink Canvas/Windows/RandWindow.xaml +++ b/Ink Canvas/Windows/RandWindow.xaml @@ -74,7 +74,7 @@ - + @@ -82,7 +82,7 @@ Content="避开生僻字" IsThreeState="True" HorizontalAlignment="Center" /> - + public partial class RandWindow : Window { - public RandWindow() { + public RandWindow(Settings settings) { InitializeComponent(); AnimationsHelper.ShowWithSlideFromBottomAndFade(this, 0.25); - BorderBtnHelp.Visibility = RandIsDisplayListManageButton == false ? Visibility.Collapsed : Visibility.Visible; + BorderBtnHelp.Visibility = settings.RandSettings.DisplayRandWindowNamesInputBtn == false ? Visibility.Collapsed : Visibility.Visible; + RandMaxPeopleOneTime = settings.RandSettings.RandWindowOnceMaxStudents; + RandDoneAutoCloseWaitTime = (int)settings.RandSettings.RandWindowOnceCloseLatency*1000; } - public RandWindow(bool IsAutoClose) { + public RandWindow(Settings settings, bool IsAutoClose) { InitializeComponent(); isAutoClose = IsAutoClose; PeopleControlPane.Opacity = 0.4; PeopleControlPane.IsHitTestVisible = false; - BorderBtnHelp.Visibility = RandIsDisplayListManageButton == false ? Visibility.Collapsed : Visibility.Visible; + BorderBtnHelp.Visibility = settings.RandSettings.DisplayRandWindowNamesInputBtn == false ? Visibility.Collapsed : Visibility.Visible; + RandMaxPeopleOneTime = settings.RandSettings.RandWindowOnceMaxStudents; + RandDoneAutoCloseWaitTime = (int)settings.RandSettings.RandWindowOnceCloseLatency * 1000; new Thread(new ThreadStart(() => { Thread.Sleep(100); @@ -66,7 +70,6 @@ namespace Ink_Canvas { public int RandWaitingThreadSleepTime = 5; public int RandMaxPeopleOneTime = 10; public int RandDoneAutoCloseWaitTime = 2500; - public bool RandIsDisplayListManageButton = false; private void BorderBtnRand_MouseUp(object sender, MouseButtonEventArgs e) { Random random = new Random();// randSeed + DateTime.Now.Millisecond / 10 % 10); diff --git a/Ink Canvas/icc.ico b/Ink Canvas/icc.ico deleted file mode 100644 index 200daa4..0000000 Binary files a/Ink Canvas/icc.ico and /dev/null differ