mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
optimize<*>: remove Windows Terminal settings because it can be set outside in Windows Terminal
This commit is contained in:
parent
44ed55937d
commit
171f1d1d0c
5 changed files with 511 additions and 546 deletions
|
@ -68,11 +68,6 @@ namespace SourceGit.Models {
|
|||
/// 上一次检测的时间(用于控制每天仅第一次启动软件时,检测)
|
||||
/// </summary>
|
||||
public int LastCheckDay { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 是否尝试使用 Windows Terminal 打开终端
|
||||
/// </summary>
|
||||
public bool UseWindowsTerminal { get; set; } = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,377 +1,369 @@
|
|||
<controls:Window
|
||||
x:Class="SourceGit.Views.Preference"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
xmlns:models="clr-namespace:SourceGit.Models"
|
||||
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
Title="{DynamicResource Text.Preference}"
|
||||
Width="500" Height="312">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<converters:FontFamiliesToName x:Key="FontFamiliesToName"/>
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="1"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Title bar -->
|
||||
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Icon -->
|
||||
<Path Grid.Column="0" Width="14" Height="14" Margin="6,0" Data="{StaticResource Icon.Preference}"/>
|
||||
|
||||
<!-- Title -->
|
||||
<TextBlock Grid.Column="1" Text="{DynamicResource Text.Preference}"/>
|
||||
|
||||
<!-- Close -->
|
||||
<controls:IconButton
|
||||
Grid.Column="3"
|
||||
Click="Quit"
|
||||
Width="28" Padding="8"
|
||||
Icon="{StaticResource Icon.Close}"
|
||||
HoverBackground="Red"
|
||||
WindowChrome.IsHitTestVisibleInChrome="True"/>
|
||||
</Grid>
|
||||
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Fill="{DynamicResource Brush.Border0}"/>
|
||||
|
||||
<!-- Tabs -->
|
||||
<TabControl Grid.Row="2" Margin="0,4">
|
||||
<!-- General Setting -->
|
||||
<TabItem Header="{DynamicResource Text.Preference.General}">
|
||||
<Grid Margin="0,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Language -->
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Locale}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:Locale.Supported}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Resource"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.Locale, Mode=TwoWay}"
|
||||
SelectionChanged="LocaleChanged"/>
|
||||
|
||||
<!-- System Font -->
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.FontFamilyWindow}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:InstalledFont.GetFonts}}"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyWindow, Mode=TwoWay, Converter={StaticResource FontFamiliesToName}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Name"
|
||||
SelectionChanged="LocaleChanged">
|
||||
<ComboBox.Resources>
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="FontFamily" Value="{Binding Name}"/>
|
||||
<Setter Property="ToolTip" Value="{Binding Name}"/>
|
||||
</Style>
|
||||
</ComboBox.Resources>
|
||||
</ComboBox>
|
||||
|
||||
<!-- Content Font -->
|
||||
<TextBlock
|
||||
Grid.Row="2" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.FontFamilyContent}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="2" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:InstalledFont.GetFonts}}"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=TwoWay, Converter={StaticResource FontFamiliesToName}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Name"
|
||||
SelectionChanged="LocaleChanged">
|
||||
<ComboBox.Resources>
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="FontFamily" Value="{Binding Name}"/>
|
||||
<Setter Property="ToolTip" Value="{Binding Name}"/>
|
||||
</Style>
|
||||
</ComboBox.Resources>
|
||||
</ComboBox>
|
||||
|
||||
<!-- Avatar -->
|
||||
<TextBlock
|
||||
Grid.Row="3" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.AvatarServer}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="3" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:AvatarServer.Supported}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Url"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.AvatarServer, Mode=TwoWay}"/>
|
||||
|
||||
<!-- Enable Check For Update -->
|
||||
<CheckBox
|
||||
Grid.Row="4" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.CheckUpdate}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.CheckForUpdate, Mode=TwoWay}"/>
|
||||
|
||||
<!-- Enable Dark Theme -->
|
||||
<CheckBox
|
||||
Grid.Row="5" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.UseDarkTheme}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.UseDarkTheme, Mode=TwoWay}"
|
||||
Checked="ChangeTheme" Unchecked="ChangeTheme"/>
|
||||
|
||||
<!-- Restore Windows -->
|
||||
<CheckBox
|
||||
Grid.Row="6" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.RestoreTabs}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Restore.IsEnabled, Mode=TwoWay}"/>
|
||||
|
||||
<!-- Use Windows Terminal -->
|
||||
<CheckBox
|
||||
Grid.Row="7" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.UseWindowsTerminal}"
|
||||
IsEnabled="{Binding ElementName=me, Path=HasWindowsTerminal}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.UseWindowsTerminal, Mode=TwoWay}"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<!-- Git Setting -->
|
||||
<TabItem Header="{DynamicResource Text.Preference.Git}">
|
||||
<Grid Margin="0,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Git Executable Path -->
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.Path}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<Grid Grid.Row="0" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:TextEdit
|
||||
Grid.Column="0"
|
||||
x:Name="editGitPath"
|
||||
Height="24"
|
||||
Text="{Binding Source={x:Static models:Preference.Instance}, Path=Git.Path, Mode=TwoWay}"
|
||||
Placeholder="{DynamicResource Text.Preference.Git.Path.Placeholder}"/>
|
||||
<controls:IconButton
|
||||
Grid.Column="1"
|
||||
Click="SelectGitPath"
|
||||
Width="24" Height="24"
|
||||
Margin="4,0,0,0" Padding="4"
|
||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
|
||||
Icon="{StaticResource Icon.Folder.Open}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- Git Version -->
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.Version}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
x:Name="textGitVersion"
|
||||
Text="{Binding ElementName=me, Path=Version}"/>
|
||||
|
||||
<!-- Default Clone Dir -->
|
||||
<TextBlock
|
||||
Grid.Row="2" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.Dir}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<Grid Grid.Row="2" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:TextEdit
|
||||
Grid.Column="0"
|
||||
x:Name="txtGitCloneDir"
|
||||
Height="24"
|
||||
Placeholder="{DynamicResource Text.Preference.Git.Dir.Placeholder}"
|
||||
Text="{Binding Source={x:Static models:Preference.Instance}, Path=Git.DefaultCloneDir, Mode=TwoWay}"/>
|
||||
<controls:IconButton
|
||||
Grid.Column="1"
|
||||
Click="SelectGitCloneDir"
|
||||
Width="24" Height="24"
|
||||
Margin="4,0,0,0" Padding="4"
|
||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
|
||||
Icon="{StaticResource Icon.Folder.Open}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- User -->
|
||||
<TextBlock
|
||||
Grid.Row="3" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.User}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="3" Grid.Column="1"
|
||||
x:Name="editGitUser"
|
||||
Height="24"
|
||||
Text="{Binding ElementName=me, Path=User, Mode=TwoWay}"
|
||||
Placeholder="{DynamicResource Text.Preference.Git.User.Placeholder}"/>
|
||||
|
||||
<!-- Email -->
|
||||
<TextBlock
|
||||
Grid.Row="4" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.Email}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="4" Grid.Column="1"
|
||||
x:Name="editGitEmail"
|
||||
Height="24"
|
||||
Text="{Binding ElementName=me, Path=Email, Mode=TwoWay}"
|
||||
Placeholder="{DynamicResource Text.Preference.Git.Email.Placeholder}"/>
|
||||
|
||||
<!-- CRLF -->
|
||||
<TextBlock
|
||||
Grid.Row="5" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.CRLF}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="5" Grid.Column="1"
|
||||
x:Name="editGitCrlf"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:CRLFOption.Supported}}"
|
||||
SelectedValuePath="Value"
|
||||
SelectedValue="{Binding ElementName=me, Path=CRLF, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Height="20">
|
||||
<TextBlock Text="{Binding Display}" Margin="2,0"/>
|
||||
<TextBlock Text="{Binding Desc}" Margin="8,0,0,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<!-- Auto Fetch -->
|
||||
<CheckBox
|
||||
Grid.Row="6" Grid.Column="1"
|
||||
VerticalAlignment="Bottom"
|
||||
Content="{DynamicResource Text.Preference.Git.AutoFetch}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Git.AutoFetchRemotes, Mode=TwoWay}"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="{DynamicResource Text.Preference.Merger}">
|
||||
<Grid Margin="0,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Merge Tool Type -->
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Merger.Type}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:MergeTool.Supported}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Type"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=MergeTool.Type, Mode=TwoWay}"
|
||||
SelectionChanged="MergeToolChanged"/>
|
||||
|
||||
<!-- Merge Tool Executable Path -->
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Merger.Path}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<Grid Grid.Row="1" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:TextEdit
|
||||
Grid.Column="0"
|
||||
Height="24"
|
||||
x:Name="txtMergeExec"
|
||||
Placeholder="{DynamicResource Text.Preference.Merger.Path.Placeholder}"
|
||||
Text="{Binding Source={x:Static models:Preference.Instance}, Path=MergeTool.Path, Mode=TwoWay}"/>
|
||||
<controls:IconButton
|
||||
Grid.Column="1"
|
||||
Click="SelectMergeTool"
|
||||
Width="24" Height="24"
|
||||
Margin="4,0,0,0" Padding="4"
|
||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
|
||||
Icon="{StaticResource Icon.Folder.Open}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</controls:Window>
|
||||
<controls:Window
|
||||
x:Class="SourceGit.Views.Preference"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
xmlns:models="clr-namespace:SourceGit.Models"
|
||||
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
ResizeMode="NoResize"
|
||||
Title="{DynamicResource Text.Preference}"
|
||||
Width="500" Height="312">
|
||||
<Grid>
|
||||
<Grid.Resources>
|
||||
<converters:FontFamiliesToName x:Key="FontFamiliesToName"/>
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="1"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Title bar -->
|
||||
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Icon -->
|
||||
<Path Grid.Column="0" Width="14" Height="14" Margin="6,0" Data="{StaticResource Icon.Preference}"/>
|
||||
|
||||
<!-- Title -->
|
||||
<TextBlock Grid.Column="1" Text="{DynamicResource Text.Preference}"/>
|
||||
|
||||
<!-- Close -->
|
||||
<controls:IconButton
|
||||
Grid.Column="3"
|
||||
Click="Quit"
|
||||
Width="28" Padding="8"
|
||||
Icon="{StaticResource Icon.Close}"
|
||||
HoverBackground="Red"
|
||||
WindowChrome.IsHitTestVisibleInChrome="True"/>
|
||||
</Grid>
|
||||
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Fill="{DynamicResource Brush.Border0}"/>
|
||||
|
||||
<!-- Tabs -->
|
||||
<TabControl Grid.Row="2" Margin="0,4">
|
||||
<!-- General Setting -->
|
||||
<TabItem Header="{DynamicResource Text.Preference.General}">
|
||||
<Grid Margin="0,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Language -->
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Locale}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:Locale.Supported}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Resource"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.Locale, Mode=TwoWay}"
|
||||
SelectionChanged="LocaleChanged"/>
|
||||
|
||||
<!-- System Font -->
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.FontFamilyWindow}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:InstalledFont.GetFonts}}"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyWindow, Mode=TwoWay, Converter={StaticResource FontFamiliesToName}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Name"
|
||||
SelectionChanged="LocaleChanged">
|
||||
<ComboBox.Resources>
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="FontFamily" Value="{Binding Name}"/>
|
||||
<Setter Property="ToolTip" Value="{Binding Name}"/>
|
||||
</Style>
|
||||
</ComboBox.Resources>
|
||||
</ComboBox>
|
||||
|
||||
<!-- Content Font -->
|
||||
<TextBlock
|
||||
Grid.Row="2" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.FontFamilyContent}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="2" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:InstalledFont.GetFonts}}"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=TwoWay, Converter={StaticResource FontFamiliesToName}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Name"
|
||||
SelectionChanged="LocaleChanged">
|
||||
<ComboBox.Resources>
|
||||
<Style TargetType="ComboBoxItem">
|
||||
<Setter Property="FontFamily" Value="{Binding Name}"/>
|
||||
<Setter Property="ToolTip" Value="{Binding Name}"/>
|
||||
</Style>
|
||||
</ComboBox.Resources>
|
||||
</ComboBox>
|
||||
|
||||
<!-- Avatar -->
|
||||
<TextBlock
|
||||
Grid.Row="3" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.AvatarServer}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="3" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:AvatarServer.Supported}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Url"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=General.AvatarServer, Mode=TwoWay}"/>
|
||||
|
||||
<!-- Enable Check For Update -->
|
||||
<CheckBox
|
||||
Grid.Row="4" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.CheckUpdate}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.CheckForUpdate, Mode=TwoWay}"/>
|
||||
|
||||
<!-- Enable Dark Theme -->
|
||||
<CheckBox
|
||||
Grid.Row="5" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.UseDarkTheme}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=General.UseDarkTheme, Mode=TwoWay}"
|
||||
Checked="ChangeTheme" Unchecked="ChangeTheme"/>
|
||||
|
||||
<!-- Restore Windows -->
|
||||
<CheckBox
|
||||
Grid.Row="6" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Preference.RestoreTabs}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Restore.IsEnabled, Mode=TwoWay}"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<!-- Git Setting -->
|
||||
<TabItem Header="{DynamicResource Text.Preference.Git}">
|
||||
<Grid Margin="0,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Git Executable Path -->
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.Path}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<Grid Grid.Row="0" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:TextEdit
|
||||
Grid.Column="0"
|
||||
x:Name="editGitPath"
|
||||
Height="24"
|
||||
Text="{Binding Source={x:Static models:Preference.Instance}, Path=Git.Path, Mode=TwoWay}"
|
||||
Placeholder="{DynamicResource Text.Preference.Git.Path.Placeholder}"/>
|
||||
<controls:IconButton
|
||||
Grid.Column="1"
|
||||
Click="SelectGitPath"
|
||||
Width="24" Height="24"
|
||||
Margin="4,0,0,0" Padding="4"
|
||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
|
||||
Icon="{StaticResource Icon.Folder.Open}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- Git Version -->
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.Version}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
x:Name="textGitVersion"
|
||||
Text="{Binding ElementName=me, Path=Version}"/>
|
||||
|
||||
<!-- Default Clone Dir -->
|
||||
<TextBlock
|
||||
Grid.Row="2" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.Dir}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<Grid Grid.Row="2" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:TextEdit
|
||||
Grid.Column="0"
|
||||
x:Name="txtGitCloneDir"
|
||||
Height="24"
|
||||
Placeholder="{DynamicResource Text.Preference.Git.Dir.Placeholder}"
|
||||
Text="{Binding Source={x:Static models:Preference.Instance}, Path=Git.DefaultCloneDir, Mode=TwoWay}"/>
|
||||
<controls:IconButton
|
||||
Grid.Column="1"
|
||||
Click="SelectGitCloneDir"
|
||||
Width="24" Height="24"
|
||||
Margin="4,0,0,0" Padding="4"
|
||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
|
||||
Icon="{StaticResource Icon.Folder.Open}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- User -->
|
||||
<TextBlock
|
||||
Grid.Row="3" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.User}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="3" Grid.Column="1"
|
||||
x:Name="editGitUser"
|
||||
Height="24"
|
||||
Text="{Binding ElementName=me, Path=User, Mode=TwoWay}"
|
||||
Placeholder="{DynamicResource Text.Preference.Git.User.Placeholder}"/>
|
||||
|
||||
<!-- Email -->
|
||||
<TextBlock
|
||||
Grid.Row="4" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.Email}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="4" Grid.Column="1"
|
||||
x:Name="editGitEmail"
|
||||
Height="24"
|
||||
Text="{Binding ElementName=me, Path=Email, Mode=TwoWay}"
|
||||
Placeholder="{DynamicResource Text.Preference.Git.Email.Placeholder}"/>
|
||||
|
||||
<!-- CRLF -->
|
||||
<TextBlock
|
||||
Grid.Row="5" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Git.CRLF}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="5" Grid.Column="1"
|
||||
x:Name="editGitCrlf"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:CRLFOption.Supported}}"
|
||||
SelectedValuePath="Value"
|
||||
SelectedValue="{Binding ElementName=me, Path=CRLF, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" Height="20">
|
||||
<TextBlock Text="{Binding Display}" Margin="2,0"/>
|
||||
<TextBlock Text="{Binding Desc}" Margin="8,0,0,0" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<!-- Auto Fetch -->
|
||||
<CheckBox
|
||||
Grid.Row="6" Grid.Column="1"
|
||||
VerticalAlignment="Bottom"
|
||||
Content="{DynamicResource Text.Preference.Git.AutoFetch}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Git.AutoFetchRemotes, Mode=TwoWay}"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
<TabItem Header="{DynamicResource Text.Preference.Merger}">
|
||||
<Grid Margin="0,8">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Merge Tool Type -->
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Merger.Type}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<ComboBox
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
Height="24"
|
||||
ItemsSource="{Binding Source={x:Static models:MergeTool.Supported}}"
|
||||
DisplayMemberPath="Name"
|
||||
SelectedValuePath="Type"
|
||||
SelectedValue="{Binding Source={x:Static models:Preference.Instance}, Path=MergeTool.Type, Mode=TwoWay}"
|
||||
SelectionChanged="MergeToolChanged"/>
|
||||
|
||||
<!-- Merge Tool Executable Path -->
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Text="{DynamicResource Text.Preference.Merger.Path}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,8,0"/>
|
||||
<Grid Grid.Row="1" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:TextEdit
|
||||
Grid.Column="0"
|
||||
Height="24"
|
||||
x:Name="txtMergeExec"
|
||||
Placeholder="{DynamicResource Text.Preference.Merger.Path.Placeholder}"
|
||||
Text="{Binding Source={x:Static models:Preference.Instance}, Path=MergeTool.Path, Mode=TwoWay}"/>
|
||||
<controls:IconButton
|
||||
Grid.Column="1"
|
||||
Click="SelectMergeTool"
|
||||
Width="24" Height="24"
|
||||
Margin="4,0,0,0" Padding="4"
|
||||
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
|
||||
Icon="{StaticResource Icon.Folder.Open}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</controls:Window>
|
||||
|
|
|
@ -1,138 +1,133 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views {
|
||||
|
||||
/// <summary>
|
||||
/// 设置面板
|
||||
/// </summary>
|
||||
public partial class Preference : Controls.Window {
|
||||
|
||||
public string User { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string CRLF { get; set; }
|
||||
public string Version { get; set; }
|
||||
public bool HasWindowsTerminal { get; set; }
|
||||
|
||||
public Preference() {
|
||||
UpdateGitInfo(false);
|
||||
|
||||
HasWindowsTerminal = Models.ExecutableFinder.Find("wt.exe") != null;
|
||||
if (!HasWindowsTerminal) Models.Preference.Instance.General.UseWindowsTerminal = false;
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private bool UpdateGitInfo(bool updateUi) {
|
||||
var isReady = Models.Preference.Instance.IsReady;
|
||||
if (isReady) {
|
||||
User = new Commands.Config().Get("user.name");
|
||||
Email = new Commands.Config().Get("user.email");
|
||||
CRLF = new Commands.Config().Get("core.autocrlf");
|
||||
Version = new Commands.Version().Query();
|
||||
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
||||
} else {
|
||||
User = "";
|
||||
Email = "";
|
||||
CRLF = "false";
|
||||
Version = "Unknown";
|
||||
}
|
||||
if (updateUi) {
|
||||
editGitUser?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
editGitEmail?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
editGitCrlf?.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateTarget();
|
||||
textGitVersion?.GetBindingExpression(TextBlock.TextProperty).UpdateTarget();
|
||||
}
|
||||
return isReady;
|
||||
}
|
||||
|
||||
#region EVENTS
|
||||
private void LocaleChanged(object sender, SelectionChangedEventArgs e) {
|
||||
Models.Locale.Change();
|
||||
}
|
||||
|
||||
private void ChangeTheme(object sender, RoutedEventArgs e) {
|
||||
Models.Theme.Change();
|
||||
}
|
||||
|
||||
private void SelectGitPath(object sender, RoutedEventArgs e) {
|
||||
var initDir = Models.ExecutableFinder.Find("git.exe");
|
||||
if (initDir == null) initDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
||||
else initDir = Path.GetDirectoryName(initDir);
|
||||
|
||||
var dialog = new OpenFileDialog {
|
||||
Filter = "Git Executable|git.exe",
|
||||
FileName = "git.exe",
|
||||
Title = App.Text("Preference.Dialog.GitExe"),
|
||||
InitialDirectory = initDir,
|
||||
CheckFileExists = true,
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == true) {
|
||||
Models.Preference.Instance.Git.Path = dialog.FileName;
|
||||
editGitPath?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
UpdateGitInfo(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectGitCloneDir(object sender, RoutedEventArgs e) {
|
||||
var dialog = new Controls.FolderDialog();
|
||||
if (dialog.ShowDialog() == true) {
|
||||
Models.Preference.Instance.Git.DefaultCloneDir = dialog.SelectedPath;
|
||||
txtGitCloneDir?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectMergeTool(object sender, RoutedEventArgs e) {
|
||||
var type = Models.Preference.Instance.MergeTool.Type;
|
||||
var tool = Models.MergeTool.Supported.Find(x => x.Type == type);
|
||||
|
||||
if (tool == null || tool.Type == 0) return;
|
||||
|
||||
var dialog = new OpenFileDialog();
|
||||
dialog.Filter = $"{tool.Name} Executable|{tool.Exec}";
|
||||
dialog.Title = App.Text("Preference.Dialog.Merger", tool.Name);
|
||||
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
||||
dialog.CheckFileExists = true;
|
||||
|
||||
if (dialog.ShowDialog() == true) {
|
||||
Models.Preference.Instance.MergeTool.Path = dialog.FileName;
|
||||
txtMergeExec?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
}
|
||||
}
|
||||
|
||||
private void MergeToolChanged(object sender, SelectionChangedEventArgs e) {
|
||||
var type = (int)(sender as ComboBox).SelectedValue;
|
||||
var tool = Models.MergeTool.Supported.Find(x => x.Type == type);
|
||||
if (tool == null) return;
|
||||
|
||||
if (IsLoaded) {
|
||||
Models.Preference.Instance.MergeTool.Path = tool.Finder();
|
||||
txtMergeExec?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
if (Models.Preference.Instance.IsReady) {
|
||||
var cmd = new Commands.Config();
|
||||
var oldUser = cmd.Get("user.name");
|
||||
if (oldUser != User) cmd.Set("user.name", User);
|
||||
|
||||
var oldEmail = cmd.Get("user.email");
|
||||
if (oldEmail != Email) cmd.Set("user.email", Email);
|
||||
|
||||
var oldCRLF = cmd.Get("core.autocrlf");
|
||||
if (oldCRLF != CRLF) cmd.Set("core.autocrlf", CRLF);
|
||||
}
|
||||
|
||||
Models.Preference.Save();
|
||||
Close();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views {
|
||||
|
||||
/// <summary>
|
||||
/// 设置面板
|
||||
/// </summary>
|
||||
public partial class Preference : Controls.Window {
|
||||
|
||||
public string User { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string CRLF { get; set; }
|
||||
public string Version { get; set; }
|
||||
|
||||
public Preference() {
|
||||
UpdateGitInfo(false);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private bool UpdateGitInfo(bool updateUi) {
|
||||
var isReady = Models.Preference.Instance.IsReady;
|
||||
if (isReady) {
|
||||
User = new Commands.Config().Get("user.name");
|
||||
Email = new Commands.Config().Get("user.email");
|
||||
CRLF = new Commands.Config().Get("core.autocrlf");
|
||||
Version = new Commands.Version().Query();
|
||||
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
||||
} else {
|
||||
User = "";
|
||||
Email = "";
|
||||
CRLF = "false";
|
||||
Version = "Unknown";
|
||||
}
|
||||
if (updateUi) {
|
||||
editGitUser?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
editGitEmail?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
editGitCrlf?.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateTarget();
|
||||
textGitVersion?.GetBindingExpression(TextBlock.TextProperty).UpdateTarget();
|
||||
}
|
||||
return isReady;
|
||||
}
|
||||
|
||||
#region EVENTS
|
||||
private void LocaleChanged(object sender, SelectionChangedEventArgs e) {
|
||||
Models.Locale.Change();
|
||||
}
|
||||
|
||||
private void ChangeTheme(object sender, RoutedEventArgs e) {
|
||||
Models.Theme.Change();
|
||||
}
|
||||
|
||||
private void SelectGitPath(object sender, RoutedEventArgs e) {
|
||||
var initDir = Models.ExecutableFinder.Find("git.exe");
|
||||
if (initDir == null) initDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
||||
else initDir = Path.GetDirectoryName(initDir);
|
||||
|
||||
var dialog = new OpenFileDialog {
|
||||
Filter = "Git Executable|git.exe",
|
||||
FileName = "git.exe",
|
||||
Title = App.Text("Preference.Dialog.GitExe"),
|
||||
InitialDirectory = initDir,
|
||||
CheckFileExists = true,
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == true) {
|
||||
Models.Preference.Instance.Git.Path = dialog.FileName;
|
||||
editGitPath?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
UpdateGitInfo(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectGitCloneDir(object sender, RoutedEventArgs e) {
|
||||
var dialog = new Controls.FolderDialog();
|
||||
if (dialog.ShowDialog() == true) {
|
||||
Models.Preference.Instance.Git.DefaultCloneDir = dialog.SelectedPath;
|
||||
txtGitCloneDir?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectMergeTool(object sender, RoutedEventArgs e) {
|
||||
var type = Models.Preference.Instance.MergeTool.Type;
|
||||
var tool = Models.MergeTool.Supported.Find(x => x.Type == type);
|
||||
|
||||
if (tool == null || tool.Type == 0) return;
|
||||
|
||||
var dialog = new OpenFileDialog();
|
||||
dialog.Filter = $"{tool.Name} Executable|{tool.Exec}";
|
||||
dialog.Title = App.Text("Preference.Dialog.Merger", tool.Name);
|
||||
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
||||
dialog.CheckFileExists = true;
|
||||
|
||||
if (dialog.ShowDialog() == true) {
|
||||
Models.Preference.Instance.MergeTool.Path = dialog.FileName;
|
||||
txtMergeExec?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
}
|
||||
}
|
||||
|
||||
private void MergeToolChanged(object sender, SelectionChangedEventArgs e) {
|
||||
var type = (int)(sender as ComboBox).SelectedValue;
|
||||
var tool = Models.MergeTool.Supported.Find(x => x.Type == type);
|
||||
if (tool == null) return;
|
||||
|
||||
if (IsLoaded) {
|
||||
Models.Preference.Instance.MergeTool.Path = tool.Finder();
|
||||
txtMergeExec?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void Quit(object sender, RoutedEventArgs e) {
|
||||
if (Models.Preference.Instance.IsReady) {
|
||||
var cmd = new Commands.Config();
|
||||
var oldUser = cmd.Get("user.name");
|
||||
if (oldUser != User) cmd.Set("user.name", User);
|
||||
|
||||
var oldEmail = cmd.Get("user.email");
|
||||
if (oldEmail != Email) cmd.Set("user.email", Email);
|
||||
|
||||
var oldCRLF = cmd.Get("core.autocrlf");
|
||||
if (oldCRLF != CRLF) cmd.Set("core.autocrlf", CRLF);
|
||||
}
|
||||
|
||||
Models.Preference.Save();
|
||||
Close();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,20 +320,11 @@ namespace SourceGit.Views.Widgets {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Models.Preference.Instance.General.UseWindowsTerminal) {
|
||||
Process.Start(new ProcessStartInfo {
|
||||
WorkingDirectory = repo.Path,
|
||||
FileName = "wt",
|
||||
Arguments = $"-d \"{repo.Path}\" \"{bash}\"",
|
||||
UseShellExecute = false,
|
||||
});
|
||||
} else {
|
||||
Process.Start(new ProcessStartInfo {
|
||||
WorkingDirectory = repo.Path,
|
||||
FileName = bash,
|
||||
UseShellExecute = true,
|
||||
});
|
||||
}
|
||||
Process.Start(new ProcessStartInfo {
|
||||
WorkingDirectory = repo.Path,
|
||||
FileName = bash,
|
||||
UseShellExecute = true,
|
||||
});
|
||||
}
|
||||
|
||||
private void OpenInVSCode(object sender, RoutedEventArgs e) {
|
||||
|
|
|
@ -86,18 +86,10 @@ namespace SourceGit.Views.Widgets {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Models.Preference.Instance.General.UseWindowsTerminal) {
|
||||
Process.Start(new ProcessStartInfo {
|
||||
FileName = "wt",
|
||||
Arguments = $"\"{bash}\"",
|
||||
UseShellExecute = false,
|
||||
});
|
||||
} else {
|
||||
Process.Start(new ProcessStartInfo {
|
||||
FileName = bash,
|
||||
UseShellExecute = true,
|
||||
});
|
||||
}
|
||||
Process.Start(new ProcessStartInfo {
|
||||
FileName = bash,
|
||||
UseShellExecute = true,
|
||||
});
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue