mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
style<Dashboard>: re-arrange toolbar buttons
This commit is contained in:
parent
d5ff070505
commit
aa331c5562
4 changed files with 60 additions and 83 deletions
|
@ -116,7 +116,6 @@
|
|||
<sys:String x:Key="Text.CreateTag.Message">Tag Message :</sys:String>
|
||||
<sys:String x:Key="Text.CreateTag.Message.Placeholder">Optional.</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.Dashboard.Open">Open</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Explore">Open In File Browser</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.VSCode">Open In Visual Studio Code</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Terminal">Open In Git Bash</sys:String>
|
||||
|
|
|
@ -115,7 +115,6 @@
|
|||
<sys:String x:Key="Text.CreateTag.Message">标签描述 :</sys:String>
|
||||
<sys:String x:Key="Text.CreateTag.Message.Placeholder">选填</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.Dashboard.Open">打开</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Explore">在文件浏览器中打开</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.VSCode">在Visual Studio Code中打开</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Terminal">在GIT终端中打开</sys:String>
|
||||
|
|
|
@ -33,15 +33,23 @@
|
|||
<controls:IconButton
|
||||
Margin="8,0"
|
||||
Padding="0,9"
|
||||
Icon="{DynamicResource Icon.Folder}"
|
||||
ToolTip="{DynamicResource Text.Dashboard.Open}"
|
||||
Click="OpenExternal"/>
|
||||
Icon="{DynamicResource Icon.Folder.Open}"
|
||||
ToolTip="{DynamicResource Text.Dashboard.Explore}"
|
||||
Click="OpenInExplorer"/>
|
||||
<controls:IconButton
|
||||
x:Name="btnVSCode"
|
||||
Margin="8,0"
|
||||
Padding="0,9"
|
||||
Icon="{DynamicResource Icon.VSCode}"
|
||||
ToolTip="{DynamicResource Text.Dashboard.VSCode}"
|
||||
Visibility="Collapsed"
|
||||
Click="OpenInVSCode"/>
|
||||
<controls:IconButton
|
||||
Margin="8,0"
|
||||
Padding="0,9"
|
||||
Icon="{DynamicResource Icon.Loading}"
|
||||
ToolTip="{DynamicResource Text.Dashboard.Refresh}"
|
||||
Click="TriggerRefresh"/>
|
||||
Icon="{DynamicResource Icon.Terminal}"
|
||||
ToolTip="{DynamicResource Text.Dashboard.Terminal}"
|
||||
Click="OpenInTerminal"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
|
@ -93,14 +101,22 @@
|
|||
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<ToggleButton
|
||||
Width="16" Height="16"
|
||||
Margin="0,0,8,0"
|
||||
Style="{StaticResource Style.ToggleButton.SplitDirection}"
|
||||
ToolTip="{DynamicResource Text.Histories.DisplayMode}"
|
||||
Visibility="{Binding ElementName=pageHistories,Path=IsSelected,Converter={StaticResource BoolToCollapsed}}"
|
||||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Window.MoveCommitInfoRight, Mode=TwoWay, Converter={StaticResource InverseBool}}"
|
||||
Checked="ChangeOrientation" Unchecked="ChangeOrientation"/>
|
||||
|
||||
|
||||
<controls:IconButton
|
||||
Margin="12,0,8,0"
|
||||
Margin="8,0"
|
||||
Padding="0,9,0,8"
|
||||
Icon="{DynamicResource Icon.Loading}"
|
||||
ToolTip="{DynamicResource Text.Dashboard.Refresh}"
|
||||
Click="TriggerRefresh"/>
|
||||
|
||||
<controls:IconButton
|
||||
Margin="8,0"
|
||||
Padding="0,8"
|
||||
Icon="{DynamicResource Icon.Setting}"
|
||||
ToolTip="{DynamicResource Text.Dashboard.Configure}"
|
||||
|
|
|
@ -56,6 +56,11 @@ namespace SourceGit.Views.Widgets {
|
|||
InitializeComponent();
|
||||
InitPages();
|
||||
|
||||
Task.Run(() => {
|
||||
var vscode = Models.ExecutableFinder.Find("code.cmd");
|
||||
if (vscode != null) Dispatcher.Invoke(() => btnVSCode.Visibility = Visibility.Visible);
|
||||
});
|
||||
|
||||
var watcher = Models.Watcher.Get(repo.Path);
|
||||
watcher.Navigate += NavigateTo;
|
||||
watcher.BranchChanged += UpdateBranches;
|
||||
|
@ -304,86 +309,44 @@ namespace SourceGit.Views.Widgets {
|
|||
#endregion
|
||||
|
||||
#region TOOLBAR_COMMANDS
|
||||
private MenuItem CreateMenuItem(string icon, string header, Action click) {
|
||||
var ret = new MenuItem();
|
||||
ret.Header = App.Text(header);
|
||||
ret.Click += (o, e) => {
|
||||
click();
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(icon)) {
|
||||
var geo = new System.Windows.Shapes.Path();
|
||||
geo.Data = FindResource(icon) as Geometry;
|
||||
geo.VerticalAlignment = VerticalAlignment.Center;
|
||||
geo.Width = 12;
|
||||
geo.Height = 12;
|
||||
|
||||
ret.Icon = geo;
|
||||
}
|
||||
|
||||
return ret;
|
||||
private void OpenInExplorer(object sender, RoutedEventArgs e) {
|
||||
Process.Start("explorer", repo.Path);
|
||||
}
|
||||
|
||||
private void OpenExternal(object sender, RoutedEventArgs e) {
|
||||
var btn = sender as Controls.IconButton;
|
||||
if (btn == null) return;
|
||||
|
||||
if (btn.ContextMenu != null) {
|
||||
btn.ContextMenu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
private void OpenInTerminal(object sender, RoutedEventArgs e) {
|
||||
var bash = Path.Combine(Models.Preference.Instance.Git.Path, "..", "bash.exe");
|
||||
if (!File.Exists(bash)) {
|
||||
Models.Exception.Raise(App.Text("MissingBash"));
|
||||
return;
|
||||
}
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.PlacementTarget = btn;
|
||||
menu.Placement = PlacementMode.Bottom;
|
||||
menu.StaysOpen = false;
|
||||
menu.Focusable = true;
|
||||
|
||||
menu.Items.Add(CreateMenuItem("Icon.Folder.Open", "Dashboard.Explore", () => {
|
||||
Process.Start("explorer", repo.Path);
|
||||
}));
|
||||
|
||||
menu.Items.Add(CreateMenuItem("Icon.Terminal", "Dashboard.Terminal", () => {
|
||||
var bash = Path.Combine(Models.Preference.Instance.Git.Path, "..", "bash.exe");
|
||||
if (!File.Exists(bash)) {
|
||||
Models.Exception.Raise(App.Text("MissingBash"));
|
||||
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,
|
||||
});
|
||||
}
|
||||
}));
|
||||
|
||||
var vscode = Models.ExecutableFinder.Find("code.cmd");
|
||||
if (vscode != null) {
|
||||
vscode = Path.Combine(Path.GetDirectoryName(vscode), "..", "Code.exe");
|
||||
menu.Items.Add(CreateMenuItem("Icon.VSCode", "Dashboard.VSCode", () => {
|
||||
Process.Start(new ProcessStartInfo {
|
||||
WorkingDirectory = repo.Path,
|
||||
FileName = vscode,
|
||||
Arguments = $"\"{repo.Path}\"",
|
||||
UseShellExecute = false,
|
||||
});
|
||||
}));
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
btn.ContextMenu = menu;
|
||||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
private void OpenInVSCode(object sender, RoutedEventArgs e) {
|
||||
var vscode = Models.ExecutableFinder.Find("code.cmd");
|
||||
if (vscode == null) return;
|
||||
|
||||
vscode = Path.Combine(Path.GetDirectoryName(vscode), "..", "Code.exe");
|
||||
Process.Start(new ProcessStartInfo {
|
||||
WorkingDirectory = repo.Path,
|
||||
FileName = vscode,
|
||||
Arguments = $"\"{repo.Path}\"",
|
||||
UseShellExecute = false,
|
||||
});
|
||||
}
|
||||
|
||||
private void TriggerRefresh(object sender, RoutedEventArgs e) {
|
||||
|
|
Loading…
Reference in a new issue