refs #118 Added UI support for enhanced strong name signing
This commit is contained in:
Родитель
c1f6e615eb
Коммит
8113384efe
|
@ -15,7 +15,7 @@ indent_style = space
|
|||
[*.xml]
|
||||
|
||||
[*.xaml]
|
||||
indent_size = 2
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
|
||||
[*.{cs,vb}]
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
<Compile Include="..\GlobalAssemblyInfo.cs">
|
||||
<Link>Properties\GlobalAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="EmptyToBoolConverter.cs" />
|
||||
<Compile Include="BrushToColorConverter.cs" />
|
||||
<Compile Include="CompComboBox.xaml.cs">
|
||||
<DependentUpon>CompComboBox.xaml</DependentUpon>
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ConfuserEx {
|
||||
[ValueConversion(typeof(string), typeof(bool), ParameterType = typeof(bool))]
|
||||
[ValueConversion(typeof(string), typeof(bool), ParameterType = typeof(string))]
|
||||
public class EmptyToBoolConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
bool stateIfEmpty = true;
|
||||
switch (parameter) {
|
||||
case bool boolParameter:
|
||||
stateIfEmpty = boolParameter;
|
||||
break;
|
||||
case string strParameter when bool.TryParse(strParameter, out var parsedStrParameter):
|
||||
stateIfEmpty = parsedStrParameter;
|
||||
break;
|
||||
}
|
||||
|
||||
if (value == null) return stateIfEmpty;
|
||||
if (!(value is string strValue)) return stateIfEmpty;
|
||||
|
||||
return string.IsNullOrEmpty(strValue) ? stateIfEmpty : !stateIfEmpty;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
|
@ -73,6 +73,46 @@ namespace ConfuserEx.ViewModel {
|
|||
}
|
||||
}
|
||||
|
||||
public string SNSigKeyPath {
|
||||
get { return module.SNSigKeyPath; }
|
||||
set {
|
||||
if (SetProperty(module.SNSigKeyPath != value, val => module.SNSigKeyPath = val, value, "SNSigKeyPath"))
|
||||
parent.IsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string SNSigKeyPassword {
|
||||
get { return module.SNSigKeyPassword; }
|
||||
set {
|
||||
if (SetProperty(module.SNSigKeyPassword != value, val => module.SNSigKeyPassword = val, value, "SNSigKeyPassword"))
|
||||
parent.IsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string SNPubKeyPath {
|
||||
get { return module.SNPubKeyPath; }
|
||||
set {
|
||||
if (SetProperty(module.SNPubKeyPath != value, val => module.SNPubKeyPath = val, value, "SNPubKeyPath"))
|
||||
parent.IsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string SNPubSigKeyPath {
|
||||
get { return module.SNPubSigKeyPath; }
|
||||
set {
|
||||
if (SetProperty(module.SNPubSigKeyPath != value, val => module.SNPubSigKeyPath = val, value, "SNPubSigKeyPath"))
|
||||
parent.IsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SNDelaySig {
|
||||
get { return module.SNDelaySig; }
|
||||
set {
|
||||
if (SetProperty(module.SNDelaySig != value, val => module.SNDelaySig = val, value, "SNDelaySig"))
|
||||
parent.IsModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<ProjectRuleVM> Rules { get; private set; }
|
||||
|
||||
ProjectModule IViewModel<ProjectModule>.Model {
|
||||
|
|
|
@ -2,14 +2,56 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:ConfuserEx"
|
||||
xmlns:vm="clr-namespace:ConfuserEx.ViewModel"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
|
||||
Title="{Binding Path, StringFormat=Edit module \'{0}\'...}" Style="{StaticResource DarkWindow}"
|
||||
SizeToContent="WidthAndHeight" ShowInTaskbar="False" ResizeMode="NoResize">
|
||||
SizeToContent="WidthAndHeight" ShowInTaskbar="False" ResizeMode="NoResize"
|
||||
d:DataContext="{d:DesignInstance vm:ProjectModuleVM}">
|
||||
<Grid Margin="5">
|
||||
<Grid.Resources>
|
||||
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource {x:Type Label}}">
|
||||
<Style.Setters>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Padding" Value="0 0 5 0" />
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Style.Setters>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Margin" Value="5" />
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
<Style TargetType="{x:Type Button}" x:Key="FilesystemSelectButton" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Style.Setters>
|
||||
<Setter Property="ContentTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock FontSize="14px" FontFamily="{DynamicResource FontAwesome}" Text="" Height="10px" TextOptions.TextRenderingMode="GrayScale" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Height" Value="26" />
|
||||
<Setter Property="Margin" Value="5" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
<local:EmptyToBoolConverter x:Key="EmptyToBoolConverter" />
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
<RowDefinition Height="36px" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150px" />
|
||||
|
@ -17,30 +59,63 @@
|
|||
<ColumnDefinition Width="35px" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Assembly Path : " Grid.Row="0" Grid.Column="0" HorizontalContentAlignment="Right"
|
||||
VerticalContentAlignment="Center" />
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Margin="5" VerticalContentAlignment="Center"
|
||||
<Label Content="Assembly Path:" Grid.Row="0" Grid.Column="0" />
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Text="{Binding Path, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
local:FileDragDrop.Command="{x:Static local:FileDragDrop.FileCmd}" />
|
||||
|
||||
<Label Content="SN Key Path : " Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="Right"
|
||||
VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="PathBox" Grid.Row="1" Grid.Column="1" Margin="5" VerticalContentAlignment="Center"
|
||||
TextChanged="PathBox_TextChanged"
|
||||
<Label Grid.Row="1" Grid.Column="0" Content="Strong Name" FontWeight="Bold" />
|
||||
<Separator Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Center"/>
|
||||
|
||||
<Label Content="Key Path:" Grid.Row="2" Grid.Column="0" />
|
||||
<TextBox x:Name="StrongNameKeyPathTextBox" Grid.Row="2" Grid.Column="1"
|
||||
Text="{Binding SNKeyPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
local:FileDragDrop.Command="{x:Static local:FileDragDrop.FileCmd}" />
|
||||
<Button Grid.Row="1" Grid.Column="2" Margin="5" VerticalAlignment="Center" Height="26" Click="ChooseSNKey">
|
||||
<TextBlock FontSize="14px" FontFamily="{DynamicResource FontAwesome}" Text="" Height="10px"
|
||||
TextOptions.TextRenderingMode="GrayScale" />
|
||||
</Button>
|
||||
<Button Grid.Row="2" Grid.Column="2" Click="ChooseSNKey" Style="{StaticResource FilesystemSelectButton}" />
|
||||
|
||||
<Label Content="SN Key Password : " Grid.Row="2" Grid.Column="0" HorizontalContentAlignment="Right"
|
||||
VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="PwdBox" Grid.Row="2" Grid.Column="1" Margin="5" Grid.ColumnSpan="2"
|
||||
VerticalContentAlignment="Center"
|
||||
Text="{Binding SNKeyPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Label Content="Key Password:" Grid.Row="3" Grid.Column="0" />
|
||||
<TextBox x:Name="StrongNameKeyPasswordTextBox" Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Text="{Binding SNKeyPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsEnabled="{Binding SNKeyPath, Converter={StaticResource EmptyToBoolConverter}, ConverterParameter=false}"/>
|
||||
|
||||
<Button Grid.Row="3" Grid.ColumnSpan="3" HorizontalAlignment="Right" Content="Done"
|
||||
<Label Grid.Row="4" Grid.Column="0" Content="Enhanced Strong Name" FontWeight="Bold" />
|
||||
<Separator Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="2" VerticalAlignment="Center"/>
|
||||
|
||||
<Label Content="Signature Key Path:" Grid.Row="5" Grid.Column="0" />
|
||||
<TextBox x:Name="StrongNameSigKeyPathTextBox" Grid.Row="5" Grid.Column="1"
|
||||
Text="{Binding SNSigKeyPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
local:FileDragDrop.Command="{x:Static local:FileDragDrop.FileCmd}" />
|
||||
<Button Grid.Row="5" Grid.Column="2" Click="ChooseSNSigKey" Style="{StaticResource FilesystemSelectButton}" />
|
||||
|
||||
<Label Content="Signature Key Password:" Grid.Row="6" Grid.Column="0" />
|
||||
<TextBox x:Name="StrongNameSigKeyPasswordTextBox" Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Text="{Binding SNSigKeyPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsEnabled="{Binding SNSigKeyPath, Converter={StaticResource EmptyToBoolConverter}, ConverterParameter=false}" />
|
||||
|
||||
<Label Content="Signature Public Key Path:" Grid.Row="7" Grid.Column="0" />
|
||||
<TextBox x:Name="StrongNamePubSigKeyPathTextBox" Grid.Row="7" Grid.Column="1"
|
||||
Text="{Binding SNPubSigKeyPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
local:FileDragDrop.Command="{x:Static local:FileDragDrop.FileCmd}" />
|
||||
<Button Grid.Row="7" Grid.Column="2" Click="ChooseSNPublicSigKey" Style="{StaticResource FilesystemSelectButton}" />
|
||||
|
||||
<Label Content="Identity Key Path:" Grid.Row="8" Grid.Column="0" />
|
||||
<TextBox x:Name="StrongNameIdentKeyPathTextBox" Grid.Row="8" Grid.Column="1"
|
||||
Text="{Binding SNKeyPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
local:FileDragDrop.Command="{x:Static local:FileDragDrop.FileCmd}" />
|
||||
<Button Grid.Row="8" Grid.Column="2" Click="ChooseSNKey" Style="{StaticResource FilesystemSelectButton}" />
|
||||
|
||||
<Label Content="Identity Key Password:" Grid.Row="9" Grid.Column="0" />
|
||||
<TextBox x:Name="StrongNameIdentKeyPasswordTextBox" Grid.Row="9" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Text="{Binding SNKeyPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
IsEnabled="{Binding SNKeyPath, Converter={StaticResource EmptyToBoolConverter}, ConverterParameter=false}" />
|
||||
|
||||
<Label Content="Identity Public Key Path:" Grid.Row="10" Grid.Column="0" />
|
||||
<TextBox x:Name="StrongNamePubKeyPathTextBox" Grid.Row="10" Grid.Column="1"
|
||||
Text="{Binding SNPubKeyPath, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
local:FileDragDrop.Command="{x:Static local:FileDragDrop.FileCmd}" />
|
||||
<Button Grid.Row="10" Grid.Column="2" Click="ChooseSNPublicKey" Style="{StaticResource FilesystemSelectButton}" />
|
||||
|
||||
<Button Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="3" HorizontalAlignment="Right" Content="Done"
|
||||
Width="70" Margin="5" Click="Done" />
|
||||
</Grid>
|
||||
</Window>
|
|
@ -12,23 +12,30 @@ namespace ConfuserEx.Views {
|
|||
InitializeComponent();
|
||||
this.module = module;
|
||||
DataContext = module;
|
||||
PwdBox.IsEnabled = !string.IsNullOrEmpty(PathBox.Text);
|
||||
}
|
||||
|
||||
void Done(object sender, RoutedEventArgs e) {
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
void PathBox_TextChanged(object sender, TextChangedEventArgs e) {
|
||||
PwdBox.IsEnabled = !string.IsNullOrEmpty(PathBox.Text);
|
||||
}
|
||||
void ChooseSNKey(object sender, RoutedEventArgs e) =>
|
||||
module.SNKeyPath = ChooseKey();
|
||||
|
||||
void ChooseSNKey(object sender, RoutedEventArgs e) {
|
||||
var ofd = new VistaOpenFileDialog();
|
||||
ofd.Filter = "Supported Key Files (*.snk, *.pfx)|*.snk;*.pfx|All Files (*.*)|*.*";
|
||||
if (ofd.ShowDialog() ?? false) {
|
||||
module.SNKeyPath = ofd.FileName;
|
||||
}
|
||||
void ChooseSNSigKey(object sender, RoutedEventArgs e) =>
|
||||
module.SNSigKeyPath = ChooseKey();
|
||||
|
||||
void ChooseSNPublicKey(object sender, RoutedEventArgs e) =>
|
||||
module.SNPubKeyPath = ChooseKey();
|
||||
|
||||
void ChooseSNPublicSigKey(object sender, RoutedEventArgs e) =>
|
||||
module.SNPubSigKeyPath = ChooseKey();
|
||||
|
||||
string ChooseKey() {
|
||||
var ofd = new VistaOpenFileDialog {
|
||||
Filter = "Supported Key Files (*.snk, *.pfx)|*.snk;*.pfx|All Files (*.*)|*.*"
|
||||
};
|
||||
|
||||
return ofd.ShowDialog() ?? false ? ofd.FileName : null;
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче