示例#1
0
        public static void SetUpXulRunner()
        {
            try
            {
#if __MonoCS__
                string initXulRunnerOption = Environment.GetEnvironmentVariable("WESAY_INIT_XULRUNNER") ?? String.Empty;
                // Initialize XULRunner - required to use the geckofx WebBrowser Control (GeckoWebBrowser).
                string xulRunnerLocation = XULRunnerLocator.GetXULRunnerLocation();
                if (String.IsNullOrEmpty(xulRunnerLocation))
                {
                    throw new ApplicationException("The XULRunner library is missing or has the wrong version");
                }
                string librarySearchPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH") ?? String.Empty;
                if (!librarySearchPath.Contains(xulRunnerLocation))
                {
                    throw new ApplicationException("LD_LIBRARY_PATH must contain " + xulRunnerLocation);
                }

                Xpcom.Initialize(xulRunnerLocation);
                GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
#endif
            }
            catch (ApplicationException e)
            {
                ErrorReport.NotifyUserOfProblem(e.Message);
            }
            catch (Exception e)
            {
                ErrorReport.NotifyUserOfProblem(e.Message);
            }
        }
示例#2
0
        public static void Main(string[] args)
        {
            // Uncomment the follow line to enable CustomPrompt's
            GeckoWebBrowser.UseCustomPrompt();

            // If you want to further customize the GeckoFx PromptService then
            // you will need make a class that implements nsIPromptService2 and nsIPrompt interfaces and
            // set the PromptFactory.PromptServiceCreator delegate. for example:
            // PromptFactory.PromptServiceCreator = () => new MyPromptService();

#if GTK
            if (!Environment.GetEnvironmentVariable("LD_LIBRARY_PATH").Contains("/usr/lib/firefox/"))
            {
                throw new ApplicationException(String.Format("LD_LIBRARY_PATH must contain {0}", "/usr/lib/firefox/"));
            }

            Xpcom.Initialize("/usr/lib/firefox/");
#else
            Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());
#endif
            // Uncomment the follow line to enable CustomPrompt's
            // GeckoPreferences.User["browser.xul.error_pages.enabled"] = false;

            GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;

            Application.ApplicationExit += (sender, e) =>
            {
                Xpcom.Shutdown();
            };

            //Application.Idle += (s, e) => Console.WriteLine(SynchronizationContext.Current);
            Application.Run(new MyForm());
        }
示例#3
0
        static void Main()
        {
            string xulRunnerLocation = XULRunnerLocator.GetXULRunnerLocation();

            if (String.IsNullOrEmpty(xulRunnerLocation))
            {
                throw new ApplicationException("The XULRunner library is missing or has the wrong version");
            }
            string librarySearchPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH") ?? String.Empty;

            if (!librarySearchPath.Contains(xulRunnerLocation))
            {
                throw new ApplicationException("LD_LIBRARY_PATH must contain " + xulRunnerLocation);
            }

            Xpcom.Initialize(xulRunnerLocation);

            var form      = new Form();
            var myBrowser = new GeckoWebBrowser {
                Dock = DockStyle.Fill
            };

            myBrowser.Navigate("https://duckduckgo.com/");
            form.Controls.Add(myBrowser);
            Application.Run(form);
        }
示例#4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // TODO: GetXULRunnerLocation isn't very robust but its ok when hacking..
            Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());

            var form1 = new Form1();

            var textBox = new HtmlTextBox();

            textBox.Location = new Point(5, 0);
            textBox.Width    = 100;
            textBox.Height   = 40;
            textBox.Visible  = true;
            var comboBox = new HtmlEditableComboBox();

            comboBox.Location = new Point(5, 45);
            comboBox.Width    = 100;
            comboBox.Height   = 40;


            form1.Controls.Add(textBox);
            form1.Controls.Add(comboBox);

            Application.Run(form1);
        }
示例#5
0
        public static void Main()
        {
            Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());

            _current = new App();
            _current.InitializeComponent();
            _current.Run();
        }
