mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 05:35:00 +00:00
code_style: arrange methods in App.axaml.cs
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
9560496c7b
commit
67f4330dd4
1 changed files with 45 additions and 45 deletions
|
@ -77,6 +77,31 @@ namespace SourceGit
|
||||||
Native.OS.SetupApp(builder);
|
Native.OS.SetupApp(builder);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void LogException(Exception ex)
|
||||||
|
{
|
||||||
|
if (ex == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var builder = new StringBuilder();
|
||||||
|
builder.Append($"Crash::: {ex.GetType().FullName}: {ex.Message}\n\n");
|
||||||
|
builder.Append("----------------------------\n");
|
||||||
|
builder.Append($"Version: {Assembly.GetExecutingAssembly().GetName().Version}\n");
|
||||||
|
builder.Append($"OS: {Environment.OSVersion}\n");
|
||||||
|
builder.Append($"Framework: {AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}\n");
|
||||||
|
builder.Append($"Source: {ex.Source}\n");
|
||||||
|
builder.Append($"Thread Name: {Thread.CurrentThread.Name ?? "Unnamed"}\n");
|
||||||
|
builder.Append($"User: {Environment.UserName}\n");
|
||||||
|
builder.Append($"App Start Time: {Process.GetCurrentProcess().StartTime}\n");
|
||||||
|
builder.Append($"Exception Time: {DateTime.Now}\n");
|
||||||
|
builder.Append($"Memory Usage: {Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024} MB\n");
|
||||||
|
builder.Append($"---------------------------\n\n");
|
||||||
|
builder.Append(ex);
|
||||||
|
|
||||||
|
var time = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||||
|
var file = Path.Combine(Native.OS.DataDir, $"crash_{time}.log");
|
||||||
|
File.WriteAllText(file, builder.ToString());
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Utility Functions
|
#region Utility Functions
|
||||||
|
@ -181,8 +206,8 @@ namespace SourceGit
|
||||||
app._fontsOverrides = null;
|
app._fontsOverrides = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultFont = FixFontFamilyName(defaultFont);
|
defaultFont = app.FixFontFamilyName(defaultFont);
|
||||||
monospaceFont = FixFontFamilyName(monospaceFont);
|
monospaceFont = app.FixFontFamilyName(monospaceFont);
|
||||||
|
|
||||||
var resDic = new ResourceDictionary();
|
var resDic = new ResourceDictionary();
|
||||||
if (!string.IsNullOrEmpty(defaultFont))
|
if (!string.IsNullOrEmpty(defaultFont))
|
||||||
|
@ -328,31 +353,6 @@ namespace SourceGit
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static void LogException(Exception ex)
|
|
||||||
{
|
|
||||||
if (ex == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var builder = new StringBuilder();
|
|
||||||
builder.Append($"Crash::: {ex.GetType().FullName}: {ex.Message}\n\n");
|
|
||||||
builder.Append("----------------------------\n");
|
|
||||||
builder.Append($"Version: {Assembly.GetExecutingAssembly().GetName().Version}\n");
|
|
||||||
builder.Append($"OS: {Environment.OSVersion}\n");
|
|
||||||
builder.Append($"Framework: {AppDomain.CurrentDomain.SetupInformation.TargetFrameworkName}\n");
|
|
||||||
builder.Append($"Source: {ex.Source}\n");
|
|
||||||
builder.Append($"Thread Name: {Thread.CurrentThread.Name ?? "Unnamed"}\n");
|
|
||||||
builder.Append($"User: {Environment.UserName}\n");
|
|
||||||
builder.Append($"App Start Time: {Process.GetCurrentProcess().StartTime}\n");
|
|
||||||
builder.Append($"Exception Time: {DateTime.Now}\n");
|
|
||||||
builder.Append($"Memory Usage: {Process.GetCurrentProcess().PrivateMemorySize64 / 1024 / 1024} MB\n");
|
|
||||||
builder.Append($"---------------------------\n\n");
|
|
||||||
builder.Append(ex);
|
|
||||||
|
|
||||||
var time = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
|
||||||
var file = Path.Combine(Native.OS.DataDir, $"crash_{time}.log");
|
|
||||||
File.WriteAllText(file, builder.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool TryLaunchAsRebaseTodoEditor(string[] args, out int exitCode)
|
private static bool TryLaunchAsRebaseTodoEditor(string[] args, out int exitCode)
|
||||||
{
|
{
|
||||||
exitCode = -1;
|
exitCode = -1;
|
||||||
|
@ -440,24 +440,6 @@ namespace SourceGit
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string FixFontFamilyName(string input)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(input))
|
|
||||||
return string.Empty;
|
|
||||||
|
|
||||||
var parts = input.Split(',');
|
|
||||||
var trimmed = new List<string>();
|
|
||||||
|
|
||||||
foreach (var part in parts)
|
|
||||||
{
|
|
||||||
var t = part.Trim();
|
|
||||||
if (!string.IsNullOrEmpty(t))
|
|
||||||
trimmed.Add(t);
|
|
||||||
}
|
|
||||||
|
|
||||||
return trimmed.Count > 0 ? string.Join(',', trimmed) : string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool TryLaunchAsCoreEditor(IClassicDesktopStyleApplicationLifetime desktop)
|
private bool TryLaunchAsCoreEditor(IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
var args = desktop.Args;
|
var args = desktop.Args;
|
||||||
|
@ -567,6 +549,24 @@ namespace SourceGit
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string FixFontFamilyName(string input)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(input))
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
var parts = input.Split(',');
|
||||||
|
var trimmed = new List<string>();
|
||||||
|
|
||||||
|
foreach (var part in parts)
|
||||||
|
{
|
||||||
|
var t = part.Trim();
|
||||||
|
if (!string.IsNullOrEmpty(t))
|
||||||
|
trimmed.Add(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
return trimmed.Count > 0 ? string.Join(',', trimmed) : string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
private ViewModels.Launcher _launcher = null;
|
private ViewModels.Launcher _launcher = null;
|
||||||
private ResourceDictionary _activeLocale = null;
|
private ResourceDictionary _activeLocale = null;
|
||||||
private ResourceDictionary _themeOverrides = null;
|
private ResourceDictionary _themeOverrides = null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue