Exemple #1
0
        internal Window NewWindow(Desktop desktop, String type, CreationFlag creationFlags, String fileName)
        {
            if (type.Length > 0)
            {
                WindowCreator creator = null;

                this.windowCreators.TryGetValue(type, out creator);

                if (null != creator)
                {
                    Window window = creator(desktop);
                    //window.SetType(type);

                    return(window);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                CreationFlag flags = creationFlags;

                if (fileName.Length > 0)
                {
                    flags |= CreationFlag.NeedLoading;
                }

                return(new Window(desktop, creationFlags, fileName));
            }
        }
Exemple #2
0
 // Use this for initialization
 void Start()
 {
     objC    = gameObject.GetComponent <ObjCreator>();
     floorC  = gameObject.GetComponent <FloorCreator>();
     wallC   = gameObject.GetComponent <WallCreator>();
     doorC   = gameObject.GetComponent <DoorCreator>();
     windowC = gameObject.GetComponent <WindowCreator>();
 }
Exemple #3
0
        protected void Initialize()
        {
            RawInputParser = new RawInputParser();
            WindowCreator  = new WindowCreator(RawInputParser);
            var windowHandle = WindowCreator.CreateWindow();

            Devices = new DeviceEnumerator(RawInputParser, windowHandle);
        }
Exemple #4
0
		public static void InitEmbedding(String binDirectory, AppFileLocation appFileLocation,
			Boolean useWindowCreator = true,
			Boolean usePromptService = true,
			Boolean useFilePicker = true,
			Boolean useHelperAppLauncherDialog = true,
			Boolean useTooltipTextProvider = false)
		{
			XpcomHelper.InitEmbedding(binDirectory, appFileLocation);

			if (useWindowCreator)
			{
				ms_WindowCreator = new WindowCreator();
				var windowWatcher = XpcomHelper.GetService<nsIWindowWatcher>(Xpcom.NS_WINDOWWATCHER_CONTRACTID);
				windowWatcher.SetWindowCreator(ms_WindowCreator);
			}

			if (usePromptService)
			{
				ms_PromptServiceFactory = new Factory<PromptService>(Xpcom.NS_PROMPTSERVICE_CONTRACTID);
				ms_PromptServiceFactory.Register();
			}

			if (useFilePicker)
			{
				ms_FilePickerFactory = new Factory<FilePicker>("@mozilla.org/filepicker;1");
				ms_FilePickerFactory.Register();
			}

			if (useHelperAppLauncherDialog)
			{
				ms_HelperAppLauncherDialogFactory = new Factory<HelperAppLauncherDialog>(Xpcom.NS_IHELPERAPPLAUNCHERDLG_CONTRACTID);
				ms_HelperAppLauncherDialogFactory.Register();
			}

			if (useTooltipTextProvider)
			{
				ms_TooltipTextProviderFactory = new Factory<TooltipTextProvider>(Xpcom.NS_TOOLTIPTEXTPROVIDER_CONTRACTID);
				ms_TooltipTextProviderFactory.Register();
			}
		}
Exemple #5
0
        protected override void OnHandleCreated(EventArgs e)
        {
            try
            {
                InOnHandleCreate = true;
#if GTK
                if (Xpcom.IsMono)
                {
                    base.OnHandleCreated(e);
                    if (m_wrapper != null)
                    {
                        m_wrapper.Init();
                    }
                }
#endif
                if (!this.DesignMode)
                {
                    Xpcom.Initialize();
                    WindowCreator.Register();
#if !GTK
                    LauncherDialogFactory.Register();
#endif

                    WebBrowser      = Xpcom.CreateInstance <nsIWebBrowser>(Contracts.WebBrowser);
                    WebBrowserFocus = (nsIWebBrowserFocus)WebBrowser;
                    BaseWindow      = (nsIBaseWindow)WebBrowser;
                    WebNav          = (nsIWebNavigation)WebBrowser;

                    WebBrowser.SetContainerWindowAttribute(this);
#if GTK
                    if (Xpcom.IsMono && m_wrapper != null)
                    {
                        BaseWindow.InitWindow(m_wrapper.BrowserWindow.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);
                    }
                    else
#endif
                    BaseWindow.InitWindow(this.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);


                    BaseWindow.Create();

                    var docShell = Xpcom.QueryInterface <nsIDocShell>(BaseWindow);
                    // Allow visible control before finished loading see https://bugzilla.mozilla.org/show_bug.cgi?id=1138536
                    docShell.CreateAboutBlankContentViewer(null);
                    Xpcom.FreeComObject(ref docShell);
                    BaseWindow.SetVisibilityAttribute(true);

                    Guid nsIWebProgressListenerGUID  = typeof(nsIWebProgressListener).GUID;
                    Guid nsIWebProgressListener2GUID = typeof(nsIWebProgressListener2).GUID;
                    WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListenerGUID);
                    WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListener2GUID);

                    if (UseHttpActivityObserver)
                    {
                        ObserverService.AddObserver(this, ObserverNotifications.HttpRequests.HttpOnModifyRequest, false);
                        Net.HttpActivityDistributor.AddObserver(this);
                    }

                    // force inital window initialization. (Events now get added after document navigation.
                    {
                        var domWindow = WebBrowser.GetContentDOMWindowAttribute();
                        EventTarget = Gecko.Interop.ExtensionMethods.AsComPtr(((nsIDOMEventTarget)domWindow));
                        using (var eventType = new nsAString("somedummyevent"))
                        {
                            EventTarget.Instance.AddEventListener(eventType, this, true, true, 2);
                            EventTarget.Instance.RemoveEventListener(eventType, this, true);
                        }
                    }

                    // history
                    {
                        var sessionHistory = WebNav.GetSessionHistoryAttribute();
                        if (sessionHistory != null)
                        {
                            sessionHistory.AddSHistoryListener(this);
                        }
                    }

                    // this fix prevents the browser from crashing if the first page loaded is invalid (missing file, invalid URL, etc)
                    var doc = Document;
                    if (doc != null)
                    {
                        // only for html documents
                        doc.Cookie = "";
                    }
                    WindowMediator.RegisterWindow(this);
                }

#if !GTK
                base.OnHandleCreated(e);
#endif
            }
            finally
            {
                InOnHandleCreate = false;
                GeckoHandleCreated(this, EventArgs.Empty);
            }
        }
