Skip to content

Commit 61cfa7e

Browse files
committed
版本 1.0.6 更新
1. 支持记忆窗口位置、尺寸和状态 2. 支持保存上一次选择的输入输出格式 3. 更换滚动条样式,优化 UI 细节 4. 修复因缺少依赖项导致转换失败的 bug
1 parent c4fe45f commit 61cfa7e

12 files changed

Lines changed: 511 additions & 117 deletions

csharp/GUI/AboutDialog.xaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
<TextBlock Text="OpenSVIP" FontSize="40" FontWeight="Bold"/>
3030
<TextBlock d:Text="框架版本:1.2.0" FontSize="16">
3131
<TextBlock.Text>
32-
<Binding Path="FrameworkVersion" StringFormat="{}框架版本:{0}"/>
32+
<Binding Path="Information.FrameworkVersion" StringFormat="{}框架版本:{0}"/>
3333
</TextBlock.Text>
3434
</TextBlock>
3535
<TextBlock d:Text="应用程序版本:1.0.0 (Preview)" FontSize="16">
3636
<TextBlock.Text>
37-
<Binding Path="Version" StringFormat="{}应用程序版本:{0}"/>
37+
<Binding Path="Information.Version" StringFormat="{}应用程序版本:{0}"/>
3838
</TextBlock.Text>
3939
</TextBlock>
4040
<TextBlock Text="预览版本 暂勿传播" Foreground="#f44336"/>
@@ -48,13 +48,13 @@
4848
<EventSetter Event="Click" Handler="OpenLinkButton_Click"/>
4949
</Style>
5050
</StackPanel.Resources>
51-
<Button ToolTip="{Binding AuthorHomePage}">
51+
<Button ToolTip="{Binding Information.AuthorHomePage}">
5252
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
5353
<materialDesign:PackIcon Kind="User" VerticalAlignment="Center" Margin="-3 0 2 0"/>
5454
<TextBlock Text="作者主页" FontSize="14" Margin="2 0 2 0"/>
5555
</StackPanel>
5656
</Button>
57-
<Button ToolTip="{Binding GitHubRepository}">
57+
<Button ToolTip="{Binding Information.GitHubRepository}">
5858
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
5959
<materialDesign:PackIcon Kind="Github" VerticalAlignment="Center" Margin="-3 0 2 0"/>
6060
<TextBlock Text="项目仓库" FontSize="14" Margin="2 0 2 0"/>

csharp/GUI/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/themes/materialdesigntheme.popupbox.xaml"/>
1313
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/themes/materialdesigntheme.chip.xaml"/>
1414
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/primary/materialdesigncolor.indigo.xaml"/>
15+
<ResourceDictionary Source="ScrollBarDictionary.xaml"/>
1516
</ResourceDictionary.MergedDictionaries>
1617
<local:NotNullConverter x:Key="NotNullConverter"/>
1718
<local:IndexToBooleanConverter x:Key="IndexToBooleanConverter"/>