示例#6
0
        public static void Main(string[] args)
        {
            #region FF浏览器的
            // If you want to customize the GeckoFx PromptService then
            // you will need make a class that implements some or all of nsIPrompt,
            // nsIAuthPrompt2, and nsIAuthPrompt interfaces and
            // set the PromptFactory.PromptServiceCreator delegate. for example:
            // PromptFactory.PromptServiceCreator = () => new MyPromptService();
            // Gecko.PromptService already implements those interfaces, and may be sub-classed.

            string xulrunnerPath = XULRunnerLocator.GetXULRunnerLocation();
            //xulrunnerPath = @"C:\mozilla-central\obj-i686-pc-mingw32\dist\bin";
#if GTK
            if (!Environment.GetEnvironmentVariable("LD_LIBRARY_PATH").Contains(xulrunnerPath))
            {
                throw new ApplicationException(String.Format("LD_LIBRARY_PATH must contain {0}", xulrunnerPath));
            }
#endif
            Xpcom.Initialize(xulrunnerPath);
            // Uncomment the follow line to enable error page
            GeckoPreferences.User["browser.xul.error_pages.enabled"] = true;

            GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;

            GeckoPreferences.User["full-screen-api.enabled"] = true;

#if DEBUG
            if (RemoteDebuggerEnabled)
            {
                StartDebugServer();
            }
#endif

            Application.ApplicationExit += (sender, e) =>
            {
                Xpcom.Shutdown();
            };
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var mainForm = new MainForm();
            Gecko.LauncherDialog.Download += (s, e) => LauncherDialog_Download(mainForm, s, e);

            //Application.Idle += (s, e) => Console.WriteLine(SynchronizationContext.Current);
            #endregion

            #region 抓异常的

            //处理未捕获的异常
            //Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            //处理UI线程异常
            Application.ThreadException += Application_ThreadException;
            //处理非UI线程异常
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            #endregion

            Application.Run(mainForm);
        }
示例#7
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SetUpErrorHandling();

#if MONO
            // Set up Xpcom for geckofx
#if false
            DummyFunction();                    // Can we avoid the need for LD_PRELOAD?
#endif
            Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());
            GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
            Application.ApplicationExit += (sender, e) => { Xpcom.Shutdown(); };
#endif

            //is mercurial set up?
            var s = HgRepository.GetEnvironmentReadinessMessage("en");
            if (!string.IsNullOrEmpty(s))
            {
                MessageBox.Show(s, "Chorus", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            //did they give us a path on the command line?
            string pathToRepository = null;
            if (args.Length > 0)
            {
                pathToRepository = args[0];
            }

            if (string.IsNullOrEmpty(pathToRepository) || !Directory.Exists(pathToRepository))
            {
                //do we have a valid path from last time?
                pathToRepository = Properties.Settings.Default.PathToRepository;
            }

            if (string.IsNullOrEmpty(pathToRepository) || !Directory.Exists(pathToRepository))
            {
                //can they find a repository for us?
                pathToRepository = Runner.BrowseForRepository();
            }
            if (string.IsNullOrEmpty(pathToRepository) || !Directory.Exists(pathToRepository))
            {
                return;                 //give up
            }


            Properties.Settings.Default.PathToRepository = pathToRepository;
            Properties.Settings.Default.Save();
            new Runner().Run(pathToRepository, new Arguments(args));

            Properties.Settings.Default.Save();
            Application.Exit();
        }
示例#8
0
        static void Main()
        {
            // Is mercurial set up?
            var readinessMessage = HgRepository.GetEnvironmentReadinessMessage("en");

            if (!string.IsNullOrEmpty(readinessMessage))
            {
                MessageBox.Show(readinessMessage, CommonResources.kFLExBridge, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (var hotspot = new HotSpotProvider())
            {
                // This is a kludge to make sure we have a real reference to PalasoUIWindowsForms.
                // Without this call, although PalasoUIWindowsForms is listed in the References of this project,
                // since we don't actually use it directly, it does not show up when calling GetReferencedAssemblies on this assembly.
                // But we need it to show up in that list so that ExceptionHandler.Init can install the intended PalasoUIWindowsForms
                // exception handler.
            }

            if (Settings.Default.CallUpgrade)
            {
                Settings.Default.Upgrade();
                Settings.Default.CallUpgrade = false;
            }

            SetUpErrorHandling();

#if MONO
            // Set up Xpcom for geckofx (used by some Chorus dialogs that we may invoke).
            Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());
            GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
            Application.ApplicationExit += (sender, e) => { Xpcom.Shutdown(); };
#endif

            // An aggregate catalog that combines multiple catalogs
            using (var catalog = new AggregateCatalog())
            {
                var thisAssembly = Assembly.GetExecutingAssembly();
                catalog.Catalogs.Add(new DirectoryCatalog(
                                         Path.GetDirectoryName(Utilities.StripFilePrefix(thisAssembly.CodeBase)),
                                         "*-ChorusPlugin.dll"));
                catalog.Catalogs.Add(new AssemblyCatalog(thisAssembly));

                // Create the CompositionContainer with the parts in the catalog
                using (var container = new CompositionContainer(catalog))
                {
                    Application.Run(container.GetExportedValue <RepositoryUtilityForm>());
                }
            }
            Settings.Default.Save();
        }
示例#9
0
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);


            Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());
            //#endif
            Application.ApplicationExit += (sender, e) =>
            {
                Xpcom.Shutdown();
            };
            Application.Run(new Form1());
        }
示例#10
0
        public static void SetUpXulRunner()
        {
            try
            {
                string geckoBrowserOption = Environment.GetEnvironmentVariable("WESAY_USE_GECKO") ?? String.Empty;
                WeSayWordsProject.GeckoOption = !(geckoBrowserOption == String.Empty || geckoBrowserOption.Equals("0", StringComparison.OrdinalIgnoreCase));
#if __MonoCS__
                // Initialize XULRunner - required to use the geckofx WebBrowser Control (GeckoWebBrowser).
                string xulRunnerLocation = XULRunnerLocator.GetXULRunnerLocation();
                if (String.IsNullOrEmpty(xulRunnerLocation))
                {
                    throw new ApplicationException("The XULRunner library is missing or has the wrong version");
                }
                string librarySearchPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH") ?? String.Empty;
                if (!librarySearchPath.Contains(xulRunnerLocation))
                {
                    throw new ApplicationException("LD_LIBRARY_PATH must contain " + xulRunnerLocation);
                }

                Xpcom.Initialize(xulRunnerLocation);
                GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
#else
                // For windows, only initialize xulrunner if we are using the gecko browser control option
                if (WeSayWordsProject.GeckoOption)
                {
                    string xulRunnerLocation = Path.Combine(FileLocator.DirectoryOfTheApplicationExecutable, "Firefox");
                    if (!Directory.Exists(xulRunnerLocation))
                    {
                        throw new ApplicationException("XULRunner needs to be installed to " + xulRunnerLocation);
                    }
                    if (!SetDllDirectory(xulRunnerLocation))
                    {
                        throw new ApplicationException("SetDllDirectory failed for " + xulRunnerLocation);
                    }
                    Xpcom.Initialize(xulRunnerLocation);
                    GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
                }
#endif
            }
            catch (ApplicationException e)
            {
                ErrorReport.NotifyUserOfProblem(e.Message);
            }
            catch (Exception e)
            {
                ErrorReport.NotifyUserOfProblem(e.Message);
            }
        }
示例#11
0
        public static void Main(string[] args)
        {
            // If you want to customize the GeckoFx PromptService then
            // you will need make a class that implements some or all of nsIPrompt,
            // nsIAuthPrompt2, and nsIAuthPrompt interfaces and
            // set the PromptFactory.PromptServiceCreator delegate. for example:
            // PromptFactory.PromptServiceCreator = () => new MyPromptService();
            // Gecko.PromptService already implements those interfaces, and may be sub-classed.

            string xulrunnerPath = XULRunnerLocator.GetXULRunnerLocation(XULRunnerLocator.GeckoHintPath("0.9.0"));

            // The Following line is useful to Tom Please don't delete
            // xulrunnerPath = @"C:\mozilla-release\obj-i686-pc-mingw32\dist\bin";
#if GTK
            if (!Environment.GetEnvironmentVariable("LD_LIBRARY_PATH").Contains(xulrunnerPath))
            {
                throw new ApplicationException(String.Format("LD_LIBRARY_PATH must contain {0}", xulrunnerPath));
            }
#endif
            Xpcom.Initialize(xulrunnerPath);
            // Uncomment the follow line to enable error page
            GeckoPreferences.User["browser.xul.error_pages.enabled"] = true;

            GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;

            GeckoPreferences.User["full-screen-api.enabled"] = true;

#if PORT
            if (RemoteDebuggerEnabled)
            {
                StartDebugServer();
            }
#endif

            Application.ApplicationExit += (sender, e) =>
            {
                Xpcom.Shutdown();
            };

            var mainForm = new MyForm();

            Gecko.LauncherDialog.Download += (s, e) => LauncherDialog_Download(mainForm, s, e);

            //Application.Idle += (s, e) => Console.WriteLine(SynchronizationContext.Current);
            Application.Run(mainForm);
        }
