Files
GeekDesk/Control/Windows/ConfigWindow.xaml.cs

119 lines
3.8 KiB
C#
Raw Permalink Normal View History

using GeekDesk.Control.UserControls.Config;
2021-12-20 09:39:27 +08:00
using GeekDesk.Interface;
2023-04-04 17:59:06 +08:00
using GeekDesk.Util;
2021-05-20 17:33:49 +08:00
using GeekDesk.ViewModel;
using HandyControl.Controls;
2022-05-10 15:33:06 +08:00
using System.Collections.Generic;
2021-05-21 17:19:46 +08:00
using System.Windows;
2022-05-10 15:33:06 +08:00
using System.Windows.Controls;
2021-05-21 17:19:46 +08:00
using System.Windows.Input;
2021-05-20 17:33:49 +08:00
namespace GeekDesk.Control.Windows
2021-05-20 17:33:49 +08:00
{
/// <summary>
/// ConfigDialog.xaml 的交互逻辑
/// </summary>
2021-12-20 09:39:27 +08:00
public partial class ConfigWindow : IWindowCommon
2021-05-20 17:33:49 +08:00
{
2021-08-20 16:50:24 +08:00
private static readonly AboutControl about = new AboutControl();
private static readonly ThemeControl theme = new ThemeControl();
private static readonly MotionControl motion = new MotionControl();
private static readonly OtherControl other = new OtherControl();
2022-05-10 15:33:06 +08:00
private static List<UserControl> ucList = new List<UserControl>();
static ConfigWindow()
{
ucList.Add(about);
ucList.Add(theme);
ucList.Add(motion);
ucList.Add(other);
}
2021-06-01 21:49:50 +08:00
public MainWindow mainWindow;
2021-05-31 17:31:16 +08:00
private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
2021-05-20 17:33:49 +08:00
{
InitializeComponent();
//BG.Source = ImageUtil.Base64ToBitmapImage(Constants.DEFAULT_BAC_IMAGE_BASE64);
2021-05-20 17:33:49 +08:00
this.DataContext = appConfig;
2021-05-31 17:31:16 +08:00
RightCard.Content = about;
2023-04-04 17:59:06 +08:00
WindowUtil.SetOwner(this, mainWindow);
2021-06-01 21:49:50 +08:00
this.mainWindow = mainWindow;
UFG.Visibility = Visibility.Collapsed;
UFG.Visibility = Visibility.Visible;
2021-05-20 17:33:49 +08:00
}
2021-05-21 17:19:46 +08:00
2021-05-21 17:19:46 +08:00
/// <summary>
/// 点击关闭按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Close_Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
2021-05-26 17:19:04 +08:00
2021-05-31 17:31:16 +08:00
private void MemuClick(object sender, RoutedEventArgs e)
{
SideMenuItem smi = sender as SideMenuItem;
switch (smi.Tag.ToString())
{
case "Motion":
2022-05-10 15:33:06 +08:00
UFG.Visibility = Visibility.Collapsed;
2021-05-31 17:31:16 +08:00
RightCard.Content = motion;
2022-05-10 15:33:06 +08:00
UFG.Visibility = Visibility.Visible;
2021-05-31 17:31:16 +08:00
break;
case "Theme":
2022-05-10 15:33:06 +08:00
UFG.Visibility = Visibility.Collapsed;
2021-05-31 17:31:16 +08:00
RightCard.Content = theme;
2022-05-10 15:33:06 +08:00
UFG.Visibility = Visibility.Visible;
2021-05-31 17:31:16 +08:00
break;
2021-07-21 11:15:51 +08:00
case "Other":
2022-05-10 15:33:06 +08:00
UFG.Visibility = Visibility.Collapsed;
2021-07-21 11:15:51 +08:00
RightCard.Content = other;
2022-05-10 15:33:06 +08:00
UFG.Visibility = Visibility.Visible;
2021-07-21 11:15:51 +08:00
break;
2021-05-31 17:31:16 +08:00
default:
2022-05-10 15:33:06 +08:00
UFG.Visibility = Visibility.Collapsed;
2021-05-31 17:31:16 +08:00
RightCard.Content = about;
2022-05-10 15:33:06 +08:00
UFG.Visibility = Visibility.Visible;
2021-05-31 17:31:16 +08:00
break;
}
}
2021-09-15 10:12:44 +08:00
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
private static System.Windows.Window window = null;
public static void Show(AppConfig appConfig, MainWindow mainWindow)
{
if (window == null || !window.Activate())
{
window = new ConfigWindow(appConfig, mainWindow);
}
window.Show();
2021-12-20 09:39:27 +08:00
Keyboard.Focus(window);
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
2022-01-09 17:44:25 +08:00
this.DataContext = null;
2021-12-20 09:39:27 +08:00
this.Close();
}
}
2021-05-20 17:33:49 +08:00
}
}