forked from amkovkov/GranuSightSoftware2
1) GSS2.Core: - strip prefixes in GSS2.Core.Analysis.AmineContent namespace class names - add IEnumerable<double>.Variance extension - remake analysis + update database so not needed to store all every file, calibration data also stored in database, also currently capturing images stored in system temporary directory and rewriting every time 2) GSS.UI.Core: AsyncImageRecordViewModel make zoom and pans public 3) GSS: - remove image-storage-clear command - remove ResultsView and ResultsViewModel, results presented in analysis - rework calibration views - add analysis views - add text and number fields editors view - add confirmation view on danger buttons
109 lines
3.6 KiB
C#
109 lines
3.6 KiB
C#
namespace GSS2;
|
|
|
|
public partial class Program
|
|
{
|
|
// Аргументы командной строки
|
|
private static List<string> _args = new List<string>();
|
|
public static string[] Args
|
|
{
|
|
get
|
|
{
|
|
var copy = new string[_args.Count()];
|
|
_args.CopyTo(copy);
|
|
return copy;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Точка входа
|
|
/// </summary>
|
|
[STAThread]
|
|
public static int Main(string[] args)
|
|
{
|
|
_args = args.ToList();
|
|
|
|
#if DEBUG
|
|
WaitDebuggerIfNeeded();
|
|
#endif
|
|
|
|
// Создаём обработчик аргументов командной строки
|
|
var rootCommand = Commands.UI.GetCommand();
|
|
Commands.CameraTuning.RegisterCommand(rootCommand);
|
|
Commands.Capture.RegisterCommand(rootCommand);
|
|
|
|
// Обрабатываем аргументы
|
|
var parseResult = rootCommand?.Parse(_args);
|
|
|
|
// Обрабатываем ошибки
|
|
if (parseResult is null)
|
|
{
|
|
Console.Error.WriteLine("Неизвестная ошибка при обработке аргументов командной строки.");
|
|
Environment.Exit(1);
|
|
}
|
|
if (parseResult.Errors.Count() != 0)
|
|
{
|
|
Console.Error.WriteLine(
|
|
(parseResult.Errors.Count() == 1 ? "Ошибка" : "Ошибки") +
|
|
" при обработке аргументов командной строки:"
|
|
);
|
|
foreach (var parseError in parseResult.Errors)
|
|
Console.Error.WriteLine(parseError.Message);
|
|
Environment.Exit(1);
|
|
}
|
|
|
|
// Исполняем команду
|
|
Console.WriteLine("Нажмите Ctrl+C для выхода.");
|
|
try
|
|
{
|
|
return parseResult.Invoke();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.Error.WriteLine("Ошибка при выполнении программы:");
|
|
Console.Write(ex.Message);
|
|
Console.Write(ex.StackTrace);
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Если в <see cref="_args"/> присутствует аргумент <i>--debug</i>,
|
|
/// то удаляет <i>--debug</i> из <see cref="_args"/>, выводит информацию о процессе в консоль и ожидает подключения отладчика
|
|
/// </summary>
|
|
private static void WaitDebuggerIfNeeded()
|
|
{
|
|
if (System.Diagnostics.Debugger.IsAttached)
|
|
return;
|
|
|
|
if (!_args.Contains("--debug"))
|
|
return;
|
|
|
|
_args.Remove("--debug");
|
|
|
|
bool keepWaiting = true;
|
|
|
|
void CancelWait(object? _, ConsoleCancelEventArgs ea)
|
|
{
|
|
ea.Cancel = true;
|
|
keepWaiting = false;
|
|
Console.WriteLine("\nОперация отменена пользователем.");
|
|
Environment.Exit(0);
|
|
}
|
|
Console.CancelKeyPress += CancelWait;
|
|
|
|
Console.WriteLine("Ожидание подключения отладчика.");
|
|
Console.WriteLine($"Имя процесса: {Environment.ProcessPath}");
|
|
Console.WriteLine($"Id процесса: {Environment.ProcessId}");
|
|
Console.WriteLine($"Id потока: {Environment.CurrentManagedThreadId}");
|
|
Console.WriteLine("Нажмите Ctrl+C для выхода.");
|
|
|
|
while (!System.Diagnostics.Debugger.IsAttached && keepWaiting)
|
|
Thread.Sleep(100);
|
|
|
|
if (System.Diagnostics.Debugger.IsAttached)
|
|
System.Diagnostics.Debugger.Break();
|
|
|
|
Console.CancelKeyPress -= CancelWait;
|
|
}
|
|
}
|