示例#12
0
        public static void SetUpXulRunner()
        {
            if (!Xpcom.IsInitialized)
            {
                try
                {
#if __MonoCS__
                    // Initialize XULRunner - required to use the geckofx WebBrowser Control (GeckoWebBrowser).
                    string xulRunnerLocation = XULRunnerLocator.GetXULRunnerLocation();
                    if (String.IsNullOrEmpty(xulRunnerLocation))
                    {
                        throw new ApplicationException("The XULRunner library is missing or has the wrong version");
                    }
                    Environment.SetEnvironmentVariable("LD_LIBRARY_PATH", xulRunnerLocation);
                    string librarySearchPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH") ?? String.Empty;
                    if (!librarySearchPath.Contains(xulRunnerLocation))
                    {
                        throw new ApplicationException("LD_LIBRARY_PATH must contain " + xulRunnerLocation);
                    }
#else
                    string xulRunnerLocation = Path.Combine(FileLocator.DirectoryOfTheApplicationExecutable, "Firefox");
                    if (!Directory.Exists(xulRunnerLocation))
                    {
                        throw new ApplicationException("XULRunner needs to be installed to " + xulRunnerLocation);
                    }
                    if (!SetDllDirectory(xulRunnerLocation))
                    {
                        throw new ApplicationException("SetDllDirectory failed for " + xulRunnerLocation);
                    }
#endif
                    Xpcom.EnableProfileMonitoring = true;
                    Xpcom.Initialize(xulRunnerLocation);
                    GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
                }
                catch (ApplicationException e)
                {
                    Assert.Fail();
                }
                catch (Exception e)
                {
                    Assert.Fail();
                }
            }
        }
示例#13
0
        static void Main()
        {
            // Don't use XULRunnerLocator.GetXULRunnerLocation() in production software.
            string firefox14Path = XULRunnerLocator.GetXULRunnerLocation();

            Xpcom.Initialize(firefox14Path);

            var form = new Form();

            _browser = new GeckoWebBrowser {
                Dock = DockStyle.Fill
            };
            _browser.Navigating += InstallCustomEventListener;
            _browser.Navigating += ListenForFakeNavigationMessages;

            _browser.Navigate("file://" + Path.Combine(Environment.CurrentDirectory, "Example6.html"));

            form.Controls.Add(_browser);
            Application.Run(form);
        }
示例#14
0
        static void StartDebugServer()
        {
            GeckoPreferences.User["devtools.debugger.remote-enabled"] = true;

            //see <geckofx_src>/chrome dir
            RegisterChromeDir(Path.GetFullPath(Path.Combine(XULRunnerLocator.GetXULRunnerLocation(), "../../chrome")));

            var browser = new GeckoWebBrowser();

            browser.NavigationError += (s, e) =>
            {
                Console.Error.WriteLine("StartDebugServer error: 0x" + e.ErrorCode.ToString("X"));
                browser.Dispose();
            };
            browser.DocumentCompleted += (s, e) =>
            {
                Console.WriteLine("StartDebugServer completed");
                browser.Dispose();
            };
            //see <geckofx_src>/chrome/debugger-server.html
            browser.Navigate("chrome://geckofx/content/debugger-server.html");
        }
示例#15
0
文件: Main.cs 项目: git-thinh/limada
        public static void Main(string[] args)
        {
            // If you want to customize the GeckoFx PromptService then
            // you will need make a class that implements some or all of nsIPrompt,
            // nsIAuthPrompt2, and nsIAuthPrompt interfaces and
            // set the PromptFactory.PromptServiceCreator delegate. for example:
            // PromptFactory.PromptServiceCreator = () => new MyPromptService();
            // Gecko.PromptService already implements those interfaces, and may be sub-classed.

            string xulrunnerPath = XULRunnerLocator.GetXULRunnerLocation();

#if GTK
            if (!Environment.GetEnvironmentVariable("LD_LIBRARY_PATH").Contains(xulrunnerPath))
            {
                throw new ApplicationException(String.Format("LD_LIBRARY_PATH must contain {0}", xulrunnerPath));
            }
#endif
            Xpcom.Initialize(xulrunnerPath);
            // Uncomment the follow line to enable error page
            GeckoPreferences.User["browser.xul.error_pages.enabled"] = true;

            GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;

            GeckoPreferences.User["full-screen-api.enabled"] = true;

            if (RemoteDebuggerEnabled)
            {
                StartDebugServer();
            }

            Application.ApplicationExit += (sender, e) =>
            {
                Xpcom.Shutdown();
            };

            //Application.Idle += (s, e) => Console.WriteLine(SynchronizationContext.Current);
            Application.Run(new MyForm());
        }
