refactor<*>: move SourceGit.Git.Preference to SourceGit.Preference

This commit is contained in:
leo 2020-12-17 11:55:06 +08:00
parent d248394e42
commit 3e6c837916
27 changed files with 236 additions and 260 deletions

View file

@ -1,3 +1,4 @@
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@ -34,7 +35,7 @@ namespace SourceGit.UI {
/// Constructor.
/// </summary>
public Clone(PopupManager mgr) {
ParentFolder = App.Preference.GitDefaultCloneDir;
ParentFolder = App.Setting.Tools.GitDefaultCloneDir;
popup = mgr;
InitializeComponent();
}
@ -82,15 +83,16 @@ namespace SourceGit.UI {
popup.Lock();
var repo = await Task.Run(() => {
var succ = await Task.Run(() => {
return Git.Repository.Clone(RemoteUri, ParentFolder, rName, repoName, popup.UpdateStatus);
});
if (repo == null) {
popup.Unlock();
} else {
popup.Close(true);
if (succ) {
var path = new DirectoryInfo(ParentFolder + "/" + repoName).FullName;
var repo = App.Setting.AddRepository(path, "");
repo.Open();
} else {
popup.Unlock();
}
}

View file

@ -305,7 +305,7 @@
Margin="4,0,0,0"
ToolTip="SWITCH TO LIST/TREE VIEW"
Style="{StaticResource Style.ToggleButton.ListOrTree}"
IsChecked="{Binding Source={x:Static source:App.Preference}, Path=UIUseListInChanges, Mode=TwoWay}"/>
IsChecked="{Binding Source={x:Static source:App.Setting}, Path=UI.UseListInChanges, Mode=TwoWay}"/>
</Grid>
<TreeView

View file

@ -56,7 +56,7 @@ namespace SourceGit.UI {
if (CommitTemplate != repo.CommitTemplate) {
repo.CommitTemplate = CommitTemplate;
Git.Preference.Save();
App.SaveSetting();
}
Close(sender, e);

View file

@ -1,4 +1,5 @@
<UserControl x:Class="SourceGit.UI.Dashboard"
x:Name="me"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -359,7 +360,7 @@
x:Name="tagListToggle"
Grid.Row="6"
Style="{StaticResource Style.ToggleButton.Expender}"
IsChecked="{Binding Source={x:Static source:App.Preference}, Path=UIShowTags, Mode=TwoWay}">
IsChecked="{Binding Path=ExpandTags, ElementName=me, Mode=TwoWay}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>

View file

@ -46,6 +46,14 @@ namespace SourceGit.UI {
private List<RemoteNode> cachedRemotes = new List<RemoteNode>();
private string abortCommand = null;
/// <summary>
/// Expand/Collapsed tags
/// </summary>
public bool ExpandTags {
get { return repo.ExpandTags; }
set { repo.ExpandTags = value; }
}
/// <summary>
/// Constructor.
/// </summary>
@ -65,9 +73,10 @@ namespace SourceGit.UI {
});
};
repo = opened;
InitializeComponent();
repo = opened;
histories.Repo = opened;
commits.Repo = opened;
@ -347,7 +356,7 @@ namespace SourceGit.UI {
}
private void OpenTerminal(object sender, RoutedEventArgs e) {
var bash = Path.Combine(App.Preference.GitExecutable, "..", "bash.exe");
var bash = Path.Combine(App.Setting.Tools.GitExecutable, "..", "bash.exe");
if (!File.Exists(bash)) {
App.RaiseError("Can NOT locate bash.exe. Make sure bash.exe exists under the same folder with git.exe");
return;

View file

@ -61,7 +61,7 @@
Margin="8,0,0,0"
Style="{StaticResource Style.ToggleButton.SplitDirection}"
ToolTip="Toggle One-Side/Two-Sides"
IsChecked="{Binding Source={x:Static sourcegit:App.Preference}, Path=UIUseOneSideDiff, Mode=TwoWay}"
IsChecked="{Binding Source={x:Static sourcegit:App.Setting}, Path=UI.UseCombinedDiff, Mode=TwoWay}"
Checked="ChangeDiffMode" Unchecked="ChangeDiffMode"/>
</StackPanel>
</Grid>

View file

@ -160,7 +160,7 @@ namespace SourceGit.UI {
var lastOldLine = "";
var lastNewLine = "";
if (App.Preference.UIUseOneSideDiff) {
if (App.Setting.UI.UseCombinedDiff) {
var blocks = new List<ChangeBlock>();
foreach (var line in lineChanges) {
@ -510,7 +510,7 @@ namespace SourceGit.UI {
if (editors.Count == 0) return;
var total = editorContainer.ActualWidth;
if (App.Preference.UIUseOneSideDiff) {
if (App.Setting.UI.UseCombinedDiff) {
var editor = editors[0];
var minWidth = total - editor.NonFrozenColumnsViewportHorizontalOffset;
var scroller = GetVisualChild<ScrollViewer>(editor);

View file

@ -12,12 +12,12 @@ namespace SourceGit.UI {
public static readonly DependencyProperty ModeProperty =
DependencyProperty.Register(
"Mode",
typeof(Git.Preference.FilesDisplayMode),
typeof(Preference.FilesDisplayMode),
typeof(FilesDisplayModeSwitch),
new PropertyMetadata(Git.Preference.FilesDisplayMode.Grid));
new PropertyMetadata(Preference.FilesDisplayMode.Grid));
public Git.Preference.FilesDisplayMode Mode {
get { return (Git.Preference.FilesDisplayMode)GetValue(ModeProperty); }
public Preference.FilesDisplayMode Mode {
get { return (Preference.FilesDisplayMode)GetValue(ModeProperty); }
set { SetValue(ModeProperty, value); }
}
@ -32,15 +32,15 @@ namespace SourceGit.UI {
}
private void UseGrid(object sender, RoutedEventArgs e) {
Mode = Git.Preference.FilesDisplayMode.Grid;
Mode = Preference.FilesDisplayMode.Grid;
}
private void UseList(object sender, RoutedEventArgs e) {
Mode = Git.Preference.FilesDisplayMode.List;
Mode = Preference.FilesDisplayMode.List;
}
private void UseTree(object sender, RoutedEventArgs e) {
Mode = Git.Preference.FilesDisplayMode.Tree;
Mode = Preference.FilesDisplayMode.Tree;
}
}
}

View file

@ -189,7 +189,7 @@
<ToggleButton
Style="{StaticResource Style.ToggleButton.Orientation}"
ToolTip="Toggle Horizontal/Vertical Layout"
IsChecked="{Binding Source={x:Static sourcegit:App.Preference}, Path=UIUseHorizontalLayout, Mode=TwoWay}"
IsChecked="{Binding Source={x:Static sourcegit:App.Setting}, Path=UI.MoveCommitViewerRight, Mode=TwoWay}"
Checked="ChangeOrientation" Unchecked="ChangeOrientation"/>
<!-- Tips to Histories Panel -->

View file

@ -630,7 +630,7 @@ namespace SourceGit.UI {
layout.RowDefinitions.Clear();
layout.ColumnDefinitions.Clear();
if (App.Preference.UIUseHorizontalLayout) {
if (App.Setting.UI.MoveCommitViewerRight) {
layout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star), MinWidth = 200 });
layout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(2) });
layout.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star), MinWidth = 200 });

View file

@ -36,13 +36,13 @@ namespace SourceGit.UI {
if (errs != null) {
App.RaiseError(errs);
} else {
App.Preference.AddRepository(workingDir, "");
App.Setting.AddRepository(workingDir, "");
}
});
popup.Close(true);
var repo = App.Preference.FindRepository(workingDir);
var repo = App.Setting.FindRepository(workingDir);
if (repo != null) repo.Open();
}

View file

@ -42,8 +42,8 @@ namespace SourceGit.UI {
public static List<InteractiveRebaseModeInfo> Supported = new List<InteractiveRebaseModeInfo>() {
new InteractiveRebaseModeInfo(InteractiveRebaseMode.Pick, "Pick", "Use this commit", Brushes.Green),
new InteractiveRebaseModeInfo(InteractiveRebaseMode.Reword, "Reword", "Edit the commit message", Brushes.Yellow),
new InteractiveRebaseModeInfo(InteractiveRebaseMode.Squash, "Squash", "Meld into previous commit", App.Preference.UseLightTheme ? Brushes.Gray : Brushes.White),
new InteractiveRebaseModeInfo(InteractiveRebaseMode.Fixup, "Fixup", "Like 'Squash' but discard log message", App.Preference.UseLightTheme ? Brushes.Gray : Brushes.White),
new InteractiveRebaseModeInfo(InteractiveRebaseMode.Squash, "Squash", "Meld into previous commit", App.Setting.UI.UseLightTheme ? Brushes.Gray : Brushes.White),
new InteractiveRebaseModeInfo(InteractiveRebaseMode.Fixup, "Fixup", "Like 'Squash' but discard log message", App.Setting.UI.UseLightTheme? Brushes.Gray : Brushes.White),
new InteractiveRebaseModeInfo(InteractiveRebaseMode.Drop, "Drop", "Remove commit", Brushes.Red),
};
}

View file

@ -10,9 +10,9 @@
mc:Ignorable="d"
MinWidth="800" MinHeight="600"
Title="Source Git"
Width="{Binding Source={x:Static source:App.Preference}, Path=UIMainWindowWidth, Mode=TwoWay}"
Height="{Binding Source={x:Static source:App.Preference}, Path=UIMainWindowHeight, Mode=TwoWay}"
WindowStartupLocation="CenterOwner">
Width="{Binding Source={x:Static source:App.Setting}, Path=UI.WindowWidth, Mode=TwoWay}"
Height="{Binding Source={x:Static source:App.Setting}, Path=UI.WindowHeight, Mode=TwoWay}"
WindowStartupLocation="CenterScreen">
<!-- Enable WindowChrome Feature -->
<WindowChrome.WindowChrome>

View file

@ -95,7 +95,7 @@ namespace SourceGit.UI {
Tabs.Add(new ManagerTab());
InitializeComponent();
openedTabs.SelectedItem = Tabs[0];
if (App.Preference.CheckUpdate) Task.Run(CheckUpdate);
if (App.Setting.CheckUpdate) Task.Run(CheckUpdate);
}
/// <summary>
@ -233,7 +233,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param>
/// <param name="e"></param>
private void ShowPreference(object sender, RoutedEventArgs e) {
var dialog = new Preference();
var dialog = new SettingDialog();
dialog.Owner = this;
dialog.ShowDialog();
}

View file

@ -130,7 +130,7 @@ namespace SourceGit.UI {
var delete = new MenuItem();
delete.Header = "Delete";
delete.Click += (o, ev) => {
App.Preference.RemoveRepository(repo.Path);
App.Setting.RemoveRepository(repo.Path);
UpdateRecentOpened();
UpdateTree();
HideBrief();
@ -157,7 +157,7 @@ namespace SourceGit.UI {
var addFolder = new MenuItem();
addFolder.Header = "Add Folder";
addFolder.Click += (o, ev) => {
var group = App.Preference.AddGroup("New Group", "");
var group = App.Setting.AddGroup("New Group", "");
UpdateTree(group.Id);
ev.Handled = true;
};
@ -195,7 +195,7 @@ namespace SourceGit.UI {
foreach (var path in paths) {
FileInfo info = new FileInfo(path);
if (info.Attributes == FileAttributes.Directory && Git.Repository.IsValid(path)) {
App.Preference.AddRepository(path, group);
App.Setting.AddRepository(path, group);
needRebuild = true;
}
}
@ -207,7 +207,7 @@ namespace SourceGit.UI {
var group = "";
var to = (sender as TreeViewItem)?.DataContext as Node;
if (to != null) group = to.IsRepo ? to.ParentId : to.Id;
App.Preference.FindRepository(node.Id).GroupId = group;
App.Setting.FindRepository(node.Id).GroupId = group;
needRebuild = true;
}
@ -222,7 +222,7 @@ namespace SourceGit.UI {
var node = selectedTreeViewItem.DataContext as Node;
if (node.IsRepo) {
ShowBrief(App.Preference.FindRepository(node.Id));
ShowBrief(App.Setting.FindRepository(node.Id));
} else {
HideBrief();
}
@ -254,7 +254,7 @@ namespace SourceGit.UI {
var node = item.DataContext as Node;
if (node != null && !node.IsRepo) {
var group = App.Preference.FindGroup(node.Id);
var group = App.Setting.FindGroup(node.Id);
group.IsExpended = item.IsExpanded;
e.Handled = true;
}
@ -298,9 +298,9 @@ namespace SourceGit.UI {
var node = text.DataContext as Node;
if (node != null) {
if (node.IsRepo) {
App.Preference.RenameRepository(node.Id, text.Text);
App.Setting.RenameRepository(node.Id, text.Text);
} else {
App.Preference.RenameGroup(node.Id, text.Text);
App.Setting.RenameGroup(node.Id, text.Text);
}
UpdateRecentOpened();
@ -345,7 +345,7 @@ namespace SourceGit.UI {
var refIdx = i;
mark.Click += (o, e) => {
var repo = App.Preference.FindRepository(node.Id);
var repo = App.Setting.FindRepository(node.Id);
if (repo != null) {
repo.Color = refIdx;
UpdateRecentOpened();
@ -364,10 +364,10 @@ namespace SourceGit.UI {
var addSubFolder = new MenuItem();
addSubFolder.Header = "Add Sub-Folder";
addSubFolder.Click += (o, ev) => {
var parent = App.Preference.FindGroup(node.Id);
var parent = App.Setting.FindGroup(node.Id);
if (parent != null) parent.IsExpended = true;
var group = App.Preference.AddGroup("New Group", node.Id);
var group = App.Setting.AddGroup("New Group", node.Id);
UpdateTree(group.Id);
ev.Handled = true;
};
@ -404,7 +404,7 @@ namespace SourceGit.UI {
popupManager.Show(new Init(popupManager, repo.Path));
} else {
App.RaiseError("Path is NOT valid git repository or has been removed.");
App.Preference.RemoveRepository(repo.Path);
App.Setting.RemoveRepository(repo.Path);
UpdateRecentOpened();
UpdateTree();
}
@ -485,7 +485,7 @@ namespace SourceGit.UI {
return;
}
var repo = App.Preference.AddRepository(path, "");
var repo = App.Setting.AddRepository(path, "");
App.Open(repo);
}
@ -493,7 +493,7 @@ namespace SourceGit.UI {
/// Update recent opened repositories.
/// </summary>
private void UpdateRecentOpened() {
var sorted = App.Preference.Repositories.OrderByDescending(a => a.LastOpenTime).ToList();
var sorted = App.Setting.Repositories.OrderByDescending(a => a.LastOpenTime).ToList();
var top5 = new List<Git.Repository>();
for (int i = 0; i < sorted.Count && i < 5; i++) {
@ -512,7 +512,7 @@ namespace SourceGit.UI {
var groupNodes = new Dictionary<string, Node>();
var nodes = new List<Node>();
foreach (var group in App.Preference.Groups) {
foreach (var group in App.Setting.Groups) {
Node node = new Node() {
Id = group.Id,
ParentId = group.ParentId,
@ -536,7 +536,7 @@ namespace SourceGit.UI {
}
}
foreach (var repo in App.Preference.Repositories) {
foreach (var repo in App.Setting.Repositories) {
Node node = new Node() {
Id = repo.Path,
ParentId = repo.GroupId,
@ -563,10 +563,10 @@ namespace SourceGit.UI {
/// <param name="node"></param>
private void DeleteNode(Node node) {
if (node.IsRepo) {
App.Preference.RemoveRepository(node.Id);
App.Setting.RemoveRepository(node.Id);
UpdateRecentOpened();
} else {
App.Preference.RemoveGroup(node.Id);
App.Setting.RemoveGroup(node.Id);
}
UpdateTree();

View file

@ -1,4 +1,4 @@
<Window x:Class="SourceGit.UI.Preference"
<Window x:Class="SourceGit.UI.SettingDialog"
x:Name="me"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -89,14 +89,14 @@
<CheckBox
Grid.Row="1"
Grid.Column="1"
IsChecked="{Binding Source={x:Static app:App.Preference}, Path=UseLightTheme, Mode=TwoWay}"
IsChecked="{Binding Source={x:Static app:App.Setting}, Path=UI.UseLightTheme, Mode=TwoWay}"
Content="Restart required"
TextElement.FontStyle="Italic"/>
<Label Grid.Row="2" Grid.Column="0" Content="Check for Update :" HorizontalAlignment="Right"/>
<CheckBox
Grid.Row="2"
Grid.Column="1"
IsChecked="{Binding Source={x:Static app:App.Preference}, Path=CheckUpdate, Mode=TwoWay}"
IsChecked="{Binding Source={x:Static app:App.Setting}, Path=CheckUpdate, Mode=TwoWay}"
TextElement.FontStyle="Italic"/>
<!-- GIT相关配置 -->
@ -111,7 +111,7 @@
<TextBox Grid.Column="0"
x:Name="txtGitPath"
Height="24"
Text="{Binding Source={x:Static app:App.Preference}, Path=GitExecutable, Mode=TwoWay}"
Text="{Binding Source={x:Static app:App.Setting}, Path=Tools.GitExecutable, Mode=TwoWay}"
helpers:TextBoxHelper.Placeholder="Input path for git.exe"/>
<Button Grid.Column="1" Width="24" Height="24" Click="SelectGitPath" Padding="0" BorderThickness="1" Style="{StaticResource Style.Button.Bordered}">
<Path Width="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder}"/>
@ -127,7 +127,7 @@
<TextBox Grid.Column="0"
x:Name="txtGitCloneDir"
Height="24"
Text="{Binding Source={x:Static app:App.Preference}, Path=GitDefaultCloneDir, Mode=TwoWay}"
Text="{Binding Source={x:Static app:App.Setting}, Path=Tools.GitDefaultCloneDir, Mode=TwoWay}"
helpers:TextBoxHelper.Placeholder="Default path to clone repo into"/>
<Button Grid.Column="1" Width="24" Height="24" Click="SelectDefaultClonePath" Padding="0" BorderThickness="1" Style="{StaticResource Style.Button.Bordered}">
<Path Width="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder}"/>
@ -165,7 +165,7 @@
Padding="2,0,0,0"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
SelectedIndex="{Binding Source={x:Static app:App.Preference}, Path=MergeTool, Mode=TwoWay}"
SelectedIndex="{Binding Source={x:Static app:App.Setting}, Path=Tools.MergeTool, Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static git:MergeTool.Supported}}"
DisplayMemberPath="Name"
SelectionChanged="ChangeMergeTool"/>
@ -179,7 +179,7 @@
<TextBox Grid.Column="0"
x:Name="txtMergePath"
Height="24"
Text="{Binding Source={x:Static app:App.Preference}, Path=MergeExecutable, Mode=TwoWay}"
Text="{Binding Source={x:Static app:App.Setting}, Path=Tools.MergeExecutable, Mode=TwoWay}"
helpers:TextBoxHelper.Placeholder="Input path for merge tool"/>
<Button Grid.Column="1" Width="24" Height="24" Click="SelectMergeToolPath" Padding="0" BorderThickness="1" Style="{StaticResource Style.Button.Bordered}">
<Path Width="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder}"/>

View file

@ -11,7 +11,7 @@ namespace SourceGit.UI {
/// <summary>
/// Preference window.
/// </summary>
public partial class Preference : Window {
public partial class SettingDialog : Window {
/// <summary>
/// Git global user name.
@ -53,7 +53,7 @@ namespace SourceGit.UI {
/// <summary>
/// Constructor.
/// </summary>
public Preference() {
public SettingDialog() {
GlobalUser = GetConfig("user.name");
GlobalUserEmail = GetConfig("user.email");
AutoCRLF = GetConfig("core.autocrlf");
@ -61,7 +61,7 @@ namespace SourceGit.UI {
InitializeComponent();
int mergeType = App.Preference.MergeTool;
int mergeType = App.Setting.Tools.MergeTool;
var merger = Git.MergeTool.Supported[mergeType];
txtMergePath.IsReadOnly = !merger.IsConfigured;
txtMergeParam.Text = merger.Parameter;
@ -106,7 +106,7 @@ namespace SourceGit.UI {
if (dialog.ShowDialog() == true) {
txtGitPath.Text = dialog.FileName;
App.Preference.GitExecutable = dialog.FileName;
App.Setting.Tools.GitExecutable = dialog.FileName;
}
}
@ -118,7 +118,7 @@ namespace SourceGit.UI {
private void SelectDefaultClonePath(object sender, RoutedEventArgs e) {
FolderDailog.Open("Select default clone path", path => {
txtGitCloneDir.Text = path;
App.Preference.GitDefaultCloneDir = path;
App.Setting.Tools.GitDefaultCloneDir = path;
});
}
@ -129,11 +129,11 @@ namespace SourceGit.UI {
/// <param name="e"></param>
private void ChangeMergeTool(object sender, SelectionChangedEventArgs e) {
if (IsLoaded) {
var t = Git.MergeTool.Supported[App.Preference.MergeTool];
var t = Git.MergeTool.Supported[App.Setting.Tools.MergeTool];
App.Preference.MergeExecutable = t.Finder();
App.Setting.Tools.MergeExecutable = t.Finder();
txtMergePath.Text = App.Preference.MergeExecutable;
txtMergePath.Text = App.Setting.Tools.MergeExecutable;
txtMergeParam.Text = t.Parameter;
txtMergePath.IsReadOnly = !t.IsConfigured;
}
@ -145,7 +145,7 @@ namespace SourceGit.UI {
/// <param name="sender"></param>
/// <param name="e"></param>
private void SelectMergeToolPath(object sender, RoutedEventArgs e) {
int mergeType = App.Preference.MergeTool;
int mergeType = App.Setting.Tools.MergeTool;
if (mergeType == 0) return;
var merger = Git.MergeTool.Supported[mergeType];
@ -157,7 +157,7 @@ namespace SourceGit.UI {
if (dialog.ShowDialog() == true) {
txtMergePath.Text = dialog.FileName;
App.Preference.MergeExecutable = dialog.FileName;
App.Setting.Tools.MergeExecutable = dialog.FileName;
}
}
@ -180,7 +180,7 @@ namespace SourceGit.UI {
if (!App.IsGitConfigured) return "";
var startInfo = new ProcessStartInfo();
startInfo.FileName = App.Preference.GitExecutable;
startInfo.FileName = App.Setting.Tools.GitExecutable;
startInfo.Arguments = $"config --global {key}";
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
@ -200,7 +200,7 @@ namespace SourceGit.UI {
if (!App.IsGitConfigured) return;
var startInfo = new ProcessStartInfo();
startInfo.FileName = App.Preference.GitExecutable;
startInfo.FileName = App.Setting.Tools.GitExecutable;
startInfo.Arguments = $"config --global {key} \"{val}\"";
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;

View file

@ -51,7 +51,7 @@
Margin="4,0,0,0"
ToolTip="SWITCH TO LIST/TREE VIEW"
Style="{StaticResource Style.ToggleButton.ListOrTree}"
IsChecked="{Binding Source={x:Static source:App.Preference}, Path=UIUseListInChanges, Mode=TwoWay}"/>
IsChecked="{Binding Source={x:Static source:App.Setting}, Path=UI.UseListInChanges, Mode=TwoWay}"/>
</Grid>
<TreeView

View file

@ -59,7 +59,7 @@
<local:FilesDisplayModeSwitch
Grid.Column="0"
Mode="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Mode=TwoWay}"
Mode="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Mode=TwoWay}"
Opacity=".4"/>
<Label Grid.Column="1" Content="UNSTAGED" FontWeight="Bold" Foreground="{StaticResource Brush.FG}" Opacity=".4"/>
<Button Grid.Column="3" Click="Stage" Margin="4,0" ToolTip="STAGE" Background="Transparent">
@ -74,7 +74,7 @@
Grid.Row="1"
x:Name="unstagedTree"
Background="{StaticResource Brush.BG2}"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
FontFamily="Consolas"
PreviewMouseWheel="TreeMouseWheel"
helpers:TreeViewHelper.EnableMultiSelection="True"
@ -127,7 +127,7 @@
<DataGrid
Grid.Row="1"
x:Name="unstagedList"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToList}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToList}}"
RowHeight="24"
SelectionChanged="UnstagedListSelectionChanged"
SelectionMode="Extended"
@ -163,7 +163,7 @@
<DataGridTextColumn
Width="Auto"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Binding="{Binding Path, Converter={StaticResource PathToFileName}}"
Foreground="{StaticResource Brush.FG}"
FontFamily="Consolas"
@ -171,7 +171,7 @@
<DataGridTextColumn
Width="*"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Binding="{Binding Path, Converter={StaticResource PathToFolderName}}"
Foreground="{StaticResource Brush.FG2}"
FontFamily="Consolas"
@ -179,7 +179,7 @@
<DataGridTextColumn
Width="*"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIUnstageDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.UnstageFileDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
Binding="{Binding Path}"
Foreground="{StaticResource Brush.FG}"
FontFamily="Consolas"
@ -215,7 +215,7 @@
<local:FilesDisplayModeSwitch
Grid.Column="0"
Mode="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Mode=TwoWay}"
Mode="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Mode=TwoWay}"
Opacity=".4"/>
<Label Grid.Column="1" Content="STAGED" FontWeight="Bold" Foreground="{StaticResource Brush.FG}" Opacity=".4"/>
<Button Grid.Column="3" Click="Unstage" ToolTip="UNSTAGE" Margin="4,0" Background="Transparent">
@ -229,7 +229,7 @@
<TreeView
Grid.Row="1"
x:Name="stageTree"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToTree}}"
Background="{StaticResource Brush.BG2}"
FontFamily="Consolas"
PreviewMouseWheel="TreeMouseWheel"
@ -284,7 +284,7 @@
Grid.Row="1"
x:Name="stageList"
RowHeight="24"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToList}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToList}}"
SelectionChanged="StagedListSelectionChanged"
SelectionMode="Extended"
SelectionUnit="FullRow"
@ -319,7 +319,7 @@
<DataGridTextColumn
Width="Auto"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Binding="{Binding Path, Converter={StaticResource PathToFileName}}"
Foreground="{StaticResource Brush.FG}"
FontFamily="Consolas"
@ -327,7 +327,7 @@
<DataGridTextColumn
Width="*"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToGrid}}"
Binding="{Binding Path, Converter={StaticResource PathToFolderName}}"
Foreground="{StaticResource Brush.FG2}"
FontFamily="Consolas"
@ -335,7 +335,7 @@
<DataGridTextColumn
Width="*"
Visibility="{Binding Source={x:Static source:App.Preference}, Path=UIStagedDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
Visibility="{Binding Source={x:Static source:App.Setting}, Path=UI.StagedFileDisplayMode, Converter={StaticResource FilesDisplayModeToListOnly}}"
Binding="{Binding Path}"
Foreground="{StaticResource Brush.FG}"
FontFamily="Consolas"

View file

@ -507,7 +507,7 @@ namespace SourceGit.UI {
private async void Stage(object sender, RoutedEventArgs e) {
var files = new List<string>();
if (App.Preference.UIUnstageDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
if (App.Setting.UI.UnstageFileDisplayMode != Preference.FilesDisplayMode.Tree) {
var selected = unstagedList.SelectedItems;
foreach (var one in selected) {
var node = one as Git.Change;
@ -707,7 +707,7 @@ namespace SourceGit.UI {
private async void Unstage(object sender, RoutedEventArgs e) {
var files = new List<string>();
if (App.Preference.UIStagedDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
if (App.Setting.UI.StagedFileDisplayMode != Preference.FilesDisplayMode.Tree) {
var selected = stageList.SelectedItems;
foreach (var one in selected) {
var node = one as Git.Change;
@ -870,8 +870,8 @@ namespace SourceGit.UI {
#region MERGE
private async void OpenMergeTool(object sender, RoutedEventArgs e) {
var mergeExe = App.Preference.MergeExecutable;
var mergeParam = Git.MergeTool.Supported[App.Preference.MergeTool].Parameter;
var mergeExe = App.Setting.Tools.MergeExecutable;
var mergeParam = Git.MergeTool.Supported[App.Setting.Tools.MergeTool].Parameter;
if (!File.Exists(mergeExe) || mergeParam.IndexOf("$MERGED") < 0) {
App.RaiseError("Invalid merge tool in preference setting!");
@ -879,7 +879,7 @@ namespace SourceGit.UI {
}
string file = null;
if (App.Preference.UIUnstageDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
if (App.Setting.UI.UnstageFileDisplayMode != Preference.FilesDisplayMode.Tree) {
var selected = unstagedList.SelectedItems;
if (selected.Count <= 0) return;
@ -906,7 +906,7 @@ namespace SourceGit.UI {
private async void UseTheirs(object sender, RoutedEventArgs e) {
var files = new List<string>();
if (App.Preference.UIUnstageDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
if (App.Setting.UI.UnstageFileDisplayMode != Preference.FilesDisplayMode.Tree) {
var selected = unstagedList.SelectedItems;
foreach (var one in selected) {
var node = one as Git.Change;
@ -935,7 +935,7 @@ namespace SourceGit.UI {
private async void UseMine(object sender, RoutedEventArgs e) {
var files = new List<string>();
if (App.Preference.UIUnstageDisplayMode != Git.Preference.FilesDisplayMode.Tree) {
if (App.Setting.UI.UnstageFileDisplayMode != Preference.FilesDisplayMode.Tree) {
var selected = unstagedList.SelectedItems;
foreach (var one in selected) {
var node = one as Git.Change;