Skip to content

Commit

Permalink
1.1.3 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceTimee committed Mar 30, 2022
1 parent 7c34dd1 commit e7f261b
Show file tree
Hide file tree
Showing 13 changed files with 278 additions and 200 deletions.
1 change: 1 addition & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace Ona_Pix
{
public partial class App : Application
{
//程序启动事件
protected override void OnStartup(StartupEventArgs e)
{
Define.MAIN_WINDOW = new(e.Args);
Expand Down
5 changes: 5 additions & 0 deletions Commons/Define.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Net.Http;
using System.Reflection;
using Ona_Pix.Pages;

namespace Ona_Pix
{
Expand All @@ -16,6 +17,10 @@ internal static class Define
internal static MainWindow? MAIN_WINDOW;
internal static readonly SettingWindow SETTING_WINDOW = new();

//页面
internal static readonly AppearancePage APPEARANCE_PAGE = (AppearancePage)SETTING_WINDOW.Resources["appearancePage"];
internal static readonly BehaviorPage BEHAVIOR_PAGE = (BehaviorPage)SETTING_WINDOW.Resources["behaviorPage"];

//字段
internal static readonly HttpClient MAIN_CLIENT = new();
internal static readonly string CURRENT_VERSION = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2];
Expand Down
2 changes: 2 additions & 0 deletions Commons/IconRemover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Ona_Pix
{
//定义IconRemover
internal static class IconRemover
{
private const int GWL_EXSTYLE = -20;
Expand Down Expand Up @@ -41,6 +42,7 @@ internal static void RemoveIcon(Window window)
}
}

//使用IconRemover
public partial class MainWindow
{
protected override void OnSourceInitialized(EventArgs e)
Expand Down
4 changes: 4 additions & 0 deletions Commons/Smms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public Smms() : base("Ona-Pix-Smms.exe")
//Control.CheckForIllegalCrossThreadCalls = false;
}

//Smms程序调用事件
public override async void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
//输出事件(输出结果)
try
{
if (!string.IsNullOrEmpty(e.Data) && !string.IsNullOrWhiteSpace(e.Data))
Expand Down Expand Up @@ -55,6 +57,7 @@ public override async void Process_OutputDataReceived(object sender, DataReceive
}
public override void Process_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
//报错事件(输出错误)
if (!string.IsNullOrEmpty(e.Data) && !string.IsNullOrWhiteSpace(e.Data))
{
ShowError!(e.Data);
Expand All @@ -63,6 +66,7 @@ public override void Process_ErrorDataReceived(object sender, DataReceivedEventA
}
public override void Process_Exited(object sender, EventArgs e)
{
//退出事件
SetControlsEnabled!();
}
}
Expand Down
3 changes: 3 additions & 0 deletions Commons/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ private void PartialAboutWindow()
GITHUB_CLIENT.DefaultRequestHeaders.Add("User-Agent", Define.USER_AGENT_HEADER);
}

//用户交互流程
private async void UpdateLink_Click(object sender, RoutedEventArgs e)
{
//用户点击关于页面的版本号
try
{
Title = "正在获取更新";
Expand Down Expand Up @@ -59,6 +61,7 @@ private async void UpdateLink_Click(object sender, RoutedEventArgs e)
}
private async void ReleaseListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
//用户选择下载内容
Title = "继续执行更新";

try
Expand Down
2 changes: 2 additions & 0 deletions Controls/ToggleSwitch.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public ToggleSwitch()
InitializeComponent();
}

//点击事件
private void ForeDot_MouseDown(object sender, MouseButtonEventArgs e)
{
SwitchStatus();
Expand All @@ -28,6 +29,7 @@ private void BackRec_MouseDown(object sender, MouseButtonEventArgs e)
SwitchStatus();
}

//切换Toggle状态
internal void SwitchStatus()
{
if (!IS_TOGGLED)
Expand Down
2 changes: 1 addition & 1 deletion Pages/AppearancePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label Content="锁定动画" />
<Label Content="固定菜单" />
<controls:ToggleSwitch x:Name="LockAnimationToggle" Style="{StaticResource SettingToggle}" MouseDown="LockAnimationToggle_MouseDown" />
</Grid>
<Grid Margin="0,0,0,10">
Expand Down
6 changes: 6 additions & 0 deletions Pages/AppearancePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public AppearancePage()
InitializeComponent();
}

//Toggle点击事件
internal void DarkModeToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//暗色模式
if (DarkModeToggle.IS_TOGGLED)
{
((BundledTheme)Application.Current.Resources.MergedDictionaries[0]).BaseTheme = BaseTheme.Dark;
Expand All @@ -33,6 +35,7 @@ internal void DarkModeToggle_MouseDown(object sender, System.Windows.Input.Mouse
}
internal void IconButtonToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//按钮图标
if (IconButtonToggle.IS_TOGGLED)
Properties.Settings.Default.IsIconButton = true;
else
Expand All @@ -44,6 +47,7 @@ internal void IconButtonToggle_MouseDown(object sender, System.Windows.Input.Mou
}
internal void LockAnimationToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//固定菜单
if (LockAnimationToggle.IS_TOGGLED)
{
Define.MAIN_WINDOW!.ActiveSpace_MouseIn(this, null!);
Expand All @@ -59,6 +63,7 @@ internal void LockAnimationToggle_MouseDown(object sender, System.Windows.Input.
}
private void HideBorderToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//隐藏边框
Define.MAIN_WINDOW!.SizeToContent = SizeToContent.Manual;

if (HideBorderToggle.IS_TOGGLED)
Expand All @@ -72,6 +77,7 @@ private void HideBorderToggle_MouseDown(object sender, System.Windows.Input.Mous
Define.MAIN_WINDOW!.SizeToContent = SizeToContent.WidthAndHeight;
}

//为按钮应用暗色模式和图标按钮
private void SetButtonContent()
{
if (IconButtonToggle.IS_TOGGLED)
Expand Down
3 changes: 3 additions & 0 deletions Pages/BehaviorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ public BehaviorPage()
InitializeComponent();
}

//Toggle点击事件
internal void DisableExceptionToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//禁用报错
if (DisableExceptionToggle.IS_TOGGLED)
Properties.Settings.Default.IsExceptionDisabled = true;
else
Expand All @@ -20,6 +22,7 @@ internal void DisableExceptionToggle_MouseDown(object sender, System.Windows.Inp
}
internal void DisableTipsToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
//禁用一言
if (DisableTipsToggle.IS_TOGGLED)
Properties.Settings.Default.IsTipsDisabled = true;
else
Expand Down
7 changes: 5 additions & 2 deletions Windows/AboutWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Ona_Pix.Pages;
using WpfAnimatedGif;

namespace Ona_Pix
Expand All @@ -31,6 +30,7 @@ public AboutWindow(bool isDarkMode)
InitializeComponent();
PartialAboutWindow();

//检查暗色模式
if (isDarkMode)
{
MemoryStream memoryStream = new();
Expand All @@ -44,7 +44,8 @@ public AboutWindow(bool isDarkMode)
ImageBehavior.SetAnimatedSource(TanImage, bitmapImage);
}

if (!((BehaviorPage)Define.SETTING_WINDOW.Resources["behaviorPage"]).DisableTipsToggle.IS_TOGGLED)
//显示随机一言(Tips)
if (!Define.BEHAVIOR_PAGE.DisableTipsToggle.IS_TOGGLED)
{
Random random = new(Convert.ToInt32(DateTime.Now.Ticks & 0x0000FFFF));
Title = $"关于: {TIPS[random.Next(0, TIPS.Length)]}";
Expand All @@ -70,8 +71,10 @@ private void AboutWin_Loaded(object sender, RoutedEventArgs e)
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); Title = "操作执行失败"; return; }
}

//链接点击事件
private void HyperLink_Click(object sender, RoutedEventArgs e)
{
//打开链接
try
{
Title = "正在打开链接";
Expand Down
Loading

0 comments on commit e7f261b

Please sign in to comment.