refactor: move some codes from App to Views.ControlExtensions

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2026-04-03 16:10:55 +08:00
parent 68831b22dc
commit 9dd1914e62
43 changed files with 637 additions and 640 deletions

View File

@@ -1,7 +1,5 @@
using System;
using System.Windows.Input;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
namespace SourceGit
@@ -45,16 +43,6 @@ namespace SourceGit
public static readonly Command OpenAboutCommand = new Command(async _ => await ShowDialog(new Views.About()));
public static readonly Command CheckForUpdateCommand = new Command(_ => (Current as App)?.Check4Update(true));
public static readonly Command QuitCommand = new Command(_ => Quit(0));
public static readonly Command CopyTextBlockCommand = new Command(async p =>
{
if (p is not TextBlock textBlock)
return;
if (textBlock.Inlines is { Count: > 0 } inlines)
await CopyTextAsync(inlines.Text);
else if (!string.IsNullOrEmpty(textBlock.Text))
await CopyTextAsync(textBlock.Text);
});
public static readonly Command HideAppCommand = new Command(_ =>
{

View File

@@ -1,19 +1,15 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core.Plugins;
using Avalonia.Input.Platform;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Media.Fonts;
@@ -32,7 +28,7 @@ namespace SourceGit
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
LogException(e.ExceptionObject as Exception);
Native.OS.LogException(e.ExceptionObject as Exception);
};
TaskScheduler.UnobservedTaskException += (_, e) =>
@@ -51,7 +47,7 @@ namespace SourceGit
}
catch (Exception ex)
{
LogException(ex);
Native.OS.LogException(ex);
}
}
@@ -76,52 +72,9 @@ namespace SourceGit
Native.OS.SetupApp(builder);
return builder;
}
public static void LogException(Exception ex)
{
if (ex == null)
return;
var crashDir = Path.Combine(Native.OS.DataDir, "crashes");
if (!Directory.Exists(crashDir))
Directory.CreateDirectory(crashDir);
var time = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
var file = Path.Combine(crashDir, $"{time}.log");
using var writer = new StreamWriter(file);
writer.WriteLine($"Crash::: {ex.GetType().FullName}: {ex.Message}");
writer.WriteLine();
writer.WriteLine("----------------------------");
writer.WriteLine($"Version: {Assembly.GetExecutingAssembly().GetName().Version}");
writer.WriteLine($"OS: {Environment.OSVersion}");
writer.WriteLine($"Framework: {AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}");
writer.WriteLine($"Source: {ex.Source}");
writer.WriteLine($"Thread Name: {Thread.CurrentThread.Name ?? "Unnamed"}");
writer.WriteLine($"App Start Time: {Process.GetCurrentProcess().StartTime}");
writer.WriteLine($"Exception Time: {DateTime.Now}");
writer.WriteLine($"Memory Usage: {Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024} MB");
writer.WriteLine("----------------------------");
writer.WriteLine();
writer.WriteLine(ex);
writer.Flush();
}
#endregion
#region Utility Functions
public static Control CreateViewForViewModel(object data)
{
var dataTypeName = data.GetType().FullName;
if (string.IsNullOrEmpty(dataTypeName) || !dataTypeName.Contains(".ViewModels.", StringComparison.Ordinal))
return null;
var viewTypeName = dataTypeName.Replace(".ViewModels.", ".Views.");
var viewType = Type.GetType(viewTypeName);
if (viewType != null)
return Activator.CreateInstance(viewType) as Control;
return null;
}
public static Task ShowDialog(object data, Window owner = null)
{
if (owner == null)
@@ -135,7 +88,7 @@ namespace SourceGit
if (data is Views.ChromelessWindow window)
return window.ShowDialog(owner);
window = CreateViewForViewModel(data) as Views.ChromelessWindow;
window = Views.ControlExtensions.CreateFromViewModels(data) as Views.ChromelessWindow;
if (window != null)
{
window.DataContext = data;
@@ -149,7 +102,7 @@ namespace SourceGit
{
if (data is not Views.ChromelessWindow window)
{
window = CreateViewForViewModel(data) as Views.ChromelessWindow;
window = Views.ControlExtensions.CreateFromViewModels(data) as Views.ChromelessWindow;
if (window == null)
return;
@@ -330,19 +283,6 @@ namespace SourceGit
}
}
public static async Task CopyTextAsync(string data)
{
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow.Clipboard: { } clipboard })
await clipboard.SetTextAsync(data ?? "");
}
public static async Task<string> GetClipboardTextAsync()
{
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow.Clipboard: { } clipboard })
return await clipboard.TryGetTextAsync();
return null;
}
public static string Text(string key, params object[] args)
{
var fmt = Current?.FindResource($"Text.{key}") as string;
@@ -355,19 +295,6 @@ namespace SourceGit
return string.Format(fmt, args);
}
public static Avalonia.Controls.Shapes.Path CreateMenuIcon(string key)
{
var icon = new Avalonia.Controls.Shapes.Path();
icon.Width = 12;
icon.Height = 12;
icon.Stretch = Stretch.Uniform;
if (Current?.FindResource(key) is StreamGeometry geo)
icon.Data = geo;
return icon;
}
public static ViewModels.Launcher GetLauncher()
{
return Current is App app ? app._launcher : null;
@@ -427,32 +354,12 @@ namespace SourceGit
if (TryLaunchAsAskpass(desktop))
return;
_ipcChannel = new Models.IpcChannel();
if (!_ipcChannel.IsFirstInstance)
{
var arg = desktop.Args is { Length: > 0 } ? desktop.Args[0].Trim() : string.Empty;
if (!string.IsNullOrEmpty(arg))
{
if (arg.StartsWith('"') && arg.EndsWith('"'))
arg = arg.Substring(1, arg.Length - 2).Trim();
if (arg.Length > 0 && !Path.IsPathFullyQualified(arg))
arg = Path.GetFullPath(arg);
}
_ipcChannel.SendToFirstInstance(arg);
Environment.Exit(0);
}
else
{
_ipcChannel.MessageReceived += TryOpenRepository;
desktop.Exit += (_, _) => _ipcChannel.Dispose();
TryLaunchAsNormal(desktop);
}
TryLaunchAsNormal(desktop);
}
}
#endregion
#region Launch Ways
private static bool TryLaunchAsRebaseTodoEditor(string[] args, out int exitCode)
{
exitCode = -1;
@@ -613,6 +520,24 @@ namespace SourceGit
private void TryLaunchAsNormal(IClassicDesktopStyleApplicationLifetime desktop)
{
_ipcChannel = new Models.IpcChannel();
if (!_ipcChannel.IsFirstInstance)
{
var arg = desktop.Args is { Length: > 0 } ? desktop.Args[0].Trim() : string.Empty;
if (!string.IsNullOrEmpty(arg))
{
if (arg.StartsWith('"') && arg.EndsWith('"'))
arg = arg.Substring(1, arg.Length - 2).Trim();
if (arg.Length > 0 && !Path.IsPathFullyQualified(arg))
arg = Path.GetFullPath(arg);
}
_ipcChannel.SendToFirstInstance(arg);
Environment.Exit(0);
return;
}
Native.OS.SetupExternalTools();
Models.AvatarManager.Instance.Start();
@@ -627,40 +552,26 @@ namespace SourceGit
desktop.MainWindow = new Views.Launcher() { DataContext = _launcher };
desktop.ShutdownMode = ShutdownMode.OnMainWindowClose;
_ipcChannel.MessageReceived += repo =>
{
Dispatcher.UIThread.Invoke(() =>
{
_launcher.TryOpenRepositoryFromPath(repo);
if (desktop.MainWindow is Views.Launcher main)
main.BringToTop();
});
};
desktop.Exit += (_, _) => _ipcChannel.Dispose();
#if !DISABLE_UPDATE_DETECTION
if (pref.ShouldCheck4UpdateOnStartup())
Check4Update();
#endif
}
#endregion
private void TryOpenRepository(string repo)
{
if (!string.IsNullOrEmpty(repo) && Directory.Exists(repo))
{
var test = new Commands.QueryRepositoryRootPath(repo).GetResult();
if (test.IsSuccess && !string.IsNullOrEmpty(test.StdOut))
{
Dispatcher.UIThread.Invoke(() =>
{
var node = ViewModels.Preferences.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), null, false);
ViewModels.Welcome.Instance.Refresh();
_launcher?.OpenRepositoryInTab(node, null);
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: Views.Launcher wnd })
wnd.BringToTop();
});
return;
}
}
Dispatcher.UIThread.Invoke(() =>
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: Views.Launcher launcher })
launcher.BringToTop();
});
}
#region Check for Updates
private void Check4Update(bool manually = false)
{
Task.Run(async () =>
@@ -716,6 +627,7 @@ namespace SourceGit
// Ignore exceptions.
}
}
#endregion
private string FixFontFamilyName(string input)
{

View File

@@ -2,9 +2,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Avalonia;
using Avalonia.Controls;
@@ -153,6 +154,35 @@ namespace SourceGit.Native
_backend.SetupWindow(window);
}
public static void LogException(Exception ex)
{
if (ex == null)
return;
var crashDir = Path.Combine(DataDir, "crashes");
if (!Directory.Exists(crashDir))
Directory.CreateDirectory(crashDir);
var time = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
var file = Path.Combine(crashDir, $"{time}.log");
using var writer = new StreamWriter(file);
writer.WriteLine($"Crash::: {ex.GetType().FullName}: {ex.Message}");
writer.WriteLine();
writer.WriteLine("----------------------------");
writer.WriteLine($"Version: {Assembly.GetExecutingAssembly().GetName().Version}");
writer.WriteLine($"OS: {Environment.OSVersion}");
writer.WriteLine($"Framework: {AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}");
writer.WriteLine($"Source: {ex.Source}");
writer.WriteLine($"Thread Name: {Thread.CurrentThread.Name ?? "Unnamed"}");
writer.WriteLine($"App Start Time: {Process.GetCurrentProcess().StartTime}");
writer.WriteLine($"Exception Time: {DateTime.Now}");
writer.WriteLine($"Memory Usage: {Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024} MB");
writer.WriteLine("----------------------------");
writer.WriteLine();
writer.WriteLine(ex);
writer.Flush();
}
public static string FindGitExecutable()
{
return _backend.FindGitExecutable();

View File

@@ -540,36 +540,6 @@
<Setter Property="Foreground" Value="{DynamicResource Brush.InlineCodeFG}"/>
</Style>
<Style Selector="SelectableTextBlock">
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Foreground" Value="{DynamicResource Brush.FG1}"/>
</Style>
<Style Selector="SelectableTextBlock[IsEnabled=True]">
<Setter Property="ContextFlyout">
<Setter.Value>
<MenuFlyout Placement="Bottom">
<MenuItem Header="{DynamicResource Text.Copy}"
Command="{Binding $parent[SelectableTextBlock].Copy}"
IsEnabled="{Binding $parent[SelectableTextBlock].CanCopy}"
InputGesture="{x:Static TextBox.CopyGesture}">
<MenuItem.Icon>
<Path Width="11" Height="11" Data="{StaticResource Icons.Copy}" VerticalAlignment="Center"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{DynamicResource Text.CopyAllText}"
Command="{x:Static s:App.CopyTextBlockCommand}"
CommandParameter="{Binding $parent[SelectableTextBlock]}">
<MenuItem.Icon>
<Path Width="11" Height="11" Data="{StaticResource Icons.Copy}" VerticalAlignment="Center"/>
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
</Setter.Value>
</Setter>
</Style>
<Style Selector="TextBox">
<Setter Property="CornerRadius" Value="0"/>
<Setter Property="Padding" Value="4,0"/>

View File

@@ -2,7 +2,6 @@
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Threading.Tasks;
using Avalonia.Threading;
namespace SourceGit.ViewModels
{
@@ -66,20 +65,6 @@ namespace SourceGit.ViewModels
_parentFolder = activeWorkspace?.DefaultCloneDir;
if (string.IsNullOrEmpty(ParentFolder))
_parentFolder = Preferences.Instance.GitDefaultCloneDir;
Task.Run(async () =>
{
try
{
var text = await App.GetClipboardTextAsync();
if (Models.Remote.IsValidURL(text))
Dispatcher.UIThread.Post(() => Remote = text);
}
catch
{
// Ignore
}
});
}
public static ValidationResult ValidateRemote(string remote, ValidationContext _)

View File

@@ -73,6 +73,9 @@ namespace SourceGit.ViewModels
_ignoreIndexChange = false;
if (TryOpenRepositoryFromPath(startupRepo))
return;
if (!string.IsNullOrEmpty(startupRepo))
{
var test = new Commands.QueryRepositoryRootPath(startupRepo).GetResult();
@@ -97,6 +100,23 @@ namespace SourceGit.ViewModels
PostActivePageChanged();
}
public bool TryOpenRepositoryFromPath(string repo)
{
if (!string.IsNullOrEmpty(repo) && Directory.Exists(repo))
{
var test = new Commands.QueryRepositoryRootPath(repo).GetResult();
if (test.IsSuccess && !string.IsNullOrEmpty(test.StdOut))
{
var node = Preferences.Instance.FindOrAddNodeByRepositoryPath(test.StdOut.Trim(), null, false);
Welcome.Instance.Refresh();
OpenRepositoryInTab(node, null);
return true;
}
}
return false;
}
public void Quit()
{
_ignoreIndexChange = true;

View File

@@ -1,8 +1,6 @@
using System;
using System.Threading.Tasks;
using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;
namespace SourceGit.ViewModels
@@ -59,12 +57,6 @@ namespace SourceGit.ViewModels
Notifications.Clear();
}
public async Task CopyPathAsync()
{
if (_node.IsRepository)
await App.CopyTextAsync(_node.Id);
}
public void ChangeDirtyState(Models.DirtyState flag, bool remove)
{
var state = _dirtyState;
@@ -106,7 +98,7 @@ namespace SourceGit.ViewModels
}
catch (Exception e)
{
App.LogException(e);
Native.OS.LogException(e);
}
dump.InProgress = false;

View File

@@ -101,7 +101,7 @@ namespace SourceGit.Views
return;
var apply = new MenuItem() { Header = App.Text("AIAssistant.Use") };
apply.Icon = App.CreateMenuIcon("Icons.Check");
apply.Icon = this.CreateMenuIcon("Icons.Check");
apply.Click += (_, ev) =>
{
vm.Use(selected);
@@ -109,10 +109,10 @@ namespace SourceGit.Views
};
var copy = new MenuItem() { Header = App.Text("Copy") };
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(selected);
await this.CopyTextAsync(selected);
ev.Handled = true;
};

View File

@@ -193,7 +193,7 @@ namespace SourceGit.Views
}
var refetch = new MenuItem();
refetch.Icon = App.CreateMenuIcon("Icons.Loading");
refetch.Icon = this.CreateMenuIcon("Icons.Loading");
refetch.Header = App.Text("Avatar.Refetch");
refetch.Click += (_, ev) =>
{
@@ -204,7 +204,7 @@ namespace SourceGit.Views
};
var load = new MenuItem();
load.Icon = App.CreateMenuIcon("Icons.Folder.Open");
load.Icon = this.CreateMenuIcon("Icons.Folder.Open");
load.Header = App.Text("Avatar.Load");
load.Click += async (_, ev) =>
{
@@ -225,7 +225,7 @@ namespace SourceGit.Views
};
var saveAs = new MenuItem();
saveAs.Icon = App.CreateMenuIcon("Icons.Save");
saveAs.Icon = this.CreateMenuIcon("Icons.Save");
saveAs.Header = App.Text("SaveAs");
saveAs.Click += async (_, ev) =>
{

View File

@@ -427,10 +427,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(selected);
await this.CopyTextAsync(selected);
ev.Handled = true;
};

View File

