public Form1()
 {
     Xpcom.Initialize(@"C:\Users\esouza\Downloads\xulrunner");     //Tell where are XUL bin
     InitializeComponent();
 }
        public GeckoElement CastToGeckoElement()
        {
            var domElement = Xpcom.QueryInterface <nsIDOMElement>(_target.Instance);

            return(domElement.Wrap(GeckoElement.CreateDomElementWrapper));
        }
예제 #3
0
        protected void AddToolbarAndBrowserToTab(TabPage tabPage, GeckoWebBrowser browser)
        {
            TextBox urlbox = new TextBox();

            urlbox.Top   = 0;
            urlbox.Width = 200;

            Button nav = new Button();

            nav.Text = "Go";
            nav.Left = urlbox.Width;

            Button newTab = new Button();

            newTab.Text = "NewTab";
            newTab.Left = nav.Left + nav.Width;

            Button stop = new Button
            {
                Text = "Stop",
                Left = newTab.Left + newTab.Width
            };

            Button closeTab = new Button();

            closeTab.Text = "GC.Collect";
            closeTab.Left = stop.Left + stop.Width;

            Button closeWithDisposeTab = new Button();

            closeWithDisposeTab.Text = "Close";
            closeWithDisposeTab.Left = closeTab.Left + closeTab.Width;

            Button open = new Button();

            open.Text = "FileOpen";
            open.Left = closeWithDisposeTab.Left + closeWithDisposeTab.Width;

            Button print = new Button();

            print.Text = "Print";
            print.Left = open.Left + open.Width;

            Button scrollDown = new Button {
                Text = "Down", Left = closeWithDisposeTab.Left + 250
            };
            Button scrollUp = new Button {
                Text = "Up", Left = closeWithDisposeTab.Left + 330
            };

            scrollDown.Click += (s, e) => { browser.Window.ScrollByPages(1); };
            scrollUp.Click   += (s, e) => { browser.Window.ScrollByPages(-1); };

            nav.Click += delegate
            {
                // use javascript to warn if url box is empty.
                if (string.IsNullOrEmpty(urlbox.Text.Trim()))
                {
                    browser.Navigate("javascript:alert('hey try typing a url!');");
                }
                browser.Navigate(urlbox.Text);
            };

            newTab.Click += delegate { AddTab(); };

            stop.Click += delegate { browser.Stop(); };

            closeTab.Click += delegate {
                GC.Collect();
                GC.WaitForPendingFinalizers();
            };

            closeWithDisposeTab.Click += delegate
            {
                m_tabControl.Controls.Remove(tabPage);
                tabPage.Dispose();
            };

            open.Click += (s, a) =>
            {
                nsIFilePicker filePicker = Xpcom.CreateInstance <nsIFilePicker>("@mozilla.org/filepicker;1");
                filePicker.Init(browser.Window.DomWindow, new nsAString("hello"), nsIFilePickerConsts.modeOpen);
                filePicker.AppendFilter(new nsAString("png"), new nsAString("*.png"));
                filePicker.AppendFilter(new nsAString("html"), new nsAString("*.html"));
                if (nsIFilePickerConsts.returnOK == filePicker.Show())
                {
                    using (nsACString str = new nsACString())
                    {
                        filePicker.GetFileAttribute().GetNativePathAttribute(str);
                        browser.Navigate(str.ToString());
                    }
                }
            };
            //url in Navigating event may be the mapped version,
            //e.g. about:config in Navigating event is jar:file:///<xulrunner>/omni.ja!/chrome/toolkit/content/global/config.xul
            browser.Navigating += (s, e) =>
            {
                Console.WriteLine("Navigating: url: " + e.Uri + ", top: " + e.DomWindowTopLevel);
            };
            browser.Navigated += (s, e) =>
            {
                if (e.DomWindowTopLevel)
                {
                    urlbox.Text = e.Uri.ToString();
                }
                Console.WriteLine("Navigated: url: " + e.Uri + ", top: " + e.DomWindowTopLevel, ", errorPage: " + e.IsErrorPage);
            };

            browser.Retargeted += (s, e) =>
            {
                var ch = e.Request as Gecko.Net.Channel;
                Console.WriteLine("Retargeted: url: " + e.Uri + ", contentType: " + ch.ContentType + ", top: " + e.DomWindowTopLevel);
            };
            browser.DocumentCompleted += (s, e) =>
            {
                Console.WriteLine("DocumentCompleted: url: " + e.Uri + ", top: " + e.IsTopLevel);
            };

            print.Click += delegate { browser.Window.Print(); };

            tabPage.Controls.Add(urlbox);
            tabPage.Controls.Add(nav);
            tabPage.Controls.Add(newTab);
            tabPage.Controls.Add(stop);
            tabPage.Controls.Add(closeTab);
            tabPage.Controls.Add(closeWithDisposeTab);
            tabPage.Controls.Add(open);
            tabPage.Controls.Add(print);
            tabPage.Controls.Add(browser);
            tabPage.Controls.Add(scrollDown);
            tabPage.Controls.Add(scrollUp);
        }
        public void CSharpInvokingJavascriptComObjects()
        {
            // Note: Firefox 17 removed enablePrivilege #546848 - refactored test so that javascript to create "@mozillazine.org/example/priority;1" is now executated by AutoJsContext

            // Register a C# COM Object

            // TODO would be nice to get nsIComponentRegistrar the xpcom way with CreateInstance
            // ie Xpcom.CreateInstance<nsIComponentRegistrar>(...
            Guid aClass  = new Guid("a7139c0e-962c-44b6-bec3-aaaaaaaaaaac");
            var  factory = new MyCSharpClassThatContainsXpComJavascriptObjectsFactory();

            Xpcom.ComponentRegistrar.RegisterFactory(ref aClass, "Example C sharp com component", "@geckofx/myclass;1", factory);

            // In order to use Components.classes etc we need to enable certan privileges.
            GeckoPreferences.User["capability.principal.codebase.p0.granted"]     = "UniversalXPConnect";
            GeckoPreferences.User["capability.principal.codebase.p0.id"]          = "file://";
            GeckoPreferences.User["capability.principal.codebase.p0.subjectName"] = "";
            GeckoPreferences.User["security.fileuri.strict_origin_policy"]        = false;

#if PORT
            browser.JavascriptError += (x, w) => Console.WriteLine("Message = {0}", w.Message);
#endif

            string intialPage = "<html><body></body></html>";

            string initialjavascript =
                "var myClassInstance = Components.classes['@geckofx/myclass;1'].createInstance(Components.interfaces.nsIWebPageDescriptor);" +
                "var reg = myClassInstance.currentDescriptor.QueryInterface(Components.interfaces.nsIComponentRegistrar);" +
                "Components.utils.import(\"resource://gre/modules/XPCOMUtils.jsm\"); " +
                "const nsISupportsPriority = Components.interfaces.nsISupportsPriority;" +
                "const nsISupports = Components.interfaces.nsISupports;" +
                "const CLASS_ID = Components.ID(\"{1C0E8D86-B661-40d0-AE3D-CA012FADF170}\");" +
                "const CLASS_NAME = \"My Supports Priority Component\";" +
                "const CONTRACT_ID = \"@mozillazine.org/example/priority;1\";" +
                "function MyPriority() {" +
                "	this._priority = nsISupportsPriority.PRIORITY_LOWEST;"+
                "};" +
                "MyPriority.prototype = {" +
                "  _priority: null," +

                "  get priority() { return this._priority; }," +
                "  set priority(aValue) { this._priority = aValue; }," +

                "  adjustPriority: function(aDelta) {" +
                "	this._priority += aDelta;"+
                "  }," +

                "  QueryInterface: function(aIID)" +
                "  { " +
                "	/*if (!aIID.equals(nsISupportsPriority) &&    "+
                "		!aIID.equals(nsISupports))"+
                "	  throw Components.results.NS_ERROR_NO_INTERFACE;*/"+
                "	return this;"+
                "  }" +
                "};" +
                "" +
                "var MyPriorityFactory = {" +
                "  createInstance: function (aOuter, aIID)" +
                "  { " +
                "	if (aOuter != null)"+
                "	  throw Components.results.NS_ERROR_NO_AGGREGATION; "+
                "	return (new MyPriority()).QueryInterface(aIID);"+
                "  }" +
                "};" +
                "" +
                "var MyPriorityModule = {" +
                "  _firstTime: true," +
                "  registerSelf: function(aCompMgr, aFileSpec, aLocation, aType)" +
                "  {" +
                "	aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);"+
                "	aCompMgr.registerFactory(CLASS_ID, CLASS_NAME, CONTRACT_ID, MyPriorityFactory);"+
                "  }," +
                "" +
                "  unregisterSelf: function(aCompMgr, aLocation, aType)" +
                "  {" +
                "	aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);"+
                "	aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);        "+
                "  }," +
                "" +
                "  getClassObject: function(aCompMgr, aCID, aIID)" +
                "  {alert('hi');" +
                "	if (!aIID.equals(Components.interfaces.nsIFactory))"+
                "	  throw Components.results.NS_ERROR_NOT_IMPLEMENTED;"+
                "" +
                "	if (aCID.equals(CLASS_ID))"+
                "	  return MyPriorityFactory;"+
                "" +
                "	throw Components.results.NS_ERROR_NO_INTERFACE;"+
                "  }," +
                "" +
                "  canUnload: function(aCompMgr) { return true; }" +
                "};" +
                "MyPriorityModule.registerSelf(reg);" +
                "";

            // Create temp file to load
            var tempfilename = Path.GetTempFileName();
            tempfilename += ".html";
            using (TextWriter tw = new StreamWriter(tempfilename))
            {
                tw.WriteLine(intialPage);
                tw.Close();
            }

            browser.Navigate(tempfilename);
            browser.NavigateFinishedNotifier.BlockUntilNavigationFinished();

            using (var context = new AutoJSContext(browser.Window))
            {
                string result  = String.Empty;
                var    success = context.EvaluateScript(initialjavascript, out result);
                Console.WriteLine("success = {0} result = {1}", success, result);
            }

            File.Delete(tempfilename);

            // Create instance of javascript xpcom objects
            var p = Xpcom.CreateInstance <nsISupportsPriority>("@mozillazine.org/example/priority;1");
            Assert.NotNull(p);

            // test invoking method of javascript xpcom object.
            Assert.AreEqual(20, p.GetPriorityAttribute());

            Xpcom.ComponentRegistrar.UnregisterFactory(ref aClass, factory);
        }
예제 #5
0
        public StorageStream()
        {
            _storageStream = Xpcom.CreateInstance2 <nsIStorageStream>(Contracts.StorageStream);

            _storageStream.Instance.Init(1024 * 32, 1024 * 1024 * 16);
        }
예제 #6
0
 public COMGC()
 {
     _timer = Xpcom.CreateInstance <nsITimer>("@mozilla.org/timer;1");
     _timer.InitWithCallback(this, 5000, nsITimerConsts.TYPE_REPEATING_SLACK);
 }
예제 #7
0
 internal InputStream(nsIInputStream inputStream)
 {
     _inputStream    = inputStream;
     _seekableStream = Xpcom.QueryInterface <nsISeekableStream>(inputStream);
     _seekable       = _seekableStream != null;
 }
예제 #8
0
        public void JavaScriptToCSharpCallBack()
        {
            // Note: Firefox 17 removed enablePrivilege #546848 - refactored test so that javascript to create "@mozillazine.org/example/priority;1" is now executated by AutoJsContext

            // Register a C# COM Object

            const string          ComponentManagerCID = "91775d60-d5dc-11d2-92fb-00e09805570f";
            nsIComponentRegistrar mgr = (nsIComponentRegistrar)Xpcom.GetObjectForIUnknown((IntPtr)Xpcom.GetService(new Guid(ComponentManagerCID)));
            Guid aClass = new Guid("a7139c0e-962c-44b6-bec3-aaaaaaaaaaab");

            mgr.RegisterFactory(ref aClass, "Example C sharp com component", "@geckofx/mysharpclass;1", new MyCSharpComClassFactory());

            // In order to use Components.classes etc we need to enable certan privileges.
            GeckoPreferences.User["capability.principal.codebase.p0.granted"]     = "UniversalXPConnect";
            GeckoPreferences.User["capability.principal.codebase.p0.id"]          = "file://";
            GeckoPreferences.User["capability.principal.codebase.p0.subjectName"] = "";
            GeckoPreferences.User["security.fileuri.strict_origin_policy"]        = false;

            browser.JavascriptError += (x, w) => Console.WriteLine(w.Message);

            string inithtml = "<html><body></body></html>";

            string initialjavascript =
                "var myClassInstance = Components.classes['@geckofx/mysharpclass;1'].createInstance(Components.interfaces.nsICommandHandler); myClassInstance.exec('hello', 'world');";

            // Create temp file to load
            var tempfilename = Path.GetTempFileName();

            tempfilename += ".html";
            using (TextWriter tw = new StreamWriter(tempfilename))
            {
                tw.WriteLine(inithtml);
                tw.Close();
            }

            browser.Navigate(tempfilename);
            browser.NavigateFinishedNotifier.BlockUntilNavigationFinished();
            File.Delete(tempfilename);

            using (var context = new AutoJSContext(GlobalJSContextHolder.BackstageJSContext))
            {
                string result  = String.Empty;
                bool   success = context.EvaluateScript(initialjavascript, out result);
                Console.WriteLine("success = {1} result = {0}", result, success);
            }

            // Test the results
            Assert.AreEqual(MyCSharpComClass._execCount, 1);
            Assert.AreEqual(MyCSharpComClass._aCommand, "hello");
            Assert.AreEqual(MyCSharpComClass._aParameters, "world");
        }
