Skip to content

Commit

Permalink
1.1.2 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceTimee committed Mar 28, 2022
1 parent d3bfd3a commit 9cc2a06
Show file tree
Hide file tree
Showing 27 changed files with 410 additions and 109 deletions.
4 changes: 2 additions & 2 deletions App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Ona_Pix.Controls"
StartupUri="/Windows/MainWindow.xaml">
xmlns:controls="clr-namespace:Ona_Pix.Controls">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand All @@ -29,6 +28,7 @@
</Style>
<Style x:Key="ActiveButton" BasedOn="{StaticResource MaterialDesignFloatingActionMiniButton}" TargetType="{x:Type Button}">
<Setter Property="Margin" Value="10,0,10,10" />
<Setter Property="Padding" Value="6.5,6.5,6.5,6.5" />
<Setter Property="Foreground" Value="{DynamicResource MaterialDesignBody}" />
</Style>
<Style x:Key="AboutLabel" BasedOn="{StaticResource MaterialDesignLabel}" TargetType="{x:Type Label}">
Expand Down
5 changes: 5 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ namespace Ona_Pix
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
Define.MAIN_WINDOW = new(e.Args);
Define.MAIN_WINDOW.Show();
}
}
}
13 changes: 9 additions & 4 deletions Commons/Define.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,30 @@ namespace Ona_Pix
{
internal static class Define
{
//委托
internal delegate void SET_WINDOW_HANDLER();
internal delegate void SET_WINDOW_HANDLER_P(dynamic value);

internal static MainWindow MAIN_WINDOW = new();
//窗口
internal static MainWindow? MAIN_WINDOW;
internal static readonly SettingWindow SETTING_WINDOW = new();

//字段
internal static readonly HttpClient MAIN_CLIENT = new();
internal static readonly string CURRENT_VERSION = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[0..^2];
internal static readonly string CACHE_PATH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Ona Pix Cache");
#region URL的正则表达式 (URL_REGEX)
#region URL 的正则表达式 (URL_REGEX)
internal const string URI_REGEX = @"^(((ht|f)tp(s?))\://)?" +
@"([a-zA-Z].)[a-zA-Z0-9\-\.]+\.(" +
@"com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk|cc|int|arpa|asia|pro|coop|aero|tv|top|xin|xyz|vip|cn|mobi|ru|de|pl|eu|io|jp|club|au|post|me|guru|expert|tw|mo|hk|fr|ar|pk|mv|in|it|ws|sh|my|cd|ac|li|co|cm|win|red|rec|travel|wang|ch|dj|er|ee|es|is|kr|mm|mn|no|ne|to|tr|za|ml|ga|xxx|porn|adult|cyou|buzz|monster|icu|shop|best|site|live|online|pw|cloud|website|life|store|fun|app|today|uno|space|world|one|link|work|email|nl|trade|bid|stream|men|art|party|date|dev|tech|church|rocks|digital|download|moe|agency|network|click|fail|news|cool|vegas|blog|review|company|la|design|services|golf|exposed|team|ltd|help|zone|loan|wtf|media|solutions|games|directory|center|care|fyi|group|ooo|science|systems|works|city|pet|run|tips|studio|guide|cash|at|support|ninja|plus|rip|marketing|vin|reisen|tools|finance|immo|wiki|viajes|global|mx|promo|recipes|photos|academy|dog|pink|money|chat|casa|cafe|ink|foundation|faith|webcam|house|technology|photography|video|blue|farm|codes|realty|tel|land|show|business|international|social|sbs|skin|page|london|health|hiv|bond|vote|autos|rest|limo|hospital|gay|bar|game|fans|ph|study|cooking|glass|place|rent|shoes|tires|wedding|cab|camp|beer|menu|movie|fish|sexy|gifts|part|mom|green|moda|baby|navy|loans|engineering|computer|camera|barga|film|kitchen|supply|pics|haus|university|fit|cheap|vet|black|law|lol|tax|bio|sale|earth|kim|love|software|fitness|llc|school|pub|deals|style|domains|band|host|direct|shopping|tube|ist|mba|photo|energy|training|taxi|gift|wine|town|bike|toys|ski|poker|yoga|parts|solar|engineer|garden|observer|sucks|hosting|bingo|christmas|gives|horse|insure|diet|fishing|whoswho|tickets|boats|flowers|storage|cfd|inc|quest|luxe|security" +
@")(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&amp;%\$#\=~_\-]+))*$";
#endregion URL的正则表达式 (URL_REGEX)
#endregion URL 的正则表达式 (URL_REGEX)
internal static readonly string[] FILE_SUFFIXES = { ".png", ".jpg", ".gif" };
internal const string GITHUB_RELEASE_API_URL = @"https://api.github.com/repos/SpaceTimee/Ona-Pix/releases/latest";
internal const string ACCEPT_HEADER = @"application/vnd.github.v3+json";
internal const string USER_AGENT_HEADER = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36";
internal const string USER_AGENT_HEADER = @"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.82 Safari/537.36";

//方法
internal static void StartProcess(string fileName)
{
ProcessStartInfo processStartInfo = new(fileName) { UseShellExecute = true };
Expand Down
2 changes: 1 addition & 1 deletion Commons/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private async void UpdateLink_Click(object sender, RoutedEventArgs e)
//接下来的正常流程: 等待用户反馈后转至 ReleaseListBox_SelectionChanged()
}
else if (messageBoxResult == MessageBoxResult.No)
LanzouLink_Click(UpdateLink, new RoutedEventArgs());
HyperLink_Click(LanzouLink, new RoutedEventArgs());
}
else
Title = "当前是最新版本";
Expand Down
10 changes: 5 additions & 5 deletions Ona-Pix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<PackageReleaseNotes>Yet Another Pixiv Tool</PackageReleaseNotes>
<Authors>Space Time</Authors>
<Company>Space Time</Company>
<AssemblyVersion>1.1.1</AssemblyVersion>
<Version>1.1.1</Version>
<FileVersion>1.1.1</FileVersion>
<InformationalVersion>1.1.1</InformationalVersion>
<AssemblyVersion>1.1.2</AssemblyVersion>
<Version>1.1.2</Version>
<FileVersion>1.1.2</FileVersion>
<InformationalVersion>1.1.2</InformationalVersion>
<PackageTags>Tool;Pixiv;Ona;Pix</PackageTags>
<ApplicationIcon>Ona-Pix-Logo.ico</ApplicationIcon>
<PackageIcon>Ona Pix Logo.png</PackageIcon>
Expand Down Expand Up @@ -69,7 +69,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MaterialDesignThemes" Version="4.3.0" />
<PackageReference Include="MaterialDesignThemes" Version="4.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SauceNET" Version="1.1.1" />
<PackageReference Include="WpfAnimatedGif" Version="2.0.2" />
Expand Down
16 changes: 16 additions & 0 deletions Pages/AppearancePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
<Label Content="暗色模式" />
<controls:ToggleSwitch x:Name="DarkModeToggle" Style="{StaticResource SettingToggle}" MouseDown="DarkModeToggle_MouseDown" />
</Grid>
<Grid x:Name="IconButtonGrid" Margin="0,0,0,10" IsEnabled="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label Content="图标按钮" />
<controls:ToggleSwitch x:Name="IconButtonToggle" Style="{StaticResource SettingToggle}" MouseDown="IconButtonToggle_MouseDown" />
</Grid>
<Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand All @@ -22,5 +30,13 @@
<Label Content="锁定动画" />
<controls:ToggleSwitch x:Name="LockAnimationToggle" Style="{StaticResource SettingToggle}" MouseDown="LockAnimationToggle_MouseDown" />
</Grid>
<Grid Margin="0,0,0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Label Content="隐藏边框" />
<controls:ToggleSwitch x:Name="HideBorderToggle" Style="{StaticResource SettingToggle}" MouseDown="HideBorderToggle_MouseDown" />
</Grid>
</StackPanel>
</UserControl>
113 changes: 110 additions & 3 deletions Pages/AppearancePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Windows;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using MaterialDesignThemes.Wpf;

namespace Ona_Pix.Pages
Expand All @@ -15,13 +18,117 @@ private void DarkModeToggle_MouseDown(object sender, System.Windows.Input.MouseB
{
((BundledTheme)Application.Current.Resources.MergedDictionaries[0]).BaseTheme =
DarkModeToggle.IS_TOGGLED ? BaseTheme.Dark : BaseTheme.Light;

SetButtonContent();
}
private void IconButtonToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
SetButtonContent();
}
private void LockAnimationToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (LockAnimationToggle.IS_TOGGLED)
Define.MAIN_WINDOW.ActiveSpace_MouseIn(this, null!);
Define.MAIN_WINDOW!.ActiveSpace_MouseIn(this, null!);
else
Define.MAIN_WINDOW!.ActiveSpace_MouseOut(this, null!);
}
private void HideBorderToggle_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Define.MAIN_WINDOW!.SizeToContent = SizeToContent.Manual;

