예제 #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Xpcom.Initialize("Firefox");
            Util.DataFolder = Path.Combine(Util.DataFolder, Application.CompanyName, Application.ProductName);
            Logger.Init(Path.Combine(Util.DataFolder, Application.ProductVersion, DateTime.Now.ToString("s").Replace(":", "-")), true);
            Logger.WriteEvent("Launch {0} {1}", Application.ProductName, Application.ProductVersion);
            AddAnySample();
            var randomName = Path.GetTempFileName();

            if (File.Exists(randomName))
            {
                File.Delete(randomName);
            }
            var indexFullName = GetResource.CreateResources(Path.GetFileNameWithoutExtension(randomName));

            Util.Folder = Path.GetDirectoryName(indexFullName);
            GetResource.AddLocalization(Util.Folder);
            var startInfo = new ProcessStartInfo
            {
                FileName               = "mono",
                Arguments              = $@"SimpleServer.exe 3010 ""{Util.Folder}""",
                WindowStyle            = ProcessWindowStyle.Hidden,
                RedirectStandardOutput = true,
                UseShellExecute        = false
            };

            using (var reactProcess = new Process {
                StartInfo = startInfo
            })
            {
                reactProcess.Start();
                var f = new Form {
                    Size = new Size(1250, 722), MinimumSize = new Size(1055, 270), WindowState = FormWindowState.Maximized
                };
                _browser = new TrappingGecko {
                    Dock = DockStyle.Fill, UseHttpActivityObserver = true
                };
                f.Text = $"{Application.ProductName}  {Application.ProductVersion}";
                f.Controls.Add(_browser);
                var portAddr = GetPortAddr(reactProcess);
                _browser.Navigate($"http://localhost:{portAddr}");
                Application.Run(f);
                reactProcess.Kill();
                reactProcess.WaitForExit();
            }

            var apiFolder = Path.Combine(Util.Folder, "api");

            if (Directory.Exists(apiFolder))
            {
                Directory.Delete(apiFolder, true);                      // remove all api related files
            }
            foreach (var fullPath in Util.SupportFile)
            {
                File.Delete(fullPath);
                Util.DeleteFolder(fullPath);
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Xpcom.Initialize("Firefox");
            var randomName = Path.GetTempFileName();

            if (File.Exists(randomName))
            {
                File.Delete(randomName);
            }
            var indexFullName = CreateResources(Path.GetFileNameWithoutExtension(randomName));

            AddLocalization(Path.GetDirectoryName(indexFullName));
            var startInfo = new ProcessStartInfo
            {
                FileName               = "SimpleServer.exe",
                Arguments              = $@"3010 ""{Path.GetDirectoryName(indexFullName)}""",
                WindowStyle            = ProcessWindowStyle.Hidden,
                RedirectStandardOutput = true,
                UseShellExecute        = false
            };

            using (var reactProcess = new Process {
                StartInfo = startInfo
            })
            {
                reactProcess.Start();
                var f = new Form {
                    Size = new Size(1024, 800)
                };
                f.Icon   = Resources.transcriber7;
                _browser = new TrappingGecko {
                    Folder = Path.GetDirectoryName(indexFullName), Dock = DockStyle.Fill, UseHttpActivityObserver = true
                };
                f.Text = $"{Application.ProductName}  {Application.ProductVersion}";
                f.Controls.Add(_browser);
                var portAddr = GetPortAddr(reactProcess);
                _browser.Navigate($"http://localhost:{portAddr}");
                Application.Run(f);
                reactProcess.Kill();
                reactProcess.WaitForExit();
            }

            var apiFolder = Path.Combine(Path.GetDirectoryName(indexFullName), "api");

            if (Directory.Exists(apiFolder))
            {
                Directory.Delete(apiFolder, true);                      // remove all api related files
            }
            foreach (var fullPath in SupportFile)
            {
                File.Delete(fullPath);
                DeleteFolder(fullPath);
            }
        }