Exemple #6
0
 public EconomicalContentImpl(DockingManagerEx owner, string title, int imageIndex, WindowCreator _creator)
     : base(owner, title, imageIndex)
 {
     this.creator = _creator;
 }
Exemple #7
0
        protected override void OnHandleCreated(EventArgs e)
        {
#if GTK
            if (Xpcom.IsMono)
            {
                base.OnHandleCreated(e);
                m_wrapper.Init();
            }
#endif
            if (!this.DesignMode)
            {
                Xpcom.Initialize();
                WindowCreator.Register();
#if !GTK
                LauncherDialogFactory.Register();
#endif

                WebBrowser      = Xpcom.CreateInstance <nsIWebBrowser>(Contracts.WebBrowser);
                WebBrowserFocus = ( nsIWebBrowserFocus )WebBrowser;
                BaseWindow      = ( nsIBaseWindow )WebBrowser;
                WebNav          = ( nsIWebNavigation )WebBrowser;

                WebBrowser.SetContainerWindowAttribute(this);
#if GTK
                if (Xpcom.IsMono)
                {
                    BaseWindow.InitWindow(m_wrapper.BrowserWindow.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);
                }
                else
#endif
                BaseWindow.InitWindow(this.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);


                BaseWindow.Create();

                Guid nsIWebProgressListenerGUID  = typeof(nsIWebProgressListener).GUID;
                Guid nsIWebProgressListener2GUID = typeof(nsIWebProgressListener2).GUID;
                WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListenerGUID);
                WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListener2GUID);

                if (UseHttpActivityObserver)
                {
                    ObserverService.AddObserver(this, ObserverNotifications.HttpRequests.HttpOnModifyRequest, false);
                    Net.HttpActivityDistributor.AddObserver(this);
                }

                // var domEventListener = new GeckoDOMEventListener(this);

                {
                    var domWindow = WebBrowser.GetContentDOMWindowAttribute();
                    EventTarget = domWindow.GetWindowRootAttribute().AsComPtr();
                    Marshal.ReleaseComObject(domWindow);
                }

                foreach (string sEventName in this.DefaultEvents)
                {
                    using (var eventType = new nsAString(sEventName))
                    {
                        EventTarget.Instance.AddEventListener(eventType, this, true, true, 2);
                    }
                }

                // history
                {
                    var sessionHistory = WebNav.GetSessionHistoryAttribute();
                    if (sessionHistory != null)
                    {
                        sessionHistory.AddSHistoryListener(this);
                    }
                }

                BaseWindow.SetVisibilityAttribute(true);

                // this fix prevents the browser from crashing if the first page loaded is invalid (missing file, invalid URL, etc)
                if (Document != null)
                {
                    // only for html documents
                    Document.Cookie = "";
                }
            }

            base.OnHandleCreated(e);
        }
        protected override void OnHandleCreated(EventArgs e)
        {
#if GTK
            if (Xpcom.IsMono)
            {
                base.OnHandleCreated(e);
                m_wrapper.Init();
            }
#endif
            if (!this.DesignMode)
            {
                Xpcom.Initialize();
                WindowCreator.Register();
#if !GTK
                LauncherDialogFactory.Register();
#endif

                WebBrowser      = Xpcom.CreateInstance <nsIWebBrowser>("@mozilla.org/embedding/browser/nsWebBrowser;1");
                WebBrowserFocus = (nsIWebBrowserFocus)WebBrowser;
                BaseWindow      = (nsIBaseWindow)WebBrowser;

                WebNav = (nsIWebNavigation)WebBrowser;

                WebBrowser.SetContainerWindowAttribute(this);
#if GTK
                if (Xpcom.IsMono)
                {
                    BaseWindow.InitWindow(m_wrapper.BrowserWindow.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);
                }
                else
#endif
                BaseWindow.InitWindow(this.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);


                RecordNewJsContext();
                BaseWindow.Create();

                Guid nsIWebProgressListenerGUID = typeof(nsIWebProgressListener).GUID;
                WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListenerGUID);

                if (UseHttpActivityObserver)
                {
                    ObserverService.AddObserver(this, ObserverNotifications.HttpRequests.HttpOnModifyRequest, false);

                    nsIHttpActivityDistributor activityDistributor = Xpcom.GetService <nsIHttpActivityDistributor>("@mozilla.org/network/http-activity-distributor;1");
                    activityDistributor = Xpcom.QueryInterface <nsIHttpActivityDistributor>(activityDistributor);
                    activityDistributor.AddObserver(this);
                }

                // var domEventListener = new GeckoDOMEventListener(this);

                _target = Xpcom.QueryInterface <nsIDOMWindow>(WebBrowser.GetContentDOMWindowAttribute()).GetWindowRootAttribute();

                _target.AddEventListener(new nsAString("submit"), this, true, true, 2);
                _target.AddEventListener(new nsAString("keydown"), this, true, true, 2);
                _target.AddEventListener(new nsAString("keyup"), this, true, true, 2);
                _target.AddEventListener(new nsAString("keypress"), this, true, true, 2);
                _target.AddEventListener(new nsAString("mousemove"), this, true, true, 2);
                _target.AddEventListener(new nsAString("mouseover"), this, true, true, 2);
                _target.AddEventListener(new nsAString("mouseout"), this, true, true, 2);
                _target.AddEventListener(new nsAString("mousedown"), this, true, true, 2);
                _target.AddEventListener(new nsAString("mouseup"), this, true, true, 2);
                _target.AddEventListener(new nsAString("click"), this, true, true, 2);
                _target.AddEventListener(new nsAString("dblclick"), this, true, true, 2);
                _target.AddEventListener(new nsAString("compositionstart"), this, true, true, 2);
                _target.AddEventListener(new nsAString("compositionend"), this, true, true, 2);
                _target.AddEventListener(new nsAString("contextmenu"), this, true, true, 2);
                _target.AddEventListener(new nsAString("DOMMouseScroll"), this, true, true, 2);
                _target.AddEventListener(new nsAString("focus"), this, true, true, 2);
                _target.AddEventListener(new nsAString("blur"), this, true, true, 2);
                // Load event added here rather than DOMDocument as DOMDocument recreated when navigating
                // ths losing attached listener.
                _target.AddEventListener(new nsAString("load"), this, true, true, 2);
                _target.AddEventListener(new nsAString("change"), this, true, true, 2);

                // history
                {
                    var sessionHistory = WebNav.GetSessionHistoryAttribute();
                    if (sessionHistory != null)
                    {
                        sessionHistory.AddSHistoryListener(this);
                    }
                }

                BaseWindow.SetVisibilityAttribute(true);

                // this fix prevents the browser from crashing if the first page loaded is invalid (missing file, invalid URL, etc)
                if (Document != null)
                {
                    // only for html documents
                    Document.Cookie = "";
                }
            }

            base.OnHandleCreated(e);
        }
        protected override void OnHandleCreated(EventArgs e)
        {
            try
            {
                InOnHandleCreate = true;
#if GTK
                if (Xpcom.IsMono)
                {
                    base.OnHandleCreated(e);
                }
#endif
                if (!this.DesignMode)
                {
                    Xpcom.Initialize();
                    WindowCreator.Register();
#if !GTK
                    LauncherDialogFactory.Register();
#endif

                    WebBrowser      = Xpcom.CreateInstance <nsIWebBrowser>(Contracts.WebBrowser);
                    WebBrowserFocus = (nsIWebBrowserFocus)Browser;
                    BaseWindow      = (nsIBaseWindow)Browser;
                    WebNav          = (nsIWebNavigation)Browser;

                    Browser.SetContainerWindowAttribute(this);
#if GTK
                    var drawn = false;
                    Gtk.DrawnHandler drawnHandler = null;
                    drawnHandler = (object o, Gtk.DrawnArgs args) =>
                    {
                        _topLevelWindow.Drawn -= drawnHandler;
                        drawn = true;
                    };
                    _topLevelWindow.Drawn += drawnHandler;

                    if (Xpcom.IsMono)
                    {
                        if (m_wrapper == null)
                        {
                            throw new InvalidOperationException("If GTK window is null we can't continue.");
                        }
                        BaseWindow.InitWindow(m_wrapper.BrowserWindow.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);
                    }
                    else
#endif
                    BaseWindow.InitWindow(this.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);
#if GTK
                    if (m_wrapper != null)
                    {
                        m_wrapper.Init();
                    }

                    // Only wait for a max of 300ms. (To prevent possiblty of a hang)
                    DateTime d = DateTime.Now;
                    while (Gtk.Application.EventsPending() && !drawn)
                    {
                        Gtk.Application.RunIteration(false);
                        if ((DateTime.Now - d).TotalMilliseconds > 300)
                        {
                            break;
                        }
                    }
#endif

                    BaseWindow.Create();

                    var docShell = Xpcom.QueryInterface <nsIDocShell>(BaseWindow);
                    // Allow visible control before finished loading see https://bugzilla.mozilla.org/show_bug.cgi?id=1138536
                    docShell.CreateAboutBlankContentViewer(null);
                    Xpcom.FreeComObject(ref docShell);
                    BaseWindow.SetVisibilityAttribute(true);

                    Guid nsIWebProgressListenerGUID  = typeof(nsIWebProgressListener).GUID;
                    Guid nsIWebProgressListener2GUID = typeof(nsIWebProgressListener2).GUID;
                    // AddEventListener Doesn't yet work
                    Browser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListenerGUID);
                    Browser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListener2GUID);

                    if (UseHttpActivityObserver)
                    {
                        ObserverService.AddObserver(this, ObserverNotifications.HttpRequests.HttpOnModifyRequest, false);
                        Net.HttpActivityDistributor.AddObserver(this);
                    }

                    // force inital window initialization. (Events now get added after document navigation.
                    {
                        var domWindow = Browser.GetContentDOMWindowAttribute();
                        EventTarget = ((nsIDOMEventTarget)domWindow).AsComPtr();
                        using (var eventType = new nsAString("somedummyevent"))
                        {
                            EventTarget.Instance.AddEventListener(eventType, this, true, true, 2);
                            EventTarget.Instance.RemoveEventListener(eventType, this, true);
                        }
                    }

                    // history
                    {
                        var sessionHistory = WebNav.GetSessionHistoryAttribute();
                        if (sessionHistory != null)
                        {
                            sessionHistory.AddSHistoryListener(this);
                        }
                    }
                    WindowMediator.RegisterWindow(this);
                }

#if !GTK
                base.OnHandleCreated(e);
#endif
            }
            finally
            {
                InOnHandleCreate = false;
                GeckoHandleCreated(this, EventArgs.Empty);
            }
        }
Exemple #10
0
 public void Awake()
 {
     instance = this;
 }
Exemple #11
0
 /// <summary>
 /// Registers windows type. Use IWindowCreatorTemplate.
 /// </summary>
 /// <param name="windowCreator">window creator factory.</param>
 /// <param name="typeName">window type name.</param>
 public void RegisterWindowType(WindowCreator windowCreator, String typeName)
 {
     this.windowCreators[typeName] = windowCreator;
 }