示例#16
0
        static void Main(string[] args)
        {
            //MessageBox.Show(@"Get ready to debug FB exe.");
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args.Length == 0)
            {
                MessageBox.Show(CommonResources.kNoCommandLineOptions, CommonResources.kFLExBridge, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            using (var hotspot = new HotSpotProvider())
            {
                // This is a kludge to make sure we have a real reference to PalasoUIWindowsForms.
                // Without this call, although PalasoUIWindowsForms is listed in the References of this project,
                // since we don't actually use it directly, it does not show up when calling GetReferencedAssemblies on this assembly.
                // But we need it to show up in that list so that ExceptionHandler.Init can install the intended PalasoUIWindowsForms
                // exception handler.
            }

            if (Settings.Default.CallUpgrade)
            {
                Settings.Default.Upgrade();
                Settings.Default.CallUpgrade = false;
            }

            SetUpErrorHandling();

            var commandLineArgs = CommandLineProcessor.ParseCommandLineArgs(args);

#if MONO
            // Set up Xpcom for geckofx (used by some Chorus dialogs that we may invoke).
            Xpcom.Initialize(XULRunnerLocator.GetXULRunnerLocation());
            GeckoPreferences.User["gfx.font_rendering.graphite.enabled"] = true;
            Application.ApplicationExit += (sender, e) => { Xpcom.Shutdown(); };
#endif

            // An aggregate catalog that combines multiple catalogs
            using (var catalog = new AggregateCatalog())
            {
                catalog.Catalogs.Add(new DirectoryCatalog(
                                         Path.GetDirectoryName(Utilities.StripFilePrefix(typeof(ActionTypeHandlerRepository).Assembly.CodeBase)),
                                         "*-ChorusPlugin.dll"));

                // Create the CompositionContainer with the parts in the catalog
                using (var container = new CompositionContainer(catalog))
                {
                    var connHelper = container.GetExportedValue <FLExConnectionHelper>();
                    if (!connHelper.Init(commandLineArgs))
                    {
                        return;
                    }

                    // Is mercurial set up?
                    var readinessMessage = HgRepository.GetEnvironmentReadinessMessage("en");
                    if (!string.IsNullOrEmpty(readinessMessage))
                    {
                        MessageBox.Show(readinessMessage, CommonResources.kFLExBridge, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        return;
                    }

                    var l10Managers = Utilities.SetupLocalization(commandLineArgs);

                    try
                    {
                        var handlerRepository = container.GetExportedValue <ActionTypeHandlerRepository>();
                        var currentHandler    = handlerRepository.GetHandler(commandLineArgs);
                        currentHandler.StartWorking(commandLineArgs);
                        var bridgeActionTypeHandlerShowWindow = currentHandler as IBridgeActionTypeHandlerShowWindow;
                        if (bridgeActionTypeHandlerShowWindow != null)
                        {
                            Application.Run(bridgeActionTypeHandlerShowWindow.MainForm);
                        }
                        var bridgeActionTypeHandlerCallEndWork = currentHandler as IBridgeActionTypeHandlerCallEndWork;
                        if (bridgeActionTypeHandlerCallEndWork != null)
                        {
                            bridgeActionTypeHandlerCallEndWork.EndWork();
                        }
                    }
                    catch
                    {
                        connHelper.SignalBridgeWorkComplete(false);
                        throw;                         // Re-throw the original exception, so the crash dlg has something to display.
                    }
                    finally
                    {
                        foreach (var manager in l10Managers.Values)
                        {
                            manager.Dispose();
                        }
                    }
                }
            }
            Settings.Default.Save();
        }