Skip to content

Commit 34d668f

Browse files
committed
支持插件选项 Tips,插件开发者设置后,可以为用户使用选项提供更详细的解释与指引
1 parent fe399fc commit 34d668f

9 files changed

Lines changed: 153 additions & 29 deletions

File tree

csharp/Framework/Option.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ public class Option
99
{
1010
[XmlAttribute]
1111
public string Name { get; set; }
12+
1213
[XmlAttribute]
1314
public string Type { get; set; }
15+
1416
[XmlAttribute]
1517
public string Default { get; set; }
18+
1619
[XmlElement]
1720
public string Notes { get; set; }
21+
22+
[XmlElement]
23+
public string Tips { get; set; }
24+
1825
[XmlArray]
1926
public Choice[] EnumChoices { get; set; } = Array.Empty<Choice>();
2027
}

csharp/GUI/MainWindow.xaml

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,22 @@
493493
<EventSetter Event="PreviewMouseWheel" Handler="OptionTreeView_MouseWheel"/>
494494
<EventSetter Event="PreviewTouchMove" Handler="OptionTreeView_TouchMove"/>
495495
</Style>
496+
<Style x:Key="TreeViewHeaderComment" TargetType="TextBlock" BasedOn="{StaticResource MaterialDesignTextBlock}">
497+
<Setter Property="VerticalAlignment" Value="Center"/>
498+
<Setter Property="Margin" Value="10 2 0 0"/>
499+
<Setter Property="Opacity" Value="0.8"/>
500+
<Setter Property="FontSize" Value="13"/>
501+
<Setter Property="TextTrimming" Value="CharacterEllipsis"/>
502+
<Setter Property="MaxWidth">
503+
<Setter.Value>
504+
<Binding
505+
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=materialDesign:Card}"
506+
Path="ActualWidth"
507+
Converter="{StaticResource DoubleConstantSubConverter}"
508+
ConverterParameter="160"/>
509+
</Setter.Value>
510+
</Setter>
511+
</Style>
496512
<Style TargetType="TreeViewItem" BasedOn="{StaticResource MaterialDesignTreeViewItem}">
497513
<Setter Property="IsExpanded" Value="True"/>
498514
<Setter Property="materialDesign:TreeViewAssist.ShowSelection" Value="False"/>
@@ -528,12 +544,25 @@
528544
x:Name="InputOptionsTreeView"
529545
ItemsSource="{Binding SelectedInputOptions}">
530546
<TreeViewItem.Header>
531-
<TextBlock
532-
Margin="-8 0 0 0"
533-
Text="输入选项"
534-
FontSize="16"
535-
ToolTip="{Binding IsExpanded, ElementName=InputOptionsTreeView, Converter={StaticResource BooleanSwitchOperationConverter}, ConverterParameter=点击收起;点击展开}"
536-
MouseDown="TreeViewHeader_Click"/>
547+
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
548+
<TextBlock
549+
VerticalAlignment="Center"
550+
Margin="-8 0 0 0"
551+
Text="输入选项"
552+
FontSize="16"
553+
ToolTip="{Binding IsExpanded, ElementName=InputOptionsTreeView, Converter={StaticResource BooleanSwitchOperationConverter}, ConverterParameter=点击收起;点击展开}"
554+
MouseDown="TreeViewHeader_Click"/>
555+
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Text="["/>
556+
<TextBlock VerticalAlignment="Center" Style="{StaticResource TreeViewHeaderComment}" Margin="7 2 0 0">
557+
<TextBlock.Text>
558+
<MultiBinding StringFormat="{}导入自 {0}">
559+
<Binding Path="SelectedInputPlugin.Format"/>
560+
<Binding Path="SelectedInputPlugin.Suffix"/>
561+
</MultiBinding>
562+
</TextBlock.Text>
563+
</TextBlock>
564+
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Text="]" Margin="7 2 0 0"/>
565+
</StackPanel>
537566
</TreeViewItem.Header>
538567
<TreeViewItem.ItemTemplate>
539568
<StaticResource ResourceKey="OptionsTreeViewItemTemplate"/>
@@ -547,12 +576,25 @@
547576
x:Name="OutputOptionsTreeView"
548577
ItemsSource="{Binding SelectedOutputOptions}">
549578
<TreeViewItem.Header>
550-
<TextBlock
551-
Margin="-8 0 0 0"
552-
Text="输出选项"
553-
FontSize="16"
554-
ToolTip="{Binding IsExpanded, ElementName=InputOptionsTreeView, Converter={StaticResource BooleanSwitchOperationConverter}, ConverterParameter=点击收起;点击展开}"
555-
MouseDown="TreeViewHeader_Click"/>
579+
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
580+
<TextBlock
581+
VerticalAlignment="Center"
582+
Margin="-8 0 0 0"
583+
Text="输出选项"
584+
FontSize="16"
585+
ToolTip="{Binding IsExpanded, ElementName=InputOptionsTreeView, Converter={StaticResource BooleanSwitchOperationConverter}, ConverterParameter=点击收起;点击展开}"
586+
MouseDown="TreeViewHeader_Click"/>
587+
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Text="["/>
588+
<TextBlock VerticalAlignment="Center" Style="{StaticResource TreeViewHeaderComment}" Margin="7 2 0 0">
589+
<TextBlock.Text>
590+
<MultiBinding StringFormat="{}导出为 {0}">
591+
<Binding Path="SelectedOutputPlugin.Format"/>
592+
<Binding Path="SelectedOutputPlugin.Suffix"/>
593+
</MultiBinding>
594+
</TextBlock.Text>
595+
</TextBlock>
596+
<TextBlock Style="{StaticResource TreeViewHeaderComment}" Text="]" Margin="7 2 0 0"/>
597+
</StackPanel>
556598
</TreeViewItem.Header>
557599
<TreeViewItem.ItemTemplate>
558600
<StaticResource ResourceKey="OptionsTreeViewItemTemplate"/>