예제 #9
0
 public void BeforeEachTestSetup()
 {
     Xpcom.Initialize(XpComTests.XulRunnerLocation);
     m_instance = Xpcom.GetService <nsIControllers>("@mozilla.org/xul/xul-controllers;1");
     Assert.IsNotNull(m_instance);
 }
예제 #10
0
 public void BeforeEachTestSetup()
 {
     Xpcom.Initialize(XpComTests.XulRunnerLocation);
 }
예제 #11
0
        public static OutputStream Create(nsIOutputStream stream)
        {
            var seekable = Xpcom.QueryInterface <nsISeekableStream>(stream);

            return(new OutputStream(stream, seekable));
        }
예제 #12
0
        private static void Main()
        {
            var profilePath = Path.Combine(Application.StartupPath, FIREFOX_TEMP);

            if (!Directory.Exists(profilePath))
            {
                Directory.CreateDirectory(profilePath);
            }
            else
            {
#if DEBUG
                // do not delete temp files in DEBUG mode.
#else
                EmptyFolder(profilePath);
#endif
            }

#if DEBUG
            Log.Logger = new LoggerConfiguration() // Logger.
                         .MinimumLevel.Verbose()
                         .WriteTo.File(@".\log\mooc.log", rollingInterval: RollingInterval.Day)
                         .CreateLogger();
#else
            Log.Logger = new LoggerConfiguration() // Logger.
                         .MinimumLevel.Information()
                         .WriteTo.File(@".\log\mooc.log", rollingInterval: RollingInterval.Day)
                         .CreateLogger();
#endif

            Xpcom.ProfileDirectory = profilePath;

            try // Check if the Firefox component exists.
            {
                Xpcom.Initialize(FIREFOX_PATH);
            }
            catch (Exception)
            {
                MessageBox.Show(
                    @"程序组件 ""FIREFOX"" 缺失, 请重新下载.", @"中国大学 MOOC 下载器", MessageBoxButtons.OK, MessageBoxIcon.Error
                    );
                return;
            }

            if (!File.Exists(FFMPEG_EXE))
            {
                MessageBox.Show(
                    @"程序组件 ""FFMPEG"" 缺失, 请重新下载.", @"中国大学 MOOC 下载器", MessageBoxButtons.OK, MessageBoxIcon.Error
                    );
                return;
            }

            Log.Information("=========程序启动=========");

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

            try
            {
                Application.Run(new MainForm());
            }
            catch (Exception exception)
            {
                Log.Error(exception, $@"程序运行发生错误: {exception.Message}");
                MessageBox.Show($@"程序运行发生错误: {exception.Message}");
            }
        }