if (HideBorderToggle.IS_TOGGLED)
{
MessageBox.Show("Warning: 开启后可能导致主窗口无法正常关闭,请记住关闭主窗口的热键 Ctrl+W");
Define.MAIN_WINDOW!.WindowStyle = WindowStyle.None;
}
else
Define.MAIN_WINDOW.ActiveSpace_MouseOut(this, null!);
Define.MAIN_WINDOW!.WindowStyle = WindowStyle.SingleBorderWindow;

Define.MAIN_WINDOW!.SizeToContent = SizeToContent.WidthAndHeight;
}

private void SetButtonContent()
{
if (IconButtonToggle.IS_TOGGLED)
{
if (!DarkModeToggle.IS_TOGGLED)
{
Define.MAIN_WINDOW!.ActiveViewButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.View.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveSearchButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Search.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveDownloadButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Download.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveLuckyButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lucky.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveSettingButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Setting.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveAboutButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.About.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
}
else
{
Define.MAIN_WINDOW!.ActiveViewButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.View_Dark.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveSearchButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Search_Dark.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveDownloadButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Download_Dark.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveLuckyButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Lucky_Dark.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveSettingButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.Setting_Dark.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
Define.MAIN_WINDOW!.ActiveAboutButton.Content = new Image()
{
Source = Imaging.CreateBitmapSourceFromHBitmap(Properties.Resources.About_Dark.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions())
};
}

Define.MAIN_WINDOW!.ActiveViewButton.ToolTip = "浏览";
Define.MAIN_WINDOW!.ActiveSearchButton.ToolTip = "搜索";
Define.MAIN_WINDOW!.ActiveDownloadButton.ToolTip = "下载";
Define.MAIN_WINDOW!.ActiveLuckyButton.ToolTip = "一图";
Define.MAIN_WINDOW!.ActiveSettingButton.ToolTip = "设置";
Define.MAIN_WINDOW!.ActiveAboutButton.ToolTip = "关于";
}
else
{
Define.MAIN_WINDOW!.ActiveViewButton.Content = "浏览";
Define.MAIN_WINDOW!.ActiveSearchButton.Content = "搜索";
Define.MAIN_WINDOW!.ActiveDownloadButton.Content = "下载";
Define.MAIN_WINDOW!.ActiveLuckyButton.Content = "一图";
Define.MAIN_WINDOW!.ActiveSettingButton.Content = "设置";
Define.MAIN_WINDOW!.ActiveAboutButton.Content = "关于";

Define.MAIN_WINDOW!.ActiveViewButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveSearchButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveDownloadButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveLuckyButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveSettingButton.ToolTip = null;
Define.MAIN_WINDOW!.ActiveAboutButton.ToolTip = null;
}
}
}
}
Loading

0 comments on commit 9cc2a06

Please sign in to comment.