csharp/GUI/OpenSvip.GUI.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
<Compile Include="TaskListViewItem.xaml.cs">
115115
<DependentUpon>TaskListViewItem.xaml</DependentUpon>
116116
</Compile>
117+
<Compile Include="ValueConverterGroup.cs" />
117118
<Compile Include="ValueConverters.cs" />
118119
<Compile Include="YesNoDialog.xaml.cs">
119120
<DependentUpon>YesNoDialog.xaml</DependentUpon>

csharp/GUI/OptionTreeViewItem.xaml

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,42 @@
2828
<Style x:Key="OptionDoubleBox" TargetType="{x:Type local:DoubleNumericBox}" BasedOn="{StaticResource OptionTextBox}">
2929
<Setter Property="InputMethod.IsInputMethodEnabled" Value="False"/>
3030
</Style>
31+
<Style x:Key="OptionInformationIcon" TargetType="materialDesign:PackIcon">
32+
<Setter Property="Kind" Value="Information"/>
33+
<Setter Property="VerticalAlignment" Value="Center"/>
34+
<Setter Property="Margin" Value="8"/>
35+
<Setter Property="Width">
36+
<Setter.Value>
37+
<Binding Path="OptionInfo.Tips" Mode="OneWay">
38+
<Binding.Converter>
39+
<local:ValueConverterGroup>
40+
<local:NotNullConverter/>
41+
<local:BooleanSwitchOperationConverter/>
42+
</local:ValueConverterGroup>
43+
</Binding.Converter>
44+
<Binding.ConverterParameter>19;0</Binding.ConverterParameter>
45+
</Binding>
46+
</Setter.Value>
47+
</Setter>
48+
<Setter Property="Height" Value="{Binding Height, RelativeSource={RelativeSource Mode=Self}}"/>
49+
<Setter Property="Opacity" Value="0.8"/>
50+
<Setter Property="ToolTip">
51+
<Setter.Value>
52+
<TextBlock FontSize="13" Text="{Binding OptionInfo.Tips}" MaxWidth="320" TextWrapping="Wrap"/>
53+
</Setter.Value>
54+
</Setter>
55+
</Style>
3156
<DataTemplate x:Key="String" d:DataType="{x:Type local:OptionViewModel}">
3257
<WrapPanel
3358
Grid.Row="0"
3459
Orientation="Horizontal"
3560
d:DataContext="{d:DesignInstance Type=local:OptionViewModel}"
3661
DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TreeViewItem}, Path=DataContext}">
3762
<TextBlock x:Name="TextBlockNearTextBox" Style="{StaticResource OptionTextBlock}" VerticalAlignment="Center" Text="{Binding Path=OptionInfo.Notes, StringFormat={}{0}:}"/>
38-
<TextBox Style="{StaticResource OptionTextBox}" VerticalAlignment="Center" Text="{Binding Path=OptionValue}" Margin="0 1 0 0" MinWidth="80"/>
63+
<StackPanel Orientation="Horizontal">
64+
<TextBox Style="{StaticResource OptionTextBox}" VerticalAlignment="Center" Text="{Binding Path=OptionValue}" Margin="0 1 0 0" MinWidth="80"/>
65+
<materialDesign:PackIcon Style="{StaticResource OptionInformationIcon}"/>
66+
</StackPanel>
3967
</WrapPanel>
4068
</DataTemplate>
4169
<DataTemplate x:Key="Integer">
@@ -45,7 +73,10 @@
4573
d:DataContext="{d:DesignInstance Type=local:OptionViewModel}"
4674
DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TreeViewItem}, Path=DataContext}">
4775
<TextBlock Style="{StaticResource OptionTextBlock}" VerticalAlignment="Center" Text="{Binding Path=OptionInfo.Notes, StringFormat={}{0}:}"/>
48-
<local:IntegerNumericBox Style="{StaticResource OptionIntegerBox}" VerticalAlignment="Center" Margin="0 2 0 0" Padding="4 2" d:Text="60" Text="{Binding Path=OptionValue}" MinWidth="35"/>
76+
<StackPanel Orientation="Horizontal">
77+
<local:IntegerNumericBox Style="{StaticResource OptionIntegerBox}" VerticalAlignment="Center" Margin="0 2 0 0" Padding="4 2" d:Text="60" Text="{Binding Path=OptionValue}" MinWidth="35"/>
78+
<materialDesign:PackIcon Style="{StaticResource OptionInformationIcon}"/>
79+
</StackPanel>
4980
</WrapPanel>
5081
</DataTemplate>
5182
<DataTemplate x:Key="Double">
@@ -55,7 +86,10 @@
5586
d:DataContext="{d:DesignInstance Type=local:OptionViewModel}"
5687
DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TreeViewItem}, Path=DataContext}">
5788
<TextBlock Style="{StaticResource OptionTextBlock}" VerticalAlignment="Center" Text="{Binding Path=OptionInfo.Notes, StringFormat={}{0}:}"/>
58-
<local:DoubleNumericBox Style="{StaticResource OptionDoubleTextBox}" VerticalAlignment="Center" Margin="0 2 0 0" Padding="4 2" d:Text="60" Text="{Binding Path=OptionValue}" MinWidth="50" Digits="3"/>
89+
<StackPanel Orientation="Horizontal">
90+
<local:DoubleNumericBox Style="{StaticResource OptionDoubleTextBox}" VerticalAlignment="Center" Margin="0 2 0 0" Padding="4 2" d:Text="60" Text="{Binding Path=OptionValue}" MinWidth="50" Digits="3"/>
91+
<materialDesign:PackIcon Style="{StaticResource OptionInformationIcon}"/>
92+
</StackPanel>
5993
</WrapPanel>
6094
</DataTemplate>
6195
<DataTemplate x:Key="Boolean">
@@ -68,7 +102,10 @@
68102
Margin="-2 0 0 0"
69103
Cursor="Hand"
70104
IsChecked="{Binding Path=OptionValue}"/>
71-
<TextBlock x:Name="AutoDetectText" Style="{StaticResource OptionTextBlock}" VerticalAlignment="Center" Margin="5 0" Text="{Binding Path=OptionInfo.Notes}"/>
105+
<StackPanel Orientation="Horizontal">
106+
<TextBlock x:Name="AutoDetectText" Style="{StaticResource OptionTextBlock}" VerticalAlignment="Center" Margin="5 0" Text="{Binding Path=OptionInfo.Notes}"/>
107+
<materialDesign:PackIcon Style="{StaticResource OptionInformationIcon}"/>
108+
</StackPanel>
72109
</WrapPanel>
73110
</DataTemplate>
74111
<DataTemplate x:Key="Enum">
@@ -78,16 +115,21 @@
78115
d:DataContext="{d:DesignInstance Type=local:OptionViewModel}"
79116
DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TreeViewItem}, Path=DataContext}">
80117
<TextBlock Style="{StaticResource OptionTextBlock}" VerticalAlignment="Center" Text="{Binding Path=OptionInfo.Notes, StringFormat={}{0}:}"/>
81-
<ComboBox
82-
ItemsSource="{Binding Path=OptionInfo.EnumChoices}"
83-
SelectedIndex="{Binding ChoiceIndex}"
84-
ToolTip="{Binding RelativeSource={RelativeSource Mode=Self}, Path=SelectedItem.Label}">
85-
<ComboBox.ItemTemplate>
86-
<DataTemplate DataType="{x:Type framwork:Choice}">
87-
<TextBlock Style="{StaticResource OptionTextBlock}" Opacity="1" TextAlignment="Center" Text="{Binding Name}" Padding="0" ToolTip="{Binding Label}"/>
88-
</DataTemplate>
89-
</ComboBox.ItemTemplate>
90-
</ComboBox>
118+
<StackPanel Orientation="Horizontal">
119+
<ComboBox
120+
Margin="0 5 0 0"
121+
Padding="0 0 0 4"
122+
ItemsSource="{Binding Path=OptionInfo.EnumChoices}"
123+
SelectedIndex="{Binding ChoiceIndex}"
124+
ToolTip="{Binding RelativeSource={RelativeSource Mode=Self}, Path=SelectedItem.Label}">
125+
<ComboBox.ItemTemplate>
126+
<DataTemplate DataType="{x:Type framwork:Choice}">
127+
<TextBlock Style="{StaticResource OptionTextBlock}" Opacity="1" TextAlignment="Center" Text="{Binding Name}" Padding="0" ToolTip="{Binding Label}"/>
128+
</DataTemplate>
129+
</ComboBox.ItemTemplate>
130+
</ComboBox>
131+
<materialDesign:PackIcon Style="{StaticResource OptionInformationIcon}"/>
132+
</StackPanel>
91133
</WrapPanel>
92134
</DataTemplate>
93135
</UserControl.Resources>