예제 #13
0
 static VersionComparator()
 {
     _versionComparator = Xpcom.GetService2 <nsIVersionComparator>(Contracts.VersionComparator);
 }
        static void Main()
        {
            const string appName = "StmAccGen";
            bool         createdNew;

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += (s, e) =>
            {
                if (e.IsTerminating)
                {
                    Logger.Fatal("FATAL_UNHANDLED_EXCEPTION", e.ExceptionObject as Exception);
                }
                else
                {
                    Logger.Error("UNHANDLED_EXCEPTION", e.ExceptionObject as Exception);
                }
            };
            AppDomain.CurrentDomain.FirstChanceException += (s, e)
                                                            => Logger.Warn("FIRST_CHANCE_EXCEPTION", e.Exception);
#endif

            Logger.SuppressErrorDialogs    = Utility.HasStartOption("-suppressErrors");
            Logger.SuppressAllErrorDialogs = Utility.HasStartOption("-suppressAllErrors");

            Logger.Warn(@"Coded by:
https://github.com/Ashesh3
https://github.com/EarsKilla

Latest versions will be here: https://github.com/EarsKilla/Steam-Account-Generator/releases");
#if PRE_RELEASE
            Logger.Warn($"Version: {Web.Updater.UpdaterHandler.CurrentVersion}-pre{Web.Updater.UpdaterHandler.PreRelease}");
#else
            Logger.Warn($"Version: {Web.Updater.UpdaterHandler.CurrentVersion}");
#endif

            Logger.Trace("Starting...");

            mutex = new Mutex(true, appName, out createdNew);
            if (!createdNew)
            {
                Logger.Trace("Another instance is running. Shutting down...");
                return;
            }

            try
            {
                Logger.Debug("Initializing gecko/xpcom...");
                Xpcom.Initialize(Pathes.DIR_GECKO);
                GeckoInitialized = true;
                Logger.Debug("Initializing gecko/xpcom: done!");
            }
            catch (Exception ex)
            {
                Logger.Error($"Initializing gecko/xpcom: error!", ex);
            }

            UpdaterHandler.Refresh();

            UseRuCaptchaDomain = Utility.HasStartOption("-rucaptcha");
            if (UseRuCaptchaDomain)
            {
                Logger.Info("Option '-rucaptcha' detected. Switched from 2captcha.com to rucaptcha.com");
            }

            Web.HttpHandler.TwoCaptchaDomain = Utility.GetStartOption(@"-(two|ru)captchaDomain[:=](.*)",
                                                                      (m) => Utility.MakeUri(m.Groups[2].Value),
                                                                      new Uri((UseRuCaptchaDomain) ? "http://rucaptcha.com" : "http://2captcha.com"));

            Web.HttpHandler.CaptchasolutionsDomain = Utility.GetStartOption(@"-captchasolutionsDomain[:=](.*)",
                                                                            (m) => Utility.MakeUri(m.Groups[1].Value),
                                                                            new Uri("http://api.captchasolutions.com/"));

            Web.MailHandler.MailboxUri = Utility.GetStartOption(@"-mailBox[:=](.*)",
                                                                (m) =>
            {
                Web.MailHandler.IsMailBoxCustom = true;
                return(Utility.MakeUri(m.Groups[1].Value));
            },
                                                                Web.MailHandler.MailboxUri);

            Web.MailHandler.CheckUserMailVerifyCount = Utility.GetStartOption(@"-mailUserChecks[:=](\d+)",
                                                                              (m) =>
            {
                if (!int.TryParse(m.Groups[1].Value, out int val))
                {
                    return(Web.MailHandler.CheckUserMailVerifyCount);
                }

                return(val);
            }, Web.MailHandler.CheckUserMailVerifyCount);
            Web.MailHandler.CheckRandomMailVerifyCount = Utility.GetStartOption(@"-mailBoxChecks[:=](\d+)",
                                                                                (m) =>
            {
                if (!int.TryParse(m.Groups[1].Value, out int val))
                {
                    return(Web.MailHandler.CheckRandomMailVerifyCount);
                }

                return(val);
            }, Web.MailHandler.CheckRandomMailVerifyCount);

            UseOldCaptchaWay = Utility.GetStartOption(@"-oldcaptcha(way)?",
                                                      (m) => true,
                                                      false);

            if (!Utility.HasStartOption("-nostyles"))
            {
                Logger.Trace("Enabling visual styles...");
                Application.EnableVisualStyles();
            }
            if (!Utility.HasStartOption("-defaultTextRendering"))
            {
                Logger.Trace($"{nameof(Application.SetCompatibleTextRenderingDefault)}(false)...");
                Application.SetCompatibleTextRenderingDefault(false);
            }
            Logger.Trace($"Starting app with {nameof(MainForm)}...");
            Application.Run(new MainForm());
        }
예제 #15
0
 protected virtual IntPtr QueryReferentImplementation(object obj, ref Guid uuid)
 {
     // by default we make QueryReferent
     return(Xpcom.QueryReferent(obj, ref uuid));
 }
 internal static nsIMutableArray CreateArray()
 {
     return(Xpcom.CreateInstance <nsIMutableArray>(Contracts.Array));
 }
예제 #17
0
        internal static Certificate Create(nsIX509Cert2 certificate)
        {
            var cert3 = Xpcom.QueryInterface <nsIX509Cert3>(certificate);

            return(new Certificate(certificate, certificate, cert3));
        }
예제 #18
0
 public ScriptableInputStream()
 {
     _scriptableInputStream = Xpcom.CreateInstance <nsIScriptableInputStream>(Contracts.ScriptableInputStream);
 }
예제 #19
0
        private void StartMakingPdf()
        {
            nsIWebBrowserPrint print = Xpcom.QueryInterface <nsIWebBrowserPrint>(_browser.Window.DomWindow);

            var service       = Xpcom.GetService <nsIPrintSettingsService>("@mozilla.org/gfx/printsettings-service;1");
            var printSettings = service.GetNewPrintSettingsAttribute();

            printSettings.SetToFileNameAttribute(_pathToTempPdf);
            printSettings.SetPrintToFileAttribute(true);
            printSettings.SetPrintSilentAttribute(true);             //don't show a printer settings dialog
            printSettings.SetShowPrintProgressAttribute(false);

            if (_conversionOrder.PageHeightInMillimeters > 0)
            {
                printSettings.SetPaperHeightAttribute(_conversionOrder.PageHeightInMillimeters);
                printSettings.SetPaperWidthAttribute(_conversionOrder.PageWidthInMillimeters);
                printSettings.SetPaperSizeUnitAttribute(1);                 //0=in, >0 = mm
            }
            else
            {
                //doesn't actually work.  Probably a problem in the geckofx wrapper. Meanwhile we just look it up from our small list
                //printSettings.SetPaperNameAttribute(_conversionOrder.PageSizeName);

                var          size = GetPaperSize(_conversionOrder.PageSizeName);
                const double inchesPerMillimeter = 0.0393701;                   // (or more precisely, 0.0393700787402)
                printSettings.SetPaperHeightAttribute(size.HeightInMillimeters * inchesPerMillimeter);
                printSettings.SetPaperWidthAttribute(size.WidthInMillimeters * inchesPerMillimeter);
            }

            // BL-2346: On Linux the margins were not being set correctly due to the "unwritable margins"
            //          which were defaulting to 0.25 inches.
            printSettings.SetUnwriteableMarginTopAttribute(0d);
            printSettings.SetUnwriteableMarginBottomAttribute(0d);
            printSettings.SetUnwriteableMarginLeftAttribute(0d);
            printSettings.SetUnwriteableMarginRightAttribute(0d);

            //this seems to be in inches, and doesn't have a unit-setter (unlike the paper size ones)
            const double kMillimetersPerInch = 25.4;             // (or more precisely, 25.3999999999726)

            printSettings.SetMarginTopAttribute(_conversionOrder.TopMarginInMillimeters / kMillimetersPerInch);
            printSettings.SetMarginBottomAttribute(_conversionOrder.BottomMarginInMillimeters / kMillimetersPerInch);
            printSettings.SetMarginLeftAttribute(_conversionOrder.LeftMarginInMillimeters / kMillimetersPerInch);
            printSettings.SetMarginRightAttribute(_conversionOrder.RightMarginInMillimeters / kMillimetersPerInch);

            printSettings.SetOrientationAttribute(_conversionOrder.Landscape ? 1 : 0);
            printSettings.SetHeaderStrCenterAttribute("");
            printSettings.SetHeaderStrLeftAttribute("");
            printSettings.SetHeaderStrRightAttribute("");
            printSettings.SetFooterStrRightAttribute("");
            printSettings.SetFooterStrLeftAttribute("");
            printSettings.SetFooterStrCenterAttribute("");

            printSettings.SetPrintBGColorsAttribute(true);
            printSettings.SetPrintBGImagesAttribute(true);

            printSettings.SetShrinkToFitAttribute(false);


            //TODO: doesn't seem to do anything. Probably a problem in the geckofx wrapper
            //printSettings.SetScalingAttribute(_conversionOrder.Zoom);

            printSettings.SetOutputFormatAttribute(2);             // 2 == kOutputFormatPDF

            Status = "Making PDF..";

            print.Print(printSettings, this);
            _checkForPdfFinishedTimer.Enabled = true;
        }
예제 #20
0
 static DnsService()
 {
     _dnsService = Xpcom.GetService2 <nsIDNSService>(Contracts.DnsService);
 }
            public nsISupports GetCurrentDescriptorAttribute()
            {
                const string          ComponentManagerCID = "91775d60-d5dc-11d2-92fb-00e09805570f";
                nsIComponentRegistrar mgr = (nsIComponentRegistrar)Xpcom.GetObjectForIUnknown((IntPtr)Xpcom.GetService(new Guid(ComponentManagerCID)));

                return((nsISupports)mgr);
            }
예제 #22
0
 public UCThaoTac()
 {
     InitializeComponent();
     Xpcom.Initialize("Firefox");
 }
예제 #23
0
 public void CleanUpNativeData(IntPtr pNativeData)
 {
     Xpcom.Free(pNativeData);
 }
 static BrowserSearchService()
 {
     _browserSearchService = Xpcom.GetService2 <nsIBrowserSearchService>(Contracts.BrowserSearchService);
 }
예제 #25
0
 public Form1()
 {
     InitializeComponent();
     Xpcom.Initialize("Firefox");
 }
예제 #26
0
 static WindowWatcher()
 {
     _watcher = Xpcom.GetService2 <nsIWindowWatcher>(Contracts.WindowWatcher);
 }
예제 #27
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();
        }
예제 #28
0
 private OutputStream(nsIOutputStream outputStream)
 {
     _outputStream   = outputStream;
     _seekableStream = Xpcom.QueryInterface <nsISeekableStream>(outputStream);
     _seekable       = _seekableStream != null;
 }
예제 #29
0
 public void BeforeEachTestSetup()
 {
     Xpcom.Initialize(XpComTests.XulRunnerLocation);
     m_instance = Xpcom.CreateInstance <nsIFocusManager>("@mozilla.org/focus-manager;1");
     Assert.IsNotNull(m_instance);
 }
예제 #30
0
 public void BeforeEachTestSetup()
 {
     Xpcom.Initialize(XpComTests.XulRunnerLocation);
     m_instance = Xpcom.GetService <nsIIOService>("@mozilla.org/network/io-service;1");
     Assert.IsNotNull(m_instance);
 }