csharp/GUI/Configurations.cs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Reflection;
5+
using System.Windows;
6+
using Tomlet;
7+
using Tomlet.Attributes;
8+
using Tomlet.Models;
9+
10+
namespace OpenSvip.GUI.Config
11+
{
12+
public class AppConfig
13+
{
14+
private const string CONFIG_FOLDER = "Config";
15+
16+
private const string CONFIG_FILENAME = "Configurations.toml";
17+
18+
private static readonly string ActualConfigFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), CONFIG_FOLDER);
19+
20+
private static readonly string ActualConfigFile = Path.Combine(ActualConfigFolder, CONFIG_FILENAME);
21+
22+
[TomlProperty("Restoration")]
23+
public Properties Properties { get; set; } = new Properties();
24+
25+
[TomlProperty("Preference")]
26+
public Settings Settings { get; set; } = new Settings();
27+
28+
static AppConfig()
29+
{
30+
TomletMain.RegisterMapper(
31+
rect => new TomlArray { rect.Left, rect.Top, rect.Width, rect.Height },
32+
tomlValue =>
33+
{
34+
if (!(tomlValue is TomlArray tomlArray))
35+
{
36+
return new Rect();
37+
}
38+
try
39+
{
40+
var arr = tomlArray.Select(val => ((TomlDouble)val).Value).ToArray();
41+
return new Rect(arr[0], arr[1], arr[2], arr[3]);
42+
}
43+
catch
44+
{
45+
return new Rect();
46+
}
47+
});
48+
}
49+
50+
public static AppConfig LoadFromFile()
51+
{
52+
try
53+
{
54+
var stream = new FileStream(ActualConfigFile, FileMode.Open, FileAccess.Read);
55+
var reader = new StreamReader(stream);
56+
var config = TomletMain.To<AppConfig>(reader.ReadToEnd());
57+
reader.Close();
58+
stream.Close();
59+
return config;
60+
}
61+
catch
62+
{
63+
return new AppConfig();
64+
}
65+
}
66+
67+
public void SaveToFile()
68+
{
69+
try
70+
{
71+
Directory.CreateDirectory(ActualConfigFolder);
72+
var stream = new FileStream(ActualConfigFile, FileMode.Create, FileAccess.Write);
73+
var writer = new StreamWriter(stream);
74+
writer.Write(TomletMain.TomlStringFrom(this));
75+
writer.Flush();
76+
stream.Flush();
77+
writer.Close();
78+
stream.Close();
79+
}
80+
catch
81+
{
82+
// ignored
83+
}
84+
}
85+
}
86+
87+
public class Information
88+
{
89+
public string Version { get; set; } = "1.0.6 (Preview)";
90+
91+
public string FrameworkVersion { get; set; } = "1.2.2";
92+
93+
public string Author { get; set; } = "YQ之神";
94+
95+
public string AuthorHomePage { get; set; } = "https://space.bilibili.com/102844209";
96+
97+
public string GitHubRepository { get; set; } = "https://github.com/yqzhishen/opensvip";
98+
}
99+
100+
[TomlDoNotInlineObject]
101+
public class Properties
102+
{
103+
public Rect MainRestoreBounds { get; set; } = new Rect();
104+
105+
public WindowState MainWindowState { get; set; } = WindowState.Normal;
106+
}
107+
108+
public class Settings
109+
{
110+
public string ImportPluginId { get; set; }
111+
112+
public string ExportPluginId { get; set; }
113+
114+
public bool AutoDetectFormat { get; set; } = true;
115+
116+
public bool AutoResetTasks { get; set; } = true;
117+
118+
public bool AutoExtension { get; set; } = true;
119+
120+
public bool OpenExportFolder { get; set; } = false;
121+
122+
public OverwriteOptions OverwriteOption { get; set; } = OverwriteOptions.Overwrite;
123+
124+
public ExportPaths DefaultExportPath { get; set; } = ExportPaths.Unset;
125+
126+
public string[] CustomExportPaths { get; set; } = Array.Empty<string>();
127+
}
128+
129+
public enum OverwriteOptions
130+
{
131+
Overwrite, Skip, Ask
132+
}
133+
134+
public enum ExportPaths
135+
{
136+
Unset, Source, Desktop, Custom
137+
}
138+
}