csharp/GUI/ValueConverterGroup.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Windows.Data;
5+
6+
namespace OpenSvip.GUI
7+
{
8+
public class ValueConverterGroup : List<IValueConverter>, IValueConverter
9+
{
10+
#region IValueConverter Members
11+
12+
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
13+
{
14+
return this.Aggregate(value, (current, converter) => converter.Convert(current, targetType, parameter, culture));
15+
}
16+
17+
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
18+
{
19+
throw new NotImplementedException();
20+
}
21+
22+
#endregion
23+
}
24+
}

csharp/GUI/ViewModels.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ public AppModel()
4545
});
4646
}
4747

48-
public string Version { get; set; } = "1.0.4 (Preview)";
48+
public string Version { get; set; } = "1.0.5 (Preview)";
4949

50-
public string FrameworkVersion { get; set; } = "1.2.1";
50+
public string FrameworkVersion { get; set; } = "1.2.2";
5151

5252
public string Author { get; set; } = "YQ之神";
5353

csharp/Plugins/BinSvip/Properties.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
<OutputOptions>
1717
<Option Name="singer" Type="string" Default="陈水若">
1818
<Notes>无法匹配歌手时,使用此缺省歌手</Notes>
19+
<Tips>请输入完整无误的歌手名字。若此选项指定的歌手不存在,将使用 X Studio 中设置的默认歌手。</Tips>
1920
</Option>
2021
<Option Name="tempo" Type="integer" Default="60">
2122
<Notes>曲速过低或过高时,使用此曲速进行对齐</Notes>
23+
<Tips>X Studio 支持的曲速范围为 20 ~ 300。曲速超出范围时,将会启用绝对时间轴以确保音符对齐。请尽量将此值设置为源工程文件中曲速的整数倍或整数分之一。只要在合理数值范围内,此选项的值不会影响对齐效果。</Tips>
2224
</Option>
2325
<Option Name="version" Type="enum" Default="auto">
2426
<Notes>指定生成的 .svip 文件版本</Notes>
27+
<Tips>此选项仅控制输出工程文件的头部版本信息。选择较旧的工程文件版本不会造成数据丢失。</Tips>
2528
<EnumChoices>
2629
<Choice Name="根据当前安装的 X Studio 自动选择" Tag="auto"/>
2730
<Choice Name="SVIP 7.0.0 (X Studio 2.0)" Tag="7.0.0"/>

csharp/Plugins/JsonSvip/Properties.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<OutputOptions>
1616
<Option Name="indented" Type="boolean" Default="false">
1717
<Notes>生成带缩进格式的 JSON 文件</Notes>
18+
<Tips>缩进格式便于阅读与修改,但会占据较大的文件体积。</Tips>
1819
</Option>
1920
</OutputOptions>
2021
</Plugin>

0 commit comments

Comments
 (0)