示例#1
0
        //
        // Summary:
        //     Callback when Desktop is successfully connected and ready to accept commands.
        public void onReady()
        {
            Openfin.Desktop.ApplicationOptions appOptions    = new Openfin.Desktop.ApplicationOptions(parentAppUuid_, parentAppUuid_, url_);
            Openfin.Desktop.WindowOptions      windowOptions = appOptions.MainWindowOptions;
            windowOptions.AutoShow      = true;
            windowOptions.DefaultWidth  = 310;
            windowOptions.DefaultHeight = 287;

            AckCallback afterCreate = (createAck) => {
                htmlApp_.run((runAck) => {
                    // Handle on UI thread to get the window bounds
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        htmlApp_.getWindow().showAt((int)Left + (int)Width + 80, (int)Top, false);
                        htmlApp_.getWindow().setAsForeground();

                        // Subscribe to handle when this app has been registered with the HTML app
                        connection_.getInterApplicationBus().subscribe(parentAppUuid_, "csharp-registered", (sourceUuid, topic, message) =>
                        {
                            // Handle on UI thread to check externalObserver_ is not defined
                            this.Dispatcher.BeginInvoke(new Action(() =>
                            {
                                if (externalObserver_ == null)
                                {
                                    // Integrate this window
                                    externalObserver_ = new Openfin.Desktop.ExternalWindowObserver(host_,
                                                                                                   port_,
                                                                                                   parentAppUuid_,
                                                                                                   name_,
                                                                                                   new WindowInteropHelper(this).Handle);
                                }
                            }));
                        });

                        // Ensure HTML is ready before registering.
                        connection_.getInterApplicationBus().subscribe(parentAppUuid_, "html-wpf-ready", (rSourceUuid, rTopic, rMessage) =>
                        {
                            // Be on UI thread to ensure externalObserver_ is not defined
                            this.Dispatcher.BeginInvoke(new Action(() =>
                            {
                                // Notify HTML to register and prepare for docking with this C# app
                                if (externalObserver_ == null)
                                {
                                    JObject payload = new JObject();
                                    DesktopUtils.updateJSONValue(payload, "name", name_);
                                    connection_.getInterApplicationBus().send(parentAppUuid_, "reserve-csharp-name", payload);
                                }
                            }));
                        });

                        connection_.getInterApplicationBus().send(parentAppUuid_, "wpf-html-ready", null);
                    }));
                });
            };

            htmlApp_ = new Openfin.Desktop.Application(appOptions, connection_, afterCreate, afterCreate);
        }
示例#2
0
        /// <summary>
        ///     Called after the websocket connection has been established
        /// </summary>
        public void onReady()
        {
            // Run on UI thread
            this.Dispatcher.Invoke(new Action(() => {
                // Default some options for the application and its main window
                ApplicationOptions options = new ApplicationOptions(receiverUuid_,
                                                                    receiverUuid_,
                                                                    "https://demoappdirectory.openf.in/desktop/examples/interapp-receiver/index.html");
                options.MainWindowOptions.AutoShow      = true;
                options.MainWindowOptions.DefaultWidth  = 800;
                options.MainWindowOptions.DefaultHeight = 600;

                // Create and run the HTML application
                htmlApp_ = new Openfin.Desktop.Application(options, connection_);

                // Setting delegate on error callback as well.
                // handles the case where the application is already running.
                htmlApp_.run(afterRun, afterRun);
            }));
        }
示例#3
0
        //
        // Summary:
        //     Callback when Desktop is successfully connected and ready to accept commands.
        public void onReady()
        {
            Openfin.Desktop.ApplicationOptions appOptions = new Openfin.Desktop.ApplicationOptions(parentAppUuid_, parentAppUuid_, url_);
            Openfin.Desktop.WindowOptions windowOptions = appOptions.MainWindowOptions;
            windowOptions.AutoShow = true;
            windowOptions.DefaultWidth = 310;
            windowOptions.DefaultHeight = 287;

            AckCallback afterCreate = (createAck) => {
                htmlApp_.run((runAck) => {

                    // Handle on UI thread to get the window bounds
                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        htmlApp_.getWindow().showAt((int)Left + (int)Width + 80, (int)Top, false);
                        htmlApp_.getWindow().setAsForeground();

                        // Subscribe to handle when this app has been registered with the HTML app
                        connection_.getInterApplicationBus().subscribe(parentAppUuid_, "csharp-registered", (sourceUuid, topic, message) =>
                        {
                            // Handle on UI thread to check externalObserver_ is not defined
                            this.Dispatcher.BeginInvoke(new Action(() =>
                            {
                                if (externalObserver_ == null)
                                {
                                    // Integrate this window
                                    externalObserver_ = new Openfin.Desktop.ExternalWindowObserver(host_,
                                                                                                   port_,
                                                                                                   parentAppUuid_,
                                                                                                   name_,
                                                                                                   new WindowInteropHelper(this).Handle);
                                }
                            }));
                        });

                        // Ensure HTML is ready before registering.
                        connection_.getInterApplicationBus().subscribe(parentAppUuid_, "html-wpf-ready", (rSourceUuid, rTopic, rMessage) =>
                        {
                            // Be on UI thread to ensure externalObserver_ is not defined
                            this.Dispatcher.BeginInvoke(new Action(() =>
                            {
                                // Notify HTML to register and prepare for docking with this C# app
                                if (externalObserver_ == null) {
                                    JObject payload = new JObject();
                                    DesktopUtils.updateJSONValue(payload, "name", name_);
                                    connection_.getInterApplicationBus().send(parentAppUuid_, "reserve-csharp-name", payload);
                                }
                            }));

                        });

                        connection_.getInterApplicationBus().send(parentAppUuid_, "wpf-html-ready", null);
                    }));
                });
            };

            htmlApp_ = new Openfin.Desktop.Application(appOptions, connection_, afterCreate, afterCreate);
        }
示例#4
0
        /// <summary>
        ///     Called after the websocket connection has been established
        /// </summary>
        public void onReady()
        {
            // Run on UI thread
            this.Dispatcher.Invoke(new Action(() => {
                // Default some options for the application and its main window
                ApplicationOptions options = new ApplicationOptions(receiverUuid_,
                                                                    receiverUuid_, 
                                                                    "https://demoappdirectory.openf.in/desktop/examples/interapp-receiver/index.html");
                options.MainWindowOptions.AutoShow = true;
                options.MainWindowOptions.DefaultWidth = 800;
                options.MainWindowOptions.DefaultHeight = 600;

                // Create and run the HTML application
                htmlApp_ = new Openfin.Desktop.Application(options, connection_);

                // Setting delegate on error callback as well. 
                // handles the case where the application is already running.
                htmlApp_.run(afterRun, afterRun);
            }));
        }