csharp/GUI/MainWindow.xaml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
77
xmlns:local="clr-namespace:OpenSvip.GUI"
8+
xmlns:config="clr-namespace:OpenSvip.GUI.Config"
89
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
910
mc:Ignorable="d"
1011
Title="OpenSVIP - 歌声合成工程文件转换器(预览版本)"
@@ -38,11 +39,11 @@
3839
</Grid.RowDefinitions>
3940
<Border Grid.Row="0" Background="WhiteSmoke">
4041
<Border.Resources>
41-
<x:Array x:Key="DefaultExportEnumValues" Type="local:DefaultExport">
42-
<local:DefaultExport>None</local:DefaultExport>
43-
<local:DefaultExport>Source</local:DefaultExport>
44-
<local:DefaultExport>Desktop</local:DefaultExport>
45-
<local:DefaultExport>Custom</local:DefaultExport>
42+
<x:Array x:Key="DefaultExportEnumValues" Type="config:ExportPaths">
43+
<config:ExportPaths>Unset</config:ExportPaths>
44+
<config:ExportPaths>Source</config:ExportPaths>
45+
<config:ExportPaths>Desktop</config:ExportPaths>
46+
<config:ExportPaths>Custom</config:ExportPaths>
4647
</x:Array>
4748
</Border.Resources>
4849
<ComboBox
@@ -51,7 +52,7 @@
5152
Height="0"
5253
Width="0"
5354
ItemsSource="{StaticResource DefaultExportEnumValues}"
54-
SelectedIndex="{Binding DefaultExportPath, Converter={StaticResource IndexToEnumValueConverter}, ConverterParameter={x:Type local:DefaultExport}}"/>
55+
SelectedIndex="{Binding DefaultExportPath, Converter={StaticResource IndexToEnumValueConverter}, ConverterParameter={x:Type config:ExportPaths}}"/>
5556
</Border>
5657
<DockPanel x:Name="MenuPanel" Grid.Row="0">
5758
<Menu IsMainMenu="True" Margin="20 0 0 0" Height="25" FontFamily="Microsoft YaHei UI" FontSize="13" FontWeight="Normal">
@@ -386,7 +387,7 @@
386387
DragLeave="FileMaskPanel_UnFocus">
387388
<ItemsControl
388389
x:Name="TaskListView"
389-
Margin="6 5 -5 5"
390+
Margin="6 5 10 5"
390391
ItemsSource="{Binding TaskList}"
391392
Visibility="{Binding HasItems, ElementName=TaskListView, Converter={StaticResource BooleanToVisibilityConverter}}"
392393
IsEnabled="{Binding ExecutionInProgress, Converter={StaticResource InvertBooleanConverter}}"
@@ -486,6 +487,7 @@
486487
</MultiBinding>
487488
</StackPanel.Visibility>
488489
<StackPanel.Resources>
490+
<Style TargetType="ScrollViewer" BasedOn="{StaticResource MaterialDesignScrollViewer}"/>
489491
<Style TargetType="TreeView" BasedOn="{StaticResource MaterialDesignTreeView}">
490492
<Setter Property="ScrollViewer.PanningMode" Value="None"/>
491493
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
@@ -502,10 +504,10 @@
502504
<Setter Property="MaxWidth">
503505
<Setter.Value>
504506
<Binding
505-
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=TreeView}"
507+
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=materialDesign:Card}"
506508
Path="ActualWidth"
507509
Converter="{StaticResource DoubleConstantSubConverter}"
508-
ConverterParameter="140"/>
510+
ConverterParameter="160"/>
509511
</Setter.Value>
510512
</Setter>
511513
</Style>
@@ -531,7 +533,7 @@
531533
<WrapPanel
532534
Grid.Row="1"
533535
Orientation="Horizontal"
534-
Width="{Binding ActualWidth, ElementName=ConverterOptionsCard, Converter={StaticResource DoubleConstantSubConverter}, ConverterParameter=70}">
536+
Width="{Binding ActualWidth, ElementName=ConverterOptionsCard, Converter={StaticResource DoubleConstantSubConverter}, ConverterParameter=64}">
535537
<local:OptionTreeViewItem DataContext="{Binding}" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
536538
</WrapPanel>
537539
</Grid>
@@ -554,7 +556,7 @@
554556
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Text="["/>
555557
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Margin="7 2 0 0">
556558
<TextBlock.Text>
557-
<Binding Path="SelectedInputPlugin.Format" StringFormat="{}导入自 {0}"/>
559+
<Binding Path="SelectedInputFormat" StringFormat="{}导入自 {0}" Mode="OneWay"/>
558560
</TextBlock.Text>
559561
</TextBlock>
560562
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Text="]" Margin="7 2 0 0"/>
@@ -582,7 +584,7 @@
582584
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Text="["/>
583585
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Margin="7 2 0 0">
584586
<TextBlock.Text>
585-
<Binding Path="SelectedOutputPlugin.Format" StringFormat="{}导出为 {0}"/>
587+
<Binding Path="SelectedOutputFormat" StringFormat="{}导出为 {0}" Mode="OneWay"/>
586588
</TextBlock.Text>
587589
</TextBlock>
588590
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Text="]" Margin="7 2 0 0"/>
@@ -654,6 +656,7 @@
654656
<TextBox
655657
VerticalAlignment="Center"
656658
Margin="10 0"
659+
Padding="0 2"
657660
materialDesign:HintAssist.Hint="{Binding IsChecked, ElementName=ExportToSourceMenuItem, Converter={StaticResource BooleanSwitchOperationConverter}, ConverterParameter=输出路径(本次);输出路径}"
658661
Text="{Binding ExportPath}"
659662
FontSize="16"
@@ -684,7 +687,7 @@
684687
FontSize="14"
685688
materialDesign:ComboBoxAssist.ShowSelectedItem="False"
686689
IsEnabled="{Binding ExecutionInProgress, Converter={StaticResource InvertBooleanConverter}}"
687-
SelectedIndex="{Binding OverWriteOption, Converter={StaticResource IndexToEnumValueConverter}, ConverterParameter={x:Type local:OverwriteOptions}}">
690+
SelectedIndex="{Binding OverWriteOption, Converter={StaticResource IndexToEnumValueConverter}, ConverterParameter={x:Type config:OverwriteOptions}}">
688691
<ComboBoxItem IsSelected="True" Content="覆盖"/>
689692
<ComboBoxItem Content="跳过"/>
690693
<ComboBoxItem Content="询问"/>

0 commit comments

Comments
 (0)