@@ -534,7 +534,7 @@ namespace SourceGit.Views
{
var compare = new MenuItem();
compare.Header = App.Text("BranchCM.CompareTwo");
compare.Icon = App.CreateMenuIcon("Icons.Compare");
compare.Icon = this.CreateMenuIcon("Icons.Compare");
compare.Click += (_, ev) =>
{
App.ShowWindow(new ViewModels.Compare(repo, branches[0], branches[1]));
@@ -547,7 +547,7 @@ namespace SourceGit.Views
{
var mergeMulti = new MenuItem();
mergeMulti.Header = App.Text("BranchCM.MergeMultiBranches", branches.Count);
mergeMulti.Icon = App.CreateMenuIcon("Icons.Merge");
mergeMulti.Icon = this.CreateMenuIcon("Icons.Merge");
mergeMulti.Click += (_, ev) =>
{
repo.MergeMultipleBranches(branches);
@@ -556,7 +556,7 @@ namespace SourceGit.Views
var deleteMulti = new MenuItem();
deleteMulti.Header = App.Text("BranchCM.DeleteMultiBranches", branches.Count);
deleteMulti.Icon = App.CreateMenuIcon("Icons.Clear");
deleteMulti.Icon = this.CreateMenuIcon("Icons.Clear");
deleteMulti.Click += (_, ev) =>
{
repo.DeleteMultipleBranches(branches, branches[0].IsLocal);
@@ -689,7 +689,7 @@ namespace SourceGit.Views
var push = new MenuItem();
push.Header = App.Text("BranchCM.Push", branch.Name);
push.Icon = App.CreateMenuIcon("Icons.Push");
push.Icon = this.CreateMenuIcon("Icons.Push");
push.IsEnabled = repo.Remotes.Count > 0;
push.Click += (_, e) =>
{
@@ -706,7 +706,7 @@ namespace SourceGit.Views
{
var fastForward = new MenuItem();
fastForward.Header = App.Text("BranchCM.FastForward", upstream.FriendlyName);
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
fastForward.Icon = this.CreateMenuIcon("Icons.FastForward");
fastForward.IsEnabled = branch.Ahead.Count == 0 && branch.Behind.Count > 0;
fastForward.Click += async (_, e) =>
{
@@ -717,7 +717,7 @@ namespace SourceGit.Views
var pull = new MenuItem();
pull.Header = App.Text("BranchCM.Pull", upstream.FriendlyName);
pull.Icon = App.CreateMenuIcon("Icons.Pull");
pull.Icon = this.CreateMenuIcon("Icons.Pull");
pull.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -735,7 +735,7 @@ namespace SourceGit.Views
var compareWith = new MenuItem();
compareWith.Header = App.Text("BranchCM.CompareWith");
compareWith.Icon = App.CreateMenuIcon("Icons.Compare");
compareWith.Icon = this.CreateMenuIcon("Icons.Compare");
compareWith.Click += (_, _) =>
{
new ViewModels.CompareCommandPalette(repo, branch).Open();
@@ -749,7 +749,7 @@ namespace SourceGit.Views
var checkout = new MenuItem();
checkout.Header = App.Text(hasNoWorktree ? "BranchCM.Checkout" : "BranchCM.SwitchToWorktree", branch.Name);
checkout.Icon = App.CreateMenuIcon("Icons.Check");
checkout.Icon = this.CreateMenuIcon("Icons.Check");
checkout.IsEnabled = !repo.IsBare || !hasNoWorktree;
checkout.Click += async (_, e) =>
{
@@ -763,7 +763,7 @@ namespace SourceGit.Views
{
var fastForward = new MenuItem();
fastForward.Header = App.Text("BranchCM.FastForward", upstream.FriendlyName);
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
fastForward.Icon = this.CreateMenuIcon("Icons.FastForward");
fastForward.IsEnabled = branch.Ahead.Count == 0 && branch.Behind.Count > 0;
fastForward.Click += async (_, e) =>
{
@@ -775,7 +775,7 @@ namespace SourceGit.Views
var fetchInto = new MenuItem();
fetchInto.Header = App.Text("BranchCM.FetchInto", upstream.FriendlyName, branch.Name);
fetchInto.Icon = App.CreateMenuIcon("Icons.Fetch");
fetchInto.Icon = this.CreateMenuIcon("Icons.Fetch");
fetchInto.IsEnabled = branch.Ahead.Count == 0;
fetchInto.Click += async (_, e) =>
{
@@ -794,7 +794,7 @@ namespace SourceGit.Views
{
var merge = new MenuItem();
merge.Header = App.Text("BranchCM.Merge", branch.Name, current.Name);
merge.Icon = App.CreateMenuIcon("Icons.Merge");
merge.Icon = this.CreateMenuIcon("Icons.Merge");
merge.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -804,7 +804,7 @@ namespace SourceGit.Views
var rebase = new MenuItem();
rebase.Header = App.Text("BranchCM.Rebase", current.Name, branch.Name);
rebase.Icon = App.CreateMenuIcon("Icons.Rebase");
rebase.Icon = this.CreateMenuIcon("Icons.Rebase");
rebase.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -814,7 +814,7 @@ namespace SourceGit.Views
var interactiveRebase = new MenuItem();
interactiveRebase.Header = App.Text("BranchCM.InteractiveRebase.Manually", current.Name, branch.Name);
interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.Icon = this.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.IsEnabled = !current.Head.Equals(branch.Head, StringComparison.Ordinal);
interactiveRebase.Click += async (_, e) =>
{
@@ -836,7 +836,7 @@ namespace SourceGit.Views
{
var move = new MenuItem();
move.Header = App.Text("BranchCM.ResetToSelectedCommit", branch.Name, selectedCommit.SHA.Substring(0, 10));
move.Icon = App.CreateMenuIcon("Icons.Reset");
move.Icon = this.CreateMenuIcon("Icons.Reset");
move.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -850,7 +850,7 @@ namespace SourceGit.Views
var compareWithCurrent = new MenuItem();
compareWithCurrent.Header = App.Text("BranchCM.CompareWithHead");
compareWithCurrent.Icon = App.CreateMenuIcon("Icons.Compare");
compareWithCurrent.Icon = this.CreateMenuIcon("Icons.Compare");
compareWithCurrent.Click += (_, _) =>
{
App.ShowWindow(new ViewModels.Compare(repo, branch, current));
@@ -858,7 +858,7 @@ namespace SourceGit.Views
var compareWith = new MenuItem();
compareWith.Header = App.Text("BranchCM.CompareWith");
compareWith.Icon = App.CreateMenuIcon("Icons.Compare");
compareWith.Icon = this.CreateMenuIcon("Icons.Compare");
compareWith.Click += (_, _) =>
{
new ViewModels.CompareCommandPalette(repo, branch).Open();
@@ -875,7 +875,7 @@ namespace SourceGit.Views
{
var finish = new MenuItem();
finish.Header = App.Text("BranchCM.Finish", branch.Name);
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
finish.Icon = this.CreateMenuIcon("Icons.GitFlow");
finish.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -891,7 +891,7 @@ namespace SourceGit.Views
{
var editDescription = new MenuItem();
editDescription.Header = App.Text("BranchCM.EditDescription", branch.Name);
editDescription.Icon = App.CreateMenuIcon("Icons.Edit");
editDescription.Icon = this.CreateMenuIcon("Icons.Edit");
editDescription.Click += async (_, e) =>
{
var desc = await new Commands.Config(repo.FullPath).GetAsync($"branch.{branch.Name}.description");
@@ -902,7 +902,7 @@ namespace SourceGit.Views
var rename = new MenuItem();
rename.Header = App.Text("BranchCM.Rename", branch.Name);
rename.Icon = App.CreateMenuIcon("Icons.Rename");
rename.Icon = this.CreateMenuIcon("Icons.Rename");
rename.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -912,7 +912,7 @@ namespace SourceGit.Views
var delete = new MenuItem();
delete.Header = App.Text("BranchCM.Delete", branch.Name);
delete.Icon = App.CreateMenuIcon("Icons.Clear");
delete.Icon = this.CreateMenuIcon("Icons.Clear");
delete.IsEnabled = !branch.IsCurrent;
delete.Click += (_, e) =>
{
@@ -928,7 +928,7 @@ namespace SourceGit.Views
}
var createBranch = new MenuItem();
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
createBranch.Icon = this.CreateMenuIcon("Icons.Branch.Add");
createBranch.Header = App.Text("CreateBranch");
createBranch.Click += (_, e) =>
{
@@ -938,7 +938,7 @@ namespace SourceGit.Views
};
var createTag = new MenuItem();
createTag.Icon = App.CreateMenuIcon("Icons.Tag.Add");
createTag.Icon = this.CreateMenuIcon("Icons.Tag.Add");
createTag.Header = App.Text("CreateTag");
createTag.Click += (_, e) =>
{
@@ -958,7 +958,7 @@ namespace SourceGit.Views
{
var createPR = new MenuItem();
createPR.Header = App.Text("BranchCM.CreatePRForUpstream", upstream.FriendlyName);
createPR.Icon = App.CreateMenuIcon("Icons.CreatePR");
createPR.Icon = this.CreateMenuIcon("Icons.CreatePR");
createPR.Click += (_, e) =>
{
Native.OS.OpenBrowser(prURL);
@@ -984,7 +984,7 @@ namespace SourceGit.Views
{
var tracking = new MenuItem();
tracking.Header = App.Text("BranchCM.Tracking");
tracking.Icon = App.CreateMenuIcon("Icons.Track");
tracking.Icon = this.CreateMenuIcon("Icons.Track");
tracking.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -996,7 +996,7 @@ namespace SourceGit.Views
}
var archive = new MenuItem();
archive.Icon = App.CreateMenuIcon("Icons.Archive");
archive.Icon = this.CreateMenuIcon("Icons.Archive");
archive.Header = App.Text("Archive");
archive.Click += (_, e) =>
{
@@ -1009,10 +1009,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("BranchCM.CopyName");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(branch.Name);
await this.CopyTextAsync(branch.Name);
e.Handled = true;
};
menu.Items.Add(copy);
@@ -1028,7 +1028,7 @@ namespace SourceGit.Views
{
var visit = new MenuItem();
visit.Header = App.Text("RemoteCM.OpenInBrowser");
visit.Icon = App.CreateMenuIcon("Icons.OpenWith");
visit.Icon = this.CreateMenuIcon("Icons.OpenWith");
visit.Click += (_, e) =>
{
Native.OS.OpenBrowser(visitURL);
@@ -1041,7 +1041,7 @@ namespace SourceGit.Views
var fetch = new MenuItem();
fetch.Header = App.Text("RemoteCM.Fetch");
fetch.Icon = App.CreateMenuIcon("Icons.Fetch");
fetch.Icon = this.CreateMenuIcon("Icons.Fetch");
fetch.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1051,7 +1051,7 @@ namespace SourceGit.Views
var prune = new MenuItem();
prune.Header = App.Text("RemoteCM.Prune");
prune.Icon = App.CreateMenuIcon("Icons.Clean");
prune.Icon = this.CreateMenuIcon("Icons.Clean");
prune.Click += async (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1061,7 +1061,7 @@ namespace SourceGit.Views
var edit = new MenuItem();
edit.Header = App.Text("RemoteCM.Edit");
edit.Icon = App.CreateMenuIcon("Icons.Edit");
edit.Icon = this.CreateMenuIcon("Icons.Edit");
edit.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1071,7 +1071,7 @@ namespace SourceGit.Views
var delete = new MenuItem();
delete.Header = App.Text("RemoteCM.Delete");
delete.Icon = App.CreateMenuIcon("Icons.Clear");
delete.Icon = this.CreateMenuIcon("Icons.Clear");
delete.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1081,10 +1081,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("RemoteCM.CopyURL");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(remote.URL);
await this.CopyTextAsync(remote.URL);
e.Handled = true;
};
@@ -1106,7 +1106,7 @@ namespace SourceGit.Views
var checkout = new MenuItem();
checkout.Header = App.Text("BranchCM.Checkout", name);
checkout.Icon = App.CreateMenuIcon("Icons.Check");
checkout.Icon = this.CreateMenuIcon("Icons.Check");
checkout.Click += async (_, e) =>
{
await repo.CheckoutBranchAsync(branch);
@@ -1119,7 +1119,7 @@ namespace SourceGit.Views
{
var pull = new MenuItem();
pull.Header = App.Text("BranchCM.PullInto", name, current.Name);
pull.Icon = App.CreateMenuIcon("Icons.Pull");
pull.Icon = this.CreateMenuIcon("Icons.Pull");
pull.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1129,7 +1129,7 @@ namespace SourceGit.Views
var merge = new MenuItem();
merge.Header = App.Text("BranchCM.Merge", name, current.Name);
merge.Icon = App.CreateMenuIcon("Icons.Merge");
merge.Icon = this.CreateMenuIcon("Icons.Merge");
merge.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1139,7 +1139,7 @@ namespace SourceGit.Views
var rebase = new MenuItem();
rebase.Header = App.Text("BranchCM.Rebase", current.Name, name);
rebase.Icon = App.CreateMenuIcon("Icons.Rebase");
rebase.Icon = this.CreateMenuIcon("Icons.Rebase");
rebase.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1149,7 +1149,7 @@ namespace SourceGit.Views
var interactiveRebase = new MenuItem();
interactiveRebase.Header = App.Text("BranchCM.InteractiveRebase.Manually", current.Name, name);
interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.Icon = this.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.IsEnabled = !current.Head.Equals(branch.Head, StringComparison.Ordinal);
interactiveRebase.Click += async (_, e) =>
{
@@ -1160,7 +1160,7 @@ namespace SourceGit.Views
var compareWithHead = new MenuItem();
compareWithHead.Header = App.Text("BranchCM.CompareWithHead");
compareWithHead.Icon = App.CreateMenuIcon("Icons.Compare");
compareWithHead.Icon = this.CreateMenuIcon("Icons.Compare");
compareWithHead.Click += (_, _) =>
{
App.ShowWindow(new ViewModels.Compare(repo, branch, current));
@@ -1168,7 +1168,7 @@ namespace SourceGit.Views
var compareWith = new MenuItem();
compareWith.Header = App.Text("BranchCM.CompareWith");
compareWith.Icon = App.CreateMenuIcon("Icons.Compare");
compareWith.Icon = this.CreateMenuIcon("Icons.Compare");
compareWith.Click += (_, _) =>
{
new ViewModels.CompareCommandPalette(repo, branch).Open();
@@ -1188,7 +1188,7 @@ namespace SourceGit.Views
var editDescription = new MenuItem();
editDescription.Header = App.Text("BranchCM.EditDescription", branch.Name);
editDescription.Icon = App.CreateMenuIcon("Icons.Edit");
editDescription.Icon = this.CreateMenuIcon("Icons.Edit");
editDescription.Click += async (_, e) =>
{
var desc = await new Commands.Config(repo.FullPath).GetAsync($"branch.{branch.Name}.description");
@@ -1199,7 +1199,7 @@ namespace SourceGit.Views
var delete = new MenuItem();
delete.Header = App.Text("BranchCM.Delete", name);
delete.Icon = App.CreateMenuIcon("Icons.Clear");
delete.Icon = this.CreateMenuIcon("Icons.Clear");
delete.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1212,7 +1212,7 @@ namespace SourceGit.Views
menu.Items.Add(new MenuItem() { Header = "-" });
var createBranch = new MenuItem();
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
createBranch.Icon = this.CreateMenuIcon("Icons.Branch.Add");
createBranch.Header = App.Text("CreateBranch");
createBranch.Click += (_, e) =>
{
@@ -1222,7 +1222,7 @@ namespace SourceGit.Views
};
var createTag = new MenuItem();
createTag.Icon = App.CreateMenuIcon("Icons.Tag.Add");
createTag.Icon = this.CreateMenuIcon("Icons.Tag.Add");
createTag.Header = App.Text("CreateTag");
createTag.Click += (_, e) =>
{
@@ -1239,7 +1239,7 @@ namespace SourceGit.Views
{
var createPR = new MenuItem();
createPR.Header = App.Text("BranchCM.CreatePR");
createPR.Icon = App.CreateMenuIcon("Icons.CreatePR");
createPR.Icon = this.CreateMenuIcon("Icons.CreatePR");
createPR.Click += (_, e) =>
{
Native.OS.OpenBrowser(prURL);
@@ -1252,7 +1252,7 @@ namespace SourceGit.Views
menu.Items.Add(new MenuItem() { Header = "-" });
var archive = new MenuItem();
archive.Icon = App.CreateMenuIcon("Icons.Archive");
archive.Icon = this.CreateMenuIcon("Icons.Archive");
archive.Header = App.Text("Archive");
archive.Click += (_, e) =>
{
@@ -1263,10 +1263,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("BranchCM.CopyName");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(name);
await this.CopyTextAsync(name);
e.Handled = true;
};
@@ -1285,13 +1285,13 @@ namespace SourceGit.Views
var custom = new MenuItem();
custom.Header = App.Text("BranchCM.CustomAction");
custom.Icon = App.CreateMenuIcon("Icons.Action");
custom.Icon = this.CreateMenuIcon("Icons.Action");
foreach (var action in actions)
{
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Icon = this.CreateMenuIcon("Icons.Action");
item.Header = label;
item.Click += async (_, e) =>
{
@@ -1314,13 +1314,13 @@ namespace SourceGit.Views
var custom = new MenuItem();
custom.Header = App.Text("RemoteCM.CustomAction");
custom.Icon = App.CreateMenuIcon("Icons.Action");
custom.Icon = this.CreateMenuIcon("Icons.Action");
foreach (var action in actions)
{
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Icon = this.CreateMenuIcon("Icons.Action");
item.Header = label;
item.Click += async (_, e) =>
{

View File

@@ -1,5 +1,6 @@
using System;
using Avalonia.Controls;
using Avalonia.Input.Platform;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
@@ -12,6 +13,29 @@ namespace SourceGit.Views
InitializeComponent();
}
protected override async void OnLoaded(RoutedEventArgs e)
{
base.OnLoaded(e);
if (DataContext is not ViewModels.Clone vm)
return;
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
if (clipboard != null)
{
try
{
var text = await clipboard.TryGetTextAsync();
if (Models.Remote.IsValidURL(text))
vm.Remote = text;
}
catch
{
// Ignore exceptions here.
}
}
}
private async void SelectParentFolder(object _, RoutedEventArgs e)
{
var options = new FolderPickerOpenOptions() { AllowMultiple = false };

View File

@@ -5,7 +5,7 @@ namespace SourceGit.Views
{
public class CommandPaletteDataTemplates : IDataTemplate
{
public Control Build(object param) => App.CreateViewForViewModel(param);
public Control Build(object param) => ControlExtensions.CreateFromViewModels(param);
public bool Match(object data) => data is ViewModels.ICommandPalette;
}
}

View File

@@ -203,6 +203,7 @@
<TextBlock Grid.Row="4" Grid.Column="0" Classes="info_label" VerticalAlignment="Top" Margin="0,4,0,0" Text="{DynamicResource Text.CommitDetail.Info.Message}" />
<v:CommitMessagePresenter Grid.Row="4" Grid.Column="1"
Margin="12,4,0,0"
Foreground="{DynamicResource Brush.FG1}"
FullMessage="{Binding #ThisControl.FullMessage}"
HorizontalAlignment="Stretch"
TextWrapping="Wrap">
@@ -213,6 +214,26 @@
</MultiBinding>
</ToolTip.IsOpen>
<v:CommitMessagePresenter.ContextFlyout>
<MenuFlyout Placement="Bottom">
<MenuItem Header="{DynamicResource Text.Copy}"
Command="{Binding $parent[SelectableTextBlock].Copy}"
IsEnabled="{Binding $parent[SelectableTextBlock].CanCopy}"
InputGesture="{x:Static TextBox.CopyGesture}">
<MenuItem.Icon>
<Path Width="11" Height="11" Data="{StaticResource Icons.Copy}" VerticalAlignment="Center"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="{DynamicResource Text.CopyAllText}"
Click="OnCopyAllCommitMessage">
<MenuItem.Icon>
<Path Width="11" Height="11" Data="{StaticResource Icons.Copy}" VerticalAlignment="Center"/>
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
</v:CommitMessagePresenter.ContextFlyout>
<v:CommitMessagePresenter.DataTemplates>
<DataTemplate DataType="m:Commit">
<StackPanel MinWidth="400" Orientation="Vertical">

View File

@@ -63,7 +63,7 @@ namespace SourceGit.Views
private async void OnCopyCommitSHA(object sender, RoutedEventArgs e)
{
if (sender is Button { DataContext: Models.Commit commit })
await App.CopyTextAsync(commit.SHA);
await this.CopyTextAsync(commit.SHA);
e.Handled = true;
}
@@ -151,28 +151,28 @@ namespace SourceGit.Views
var copyName = new MenuItem();
copyName.Header = App.Text("CommitDetail.Info.CopyName");
copyName.Icon = App.CreateMenuIcon("Icons.Copy");
copyName.Icon = this.CreateMenuIcon("Icons.Copy");
copyName.Click += async (_, ev) =>
{
await App.CopyTextAsync(user.Name);
await this.CopyTextAsync(user.Name);
ev.Handled = true;
};
var copyEmail = new MenuItem();
copyEmail.Header = App.Text("CommitDetail.Info.CopyEmail");
copyEmail.Icon = App.CreateMenuIcon("Icons.Email");
copyEmail.Icon = this.CreateMenuIcon("Icons.Email");
copyEmail.Click += async (_, ev) =>
{
await App.CopyTextAsync(user.Email);
await this.CopyTextAsync(user.Email);
ev.Handled = true;
};
var copyUser = new MenuItem();
copyUser.Header = App.Text("CommitDetail.Info.CopyNameAndEmail");
copyUser.Icon = App.CreateMenuIcon("Icons.User");
copyUser.Icon = this.CreateMenuIcon("Icons.User");
copyUser.Click += async (_, ev) =>
{
await App.CopyTextAsync(user.ToString());
await this.CopyTextAsync(user.ToString());
ev.Handled = true;
};
@@ -183,5 +183,12 @@ namespace SourceGit.Views
menu.Open(control);
e.Handled = true;
}
private async void OnCopyAllCommitMessage(object sender, RoutedEventArgs e)
{
if (DataContext is ViewModels.CommitDetail detail)
await this.CopyTextAsync(detail.FullMessage.Message);
e.Handled = true;
}
}
}

View File

@@ -62,7 +62,7 @@ namespace SourceGit.Views
builder.AppendLine(copyAbsPath ? vm.GetAbsPath(c.Path) : c.Path);
}
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
}
else if (e.Key == Key.F && e.KeyModifiers == cmdKey)

View File

@@ -25,7 +25,7 @@ namespace SourceGit.Views
var fullPath = Native.OS.GetAbsPath(repo.FullPath, node.FullPath);
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = Directory.Exists(fullPath);
explore.Click += (_, ev) =>
{
@@ -35,7 +35,7 @@ namespace SourceGit.Views
var history = new MenuItem();
history.Header = App.Text("DirHistories");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) =>
{
App.ShowWindow(new ViewModels.DirHistories(repo, node.FullPath, commit.SHA));
@@ -44,7 +44,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -75,21 +75,21 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
await App.CopyTextAsync(node.FullPath);
await this.CopyTextAsync(node.FullPath);
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
await App.CopyTextAsync(fullPath);
await this.CopyTextAsync(fullPath);
e.Handled = true;
};
@@ -112,7 +112,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -149,7 +149,7 @@ namespace SourceGit.Views
{
var resetToThisRevision = new MenuItem();
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
resetToThisRevision.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToThisRevision.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToThisRevision.Click += async (_, ev) =>
{
await vm.ResetMultipleToThisRevisionAsync(changes);
@@ -158,7 +158,7 @@ namespace SourceGit.Views
var resetToFirstParent = new MenuItem();
resetToFirstParent.Header = App.Text("ChangeCM.CheckoutFirstParentRevision");
resetToFirstParent.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToFirstParent.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToFirstParent.IsEnabled = commit.Parents.Count > 0;
resetToFirstParent.Click += async (_, ev) =>
{
@@ -173,7 +173,7 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
@@ -181,13 +181,13 @@ namespace SourceGit.Views
foreach (var c in changes)
builder.AppendLine(c.Path);
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
@@ -195,7 +195,7 @@ namespace SourceGit.Views
foreach (var c in changes)
builder.AppendLine(Native.OS.GetAbsPath(repo.FullPath, c.Path));
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
};
@@ -211,7 +211,7 @@ namespace SourceGit.Views
var openWith = new MenuItem();
openWith.Header = App.Text("Open");
openWith.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWith.Icon = this.CreateMenuIcon("Icons.OpenWith");
openWith.IsEnabled = change.Index != Models.ChangeState.Deleted;
if (openWith.IsEnabled)
{
@@ -249,7 +249,7 @@ namespace SourceGit.Views
var openWithMerger = new MenuItem();
openWithMerger.Header = App.Text("OpenInExternalMergeTool");
openWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Icon = this.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D";
openWithMerger.Click += (_, ev) =>
{
@@ -260,7 +260,7 @@ namespace SourceGit.Views
var fullPath = Native.OS.GetAbsPath(repo.FullPath, change.Path);
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = File.Exists(fullPath);
explore.Click += (_, ev) =>
{
@@ -270,7 +270,7 @@ namespace SourceGit.Views
var history = new MenuItem();
history.Header = App.Text("FileHistory");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) =>
{
App.ShowWindow(new ViewModels.FileHistories(repo.FullPath, change.Path, commit.SHA));
@@ -279,7 +279,7 @@ namespace SourceGit.Views
var blame = new MenuItem();
blame.Header = App.Text("Blame");
blame.Icon = App.CreateMenuIcon("Icons.Blame");
blame.Icon = this.CreateMenuIcon("Icons.Blame");
blame.IsEnabled = change.Index != Models.ChangeState.Deleted;
blame.Click += (_, ev) =>
{
@@ -289,7 +289,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -332,7 +332,7 @@ namespace SourceGit.Views
{
var resetToThisRevision = new MenuItem();
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
resetToThisRevision.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToThisRevision.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToThisRevision.Click += async (_, ev) =>
{
await vm.ResetToThisRevisionAsync(change);
@@ -341,7 +341,7 @@ namespace SourceGit.Views
var resetToFirstParent = new MenuItem();
resetToFirstParent.Header = App.Text("ChangeCM.CheckoutFirstParentRevision");
resetToFirstParent.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToFirstParent.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToFirstParent.IsEnabled = commit.Parents.Count > 0;
resetToFirstParent.Click += async (_, ev) =>
{
@@ -357,11 +357,11 @@ namespace SourceGit.Views
{
var lfs = new MenuItem();
lfs.Header = App.Text("GitLFS");
lfs.Icon = App.CreateMenuIcon("Icons.LFS");
lfs.Icon = this.CreateMenuIcon("Icons.LFS");
var lfsLock = new MenuItem();
lfsLock.Header = App.Text("GitLFS.Locks.Lock");
lfsLock.Icon = App.CreateMenuIcon("Icons.Lock");
lfsLock.Icon = this.CreateMenuIcon("Icons.Lock");
if (repo.Remotes.Count == 1)
{
lfsLock.Click += async (_, e) =>
@@ -389,7 +389,7 @@ namespace SourceGit.Views
var lfsUnlock = new MenuItem();
lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock");
lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock");
lfsUnlock.Icon = this.CreateMenuIcon("Icons.Unlock");
if (repo.Remotes.Count == 1)
{
lfsUnlock.Click += async (_, e) =>
@@ -426,13 +426,13 @@ namespace SourceGit.Views
var target = new Models.CustomActionTargetFile(change.Path, vm.Commit);
var custom = new MenuItem();
custom.Header = App.Text("FileCM.CustomAction");
custom.Icon = App.CreateMenuIcon("Icons.Action");
custom.Icon = this.CreateMenuIcon("Icons.Action");
foreach (var action in actions)
{
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Icon = this.CreateMenuIcon("Icons.Action");
item.Header = label;
item.Click += async (_, e) =>
{
@@ -449,21 +449,21 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
await App.CopyTextAsync(change.Path);
await this.CopyTextAsync(change.Path);
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
await App.CopyTextAsync(fullPath);
await this.CopyTextAsync(fullPath);
e.Handled = true;
};
@@ -484,9 +484,9 @@ namespace SourceGit.Views
e.KeyModifiers.HasFlag(OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
{
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
await App.CopyTextAsync(vm.GetAbsPath(change.Path));
await this.CopyTextAsync(vm.GetAbsPath(change.Path));
else
await App.CopyTextAsync(change.Path);
await this.CopyTextAsync(change.Path);
e.Handled = true;
return;

View File

@@ -134,7 +134,7 @@ namespace SourceGit.Views
{
var open = new MenuItem();
open.Header = App.Text("SHALinkCM.NavigateTo");
open.Icon = App.CreateMenuIcon("Icons.Commit");
open.Icon = this.CreateMenuIcon("Icons.Commit");
open.Click += (_, ev) =>
{
detail.NavigateTo(link);
@@ -143,10 +143,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("SHALinkCM.CopySHA");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(link);
await this.CopyTextAsync(link);
ev.Handled = true;
};
@@ -167,7 +167,7 @@ namespace SourceGit.Views
{
var open = new MenuItem();
open.Header = App.Text("IssueLinkCM.OpenInBrowser");
open.Icon = App.CreateMenuIcon("Icons.OpenWith");
open.Icon = this.CreateMenuIcon("Icons.OpenWith");
open.Click += (_, ev) =>
{
Native.OS.OpenBrowser(link);
@@ -176,10 +176,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("IssueLinkCM.CopyLink");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(link);
await this.CopyTextAsync(link);
ev.Handled = true;
};

View File

@@ -337,7 +337,7 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.IsEnabled = hasSelected;
copy.Click += (_, ev) =>
{
@@ -347,7 +347,7 @@ namespace SourceGit.Views
var cut = new MenuItem();
cut.Header = App.Text("Cut");
cut.Icon = App.CreateMenuIcon("Icons.Cut");
cut.Icon = this.CreateMenuIcon("Icons.Cut");
cut.IsEnabled = hasSelected;
cut.Click += (_, ev) =>
{
@@ -357,7 +357,7 @@ namespace SourceGit.Views
var paste = new MenuItem();
paste.Header = App.Text("Paste");
paste.Icon = App.CreateMenuIcon("Icons.Paste");
paste.Icon = this.CreateMenuIcon("Icons.Paste");
paste.Click += (_, ev) =>
{
Paste();
@@ -447,7 +447,7 @@ namespace SourceGit.Views
menu.Items.Add(new MenuItem()
{
Header = App.Text("WorkingCopy.NoCommitTemplates"),
Icon = App.CreateMenuIcon("Icons.Code"),
Icon = this.CreateMenuIcon("Icons.Code"),
IsEnabled = false
});
}
@@ -455,7 +455,7 @@ namespace SourceGit.Views
{
for (int i = 0; i < templateCount; i++)
{
var icon = App.CreateMenuIcon("Icons.Code");
var icon = this.CreateMenuIcon("Icons.Code");
icon.Fill = foreground;
var template = repo.Settings.CommitTemplates[i];
@@ -484,7 +484,7 @@ namespace SourceGit.Views
friendlyName = $"~{gitTemplate.AsSpan(prefixLen)}";
}
var icon = App.CreateMenuIcon("Icons.Code");
var icon = this.CreateMenuIcon("Icons.Code");
icon.Fill = foreground;
var gitTemplateItem = new MenuItem();
@@ -508,7 +508,7 @@ namespace SourceGit.Views
menu.Items.Add(new MenuItem()
{
Header = App.Text("WorkingCopy.NoCommitHistories"),
Icon = App.CreateMenuIcon("Icons.Histories"),
Icon = this.CreateMenuIcon("Icons.Histories"),
IsEnabled = false
});
}
@@ -524,7 +524,7 @@ namespace SourceGit.Views
TextTrimming = TextTrimming.CharacterEllipsis
};
var icon = App.CreateMenuIcon("Icons.Histories");
var icon = this.CreateMenuIcon("Icons.Histories");
icon.Fill = foreground;
var item = new MenuItem();
@@ -541,7 +541,7 @@ namespace SourceGit.Views
menu.Items.Add(new MenuItem() { Header = "-" });
var clearIcon = App.CreateMenuIcon("Icons.Clear");
var clearIcon = this.CreateMenuIcon("Icons.Clear");
clearIcon.Fill = foreground;
var clearHistoryItem = new MenuItem();

View File

@@ -24,7 +24,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = this.StorageProvider;
@@ -60,7 +60,7 @@ namespace SourceGit.Views
var change = selected[0];
var openWithMerger = new MenuItem();
openWithMerger.Header = App.Text("OpenInExternalMergeTool");
openWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Icon = this.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D";
openWithMerger.Click += (_, ev) =>
{
@@ -74,7 +74,7 @@ namespace SourceGit.Views
var full = vm.GetAbsPath(change.Path);
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = File.Exists(full);
explore.Click += (_, ev) =>
{
@@ -91,7 +91,7 @@ namespace SourceGit.Views
{
var resetToLeft = new MenuItem();
resetToLeft.Header = App.Text("ChangeCM.ResetFileTo", vm.BaseName);
resetToLeft.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToLeft.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToLeft.Click += async (_, ev) =>
{
await vm.ResetToLeftAsync(change);
@@ -100,7 +100,7 @@ namespace SourceGit.Views
var resetToRight = new MenuItem();
resetToRight.Header = App.Text("ChangeCM.ResetFileTo", vm.ToName);
resetToRight.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToRight.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToRight.Click += async (_, ev) =>
{
await vm.ResetToRightAsync(change);
@@ -114,21 +114,21 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
await App.CopyTextAsync(change.Path);
await this.CopyTextAsync(change.Path);
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, ev) =>
{
await App.CopyTextAsync(vm.GetAbsPath(change.Path));
await this.CopyTextAsync(vm.GetAbsPath(change.Path));
ev.Handled = true;
};
@@ -144,7 +144,7 @@ namespace SourceGit.Views
{
var resetToLeft = new MenuItem();
resetToLeft.Header = App.Text("ChangeCM.ResetFileTo", vm.BaseName);
resetToLeft.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToLeft.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToLeft.Click += async (_, ev) =>
{
await vm.ResetMultipleToLeftAsync(selected);
@@ -153,7 +153,7 @@ namespace SourceGit.Views
var resetToRight = new MenuItem();
resetToRight.Header = App.Text("ChangeCM.ResetFileTo", vm.ToName);
resetToRight.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToRight.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToRight.Click += async (_, ev) =>
{
await vm.ResetMultipleToRightAsync(selected);
@@ -167,7 +167,7 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
@@ -175,13 +175,13 @@ namespace SourceGit.Views
foreach (var c in selected)
builder.AppendLine(c.Path);
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, ev) =>
{
@@ -189,7 +189,7 @@ namespace SourceGit.Views
foreach (var c in selected)
builder.AppendLine(vm.GetAbsPath(c.Path));
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
ev.Handled = true;
};
@@ -235,7 +235,7 @@ namespace SourceGit.Views
builder.AppendLine(copyAbsPath ? vm.GetAbsPath(c.Path) : c.Path);
}
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
}
else if (e.Key == Key.F && e.KeyModifiers == cmdKey)

View File

@@ -0,0 +1,48 @@
using System;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Shapes;
using Avalonia.Media;
namespace SourceGit.Views
{
public static class ControlExtensions
{
public static Control CreateFromViewModels(object data)
{
var dataTypeName = data.GetType().FullName;
if (string.IsNullOrEmpty(dataTypeName) || !dataTypeName.Contains(".ViewModels.", StringComparison.Ordinal))
return null;
var viewTypeName = dataTypeName.Replace(".ViewModels.", ".Views.");
var viewType = Type.GetType(viewTypeName);
if (viewType != null)
return Activator.CreateInstance(viewType) as Control;
return null;
}
public static async Task CopyTextAsync(this Control control, string text)
{
var clipboard = TopLevel.GetTopLevel(control)?.Clipboard;
if (clipboard != null)
await clipboard.SetTextAsync(text);
}
public static Path CreateMenuIcon(this Control control, string iconKey)
{
if (control?.FindResource(iconKey) is StreamGeometry geo)
{
return new Path()
{
Data = geo,
Width = 12,
Height = 12,
Stretch = Stretch.Uniform
};
}
return null;
}
}
}

View File

@@ -35,7 +35,7 @@
<DataTemplate DataType="m:Branch">
<StackPanel Orientation="Horizontal">
<Path Width="14" Height="14" Data="{StaticResource Icons.Branch}"/>
<SelectableTextBlock VerticalAlignment="Center" Text="{Binding FriendlyName}" Margin="8,0,0,0"/>
<TextBlock VerticalAlignment="Center" Text="{Binding FriendlyName}" Margin="8,0,0,0"/>
</StackPanel>
</DataTemplate>

View File

@@ -30,14 +30,14 @@
<DataTemplate DataType="m:Null">
<StackPanel Orientation="Horizontal">
<Path Width="14" Height="14" Data="{StaticResource Icons.Repositories}"/>
<SelectableTextBlock VerticalAlignment="Center" Text="{DynamicResource Text.ExecuteCustomAction.Repository}" Margin="8,0,0,0" IsTabStop="False"/>
<TextBlock VerticalAlignment="Center" Text="{DynamicResource Text.ExecuteCustomAction.Repository}" Margin="8,0,0,0" IsTabStop="False"/>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="m:Branch">
<StackPanel Orientation="Horizontal">
<Path Width="14" Height="14" Data="{StaticResource Icons.Branch}"/>
<SelectableTextBlock VerticalAlignment="Center" Text="{Binding FriendlyName}" Margin="8,0,0,0" IsTabStop="False"/>
<TextBlock VerticalAlignment="Center" Text="{Binding FriendlyName}" Margin="8,0,0,0" IsTabStop="False"/>
</StackPanel>
</DataTemplate>

View File

@@ -97,7 +97,7 @@ namespace SourceGit.Views
}
var include = new MenuItem();
include.Icon = App.CreateMenuIcon("Icons.Filter");
include.Icon = this.CreateMenuIcon("Icons.Filter");
include.Header = App.Text("Repository.FilterCommits.Include");
include.IsEnabled = current != Models.FilterMode.Included;
include.Click += (_, ev) =>
@@ -107,7 +107,7 @@ namespace SourceGit.Views
};
var exclude = new MenuItem();
exclude.Icon = App.CreateMenuIcon("Icons.EyeClose");
exclude.Icon = this.CreateMenuIcon("Icons.EyeClose");
exclude.Header = App.Text("Repository.FilterCommits.Exclude");
exclude.IsEnabled = current != Models.FilterMode.Excluded;
exclude.Click += (_, ev) =>
@@ -142,7 +142,7 @@ namespace SourceGit.Views
}
var include = new MenuItem();
include.Icon = App.CreateMenuIcon("Icons.Filter");
include.Icon = this.CreateMenuIcon("Icons.Filter");
include.Header = App.Text("Repository.FilterCommits.Include");
include.IsEnabled = current != Models.FilterMode.Included;
include.Click += (_, ev) =>
@@ -152,7 +152,7 @@ namespace SourceGit.Views
};
var exclude = new MenuItem();
exclude.Icon = App.CreateMenuIcon("Icons.EyeClose");
exclude.Icon = this.CreateMenuIcon("Icons.EyeClose");
exclude.Header = App.Text("Repository.FilterCommits.Exclude");
exclude.IsEnabled = current != Models.FilterMode.Excluded;
exclude.Click += (_, ev) =>

View File

@@ -352,7 +352,7 @@ namespace SourceGit.Views
var authorColumn = new MenuItem();
authorColumn.Header = App.Text("Histories.Header.Author");
if (vm.IsAuthorColumnVisible)
authorColumn.Icon = App.CreateMenuIcon("Icons.Check");
authorColumn.Icon = this.CreateMenuIcon("Icons.Check");
authorColumn.Click += (_, ev) =>
{
vm.IsAuthorColumnVisible = !vm.IsAuthorColumnVisible;
@@ -362,7 +362,7 @@ namespace SourceGit.Views
var shaColumn = new MenuItem();
shaColumn.Header = App.Text("Histories.Header.SHA");
if (vm.IsSHAColumnVisible)
shaColumn.Icon = App.CreateMenuIcon("Icons.Check");
shaColumn.Icon = this.CreateMenuIcon("Icons.Check");
shaColumn.Click += (_, ev) =>
{
vm.IsSHAColumnVisible = !vm.IsSHAColumnVisible;
@@ -372,7 +372,7 @@ namespace SourceGit.Views
var timeColumn = new MenuItem();
timeColumn.Header = App.Text("Histories.Header.DateTime");
if (vm.IsDateTimeColumnVisible)
timeColumn.Icon = App.CreateMenuIcon("Icons.Check");
timeColumn.Icon = this.CreateMenuIcon("Icons.Check");
timeColumn.Click += (_, ev) =>
{
vm.IsDateTimeColumnVisible = !vm.IsDateTimeColumnVisible;
@@ -406,7 +406,7 @@ namespace SourceGit.Views
builder.Append(commit.SHA.AsSpan(0, 10)).Append(" - ").AppendLine(commit.Subject);
}
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
return;
}
@@ -489,7 +489,7 @@ namespace SourceGit.Views
{
var cherryPick = new MenuItem();
cherryPick.Header = App.Text("CommitCM.CherryPickMultiple");
cherryPick.Icon = App.CreateMenuIcon("Icons.CherryPick");
cherryPick.Icon = this.CreateMenuIcon("Icons.CherryPick");
cherryPick.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -503,7 +503,7 @@ namespace SourceGit.Views
{
var merge = new MenuItem();
merge.Header = App.Text("CommitCM.MergeMultiple");
merge.Icon = App.CreateMenuIcon("Icons.Merge");
merge.Icon = this.CreateMenuIcon("Icons.Merge");
merge.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -518,7 +518,7 @@ namespace SourceGit.Views
}
var saveToPatch = new MenuItem();
saveToPatch.Icon = App.CreateMenuIcon("Icons.Save");
saveToPatch.Icon = this.CreateMenuIcon("Icons.Save");
saveToPatch.Header = App.Text("CommitCM.SaveAsPatch");
saveToPatch.Click += async (_, e) =>
{
@@ -565,39 +565,39 @@ namespace SourceGit.Views
foreach (var c in selected)
builder.Append(c.SHA.AsSpan(0, 10)).Append(" - ").AppendLine(c.Subject);
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
};
var copyShas = new MenuItem();
copyShas.Header = App.Text("CommitCM.CopySHA");
copyShas.Icon = App.CreateMenuIcon("Icons.Hash");
copyShas.Icon = this.CreateMenuIcon("Icons.Hash");
copyShas.Click += async (_, e) =>
{
var builder = new StringBuilder();
foreach (var c in selected)
builder.AppendLine(c.SHA);
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
};
var copySubjects = new MenuItem();
copySubjects.Header = App.Text("CommitCM.CopySubject");
copySubjects.Icon = App.CreateMenuIcon("Icons.Subject");
copySubjects.Icon = this.CreateMenuIcon("Icons.Subject");
copySubjects.Click += async (_, e) =>
{
var builder = new StringBuilder();
foreach (var c in selected)
builder.AppendLine(c.Subject);
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
};
var copyMessage = new MenuItem();
copyMessage.Header = App.Text("CommitCM.CopyCommitMessage");
copyMessage.Icon = App.CreateMenuIcon("Icons.Message");
copyMessage.Icon = this.CreateMenuIcon("Icons.Message");
copyMessage.Click += async (_, e) =>
{
var vm = DataContext as ViewModels.Histories;
@@ -608,13 +608,13 @@ namespace SourceGit.Views
messages.Add(message);
}
await App.CopyTextAsync(string.Join("\n-----\n", messages));
await this.CopyTextAsync(string.Join("\n-----\n", messages));
e.Handled = true;
};
var copy = new MenuItem();
copy.Header = App.Text("Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Items.Add(copyInfos);
copy.Items.Add(new MenuItem() { Header = "-" });
copy.Items.Add(copyShas);
@@ -672,7 +672,7 @@ namespace SourceGit.Views
}
var createBranch = new MenuItem();
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
createBranch.Icon = this.CreateMenuIcon("Icons.Branch.Add");
createBranch.Header = App.Text("CreateBranch");
createBranch.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+B" : "Ctrl+Shift+B";
createBranch.Click += (_, e) =>
@@ -684,7 +684,7 @@ namespace SourceGit.Views
menu.Items.Add(createBranch);
var createTag = new MenuItem();
createTag.Icon = App.CreateMenuIcon("Icons.Tag.Add");
createTag.Icon = this.CreateMenuIcon("Icons.Tag.Add");
createTag.Header = App.Text("CreateTag");
createTag.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+T" : "Ctrl+Shift+T";
createTag.Click += (_, e) =>
@@ -706,7 +706,7 @@ namespace SourceGit.Views
{
var reword = new MenuItem();
reword.Header = App.Text("CommitCM.Reword");
reword.Icon = App.CreateMenuIcon("Icons.Edit");
reword.Icon = this.CreateMenuIcon("Icons.Edit");
reword.Click += async (_, e) =>
{
await vm.RewordHeadAsync(commit);
@@ -716,7 +716,7 @@ namespace SourceGit.Views
var squash = new MenuItem();
squash.Header = App.Text("CommitCM.Squash");
squash.Icon = App.CreateMenuIcon("Icons.SquashIntoParent");
squash.Icon = this.CreateMenuIcon("Icons.SquashIntoParent");
squash.IsEnabled = commit.Parents.Count == 1;
squash.Click += async (_, e) =>
{
@@ -727,7 +727,7 @@ namespace SourceGit.Views
var fixup = new MenuItem();
fixup.Header = App.Text("CommitCM.Fixup");
fixup.Icon = App.CreateMenuIcon("Icons.Fix");
fixup.Icon = this.CreateMenuIcon("Icons.Fix");
fixup.IsEnabled = commit.Parents.Count == 1;
fixup.Click += async (_, e) =>
{
@@ -740,7 +740,7 @@ namespace SourceGit.Views
{
var reset = new MenuItem();
reset.Header = App.Text("CommitCM.Reset", current.Name, target);
reset.Icon = App.CreateMenuIcon("Icons.Reset");
reset.Icon = this.CreateMenuIcon("Icons.Reset");
reset.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -754,7 +754,7 @@ namespace SourceGit.Views
{
var rebase = new MenuItem();
rebase.Header = App.Text("CommitCM.Rebase", current.Name, target);
rebase.Icon = App.CreateMenuIcon("Icons.Rebase");
rebase.Icon = this.CreateMenuIcon("Icons.Rebase");
rebase.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -767,7 +767,7 @@ namespace SourceGit.Views
{
var merge = new MenuItem();
merge.Header = App.Text("CommitCM.Merge", current.Name);
merge.Icon = App.CreateMenuIcon("Icons.Merge");
merge.Icon = this.CreateMenuIcon("Icons.Merge");
merge.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -780,7 +780,7 @@ namespace SourceGit.Views
var cherryPick = new MenuItem();
cherryPick.Header = App.Text("CommitCM.CherryPick");
cherryPick.Icon = App.CreateMenuIcon("Icons.CherryPick");
cherryPick.Icon = this.CreateMenuIcon("Icons.CherryPick");
cherryPick.Click += async (_, e) =>
{
await vm.CherryPickAsync(commit);
@@ -791,7 +791,7 @@ namespace SourceGit.Views
var revert = new MenuItem();
revert.Header = App.Text("CommitCM.Revert");
revert.Icon = App.CreateMenuIcon("Icons.Undo");
revert.Icon = this.CreateMenuIcon("Icons.Undo");
revert.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -804,7 +804,7 @@ namespace SourceGit.Views
{
var dropHead = new MenuItem();
dropHead.Header = App.Text("CommitCM.Drop");
dropHead.Icon = App.CreateMenuIcon("Icons.Clear");
dropHead.Icon = this.CreateMenuIcon("Icons.Clear");
dropHead.Click += async (_, e) =>
{
await vm.DropHeadAsync(commit);
@@ -816,7 +816,7 @@ namespace SourceGit.Views
{
var checkoutCommit = new MenuItem();
checkoutCommit.Header = App.Text("CommitCM.Checkout");
checkoutCommit.Icon = App.CreateMenuIcon("Icons.Detached");
checkoutCommit.Icon = this.CreateMenuIcon("Icons.Detached");
checkoutCommit.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -829,7 +829,7 @@ namespace SourceGit.Views
{
var manually = new MenuItem();
manually.Header = App.Text("CommitCM.InteractiveRebase.Manually", current.Name, target);
manually.Icon = App.CreateMenuIcon("Icons.InteractiveRebase");
manually.Icon = this.CreateMenuIcon("Icons.InteractiveRebase");
manually.Click += async (_, e) =>
{
await App.ShowDialog(new ViewModels.InteractiveRebase(repo, commit));
@@ -838,7 +838,7 @@ namespace SourceGit.Views
var reword = new MenuItem();
reword.Header = App.Text("CommitCM.InteractiveRebase.Reword");
reword.Icon = App.CreateMenuIcon("Icons.Rename");
reword.Icon = this.CreateMenuIcon("Icons.Rename");
reword.Click += async (_, e) =>
{
await vm.InteractiveRebaseAsync(commit, Models.InteractiveRebaseAction.Reword);
@@ -847,7 +847,7 @@ namespace SourceGit.Views
var edit = new MenuItem();
edit.Header = App.Text("CommitCM.InteractiveRebase.Edit");
edit.Icon = App.CreateMenuIcon("Icons.Edit");
edit.Icon = this.CreateMenuIcon("Icons.Edit");
edit.Click += async (_, e) =>
{
await vm.InteractiveRebaseAsync(commit, Models.InteractiveRebaseAction.Edit);
@@ -856,7 +856,7 @@ namespace SourceGit.Views
var squash = new MenuItem();
squash.Header = App.Text("CommitCM.InteractiveRebase.Squash");
squash.Icon = App.CreateMenuIcon("Icons.SquashIntoParent");
squash.Icon = this.CreateMenuIcon("Icons.SquashIntoParent");
squash.Click += async (_, e) =>
{
await vm.InteractiveRebaseAsync(commit, Models.InteractiveRebaseAction.Squash);
@@ -865,7 +865,7 @@ namespace SourceGit.Views
var fixup = new MenuItem();
fixup.Header = App.Text("CommitCM.InteractiveRebase.Fixup");
fixup.Icon = App.CreateMenuIcon("Icons.Fix");
fixup.Icon = this.CreateMenuIcon("Icons.Fix");
fixup.Click += async (_, e) =>
{
await vm.InteractiveRebaseAsync(commit, Models.InteractiveRebaseAction.Fixup);
@@ -874,7 +874,7 @@ namespace SourceGit.Views
var drop = new MenuItem();
drop.Header = App.Text("CommitCM.InteractiveRebase.Drop");
drop.Icon = App.CreateMenuIcon("Icons.Clear");
drop.Icon = this.CreateMenuIcon("Icons.Clear");
drop.Click += async (_, e) =>
{
await vm.InteractiveRebaseAsync(commit, Models.InteractiveRebaseAction.Drop);
@@ -883,7 +883,7 @@ namespace SourceGit.Views
var interactiveRebase = new MenuItem();
interactiveRebase.Header = App.Text("CommitCM.InteractiveRebase");
interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.Icon = this.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.Items.Add(manually);
interactiveRebase.Items.Add(new MenuItem() { Header = "-" });
interactiveRebase.Items.Add(reword);
@@ -899,7 +899,7 @@ namespace SourceGit.Views
{
var interactiveRebase = new MenuItem();
interactiveRebase.Header = App.Text("CommitCM.InteractiveRebase.Manually", current.Name, target);
interactiveRebase.Icon = App.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.Icon = this.CreateMenuIcon("Icons.InteractiveRebase");
interactiveRebase.Click += async (_, e) =>
{
await App.ShowDialog(new ViewModels.InteractiveRebase(repo, commit));
@@ -921,7 +921,7 @@ namespace SourceGit.Views
var upstream = repo.Branches.Find(x => x.FullName.Equals(current.Upstream, StringComparison.Ordinal));
var pushRevision = new MenuItem();
pushRevision.Header = App.Text("CommitCM.PushRevision", commit.SHA.Substring(0, 10), upstream.FriendlyName);
pushRevision.Icon = App.CreateMenuIcon("Icons.Push");
pushRevision.Icon = this.CreateMenuIcon("Icons.Push");
pushRevision.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -934,7 +934,7 @@ namespace SourceGit.Views
var compareWithHead = new MenuItem();
compareWithHead.Header = App.Text("CommitCM.CompareWithHead");
compareWithHead.Icon = App.CreateMenuIcon("Icons.Compare");
compareWithHead.Icon = this.CreateMenuIcon("Icons.Compare");
compareWithHead.Click += async (_, e) =>
{
var head = await vm.CompareWithHeadAsync(commit);
@@ -949,7 +949,7 @@ namespace SourceGit.Views
{
var compareWithWorktree = new MenuItem();
compareWithWorktree.Header = App.Text("CommitCM.CompareWithWorktree");
compareWithWorktree.Icon = App.CreateMenuIcon("Icons.Compare");
compareWithWorktree.Icon = this.CreateMenuIcon("Icons.Compare");
compareWithWorktree.Click += (_, e) =>
{
vm.CompareWithWorktree(commit);
@@ -962,7 +962,7 @@ namespace SourceGit.Views
}
var saveToPatch = new MenuItem();
saveToPatch.Icon = App.CreateMenuIcon("Icons.Save");
saveToPatch.Icon = this.CreateMenuIcon("Icons.Save");
saveToPatch.Header = App.Text("CommitCM.SaveAsPatch");
saveToPatch.Click += async (_, e) =>
{
@@ -991,7 +991,7 @@ namespace SourceGit.Views
menu.Items.Add(saveToPatch);
var archive = new MenuItem();
archive.Icon = App.CreateMenuIcon("Icons.Archive");
archive.Icon = this.CreateMenuIcon("Icons.Archive");
archive.Header = App.Text("Archive");
archive.Click += (_, e) =>
{
@@ -1007,13 +1007,13 @@ namespace SourceGit.Views
{
var custom = new MenuItem();
custom.Header = App.Text("CommitCM.CustomAction");
custom.Icon = App.CreateMenuIcon("Icons.Action");
custom.Icon = this.CreateMenuIcon("Icons.Action");
foreach (var action in actions)
{
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Icon = this.CreateMenuIcon("Icons.Action");
item.Header = label;
item.Click += async (_, e) =>
{
@@ -1033,59 +1033,59 @@ namespace SourceGit.Views
copyInfo.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyInfo.Click += async (_, e) =>
{
await App.CopyTextAsync($"{commit.SHA.AsSpan(0, 10)} - {commit.Subject}");
await this.CopyTextAsync($"{commit.SHA.AsSpan(0, 10)} - {commit.Subject}");
e.Handled = true;
};
var copySHA = new MenuItem();
copySHA.Header = App.Text("CommitCM.CopySHA");
copySHA.Icon = App.CreateMenuIcon("Icons.Hash");
copySHA.Icon = this.CreateMenuIcon("Icons.Hash");
copySHA.Click += async (_, e) =>
{
await App.CopyTextAsync(commit.SHA);
await this.CopyTextAsync(commit.SHA);
e.Handled = true;
};
var copySubject = new MenuItem();
copySubject.Header = App.Text("CommitCM.CopySubject");
copySubject.Icon = App.CreateMenuIcon("Icons.Subject");
copySubject.Icon = this.CreateMenuIcon("Icons.Subject");
copySubject.Click += async (_, e) =>
{
await App.CopyTextAsync(commit.Subject);
await this.CopyTextAsync(commit.Subject);
e.Handled = true;
};
var copyMessage = new MenuItem();
copyMessage.Header = App.Text("CommitCM.CopyCommitMessage");
copyMessage.Icon = App.CreateMenuIcon("Icons.Message");
copyMessage.Icon = this.CreateMenuIcon("Icons.Message");
copyMessage.Click += async (_, e) =>
{
var message = await vm.GetCommitFullMessageAsync(commit);
await App.CopyTextAsync(message);
await this.CopyTextAsync(message);
e.Handled = true;
};
var copyAuthor = new MenuItem();
copyAuthor.Header = App.Text("CommitCM.CopyAuthor");
copyAuthor.Icon = App.CreateMenuIcon("Icons.User");
copyAuthor.Icon = this.CreateMenuIcon("Icons.User");
copyAuthor.Click += async (_, e) =>
{
await App.CopyTextAsync(commit.Author.ToString());
await this.CopyTextAsync(commit.Author.ToString());
e.Handled = true;
};
var copyCommitter = new MenuItem();
copyCommitter.Header = App.Text("CommitCM.CopyCommitter");
copyCommitter.Icon = App.CreateMenuIcon("Icons.User");
copyCommitter.Icon = this.CreateMenuIcon("Icons.User");
copyCommitter.Click += async (_, e) =>
{
await App.CopyTextAsync(commit.Committer.ToString());
await this.CopyTextAsync(commit.Committer.ToString());
e.Handled = true;
};
var copy = new MenuItem();
copy.Header = App.Text("Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Items.Add(copyInfo);
copy.Items.Add(new MenuItem() { Header = "-" });
copy.Items.Add(copySHA);
@@ -1101,7 +1101,7 @@ namespace SourceGit.Views
private void FillCurrentBranchMenu(ContextMenu menu, ViewModels.Repository repo, Models.Branch current)
{
var submenu = new MenuItem();
submenu.Icon = App.CreateMenuIcon("Icons.Branch");
submenu.Icon = this.CreateMenuIcon("Icons.Branch");
submenu.Header = current.Name;
var visibility = new MenuItem();
@@ -1116,7 +1116,7 @@ namespace SourceGit.Views
var fastForward = new MenuItem();
fastForward.Header = App.Text("BranchCM.FastForward", upstream);
fastForward.Icon = App.CreateMenuIcon("Icons.FastForward");
fastForward.Icon = this.CreateMenuIcon("Icons.FastForward");
fastForward.IsEnabled = current.Ahead.Count == 0 && current.Behind.Count > 0;
fastForward.Click += async (_, e) =>
{
@@ -1133,7 +1133,7 @@ namespace SourceGit.Views
var pull = new MenuItem();
pull.Header = App.Text("BranchCM.Pull", upstream);
pull.Icon = App.CreateMenuIcon("Icons.Pull");
pull.Icon = this.CreateMenuIcon("Icons.Pull");
pull.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1145,7 +1145,7 @@ namespace SourceGit.Views
var push = new MenuItem();
push.Header = App.Text("BranchCM.Push", current.Name);
push.Icon = App.CreateMenuIcon("Icons.Push");
push.Icon = this.CreateMenuIcon("Icons.Push");
push.IsEnabled = repo.Remotes.Count > 0;
push.Click += (_, e) =>
{
@@ -1157,7 +1157,7 @@ namespace SourceGit.Views
var rename = new MenuItem();
rename.Header = App.Text("BranchCM.Rename", current.Name);
rename.Icon = App.CreateMenuIcon("Icons.Rename");
rename.Icon = this.CreateMenuIcon("Icons.Rename");
rename.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1174,7 +1174,7 @@ namespace SourceGit.Views
{
var finish = new MenuItem();
finish.Header = App.Text("BranchCM.Finish", current.Name);
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
finish.Icon = this.CreateMenuIcon("Icons.GitFlow");
finish.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1188,10 +1188,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("BranchCM.CopyName");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(current.Name);
await this.CopyTextAsync(current.Name);
e.Handled = true;
};
submenu.Items.Add(copy);
@@ -1202,7 +1202,7 @@ namespace SourceGit.Views
private void FillOtherLocalBranchMenu(ContextMenu menu, ViewModels.Repository repo, Models.Branch branch, Models.Branch current, bool merged)
{
var submenu = new MenuItem();
submenu.Icon = App.CreateMenuIcon("Icons.Branch");
submenu.Icon = this.CreateMenuIcon("Icons.Branch");
submenu.Header = branch.Name;
var visibility = new MenuItem();
@@ -1215,7 +1215,7 @@ namespace SourceGit.Views
{
var checkout = new MenuItem();
checkout.Header = App.Text("BranchCM.Checkout", branch.Name);
checkout.Icon = App.CreateMenuIcon("Icons.Check");
checkout.Icon = this.CreateMenuIcon("Icons.Check");
checkout.Click += async (_, e) =>
{
await repo.CheckoutBranchAsync(branch);
@@ -1225,7 +1225,7 @@ namespace SourceGit.Views
var merge = new MenuItem();
merge.Header = App.Text("BranchCM.Merge", branch.Name, current.Name);
merge.Icon = App.CreateMenuIcon("Icons.Merge");
merge.Icon = this.CreateMenuIcon("Icons.Merge");
merge.IsEnabled = !merged;
merge.Click += (_, e) =>
{
@@ -1238,7 +1238,7 @@ namespace SourceGit.Views
var rename = new MenuItem();
rename.Header = App.Text("BranchCM.Rename", branch.Name);
rename.Icon = App.CreateMenuIcon("Icons.Rename");
rename.Icon = this.CreateMenuIcon("Icons.Rename");
rename.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1249,7 +1249,7 @@ namespace SourceGit.Views
var delete = new MenuItem();
delete.Header = App.Text("BranchCM.Delete", branch.Name);
delete.Icon = App.CreateMenuIcon("Icons.Clear");
delete.Icon = this.CreateMenuIcon("Icons.Clear");
delete.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1266,7 +1266,7 @@ namespace SourceGit.Views
{
var finish = new MenuItem();
finish.Header = App.Text("BranchCM.Finish", branch.Name);
finish.Icon = App.CreateMenuIcon("Icons.GitFlow");
finish.Icon = this.CreateMenuIcon("Icons.GitFlow");
finish.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1280,10 +1280,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("BranchCM.CopyName");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(branch.Name);
await this.CopyTextAsync(branch.Name);
e.Handled = true;
};
submenu.Items.Add(copy);
@@ -1296,7 +1296,7 @@ namespace SourceGit.Views
var name = branch.FriendlyName;
var submenu = new MenuItem();
submenu.Icon = App.CreateMenuIcon("Icons.Branch");
submenu.Icon = this.CreateMenuIcon("Icons.Branch");
submenu.Header = name;
var visibility = new MenuItem();
@@ -1307,7 +1307,7 @@ namespace SourceGit.Views
var checkout = new MenuItem();
checkout.Header = App.Text("BranchCM.Checkout", name);
checkout.Icon = App.CreateMenuIcon("Icons.Check");
checkout.Icon = this.CreateMenuIcon("Icons.Check");
checkout.Click += async (_, e) =>
{
await repo.CheckoutBranchAsync(branch);
@@ -1317,7 +1317,7 @@ namespace SourceGit.Views
var merge = new MenuItem();
merge.Header = App.Text("BranchCM.Merge", name, current.Name);
merge.Icon = App.CreateMenuIcon("Icons.Merge");
merge.Icon = this.CreateMenuIcon("Icons.Merge");
merge.IsEnabled = !merged;
merge.Click += (_, e) =>
{
@@ -1330,7 +1330,7 @@ namespace SourceGit.Views
var delete = new MenuItem();
delete.Header = App.Text("BranchCM.Delete", name);
delete.Icon = App.CreateMenuIcon("Icons.Clear");
delete.Icon = this.CreateMenuIcon("Icons.Clear");
delete.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1342,10 +1342,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("BranchCM.CopyName");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(name);
await this.CopyTextAsync(name);
e.Handled = true;
};
submenu.Items.Add(copy);
@@ -1357,7 +1357,7 @@ namespace SourceGit.Views
{
var submenu = new MenuItem();
submenu.Header = tag.Name;
submenu.Icon = App.CreateMenuIcon("Icons.Tag");
submenu.Icon = this.CreateMenuIcon("Icons.Tag");
submenu.MinWidth = 200;
var visibility = new MenuItem();
@@ -1368,7 +1368,7 @@ namespace SourceGit.Views
var push = new MenuItem();
push.Header = App.Text("TagCM.Push", tag.Name);
push.Icon = App.CreateMenuIcon("Icons.Push");
push.Icon = this.CreateMenuIcon("Icons.Push");
push.IsEnabled = repo.Remotes.Count > 0;
push.Click += (_, e) =>
{
@@ -1382,7 +1382,7 @@ namespace SourceGit.Views
{
var merge = new MenuItem();
merge.Header = App.Text("TagCM.Merge", tag.Name, current.Name);
merge.Icon = App.CreateMenuIcon("Icons.Merge");
merge.Icon = this.CreateMenuIcon("Icons.Merge");
merge.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1394,7 +1394,7 @@ namespace SourceGit.Views
var delete = new MenuItem();
delete.Header = App.Text("TagCM.Delete", tag.Name);
delete.Icon = App.CreateMenuIcon("Icons.Clear");
delete.Icon = this.CreateMenuIcon("Icons.Clear");
delete.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1406,10 +1406,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("TagCM.CopyName");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(tag.Name);
await this.CopyTextAsync(tag.Name);
e.Handled = true;
};
submenu.Items.Add(copy);

View File

@@ -373,7 +373,7 @@ namespace SourceGit.Views
{
var workspace = pref.Workspaces[i];
var icon = App.CreateMenuIcon(workspace.IsActive ? "Icons.Check" : "Icons.Workspace");
var icon = this.CreateMenuIcon(workspace.IsActive ? "Icons.Check" : "Icons.Workspace");
icon.Fill = workspace.Brush;
var item = new MenuItem();

View File

@@ -71,7 +71,7 @@ namespace SourceGit.Views
private async void OnCopyNotification(object sender, RoutedEventArgs e)
{
if (sender is Button { DataContext: Models.Notification notice })
await App.CopyTextAsync(notice.Message);
await this.CopyTextAsync(notice.Message);
e.Handled = true;
}

View File

@@ -284,7 +284,7 @@ namespace SourceGit.Views
{
var refresh = new MenuItem();
refresh.Header = App.Text("PageTabBar.Tab.Refresh");
refresh.Icon = App.CreateMenuIcon("Icons.Loading");
refresh.Icon = this.CreateMenuIcon("Icons.Loading");
refresh.Tag = "F5";
refresh.Click += (_, ev) =>
{
@@ -295,10 +295,10 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("PageTabBar.Tab.CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Click += async (_, ev) =>
{
await page.CopyPathAsync();
await this.CopyTextAsync(repo.FullPath);
ev.Handled = true;
};
menu.Items.Add(copyPath);
@@ -306,19 +306,19 @@ namespace SourceGit.Views
var bookmark = new MenuItem();
bookmark.Header = App.Text("PageTabBar.Tab.Bookmark");
bookmark.Icon = App.CreateMenuIcon("Icons.Bookmark");
bookmark.Icon = this.CreateMenuIcon("Icons.Bookmark");
for (int i = 0; i < Models.Bookmarks.Brushes.Length; i++)
{
var brush = Models.Bookmarks.Brushes[i];
var icon = App.CreateMenuIcon("Icons.Bookmark");
var icon = this.CreateMenuIcon("Icons.Bookmark");
if (brush != null)
icon.Fill = brush;
var dupIdx = i;
var setter = new MenuItem() { Header = icon };
if (i == page.Node.Bookmark)
setter.Icon = App.CreateMenuIcon("Icons.Check");
setter.Icon = this.CreateMenuIcon("Icons.Check");
else
setter.Click += (_, ev) =>
{
@@ -335,13 +335,13 @@ namespace SourceGit.Views
{
var moveTo = new MenuItem();
moveTo.Header = App.Text("PageTabBar.Tab.MoveToWorkspace");
moveTo.Icon = App.CreateMenuIcon("Icons.MoveTo");
moveTo.Icon = this.CreateMenuIcon("Icons.MoveTo");
foreach (var ws in workspaces)
{
var dupWs = ws;
var isCurrent = dupWs == vm.ActiveWorkspace;
var icon = App.CreateMenuIcon(isCurrent ? "Icons.Check" : "Icons.Workspace");
var icon = this.CreateMenuIcon(isCurrent ? "Icons.Check" : "Icons.Workspace");
icon.Fill = dupWs.Brush;
var target = new MenuItem();

View File

@@ -391,10 +391,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(selected);
await this.CopyTextAsync(selected);
ev.Handled = true;
};

View File

@@ -14,7 +14,7 @@ namespace SourceGit.Views
public Control Build(object param)
{
var control = App.CreateViewForViewModel(param);
var control = ControlExtensions.CreateFromViewModels(param);
control.Loaded += (o, e) =>
{

View File

@@ -94,7 +94,7 @@ namespace SourceGit.Views
var switchTo = new MenuItem();
switchTo.Header = App.Text("Worktree.Open");
switchTo.Icon = App.CreateMenuIcon("Icons.Folder.Open");
switchTo.Icon = this.CreateMenuIcon("Icons.Folder.Open");
switchTo.Click += (_, ev) =>
{
repo.OpenWorktree(worktree);
@@ -107,7 +107,7 @@ namespace SourceGit.Views
{
var unlock = new MenuItem();
unlock.Header = App.Text("Worktree.Unlock");
unlock.Icon = App.CreateMenuIcon("Icons.Unlock");
unlock.Icon = this.CreateMenuIcon("Icons.Unlock");
unlock.Click += async (_, ev) =>
{
await repo.UnlockWorktreeAsync(worktree);
@@ -119,7 +119,7 @@ namespace SourceGit.Views
{
var loc = new MenuItem();
loc.Header = App.Text("Worktree.Lock");
loc.Icon = App.CreateMenuIcon("Icons.Lock");
loc.Icon = this.CreateMenuIcon("Icons.Lock");
loc.IsEnabled = !worktree.IsMain;
loc.Click += async (_, ev) =>
{
@@ -131,7 +131,7 @@ namespace SourceGit.Views
var remove = new MenuItem();
remove.Header = App.Text("Worktree.Remove");
remove.Icon = App.CreateMenuIcon("Icons.Clear");
remove.Icon = this.CreateMenuIcon("Icons.Clear");
remove.IsEnabled = !worktree.IsCurrent && !worktree.IsMain;
remove.Click += (_, ev) =>
{
@@ -143,10 +143,10 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("Worktree.CopyPath");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(worktree.FullPath);
await this.CopyTextAsync(worktree.FullPath);
ev.Handled = true;
};
menu.Items.Add(new MenuItem() { Header = "-" });
@@ -354,7 +354,7 @@ namespace SourceGit.Views
var horizontal = new MenuItem();
horizontal.Header = App.Text("Repository.HistoriesLayout.Horizontal");
if (isHorizontal)
horizontal.Icon = App.CreateMenuIcon("Icons.Check");
horizontal.Icon = this.CreateMenuIcon("Icons.Check");
horizontal.Click += (_, ev) =>
{
pref.UseTwoColumnsLayoutInHistories = true;
@@ -364,7 +364,7 @@ namespace SourceGit.Views
var vertical = new MenuItem();
vertical.Header = App.Text("Repository.HistoriesLayout.Vertical");
if (!isHorizontal)
vertical.Icon = App.CreateMenuIcon("Icons.Check");
vertical.Icon = this.CreateMenuIcon("Icons.Check");
vertical.Click += (_, ev) =>
{
pref.UseTwoColumnsLayoutInHistories = false;
@@ -379,7 +379,7 @@ namespace SourceGit.Views
reflog.Header = App.Text("Repository.ShowLostCommits");
reflog.Tag = "--reflog";
if (repo.HistoryShowFlags.HasFlag(Models.HistoryShowFlags.Reflog))
reflog.Icon = App.CreateMenuIcon("Icons.Check");
reflog.Icon = this.CreateMenuIcon("Icons.Check");
reflog.Click += (_, ev) =>
{
repo.ToggleHistoryShowFlag(Models.HistoryShowFlags.Reflog);
@@ -390,7 +390,7 @@ namespace SourceGit.Views
firstParentOnly.Header = App.Text("Repository.ShowFirstParentOnly");
firstParentOnly.Tag = "--first-parent";
if (repo.HistoryShowFlags.HasFlag(Models.HistoryShowFlags.FirstParentOnly))
firstParentOnly.Icon = App.CreateMenuIcon("Icons.Check");
firstParentOnly.Icon = this.CreateMenuIcon("Icons.Check");
firstParentOnly.Click += (_, ev) =>
{
repo.ToggleHistoryShowFlag(Models.HistoryShowFlags.FirstParentOnly);
@@ -401,7 +401,7 @@ namespace SourceGit.Views
simplifyByDecoration.Header = App.Text("Repository.ShowDecoratedCommitsOnly");
simplifyByDecoration.Tag = "--simplify-by-decoration";
if (repo.HistoryShowFlags.HasFlag(Models.HistoryShowFlags.SimplifyByDecoration))
simplifyByDecoration.Icon = App.CreateMenuIcon("Icons.Check");
simplifyByDecoration.Icon = this.CreateMenuIcon("Icons.Check");
simplifyByDecoration.Click += (_, ev) =>
{
repo.ToggleHistoryShowFlag(Models.HistoryShowFlags.SimplifyByDecoration);
@@ -416,7 +416,7 @@ namespace SourceGit.Views
dateOrder.Header = App.Text("Repository.HistoriesOrder.ByDate");
dateOrder.Tag = "--date-order";
if (!repo.EnableTopoOrderInHistory)
dateOrder.Icon = App.CreateMenuIcon("Icons.Check");
dateOrder.Icon = this.CreateMenuIcon("Icons.Check");
dateOrder.Click += (_, ev) =>
{
repo.EnableTopoOrderInHistory = false;
@@ -427,7 +427,7 @@ namespace SourceGit.Views
topoOrder.Header = App.Text("Repository.HistoriesOrder.Topo");
topoOrder.Tag = "--topo-order";
if (repo.EnableTopoOrderInHistory)
topoOrder.Icon = App.CreateMenuIcon("Icons.Check");
topoOrder.Icon = this.CreateMenuIcon("Icons.Check");
topoOrder.Click += (_, ev) =>
{
repo.EnableTopoOrderInHistory = true;
@@ -462,7 +462,7 @@ namespace SourceGit.Views
var byNameAsc = new MenuItem();
byNameAsc.Header = App.Text("Repository.BranchSort.ByName");
if (isSortByName)
byNameAsc.Icon = App.CreateMenuIcon("Icons.Check");
byNameAsc.Icon = this.CreateMenuIcon("Icons.Check");
byNameAsc.Click += (_, ev) =>
{
if (!isSortByName)
@@ -473,7 +473,7 @@ namespace SourceGit.Views
var byCommitterDate = new MenuItem();
byCommitterDate.Header = App.Text("Repository.BranchSort.ByCommitterDate");
if (!isSortByName)
byCommitterDate.Icon = App.CreateMenuIcon("Icons.Check");
byCommitterDate.Icon = this.CreateMenuIcon("Icons.Check");
byCommitterDate.Click += (_, ev) =>
{
if (isSortByName)
@@ -499,7 +499,7 @@ namespace SourceGit.Views
var byNameAsc = new MenuItem();
byNameAsc.Header = App.Text("Repository.BranchSort.ByName");
if (isSortByName)
byNameAsc.Icon = App.CreateMenuIcon("Icons.Check");
byNameAsc.Icon = this.CreateMenuIcon("Icons.Check");
byNameAsc.Click += (_, ev) =>
{
if (!isSortByName)
@@ -510,7 +510,7 @@ namespace SourceGit.Views
var byCommitterDate = new MenuItem();
byCommitterDate.Header = App.Text("Repository.BranchSort.ByCommitterDate");
if (!isSortByName)
byCommitterDate.Icon = App.CreateMenuIcon("Icons.Check");
byCommitterDate.Icon = this.CreateMenuIcon("Icons.Check");
byCommitterDate.Click += (_, ev) =>
{
if (isSortByName)
@@ -536,7 +536,7 @@ namespace SourceGit.Views
var byCreatorDate = new MenuItem();
byCreatorDate.Header = App.Text("Repository.Tags.OrderByCreatorDate");
if (!isSortByName)
byCreatorDate.Icon = App.CreateMenuIcon("Icons.Check");
byCreatorDate.Icon = this.CreateMenuIcon("Icons.Check");
byCreatorDate.Click += (_, ev) =>
{
if (isSortByName)
@@ -547,7 +547,7 @@ namespace SourceGit.Views
var byName = new MenuItem();
byName.Header = App.Text("Repository.Tags.OrderByName");
if (isSortByName)
byName.Icon = App.CreateMenuIcon("Icons.Check");
byName.Icon = this.CreateMenuIcon("Icons.Check");
byName.Click += (_, ev) =>
{
if (!isSortByName)

View File

@@ -30,7 +30,7 @@ namespace SourceGit.Views
var explore = new MenuItem();
explore.Header = App.Text("Repository.Explore");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.Click += (_, e) =>
{
Native.OS.OpenInFileManager(fullpath);
@@ -39,7 +39,7 @@ namespace SourceGit.Views
var terminal = new MenuItem();
terminal.Header = App.Text("Repository.Terminal");
terminal.Icon = App.CreateMenuIcon("Icons.Terminal");
terminal.Icon = this.CreateMenuIcon("Icons.Terminal");
terminal.Click += (_, e) =>
{
Native.OS.OpenTerminal(fullpath);
@@ -118,7 +118,7 @@ namespace SourceGit.Views
var item = new MenuItem();
item.Header = App.Text("Repository.Visit", name);
item.Icon = App.CreateMenuIcon("Icons.Remotes");
item.Icon = this.CreateMenuIcon("Icons.Remotes");
item.Click += (_, e) =>
{
Native.OS.OpenBrowser(dupUrl);
@@ -235,7 +235,7 @@ namespace SourceGit.Views
{
var startFeature = new MenuItem();
startFeature.Header = App.Text("GitFlow.StartFeature");
startFeature.Icon = App.CreateMenuIcon("Icons.GitFlow.Feature");
startFeature.Icon = this.CreateMenuIcon("Icons.GitFlow.Feature");
startFeature.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -245,7 +245,7 @@ namespace SourceGit.Views
var startRelease = new MenuItem();
startRelease.Header = App.Text("GitFlow.StartRelease");
startRelease.Icon = App.CreateMenuIcon("Icons.GitFlow.Release");
startRelease.Icon = this.CreateMenuIcon("Icons.GitFlow.Release");
startRelease.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -255,7 +255,7 @@ namespace SourceGit.Views
var startHotfix = new MenuItem();
startHotfix.Header = App.Text("GitFlow.StartHotfix");
startHotfix.Icon = App.CreateMenuIcon("Icons.GitFlow.Hotfix");
startHotfix.Icon = this.CreateMenuIcon("Icons.GitFlow.Hotfix");
startHotfix.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -271,7 +271,7 @@ namespace SourceGit.Views
{
var init = new MenuItem();
init.Header = App.Text("GitFlow.Init");
init.Icon = App.CreateMenuIcon("Icons.Init");
init.Icon = this.CreateMenuIcon("Icons.Init");
init.Click += (_, e) =>
{
if (repo.CurrentBranch == null)
@@ -301,7 +301,7 @@ namespace SourceGit.Views
{
var addPattern = new MenuItem();
addPattern.Header = App.Text("GitLFS.AddTrackPattern");
addPattern.Icon = App.CreateMenuIcon("Icons.File.Add");
addPattern.Icon = this.CreateMenuIcon("Icons.File.Add");
addPattern.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -314,7 +314,7 @@ namespace SourceGit.Views
var fetch = new MenuItem();
fetch.Header = App.Text("GitLFS.Fetch");
fetch.Icon = App.CreateMenuIcon("Icons.Fetch");
fetch.Icon = this.CreateMenuIcon("Icons.Fetch");
fetch.IsEnabled = repo.Remotes.Count > 0;
fetch.Click += async (_, e) =>
{
@@ -332,7 +332,7 @@ namespace SourceGit.Views
var pull = new MenuItem();
pull.Header = App.Text("GitLFS.Pull");
pull.Icon = App.CreateMenuIcon("Icons.Pull");
pull.Icon = this.CreateMenuIcon("Icons.Pull");
pull.IsEnabled = repo.Remotes.Count > 0;
pull.Click += async (_, e) =>
{
@@ -350,7 +350,7 @@ namespace SourceGit.Views
var push = new MenuItem();
push.Header = App.Text("GitLFS.Push");
push.Icon = App.CreateMenuIcon("Icons.Push");
push.Icon = this.CreateMenuIcon("Icons.Push");
push.IsEnabled = repo.Remotes.Count > 0;
push.Click += async (_, e) =>
{
@@ -368,7 +368,7 @@ namespace SourceGit.Views
var prune = new MenuItem();
prune.Header = App.Text("GitLFS.Prune");
prune.Icon = App.CreateMenuIcon("Icons.Clean");
prune.Icon = this.CreateMenuIcon("Icons.Clean");
prune.Click += async (_, e) =>
{
if (repo.CanCreatePopup())
@@ -381,7 +381,7 @@ namespace SourceGit.Views
var locks = new MenuItem();
locks.Header = App.Text("GitLFS.Locks");
locks.Icon = App.CreateMenuIcon("Icons.Lock");
locks.Icon = this.CreateMenuIcon("Icons.Lock");
locks.IsEnabled = repo.Remotes.Count > 0;
if (repo.Remotes.Count == 1)
{
@@ -414,7 +414,7 @@ namespace SourceGit.Views
{
var install = new MenuItem();
install.Header = App.Text("GitLFS.Install");
install.Icon = App.CreateMenuIcon("Icons.Init");
install.Icon = this.CreateMenuIcon("Icons.Init");
install.Click += async (_, e) =>
{
await repo.InstallLFSAsync();
@@ -468,7 +468,7 @@ namespace SourceGit.Views
{
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Icon = this.CreateMenuIcon("Icons.Action");
item.Header = label;
item.Click += async (_, e) =>
{

View File

@@ -38,7 +38,7 @@
<DataTemplate DataType="m:Branch">
<StackPanel Orientation="Horizontal">
<Path Width="14" Height="14" Data="{StaticResource Icons.Branch}"/>
<SelectableTextBlock VerticalAlignment="Center" Text="{Binding FriendlyName}" Margin="8,0,0,0"/>
<TextBlock VerticalAlignment="Center" Text="{Binding FriendlyName}" Margin="8,0,0,0"/>
</StackPanel>
</DataTemplate>

View File

@@ -23,7 +23,7 @@ namespace SourceGit.Views
{
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -60,7 +60,7 @@ namespace SourceGit.Views
var openWithMerger = new MenuItem();
openWithMerger.Header = App.Text("OpenInExternalMergeTool");
openWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Icon = this.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D";
openWithMerger.Click += (_, ev) =>
{
@@ -73,7 +73,7 @@ namespace SourceGit.Views
{
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = File.Exists(changeFullPath);
explore.Click += (_, ev) =>
{
@@ -85,7 +85,7 @@ namespace SourceGit.Views
var resetToLeft = new MenuItem();
resetToLeft.Header = App.Text("ChangeCM.ResetFileTo", vm.LeftSideDesc);
resetToLeft.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToLeft.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToLeft.IsEnabled = vm.CanResetToLeft;
resetToLeft.Click += async (_, ev) =>
{
@@ -95,7 +95,7 @@ namespace SourceGit.Views
var resetToRight = new MenuItem();
resetToRight.Header = App.Text("ChangeCM.ResetFileTo", vm.RightSideDesc);
resetToRight.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToRight.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToRight.IsEnabled = vm.CanResetToRight;
resetToRight.Click += async (_, ev) =>
{
@@ -105,21 +105,21 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
await App.CopyTextAsync(change.Path);
await this.CopyTextAsync(change.Path);
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, ev) =>
{
await App.CopyTextAsync(changeFullPath);
await this.CopyTextAsync(changeFullPath);
ev.Handled = true;
};
@@ -136,7 +136,7 @@ namespace SourceGit.Views
{
var resetToLeft = new MenuItem();
resetToLeft.Header = App.Text("ChangeCM.ResetFileTo", vm.LeftSideDesc);
resetToLeft.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToLeft.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToLeft.IsEnabled = vm.CanResetToLeft;
resetToLeft.Click += async (_, ev) =>
{
@@ -146,7 +146,7 @@ namespace SourceGit.Views
var resetToRight = new MenuItem();
resetToRight.Header = App.Text("ChangeCM.ResetFileTo", vm.RightSideDesc);
resetToRight.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToRight.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToRight.IsEnabled = vm.CanResetToRight;
resetToRight.Click += async (_, ev) =>
{
@@ -156,7 +156,7 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
@@ -164,13 +164,13 @@ namespace SourceGit.Views
foreach (var c in selected)
builder.AppendLine(c.Path);
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, ev) =>
{
@@ -178,7 +178,7 @@ namespace SourceGit.Views
foreach (var c in selected)
builder.AppendLine(vm.GetAbsPath(c.Path));
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
ev.Handled = true;
};
@@ -256,7 +256,7 @@ namespace SourceGit.Views
builder.AppendLine(copyAbsPath ? vm.GetAbsPath(c.Path) : c.Path);
}
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
}
else if (e.Key == Key.F && e.KeyModifiers == cmdKey)

View File

@@ -110,7 +110,7 @@ namespace SourceGit.Views
var copy = new MenuItem() { Header = App.Text("Copy") };
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(selected);
await this.CopyTextAsync(selected);
ev.Handled = true;
};

View File

@@ -142,7 +142,7 @@ namespace SourceGit.Views
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
path = detail.GetAbsPath(path);
await App.CopyTextAsync(path);
await this.CopyTextAsync(path);
e.Handled = true;
}
}
@@ -459,7 +459,7 @@ namespace SourceGit.Views
var fullPath = Native.OS.GetAbsPath(repo.FullPath, path);
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = Directory.Exists(fullPath);
explore.Click += (_, ev) =>
{
@@ -469,7 +469,7 @@ namespace SourceGit.Views
var history = new MenuItem();
history.Header = App.Text("DirHistories");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) =>
{
App.ShowWindow(new ViewModels.DirHistories(repo, path, commit.SHA));
@@ -478,21 +478,21 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
await App.CopyTextAsync(path);
await this.CopyTextAsync(path);
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
await App.CopyTextAsync(fullPath);
await this.CopyTextAsync(fullPath);
e.Handled = true;
};
@@ -513,7 +513,7 @@ namespace SourceGit.Views
var openWith = new MenuItem();
openWith.Header = App.Text("Open");
openWith.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWith.Icon = this.CreateMenuIcon("Icons.OpenWith");
openWith.IsEnabled = file.Type == Models.ObjectType.Blob;
if (openWith.IsEnabled)
{
@@ -552,7 +552,7 @@ namespace SourceGit.Views
var saveAs = new MenuItem();
saveAs.Header = App.Text("SaveAs");
saveAs.Icon = App.CreateMenuIcon("Icons.Save");
saveAs.Icon = this.CreateMenuIcon("Icons.Save");
saveAs.IsEnabled = file.Type == Models.ObjectType.Blob;
saveAs.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+S" : "Ctrl+Shift+S";
saveAs.Click += async (_, ev) =>
@@ -583,7 +583,7 @@ namespace SourceGit.Views
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = File.Exists(fullPath) || Directory.Exists(fullPath);
explore.Click += (_, ev) =>
{
@@ -598,7 +598,7 @@ namespace SourceGit.Views
var history = new MenuItem();
history.Header = App.Text("FileHistory");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, ev) =>
{
App.ShowWindow(new ViewModels.FileHistories(repo.FullPath, file.Path, commit.SHA));
@@ -607,7 +607,7 @@ namespace SourceGit.Views
var blame = new MenuItem();
blame.Header = App.Text("Blame");
blame.Icon = App.CreateMenuIcon("Icons.Blame");
blame.Icon = this.CreateMenuIcon("Icons.Blame");
blame.IsEnabled = file.Type == Models.ObjectType.Blob;
blame.Click += (_, ev) =>
{
@@ -623,7 +623,7 @@ namespace SourceGit.Views
{
var resetToThisRevision = new MenuItem();
resetToThisRevision.Header = App.Text("ChangeCM.CheckoutThisRevision");
resetToThisRevision.Icon = App.CreateMenuIcon("Icons.File.Checkout");
resetToThisRevision.Icon = this.CreateMenuIcon("Icons.File.Checkout");
resetToThisRevision.Click += async (_, ev) =>
{
await vm.ResetToThisRevisionAsync(file.Path);
@@ -637,11 +637,11 @@ namespace SourceGit.Views
{
var lfs = new MenuItem();
lfs.Header = App.Text("GitLFS");
lfs.Icon = App.CreateMenuIcon("Icons.LFS");
lfs.Icon = this.CreateMenuIcon("Icons.LFS");
var lfsLock = new MenuItem();
lfsLock.Header = App.Text("GitLFS.Locks.Lock");
lfsLock.Icon = App.CreateMenuIcon("Icons.Lock");
lfsLock.Icon = this.CreateMenuIcon("Icons.Lock");
if (repo.Remotes.Count == 1)
{
lfsLock.Click += async (_, e) =>
@@ -669,7 +669,7 @@ namespace SourceGit.Views
var lfsUnlock = new MenuItem();
lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock");
lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock");
lfsUnlock.Icon = this.CreateMenuIcon("Icons.Unlock");
if (repo.Remotes.Count == 1)
{
lfsUnlock.Click += async (_, e) =>
@@ -706,13 +706,13 @@ namespace SourceGit.Views
var target = new Models.CustomActionTargetFile(file.Path, vm.Commit);
var custom = new MenuItem();
custom.Header = App.Text("FileCM.CustomAction");
custom.Icon = App.CreateMenuIcon("Icons.Action");
custom.Icon = this.CreateMenuIcon("Icons.Action");
foreach (var action in actions)
{
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Icon = this.CreateMenuIcon("Icons.Action");
item.Header = label;
item.Click += async (_, e) =>
{
@@ -729,21 +729,21 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
await App.CopyTextAsync(file.Path);
await this.CopyTextAsync(file.Path);
ev.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
await App.CopyTextAsync(fullPath);
await this.CopyTextAsync(fullPath);
e.Handled = true;
};

View File

@@ -39,7 +39,7 @@ namespace SourceGit.Views
}
else if (e.Key is Key.C && e.KeyModifiers == (OperatingSystem.IsMacOS() ? KeyModifiers.Meta : KeyModifiers.Control))
{
await App.CopyTextAsync(stash.Message);
await this.CopyTextAsync(stash.Message);
e.Handled = true;
}
}
@@ -52,7 +52,7 @@ namespace SourceGit.Views
{
var apply = new MenuItem();
apply.Header = App.Text("StashCM.Apply");
apply.Icon = App.CreateMenuIcon("Icons.CheckCircled");
apply.Icon = this.CreateMenuIcon("Icons.CheckCircled");
apply.Click += (_, ev) =>
{
vm.Apply(stash);
@@ -61,7 +61,7 @@ namespace SourceGit.Views
var branch = new MenuItem();
branch.Header = App.Text("StashCM.Branch");
branch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
branch.Icon = this.CreateMenuIcon("Icons.Branch.Add");
branch.Click += (_, ev) =>
{
vm.CheckoutBranch(stash);
@@ -70,7 +70,7 @@ namespace SourceGit.Views
var drop = new MenuItem();
drop.Header = App.Text("StashCM.Drop");
drop.Icon = App.CreateMenuIcon("Icons.Clear");
drop.Icon = this.CreateMenuIcon("Icons.Clear");
drop.Tag = "Back/Delete";
drop.Click += (_, ev) =>
{
@@ -80,7 +80,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("StashCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, ev) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -108,11 +108,11 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("StashCM.CopyMessage");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(stash.Message);
await this.CopyTextAsync(stash.Message);
ev.Handled = true;
};
@@ -153,7 +153,7 @@ namespace SourceGit.Views
var openWithMerger = new MenuItem();
openWithMerger.Header = App.Text("OpenInExternalMergeTool");
openWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Icon = this.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D";
openWithMerger.Click += (_, ev) =>
{
@@ -163,7 +163,7 @@ namespace SourceGit.Views
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = File.Exists(fullPath);
explore.Click += (_, ev) =>
{
@@ -178,7 +178,7 @@ namespace SourceGit.Views
var applyChanges = new MenuItem();
applyChanges.Header = App.Text("StashCM.ApplyFileChanges");
applyChanges.Icon = App.CreateMenuIcon("Icons.Diff");
applyChanges.Icon = this.CreateMenuIcon("Icons.Diff");
applyChanges.Click += async (_, ev) =>
{
await vm.ApplySelectedChanges(selected);
@@ -187,7 +187,7 @@ namespace SourceGit.Views
var checkoutFiles = new MenuItem();
checkoutFiles.Header = App.Text("ChangeCM.CheckoutThisRevision");
checkoutFiles.Icon = App.CreateMenuIcon("Icons.File.Checkout");
checkoutFiles.Icon = this.CreateMenuIcon("Icons.File.Checkout");
checkoutFiles.Click += async (_, ev) =>
{
await vm.CheckoutFilesAsync(selected);
@@ -196,13 +196,13 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, ev) =>
{
if (selected.Count == 1)
{
await App.CopyTextAsync(selected[0].Path);
await this.CopyTextAsync(selected[0].Path);
}
else
{
@@ -210,7 +210,7 @@ namespace SourceGit.Views
foreach (var c in selected)
builder.AppendLine(c.Path);
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
}
ev.Handled = true;
@@ -218,13 +218,13 @@ namespace SourceGit.Views
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, ev) =>
{
if (selected.Count == 1)
{
await App.CopyTextAsync(vm.GetAbsPath(selected[0].Path));
await this.CopyTextAsync(vm.GetAbsPath(selected[0].Path));
}
else
{
@@ -232,7 +232,7 @@ namespace SourceGit.Views
foreach (var c in selected)
builder.AppendLine(vm.GetAbsPath(c.Path));
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
}
ev.Handled = true;
@@ -271,7 +271,7 @@ namespace SourceGit.Views
builder.AppendLine(copyAbsPath ? vm.GetAbsPath(c.Path) : c.Path);
}
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
e.Handled = true;
}
}

View File

@@ -183,7 +183,7 @@ namespace SourceGit.Views
{
var open = new MenuItem();
open.Header = App.Text("Submodule.Open");
open.Icon = App.CreateMenuIcon("Icons.Folder.Open");
open.Icon = this.CreateMenuIcon("Icons.Folder.Open");
open.IsEnabled = submodule.Status != Models.SubmoduleStatus.NotInited;
open.Click += (_, ev) =>
{
@@ -193,7 +193,7 @@ namespace SourceGit.Views
var update = new MenuItem();
update.Header = App.Text("Submodule.Update");
update.Icon = App.CreateMenuIcon("Icons.Loading");
update.Icon = this.CreateMenuIcon("Icons.Loading");
update.Click += (_, ev) =>
{
if (repo.CanCreatePopup())
@@ -203,7 +203,7 @@ namespace SourceGit.Views
var move = new MenuItem();
move.Header = App.Text("Submodule.Move");
move.Icon = App.CreateMenuIcon("Icons.MoveTo");
move.Icon = this.CreateMenuIcon("Icons.MoveTo");
move.Click += (_, ev) =>
{
if (repo.CanCreatePopup())
@@ -213,7 +213,7 @@ namespace SourceGit.Views
var setURL = new MenuItem();
setURL.Header = App.Text("Submodule.SetURL");
setURL.Icon = App.CreateMenuIcon("Icons.Edit");
setURL.Icon = this.CreateMenuIcon("Icons.Edit");
setURL.Click += (_, ev) =>
{
if (repo.CanCreatePopup())
@@ -223,7 +223,7 @@ namespace SourceGit.Views
var setBranch = new MenuItem();
setBranch.Header = App.Text("Submodule.SetBranch");
setBranch.Icon = App.CreateMenuIcon("Icons.Track");
setBranch.Icon = this.CreateMenuIcon("Icons.Track");
setBranch.Click += (_, ev) =>
{
if (repo.CanCreatePopup())
@@ -233,7 +233,7 @@ namespace SourceGit.Views
var deinit = new MenuItem();
deinit.Header = App.Text("Submodule.Deinit");
deinit.Icon = App.CreateMenuIcon("Icons.Undo");
deinit.Icon = this.CreateMenuIcon("Icons.Undo");
deinit.IsEnabled = submodule.Status != Models.SubmoduleStatus.NotInited;
deinit.Click += (_, ev) =>
{
@@ -244,7 +244,7 @@ namespace SourceGit.Views
var rm = new MenuItem();
rm.Header = App.Text("Submodule.Remove");
rm.Icon = App.CreateMenuIcon("Icons.Clear");
rm.Icon = this.CreateMenuIcon("Icons.Clear");
rm.Click += (_, ev) =>
{
if (repo.CanCreatePopup())
@@ -254,7 +254,7 @@ namespace SourceGit.Views
var histories = new MenuItem();
histories.Header = App.Text("Submodule.Histories");
histories.Icon = App.CreateMenuIcon("Icons.Histories");
histories.Icon = this.CreateMenuIcon("Icons.Histories");
histories.Click += (_, ev) =>
{
App.ShowWindow(new ViewModels.FileHistories(repo.FullPath, submodule.Path));
@@ -263,43 +263,43 @@ namespace SourceGit.Views
var copySHA = new MenuItem();
copySHA.Header = App.Text("CommitDetail.Info.SHA");
copySHA.Icon = App.CreateMenuIcon("Icons.Hash");
copySHA.Icon = this.CreateMenuIcon("Icons.Hash");
copySHA.Click += async (_, ev) =>
{
await App.CopyTextAsync(submodule.SHA);
await this.CopyTextAsync(submodule.SHA);
ev.Handled = true;
};
var copyBranch = new MenuItem();
copyBranch.Header = App.Text("Submodule.CopyBranch");
copyBranch.Icon = App.CreateMenuIcon("Icons.Branch");
copyBranch.Icon = this.CreateMenuIcon("Icons.Branch");
copyBranch.Click += async (_, ev) =>
{
await App.CopyTextAsync(submodule.Branch);
await this.CopyTextAsync(submodule.Branch);
ev.Handled = true;
};
var copyRelativePath = new MenuItem();
copyRelativePath.Header = App.Text("Submodule.CopyPath");
copyRelativePath.Icon = App.CreateMenuIcon("Icons.Folder");
copyRelativePath.Icon = this.CreateMenuIcon("Icons.Folder");
copyRelativePath.Click += async (_, ev) =>
{
await App.CopyTextAsync(submodule.Path);
await this.CopyTextAsync(submodule.Path);
ev.Handled = true;
};
var copyURL = new MenuItem();
copyURL.Header = App.Text("Submodule.URL");
copyURL.Icon = App.CreateMenuIcon("Icons.Link");
copyURL.Icon = this.CreateMenuIcon("Icons.Link");
copyURL.Click += async (_, ev) =>
{
await App.CopyTextAsync(submodule.URL);
await this.CopyTextAsync(submodule.URL);
ev.Handled = true;
};
var copy = new MenuItem();
copy.Header = App.Text("Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Items.Add(copySHA);
copy.Items.Add(copyBranch);
copy.Items.Add(copyRelativePath);

View File

@@ -236,7 +236,7 @@ namespace SourceGit.Views
var tag = selected[0];
var createBranch = new MenuItem();
createBranch.Icon = App.CreateMenuIcon("Icons.Branch.Add");
createBranch.Icon = this.CreateMenuIcon("Icons.Branch.Add");
createBranch.Header = App.Text("CreateBranch");
createBranch.Click += (_, ev) =>
{
@@ -247,7 +247,7 @@ namespace SourceGit.Views
var pushTag = new MenuItem();
pushTag.Header = App.Text("TagCM.Push", tag.Name);
pushTag.Icon = App.CreateMenuIcon("Icons.Push");
pushTag.Icon = this.CreateMenuIcon("Icons.Push");
pushTag.IsEnabled = repo.Remotes.Count > 0;
pushTag.Click += (_, ev) =>
{
@@ -258,7 +258,7 @@ namespace SourceGit.Views
var deleteTag = new MenuItem();
deleteTag.Header = App.Text("TagCM.Delete", tag.Name);
deleteTag.Icon = App.CreateMenuIcon("Icons.Clear");
deleteTag.Icon = this.CreateMenuIcon("Icons.Clear");
deleteTag.Click += (_, ev) =>
{
if (repo.CanCreatePopup())
@@ -268,7 +268,7 @@ namespace SourceGit.Views
var compareWithHead = new MenuItem();
compareWithHead.Header = App.Text("TagCM.CompareWithHead");
compareWithHead.Icon = App.CreateMenuIcon("Icons.Compare");
compareWithHead.Icon = this.CreateMenuIcon("Icons.Compare");
compareWithHead.Click += (_, _) =>
{
App.ShowWindow(new ViewModels.Compare(repo, tag, repo.CurrentBranch));
@@ -276,14 +276,14 @@ namespace SourceGit.Views
var compareWith = new MenuItem();
compareWith.Header = App.Text("TagCM.CompareWith");
compareWith.Icon = App.CreateMenuIcon("Icons.Compare");
compareWith.Icon = this.CreateMenuIcon("Icons.Compare");
compareWith.Click += (_, _) =>
{
new ViewModels.CompareCommandPalette(repo, tag).Open();
};
var archive = new MenuItem();
archive.Icon = App.CreateMenuIcon("Icons.Archive");
archive.Icon = this.CreateMenuIcon("Icons.Archive");
archive.Header = App.Text("Archive");
archive.Click += (_, ev) =>
{
@@ -309,13 +309,13 @@ namespace SourceGit.Views
{
var custom = new MenuItem();
custom.Header = App.Text("TagCM.CustomAction");
custom.Icon = App.CreateMenuIcon("Icons.Action");
custom.Icon = this.CreateMenuIcon("Icons.Action");
foreach (var action in actions)
{
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Icon = this.CreateMenuIcon("Icons.Action");
item.Header = label;
item.Click += async (_, ev) =>
{
@@ -332,24 +332,24 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
var copyName = new MenuItem();
copyName.Header = App.Text("TagCM.Copy.Name");
copyName.Icon = App.CreateMenuIcon("Icons.Tag");
copyName.Icon = this.CreateMenuIcon("Icons.Tag");
copyName.Click += async (_, ev) =>
{
await App.CopyTextAsync(tag.Name);
await this.CopyTextAsync(tag.Name);
ev.Handled = true;
};
var copyMessage = new MenuItem();
copyMessage.Header = App.Text("TagCM.Copy.Message");
copyMessage.Icon = App.CreateMenuIcon("Icons.Info");
copyMessage.Icon = this.CreateMenuIcon("Icons.Info");
copyMessage.IsEnabled = !string.IsNullOrEmpty(tag.Message);
copyMessage.Click += async (_, ev) =>
{
await App.CopyTextAsync(tag.Message);
await this.CopyTextAsync(tag.Message);
ev.Handled = true;
};
@@ -360,10 +360,10 @@ namespace SourceGit.Views
{
var copyCreator = new MenuItem();
copyCreator.Header = App.Text("TagCM.Copy.Tagger");
copyCreator.Icon = App.CreateMenuIcon("Icons.User");
copyCreator.Icon = this.CreateMenuIcon("Icons.User");
copyCreator.Click += async (_, ev) =>
{
await App.CopyTextAsync(tag.Creator.ToString());
await this.CopyTextAsync(tag.Creator.ToString());
ev.Handled = true;
};
copy.Items.Add(copyCreator);
@@ -380,7 +380,7 @@ namespace SourceGit.Views
{
var compare = new MenuItem();
compare.Header = App.Text("TagCM.CompareTwo");
compare.Icon = App.CreateMenuIcon("Icons.Compare");
compare.Icon = this.CreateMenuIcon("Icons.Compare");
compare.Click += (_, ev) =>
{
var (based, to) = (selected[0], selected[1]);
@@ -395,7 +395,7 @@ namespace SourceGit.Views
var deleteMultiple = new MenuItem();
deleteMultiple.Header = App.Text("TagCM.DeleteMultiple", selected.Count);
deleteMultiple.Icon = App.CreateMenuIcon("Icons.Clear");
deleteMultiple.Icon = this.CreateMenuIcon("Icons.Clear");
deleteMultiple.Click += (_, ev) =>
{
if (repo.CanCreatePopup())

View File

@@ -647,7 +647,7 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("Copy");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, ev) =>
{
await CopyWithoutIndicatorsAsync();
@@ -823,7 +823,7 @@ namespace SourceGit.Views
var selection = TextArea.Selection;
if (selection.IsEmpty)
{
await App.CopyTextAsync(string.Empty);
await this.CopyTextAsync(string.Empty);
return;
}
@@ -841,9 +841,9 @@ namespace SourceGit.Views
if (startIdx == endIdx)
{
if (lines[startIdx].Type is Models.TextDiffLineType.Indicator or Models.TextDiffLineType.None)
await App.CopyTextAsync(string.Empty);
await this.CopyTextAsync(string.Empty);
else
await App.CopyTextAsync(SelectedText);
await this.CopyTextAsync(SelectedText);
return;
}
@@ -883,7 +883,7 @@ namespace SourceGit.Views
builder.Append(line.Content).Append('\n');
}
await App.CopyTextAsync(builder.ToString());
await this.CopyTextAsync(builder.ToString());
}
private bool _execSizeChanged;

View File

@@ -18,16 +18,16 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("ViewLogs.CopyLog");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Click += async (_, ev) =>
{
await App.CopyTextAsync(log.Content);
await this.CopyTextAsync(log.Content);
ev.Handled = true;
};
var rm = new MenuItem();
rm.Header = App.Text("ViewLogs.Delete");
rm.Icon = App.CreateMenuIcon("Icons.Clear");
rm.Icon = this.CreateMenuIcon("Icons.Clear");
rm.Click += (_, ev) =>
{
vm.Logs.Remove(log);

View File

@@ -105,7 +105,7 @@ namespace SourceGit.Views
{
var openAll = new MenuItem();
openAll.Header = App.Text("Welcome.OpenAllInNode");
openAll.Icon = App.CreateMenuIcon("Icons.Folder.Open");
openAll.Icon = this.CreateMenuIcon("Icons.Folder.Open");
openAll.Click += (_, e) =>
{
node.Open();
@@ -120,7 +120,7 @@ namespace SourceGit.Views
{
var open = new MenuItem();
open.Header = App.Text("Welcome.OpenOrInit");
open.Icon = App.CreateMenuIcon("Icons.Folder.Open");
open.Icon = this.CreateMenuIcon("Icons.Folder.Open");
open.Click += (_, e) =>
{
node.Open();
@@ -129,7 +129,7 @@ namespace SourceGit.Views
var explore = new MenuItem();
explore.Header = App.Text("Repository.Explore");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.Click += (_, e) =>
{
node.OpenInFileManager();
@@ -138,7 +138,7 @@ namespace SourceGit.Views
var terminal = new MenuItem();
terminal.Header = App.Text("Repository.Terminal");
terminal.Icon = App.CreateMenuIcon("Icons.Terminal");
terminal.Icon = this.CreateMenuIcon("Icons.Terminal");
terminal.Click += (_, e) =>
{
node.OpenTerminal();
@@ -155,7 +155,7 @@ namespace SourceGit.Views
{
var addSubFolder = new MenuItem();
addSubFolder.Header = App.Text("Welcome.AddSubFolder");
addSubFolder.Icon = App.CreateMenuIcon("Icons.Folder.Add");
addSubFolder.Icon = this.CreateMenuIcon("Icons.Folder.Add");
addSubFolder.Click += (_, e) =>
{
node.AddSubFolder();
@@ -166,7 +166,7 @@ namespace SourceGit.Views
var edit = new MenuItem();
edit.Header = App.Text("Welcome.Edit");
edit.Icon = App.CreateMenuIcon("Icons.Edit");
edit.Icon = this.CreateMenuIcon("Icons.Edit");
edit.Click += (_, e) =>
{
node.Edit();
@@ -175,7 +175,7 @@ namespace SourceGit.Views
var move = new MenuItem();
move.Header = App.Text("Welcome.Move");
move.Icon = App.CreateMenuIcon("Icons.MoveTo");
move.Icon = this.CreateMenuIcon("Icons.MoveTo");
move.Click += (_, e) =>
{
node.Move();
@@ -184,7 +184,7 @@ namespace SourceGit.Views
var delete = new MenuItem();
delete.Header = App.Text("Welcome.Delete");
delete.Icon = App.CreateMenuIcon("Icons.Clear");
delete.Icon = this.CreateMenuIcon("Icons.Clear");
delete.Click += (_, e) =>
{
node.Delete();

View File

@@ -120,9 +120,9 @@ namespace SourceGit.Views
{
var change = vm.SelectedUnstaged[0];
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
await App.CopyTextAsync(Native.OS.GetAbsPath(vm.Repository.FullPath, change.Path));
await this.CopyTextAsync(Native.OS.GetAbsPath(vm.Repository.FullPath, change.Path));
else
await App.CopyTextAsync(change.Path);
await this.CopyTextAsync(change.Path);
e.Handled = true;
}
@@ -159,9 +159,9 @@ namespace SourceGit.Views
{
var change = vm.SelectedStaged[0];
if (e.KeyModifiers.HasFlag(KeyModifiers.Shift))
await App.CopyTextAsync(Native.OS.GetAbsPath(vm.Repository.FullPath, change.Path));
await this.CopyTextAsync(Native.OS.GetAbsPath(vm.Repository.FullPath, change.Path));
else
await App.CopyTextAsync(change.Path);
await this.CopyTextAsync(change.Path);
e.Handled = true;
}
@@ -282,7 +282,7 @@ namespace SourceGit.Views
var diffWithMerger = new MenuItem();
diffWithMerger.Header = App.Text("OpenInExternalMergeTool");
diffWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
diffWithMerger.Icon = this.CreateMenuIcon("Icons.OpenWith");
diffWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D";
diffWithMerger.Click += (_, ev) =>
{
@@ -295,7 +295,7 @@ namespace SourceGit.Views
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = File.Exists(path) || Directory.Exists(path);
explore.Click += (_, e) =>
{
@@ -309,7 +309,7 @@ namespace SourceGit.Views
if (change.IsConflicted)
{
var useTheirs = new MenuItem();
useTheirs.Icon = App.CreateMenuIcon("Icons.Incoming");
useTheirs.Icon = this.CreateMenuIcon("Icons.Incoming");
useTheirs.Click += async (_, e) =>
{
await vm.UseTheirsAsync(selectedUnstaged);
@@ -317,7 +317,7 @@ namespace SourceGit.Views
};
var useMine = new MenuItem();
useMine.Icon = App.CreateMenuIcon("Icons.Local");
useMine.Icon = this.CreateMenuIcon("Icons.Local");
useMine.Click += async (_, e) =>
{
await vm.UseMineAsync(selectedUnstaged);
@@ -355,7 +355,7 @@ namespace SourceGit.Views
{
var mergeBuiltin = new MenuItem();
mergeBuiltin.Header = App.Text("ChangeCM.Merge");
mergeBuiltin.Icon = App.CreateMenuIcon("Icons.Conflict");
mergeBuiltin.Icon = this.CreateMenuIcon("Icons.Conflict");
mergeBuiltin.Click += async (_, e) =>
{
var head = await new Commands.QuerySingleCommit(repo.FullPath, "HEAD").GetResultAsync();
@@ -365,7 +365,7 @@ namespace SourceGit.Views
var mergeExternal = new MenuItem();
mergeExternal.Header = App.Text("ChangeCM.MergeExternal");
mergeExternal.Icon = App.CreateMenuIcon("Icons.OpenWith");
mergeExternal.Icon = this.CreateMenuIcon("Icons.OpenWith");
mergeExternal.Click += async (_, e) =>
{
await vm.UseExternalMergeToolAsync(change);
@@ -382,7 +382,7 @@ namespace SourceGit.Views
{
var stage = new MenuItem();
stage.Header = App.Text("FileCM.Stage");
stage.Icon = App.CreateMenuIcon("Icons.File.Add");
stage.Icon = this.CreateMenuIcon("Icons.File.Add");
stage.Tag = "Enter/Space";
stage.Click += async (_, e) =>
{
@@ -392,7 +392,7 @@ namespace SourceGit.Views
var discard = new MenuItem();
discard.Header = App.Text("FileCM.Discard");
discard.Icon = App.CreateMenuIcon("Icons.Undo");
discard.Icon = this.CreateMenuIcon("Icons.Undo");
discard.Tag = "Back/Delete";
discard.Click += (_, e) =>
{
@@ -402,7 +402,7 @@ namespace SourceGit.Views
var stash = new MenuItem();
stash.Header = App.Text("FileCM.Stash");
stash.Icon = App.CreateMenuIcon("Icons.Stashes.Add");
stash.Icon = this.CreateMenuIcon("Icons.Stashes.Add");
stash.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -413,7 +413,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -441,7 +441,7 @@ namespace SourceGit.Views
var assumeUnchanged = new MenuItem();
assumeUnchanged.Header = App.Text("FileCM.AssumeUnchanged");
assumeUnchanged.Icon = App.CreateMenuIcon("Icons.File.Ignore");
assumeUnchanged.Icon = this.CreateMenuIcon("Icons.File.Ignore");
assumeUnchanged.IsVisible = change.WorkTree != Models.ChangeState.Untracked;
assumeUnchanged.Click += async (_, e) =>
{
@@ -464,7 +464,7 @@ namespace SourceGit.Views
{
var addToIgnore = new MenuItem();
addToIgnore.Header = App.Text("WorkingCopy.AddToGitIgnore");
addToIgnore.Icon = App.CreateMenuIcon("Icons.GitIgnore");
addToIgnore.Icon = this.CreateMenuIcon("Icons.GitIgnore");
if (hasSelectedFolder)
{
@@ -524,7 +524,7 @@ namespace SourceGit.Views
{
var addToIgnore = new MenuItem();
addToIgnore.Header = App.Text("WorkingCopy.AddToGitIgnore");
addToIgnore.Icon = App.CreateMenuIcon("Icons.GitIgnore");
addToIgnore.Icon = this.CreateMenuIcon("Icons.GitIgnore");
var ignoreFolder = new MenuItem();
ignoreFolder.Header = App.Text("WorkingCopy.AddToGitIgnore.InFolder");
@@ -544,7 +544,7 @@ namespace SourceGit.Views
{
var lfs = new MenuItem();
lfs.Header = App.Text("GitLFS");
lfs.Icon = App.CreateMenuIcon("Icons.LFS");
lfs.Icon = this.CreateMenuIcon("Icons.LFS");
var isLFSFiltered = new Commands.IsLFSFiltered(repo.FullPath, change.Path).GetResult();
if (!isLFSFiltered)
@@ -576,7 +576,7 @@ namespace SourceGit.Views
var lfsLock = new MenuItem();
lfsLock.Header = App.Text("GitLFS.Locks.Lock");
lfsLock.Icon = App.CreateMenuIcon("Icons.Lock");
lfsLock.Icon = this.CreateMenuIcon("Icons.Lock");
lfsLock.IsEnabled = repo.Remotes.Count > 0;
if (repo.Remotes.Count == 1)
{
@@ -605,7 +605,7 @@ namespace SourceGit.Views
var lfsUnlock = new MenuItem();
lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock");
lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock");
lfsUnlock.Icon = this.CreateMenuIcon("Icons.Unlock");
lfsUnlock.IsEnabled = repo.Remotes.Count > 0;
if (repo.Remotes.Count == 1)
{
@@ -644,7 +644,7 @@ namespace SourceGit.Views
{
var history = new MenuItem();
history.Header = App.Text("DirHistories");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, e) =>
{
App.ShowWindow(new ViewModels.DirHistories(repo, selectedSingleFolder));
@@ -658,7 +658,7 @@ namespace SourceGit.Views
{
var history = new MenuItem();
history.Header = App.Text("FileHistory");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, e) =>
{
App.ShowWindow(new ViewModels.FileHistories(repo.FullPath, change.Path));
@@ -667,7 +667,7 @@ namespace SourceGit.Views
var blame = new MenuItem();
blame.Header = App.Text("Blame") + " (HEAD-only)";
blame.Icon = App.CreateMenuIcon("Icons.Blame");
blame.Icon = this.CreateMenuIcon("Icons.Blame");
blame.Click += async (_, ev) =>
{
var commit = await new Commands.QuerySingleCommit(repo.FullPath, "HEAD").GetResultAsync();
@@ -684,21 +684,21 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("CopyPath");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(hasSelectedFolder ? selectedSingleFolder : change.Path);
await this.CopyTextAsync(hasSelectedFolder ? selectedSingleFolder : change.Path);
e.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
await App.CopyTextAsync(hasSelectedFolder ? Native.OS.GetAbsPath(repo.FullPath, selectedSingleFolder) : path);
await this.CopyTextAsync(hasSelectedFolder ? Native.OS.GetAbsPath(repo.FullPath, selectedSingleFolder) : path);
e.Handled = true;
};
@@ -726,7 +726,7 @@ namespace SourceGit.Views
}
var useTheirs = new MenuItem();
useTheirs.Icon = App.CreateMenuIcon("Icons.Incoming");
useTheirs.Icon = this.CreateMenuIcon("Icons.Incoming");
useTheirs.Click += async (_, e) =>
{
await vm.UseTheirsAsync(selectedUnstaged);
@@ -734,7 +734,7 @@ namespace SourceGit.Views
};
var useMine = new MenuItem();
useMine.Icon = App.CreateMenuIcon("Icons.Local");
useMine.Icon = this.CreateMenuIcon("Icons.Local");
useMine.Click += async (_, e) =>
{
await vm.UseMineAsync(selectedUnstaged);
@@ -775,7 +775,7 @@ namespace SourceGit.Views
var dir = Path.Combine(repo.FullPath, selectedSingleFolder);
var explore = new MenuItem();
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.IsEnabled = Directory.Exists(dir);
explore.Click += (_, e) =>
{
@@ -788,7 +788,7 @@ namespace SourceGit.Views
var stage = new MenuItem();
stage.Header = App.Text("FileCM.StageMulti", selectedUnstaged.Count);
stage.Icon = App.CreateMenuIcon("Icons.File.Add");
stage.Icon = this.CreateMenuIcon("Icons.File.Add");
stage.Tag = "Enter/Space";
stage.Click += async (_, e) =>
{
@@ -798,7 +798,7 @@ namespace SourceGit.Views
var discard = new MenuItem();
discard.Header = App.Text("FileCM.DiscardMulti", selectedUnstaged.Count);
discard.Icon = App.CreateMenuIcon("Icons.Undo");
discard.Icon = this.CreateMenuIcon("Icons.Undo");
discard.Tag = "Back/Delete";
discard.Click += (_, e) =>
{
@@ -808,7 +808,7 @@ namespace SourceGit.Views
var stash = new MenuItem();
stash.Header = App.Text("FileCM.StashMulti", selectedUnstaged.Count);
stash.Icon = App.CreateMenuIcon("Icons.Stashes.Add");
stash.Icon = this.CreateMenuIcon("Icons.Stashes.Add");
stash.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -819,7 +819,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -863,12 +863,12 @@ namespace SourceGit.Views
var addToIgnore = new MenuItem();
addToIgnore.Header = App.Text("WorkingCopy.AddToGitIgnore");
addToIgnore.Icon = App.CreateMenuIcon("Icons.GitIgnore");
addToIgnore.Icon = this.CreateMenuIcon("Icons.GitIgnore");
addToIgnore.Items.Add(ignoreFolder);
var history = new MenuItem();
history.Header = App.Text("DirHistories");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, e) =>
{
App.ShowWindow(new ViewModels.DirHistories(repo, selectedSingleFolder));
@@ -877,21 +877,21 @@ namespace SourceGit.Views
var copy = new MenuItem();
copy.Header = App.Text("CopyPath");
copy.Icon = App.CreateMenuIcon("Icons.Copy");
copy.Icon = this.CreateMenuIcon("Icons.Copy");
copy.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copy.Click += async (_, e) =>
{
await App.CopyTextAsync(selectedSingleFolder);
await this.CopyTextAsync(selectedSingleFolder);
e.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
await App.CopyTextAsync(Native.OS.GetAbsPath(repo.FullPath, selectedSingleFolder));
await this.CopyTextAsync(Native.OS.GetAbsPath(repo.FullPath, selectedSingleFolder));
e.Handled = true;
};
@@ -922,7 +922,7 @@ namespace SourceGit.Views
if (services.Count > 0)
{
ai = new MenuItem();
ai.Icon = App.CreateMenuIcon("Icons.AIAssist");
ai.Icon = this.CreateMenuIcon("Icons.AIAssist");
ai.Header = App.Text("ChangeCM.GenerateCommitMessage");
if (services.Count == 1)
@@ -960,7 +960,7 @@ namespace SourceGit.Views
var openWithMerger = new MenuItem();
openWithMerger.Header = App.Text("OpenInExternalMergeTool");
openWithMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Icon = this.CreateMenuIcon("Icons.OpenWith");
openWithMerger.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+D" : "Ctrl+Shift+D";
openWithMerger.Click += (_, ev) =>
{
@@ -971,7 +971,7 @@ namespace SourceGit.Views
var explore = new MenuItem();
explore.IsEnabled = File.Exists(path) || Directory.Exists(path);
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.Click += (_, e) =>
{
var target = hasSelectedFolder ? Native.OS.GetAbsPath(repo.FullPath, selectedSingleFolder) : path;
@@ -981,7 +981,7 @@ namespace SourceGit.Views
var unstage = new MenuItem();
unstage.Header = App.Text("FileCM.Unstage");
unstage.Icon = App.CreateMenuIcon("Icons.File.Remove");
unstage.Icon = this.CreateMenuIcon("Icons.File.Remove");
unstage.Tag = "Enter/Space";
unstage.Click += async (_, e) =>
{
@@ -991,7 +991,7 @@ namespace SourceGit.Views
var stash = new MenuItem();
stash.Header = App.Text("FileCM.Stash");
stash.Icon = App.CreateMenuIcon("Icons.Stashes.Add");
stash.Icon = this.CreateMenuIcon("Icons.Stashes.Add");
stash.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1002,7 +1002,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -1041,11 +1041,11 @@ namespace SourceGit.Views
{
var lfs = new MenuItem();
lfs.Header = App.Text("GitLFS");
lfs.Icon = App.CreateMenuIcon("Icons.LFS");
lfs.Icon = this.CreateMenuIcon("Icons.LFS");
var lfsLock = new MenuItem();
lfsLock.Header = App.Text("GitLFS.Locks.Lock");
lfsLock.Icon = App.CreateMenuIcon("Icons.Lock");
lfsLock.Icon = this.CreateMenuIcon("Icons.Lock");
lfsLock.IsEnabled = repo.Remotes.Count > 0;
if (repo.Remotes.Count == 1)
{
@@ -1074,7 +1074,7 @@ namespace SourceGit.Views
var lfsUnlock = new MenuItem();
lfsUnlock.Header = App.Text("GitLFS.Locks.Unlock");
lfsUnlock.Icon = App.CreateMenuIcon("Icons.Unlock");
lfsUnlock.Icon = this.CreateMenuIcon("Icons.Unlock");
lfsUnlock.IsEnabled = repo.Remotes.Count > 0;
if (repo.Remotes.Count == 1)
{
@@ -1115,7 +1115,7 @@ namespace SourceGit.Views
{
var history = new MenuItem();
history.Header = App.Text("DirHistories");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, e) =>
{
App.ShowWindow(new ViewModels.DirHistories(repo, selectedSingleFolder));
@@ -1129,7 +1129,7 @@ namespace SourceGit.Views
{
var history = new MenuItem();
history.Header = App.Text("FileHistory");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, e) =>
{
App.ShowWindow(new ViewModels.FileHistories(repo.FullPath, change.Path));
@@ -1138,7 +1138,7 @@ namespace SourceGit.Views
var blame = new MenuItem();
blame.Header = App.Text("Blame") + " (HEAD-only)";
blame.Icon = App.CreateMenuIcon("Icons.Blame");
blame.Icon = this.CreateMenuIcon("Icons.Blame");
blame.Click += async (_, e) =>
{
var commit = await new Commands.QuerySingleCommit(repo.FullPath, "HEAD").GetResultAsync();
@@ -1155,22 +1155,22 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, e) =>
{
await App.CopyTextAsync(hasSelectedFolder ? selectedSingleFolder : change.Path);
await this.CopyTextAsync(hasSelectedFolder ? selectedSingleFolder : change.Path);
e.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
var target = hasSelectedFolder ? Native.OS.GetAbsPath(repo.FullPath, selectedSingleFolder) : path;
await App.CopyTextAsync(target);
await this.CopyTextAsync(target);
e.Handled = true;
};
@@ -1185,7 +1185,7 @@ namespace SourceGit.Views
var explore = new MenuItem();
explore.IsEnabled = Directory.Exists(dir);
explore.Header = App.Text("RevealFile");
explore.Icon = App.CreateMenuIcon("Icons.Explore");
explore.Icon = this.CreateMenuIcon("Icons.Explore");
explore.Click += (_, e) =>
{
Native.OS.OpenInFileManager(dir);
@@ -1198,7 +1198,7 @@ namespace SourceGit.Views
var unstage = new MenuItem();
unstage.Header = App.Text("FileCM.UnstageMulti", selectedStaged.Count);
unstage.Icon = App.CreateMenuIcon("Icons.File.Remove");
unstage.Icon = this.CreateMenuIcon("Icons.File.Remove");
unstage.Tag = "Enter/Space";
unstage.Click += async (_, e) =>
{
@@ -1208,7 +1208,7 @@ namespace SourceGit.Views
var stash = new MenuItem();
stash.Header = App.Text("FileCM.StashMulti", selectedStaged.Count);
stash.Icon = App.CreateMenuIcon("Icons.Stashes.Add");
stash.Icon = this.CreateMenuIcon("Icons.Stashes.Add");
stash.Click += (_, e) =>
{
if (repo.CanCreatePopup())
@@ -1219,7 +1219,7 @@ namespace SourceGit.Views
var patch = new MenuItem();
patch.Header = App.Text("FileCM.SaveAsPatch");
patch.Icon = App.CreateMenuIcon("Icons.Save");
patch.Icon = this.CreateMenuIcon("Icons.Save");
patch.Click += async (_, e) =>
{
var storageProvider = TopLevel.GetTopLevel(this)?.StorageProvider;
@@ -1259,7 +1259,7 @@ namespace SourceGit.Views
{
var history = new MenuItem();
history.Header = App.Text("DirHistories");
history.Icon = App.CreateMenuIcon("Icons.Histories");
history.Icon = this.CreateMenuIcon("Icons.Histories");
history.Click += (_, e) =>
{
App.ShowWindow(new ViewModels.DirHistories(repo, selectedSingleFolder));
@@ -1268,21 +1268,21 @@ namespace SourceGit.Views
var copyPath = new MenuItem();
copyPath.Header = App.Text("CopyPath");
copyPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyPath.Tag = OperatingSystem.IsMacOS() ? "⌘+C" : "Ctrl+C";
copyPath.Click += async (_, e) =>
{
await App.CopyTextAsync(selectedSingleFolder);
await this.CopyTextAsync(selectedSingleFolder);
e.Handled = true;
};
var copyFullPath = new MenuItem();
copyFullPath.Header = App.Text("CopyFullPath");
copyFullPath.Icon = App.CreateMenuIcon("Icons.Copy");
copyFullPath.Icon = this.CreateMenuIcon("Icons.Copy");
copyFullPath.Tag = OperatingSystem.IsMacOS() ? "⌘+⇧+C" : "Ctrl+Shift+C";
copyFullPath.Click += async (_, e) =>
{
await App.CopyTextAsync(Native.OS.GetAbsPath(repo.FullPath, selectedSingleFolder));
await this.CopyTextAsync(Native.OS.GetAbsPath(repo.FullPath, selectedSingleFolder));
e.Handled = true;
};
@@ -1301,7 +1301,7 @@ namespace SourceGit.Views
{
var openWith = new MenuItem();
openWith.Header = App.Text("Open");
openWith.Icon = App.CreateMenuIcon("Icons.OpenWith");
openWith.Icon = this.CreateMenuIcon("Icons.OpenWith");
openWith.IsEnabled = File.Exists(fullpath);
if (openWith.IsEnabled)
{
@@ -1349,13 +1349,13 @@ namespace SourceGit.Views
var target = new Models.CustomActionTargetFile(path, null);
var custom = new MenuItem();
custom.Header = App.Text("FileCM.CustomAction");
custom.Icon = App.CreateMenuIcon("Icons.Action");
custom.Icon = this.CreateMenuIcon("Icons.Action");
foreach (var action in actions)
{
var (dup, label) = action;
var item = new MenuItem();
item.Icon = App.CreateMenuIcon("Icons.Action");
item.Icon = this.CreateMenuIcon("Icons.Action");
item.Header = label;
item.Click += async (_, e) =>
{