public MainWindow() { InitializeComponent(); //Canvas.SetLeft(playListCanvas, playListCanvas.Width - 20); // SetCanvesAutoEnter_Right_SreenWhenMouseLeave(playListCanvas, 40); // SetCanvesAutoOut_Right_SreenWhenMouseEnter(playListCanvas); // var zipRepertory = new ZipRepertory(); // var filename = @"G:\Work\bak\9月-2无logo.zip"; var files = GetAllFiles(@"G:\Res"); var Videos = (from a in files where a.Contains(".dat") || a.Contains(".mov") || a.Contains("Video") select a).ToList <string>(); for (int i = 0; i < Videos.Count; i++) { _viewModel.PlayLists.Add(new PlayListNode(Videos[i])); } // CurrentStream = zipRepertory.GetVideoStream(filename, ZipHashCode.HashKey); VlcHelper.Initialize(VlcPlayer); // var temp = CurrentStream.Stream.Entries.FirstOrDefault(CurrentStream.check); // VlcPlayer.SourceProvider.MediaPlayer.Play(temp.OpenEntryStream()); VlcPlayer.SourceProvider.MediaPlayer.Playing += MediaPlayer_Playing;; VlcPlayer.SourceProvider.MediaPlayer.PositionChanged += MediaPlayer_PositionChanged; this.DataContext = _viewModel; }
private static void Main(string[] args) { //uninstall? string[] arguments = Environment.GetCommandLineArgs(); foreach (string argument in arguments) { if (argument.Split('=')[0].ToLower() == "/u") { string guid = argument.Split('=')[1]; string path = Environment.GetFolderPath(Environment.SpecialFolder.System); var si = new ProcessStartInfo(path + "/msiexec.exe", "/x " + guid); Process.Start(si); Application.Exit(); return; } } try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool firstInstance; Mutex = new Mutex(false, "iSpy", out firstInstance); string executableName = Application.ExecutablePath; var executableFileInfo = new FileInfo(executableName); ExecutableDirectory = executableFileInfo.DirectoryName; bool ei = (!Directory.Exists(AppDataPath) || !Directory.Exists(AppDataPath + @"XML\") || !File.Exists(AppDataPath + @"XML\config.xml")); if (ei) { EnsureInstall(true); } bool silentstartup = false; string command = ""; if (args.Length > 0) { //if (args[0].ToLower().Trim() == "-firstrun" && !ei) // EnsureInstall(false); if (args[0].ToLower().Trim() == "-reset" && !ei) { if (MessageBox.Show("Reset iSpy? This will overwrite all your settings.", "Confirm", MessageBoxButtons.OKCancel) == DialogResult.OK) { EnsureInstall(true); } } if (args[0].ToLower().Trim() == "-silent" || args[0].ToLower().Trim('\\') == "s") { silentstartup = true; } else { for (int index = 0; index < args.Length; index++) { string s = args[index]; command += s + " "; } } } if (!firstInstance) { if (!String.IsNullOrEmpty(command)) { File.WriteAllText(AppDataPath + "external_command.txt", command); //ensures pickup by filesystemwatcher Thread.Sleep(1000); } else { MessageBox.Show(LocRm.GetString("iSpyRunning"), LocRm.GetString("Note"), MessageBoxButtons.OK, MessageBoxIcon.Error); } Application.Exit(); Mutex.Close(); Mutex.Dispose(); return; } File.WriteAllText(AppDataPath + "external_command.txt", ""); //VLC integration if (VlcHelper.VlcInstalled) { VlcHelper.AddVlcToPath(); } WriterMutex = new Mutex(); Application.ThreadException += ApplicationThreadException; var mf = new MainForm(silentstartup, command); Application.Run(mf); Mutex.Close(); WriterMutex.Close(); Mutex.Dispose(); WriterMutex.Dispose(); } catch (Exception ex) { try { MainForm.LogExceptionToFile(ex); } catch { } while (ex.InnerException != null) { try { MainForm.LogExceptionToFile(ex); } catch { } } } }
private static void Main(string[] args) { //uninstall? string[] arguments = Environment.GetCommandLineArgs(); foreach (string argument in arguments) { if (argument.Split('=')[0].ToLower() == "/u") { string guid = argument.Split('=')[1]; string path = Environment.GetFolderPath(Environment.SpecialFolder.System); var si = new ProcessStartInfo(path + "/msiexec.exe", "/x " + guid); Process.Start(si); Application.Exit(); return; } } var version = Environment.OSVersion.Version; bool canrun = true; switch (version.Major) { case 5: canrun = false; break; case 6: switch (version.Minor) { case 0: canrun = false; break; } break; } if (!canrun) { MessageBox.Show("iSpy is not supported on this operating system. Please uninstall and download v6.5.8.0 instead. Your settings will be saved."); Process.Start("http://www.ispyconnect.com/download.aspx"); return; } try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool firstInstance = true; var me = Process.GetCurrentProcess(); var arrProcesses = Process.GetProcessesByName(me.ProcessName); //only want to do this if not passing in a command if (arrProcesses.Length > 1) { firstInstance = false; } string executableName = Application.ExecutablePath; var executableFileInfo = new FileInfo(executableName); ExecutableDirectory = executableFileInfo.DirectoryName; bool ei = (!Directory.Exists(AppDataPath) || !Directory.Exists(AppDataPath + @"XML\") || !File.Exists(AppDataPath + @"XML\config.xml")); if (ei) { EnsureInstall(true); } else { try { var o = Registry.CurrentUser.OpenSubKey(@"Software\ispy", true); if (o?.GetValue("firstrun") != null) { o.DeleteValue("firstrun"); //copy over updated static files on first run of new install EnsureInstall(false); } } catch (Exception ex) { Logger.LogException(ex, "startup"); } } VlcHelper.FindVLC(); bool silentstartup = false; string command = ""; if (args.Length > 0) { if (args[0].ToLower().Trim() == "-reset" && !ei) { if (firstInstance) { if ( MessageBox.Show("Reset iSpy? This will overwrite all your settings.", "Confirm", MessageBoxButtons.OKCancel) == DialogResult.OK) { EnsureInstall(true); } } else { MessageBox.Show("Please exit iSpy before resetting it."); } } if (args[0].ToLower().Trim() == "-silent" || args[0].ToLower().Trim('\\') == "s") { if (firstInstance) { silentstartup = true; } } else { command = args.Aggregate(command, (current, s) => current + (s + " ")); } } if (!firstInstance) { if (!string.IsNullOrEmpty(command)) { File.WriteAllText(AppDataPath + "external_command.txt", command); Thread.Sleep(1000); } else { //show form File.WriteAllText(AppDataPath + "external_command.txt", "showform"); Thread.Sleep(1000); } Application.Exit(); return; } if (IntPtr.Size == 8) { Platform = "x64"; } File.WriteAllText(AppDataPath + "external_command.txt", ""); // in case our https certificate ever expires or there is some other issue ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate; ServicePointManager.Expect100Continue = false; ServicePointManager.DefaultConnectionLimit = 1000; //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; FfmpegMutex = new Mutex(); Application.ThreadException += ApplicationThreadException; AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; _previousExecutionState = NativeCalls.SetThreadExecutionState(NativeCalls.EsContinuous | NativeCalls.EsSystemRequired); AppIdle = new WinFormsAppIdleHandler(); var mf = new MainForm(silentstartup, command); GC.KeepAlive(FfmpegMutex); Application.Run(mf); FfmpegMutex.Close(); ffmpeg.avformat_network_deinit(); if (_previousExecutionState != 0) { NativeCalls.SetThreadExecutionState(_previousExecutionState); } } catch (Exception ex) { try { Logger.LogException(ex); } catch { } while (ex.InnerException != null) { try { Logger.LogException(ex); } catch { } ex = ex.InnerException; } } try { Logger.WriteLogs(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static void Main(string[] args) { //uninstall? string[] arguments = Environment.GetCommandLineArgs(); foreach (string argument in arguments) { if (argument.Split('=')[0].ToLower() == "/u") { string guid = argument.Split('=')[1]; string path = Environment.GetFolderPath(Environment.SpecialFolder.System); var si = new ProcessStartInfo(path + "/msiexec.exe", "/x " + guid); Process.Start(si); Application.Exit(); return; } } try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); bool firstInstance = true; //Mutex = new Mutex(false, "iSpy", out firstInstance); var me = Process.GetCurrentProcess(); var arrProcesses = Process.GetProcessesByName(me.ProcessName); if (arrProcesses.Length > 1) { File.WriteAllText(AppDataPath + "external_command.txt", "showform"); //ensures pickup by filesystemwatcher Thread.Sleep(1000); firstInstance = false; } string executableName = Application.ExecutablePath; var executableFileInfo = new FileInfo(executableName); ExecutableDirectory = executableFileInfo.DirectoryName; bool ei = (!Directory.Exists(AppDataPath) || !Directory.Exists(AppDataPath + @"XML\") || !File.Exists(AppDataPath + @"XML\config.xml")); if (ei) { EnsureInstall(true); } bool silentstartup = false; string command = ""; if (args.Length > 0) { //if (args[0].ToLower().Trim() == "-firstrun" && !ei) // EnsureInstall(false); if (args[0].ToLower().Trim() == "-reset" && !ei) { if (firstInstance) { if ( MessageBox.Show("Reset iSpy? This will overwrite all your settings.", "Confirm", MessageBoxButtons.OKCancel) == DialogResult.OK) { EnsureInstall(true); } } else { MessageBox.Show("Please exit iSpy before resetting it."); } } if (args[0].ToLower().Trim() == "-silent" || args[0].ToLower().Trim('\\') == "s") { if (firstInstance) { silentstartup = true; } } else { for (int index = 0; index < args.Length; index++) { string s = args[index]; command += s + " "; } } } if (!firstInstance) { if (!String.IsNullOrEmpty(command)) { File.WriteAllText(AppDataPath + "external_command.txt", command); //ensures pickup by filesystemwatcher Thread.Sleep(1000); } Application.Exit(); return; } if (VlcHelper.VlcInstalled) { VlcHelper.AddVlcToPath(); } File.WriteAllText(AppDataPath + "external_command.txt", ""); // in case our https certificate ever expires or there is some other issue ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; WriterMutex = new Mutex(); Application.ThreadException += ApplicationThreadException; var mf = new MainForm(silentstartup, command); Application.Run(mf); WriterMutex.Close(); WriterMutex.Dispose(); } catch (Exception ex) { try { Log.Error("", ex);//MainForm.LogExceptionToFile(ex); } catch { } while (ex.InnerException != null) { try { Log.Error("", ex);//MainForm.LogExceptionToFile(ex); } catch { } } } }
public MainForm() { this.InitializeComponent(); VlcHelper.FixupVlcControl(this.VlcControl_Main); }