103 lines
2.9 KiB
C#
103 lines
2.9 KiB
C#
using System;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
using VideoReader.Properties;
|
|
|
|
namespace VideoReader;
|
|
|
|
internal static class Program
|
|
{
|
|
public static int FrameRate = 30;
|
|
|
|
public static string log_file = "";
|
|
|
|
public static string[] Arg;
|
|
|
|
[STAThread]
|
|
private static void Main(string[] arg)
|
|
{
|
|
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
|
|
Arg = arg;
|
|
byte chenal = 0;
|
|
foreach (string text in arg)
|
|
{
|
|
string s = text;
|
|
if (text.StartsWith("-c"))
|
|
{
|
|
s = text.Trim().Skip(2).ToString();
|
|
}
|
|
try
|
|
{
|
|
chenal = (byte)int.Parse(s);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
Settings.Default.Chenal = chenal;
|
|
((SettingsBase)Settings.Default).Save();
|
|
new Mutex(initiallyOwned: false, $"Start_current_video_Reader_{Settings.Default.Chenal}", out var createdNew);
|
|
if (!createdNew)
|
|
{
|
|
MessageBox.Show($"Уже запущен! ({Settings.Default.Chenal})");
|
|
return;
|
|
}
|
|
switch (Environment.OSVersion.Platform)
|
|
{
|
|
case PlatformID.Win32S:
|
|
case PlatformID.Win32Windows:
|
|
case PlatformID.Win32NT:
|
|
{
|
|
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
InteropHelper.RegisterLibrariesSearchPath(string.Format("{0}/FFmpeg/bin/{1}", directoryName, Environment.Is64BitProcess ? "x64" : "x86"));
|
|
break;
|
|
}
|
|
case PlatformID.Unix:
|
|
case PlatformID.MacOSX:
|
|
InteropHelper.RegisterLibrariesSearchPath(Environment.GetEnvironmentVariable("LD_LIBRARY_PATH"));
|
|
break;
|
|
}
|
|
Application.EnableVisualStyles();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.ThreadException += Application_ThreadException;
|
|
Application.Run((Form)(object)new Form1());
|
|
}
|
|
|
|
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
|
{
|
|
Console.WriteLine(e.Exception.Message);
|
|
Console.WriteLine(e.Exception.StackTrace);
|
|
using StreamWriter streamWriter = new StreamWriter($"{Directory.GetCurrentDirectory()}\\{DateTime.Now:yyMMdd}_fatal.err", append: true, Encoding.Default);
|
|
streamWriter.Write($"{DateTime.Now:HH:mm:ss:fff} : ");
|
|
streamWriter.Write(e);
|
|
streamWriter.WriteLine();
|
|
streamWriter.Close();
|
|
}
|
|
|
|
public static void ErrWrite(Exception e)
|
|
{
|
|
string text = e.ToString();
|
|
File.AppendAllText(log_file + ".err", $"{DateTime.Now:HH:mm:ss.fffffff}:{text}/n");
|
|
Console.WriteLine(text);
|
|
}
|
|
|
|
public static void ErrPrim(string pref, string suff)
|
|
{
|
|
StreamWriter streamWriter = new StreamWriter(log_file + ".err", append: true);
|
|
streamWriter.WriteLine($"{DateTime.Now:HH:mm:ss.fffffff}: +++ {pref}:{suff}");
|
|
streamWriter.Close();
|
|
}
|
|
|
|
public static void LogWrite(string prim, string str)
|
|
{
|
|
StreamWriter streamWriter = new StreamWriter(log_file + ".log", append: true);
|
|
streamWriter.WriteLine($"{DateTime.Now:HH:mm:ss.fffffff}:{prim}:{str}");
|
|
streamWriter.Close();
|
|
}
|
|
}
|