Esempio n. 1
0
            public ApplicationContext(string[] args)
            {
                var    nonFSBLArgs = GetNonFinsembleArgs(args);
                string name        = nonFSBLArgs.First();
                Form   form        = CreateForm(name);
                var    fsbl        = new Finsemble(args.ToArray(), form);

                fsbl.Connected += (s, e) =>
                {
                    Debug.WriteLine("FSBL connected");

                    IIntegratable fsblForm = form as IIntegratable;
                    if (fsblForm != null)
                    {
                        fsblForm.SetFinsemble(fsbl);
                    }
                };

                // Dispose of Finsemble object when window is closed.
                form.Closed += (s, e) =>
                {
                    Debug.WriteLine("disposing window from app.xaml");
                    fsbl.Dispose();
                    Debug.WriteLine("dispose completed");
                };
                fsbl.Connect();
                this.MainForm         = form;
                this.IsSingleInstance = true;
            }
Esempio n. 2
0
            /// <summary>
            /// The OnStartupNextInstance.
            /// </summary>
            /// <param name="eventArgs">The eventArgs<see cref="StartupNextInstanceEventArgs"/>.</param>
            protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
            {
                var    nonFSBLArgs = GetNonFinsembleArgs(eventArgs.CommandLine);
                string name        = nonFSBLArgs.First();
                Form   form        = CreateForm(name);
                var    fsbl        = new Finsemble(eventArgs.CommandLine.ToArray(), form);

                fsbl.Connected += (s, e) =>
                {
                    Debug.WriteLine("FSBL connected");
                    IIntegratable fsblForm = form as IIntegratable;
                    if (fsblForm != null)
                    {
                        fsblForm.SetFinsemble(fsbl);
                    }
                };

                // Dispose of Finsemble object when window is closed.
                form.Closed += (s, e) =>
                {
                    Debug.WriteLine("disposing window from app.xaml");
                    fsbl.Dispose();
                    Debug.WriteLine("dispose completed");
                };
                fsbl.Connect();
                form.Show();
            }
        /// <summary>
        /// Main runner for Finsemble and Bloomberg integration
        /// </summary>
        /// <param name="args">Arguments used to initialize Finsemble connection - generated by Finsemble when it spawns the component.</param>
        public static void Main(string[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif
            lock (lockObj)
            {
                AppDomain.CurrentDomain.ProcessExit += new System.EventHandler(CurrentDomain_ProcessExit);
            }

            // Initialize Finsemble
            try
            {
                FSBL               = new Finsemble(args, null);
                FSBL.Connected    += OnConnected;
                FSBL.Disconnected += OnShutdown;
                FSBL.Connect();
            }
            catch (Exception err)
            {
                Console.WriteLine("Exception thrown while connecting to Finsemble, error: " + err.Message);
            }
            // Block main thread until worker is finished.
            autoEvent.WaitOne();
        }
 public MainWindow(string[] args)
 {
     //Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble.
     finsemble = new Finsemble(args, this);
     finsemble.Connect();
     finsemble.Connected += Finsemble_Connected;
 }
        /// <summary>
        /// The MainWindow is created by the App so that we can get command line arguments passed from Finsemble.
        /// </summary>
        /// <param name="args"></param>
        public MainWindow(string[] args)
        {
            // Trigger actions on close when requested by Finsemble, e.g.:
            this.Closing += MainWindow_Closing;

            FSBL            = new Finsemble(args, this);  // Finsemble needs the command line arguments to connect and also this Window to manage snapping, docking etc.
            FSBL.Connected += Finsemble_Connected;
            FSBL.Connect();
        }
Esempio n. 6
0
        /// <summary>
        /// The MainWindow is created by the App so that we can get command line arguments passed from Finsemble.
        /// </summary>
        /// <param name="args"></param>
        public MainWindow(string[] args)
        {
            // Trigger actions on close when requested by Finsemble, e.g.:
            this.Closing += MainWindow_Closing;

            //Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble.
            FSBL            = new Finsemble(args, this);  // Finsemble needs the command line arguments to connect and also this Window to manage snapping, docking etc.
            FSBL.Connected += Finsemble_Connected;
            FSBL.Connect();
        }
Esempio n. 7
0
        public FormExample(String[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif
            InitializeComponent();

            FSBL            = new Finsemble(args, this);
            FSBL.Connected += FinsembleConnected;
            FSBL.Connect();
        }
Esempio n. 8
0
 /// <summary>
 /// The MainWindow is created by the App so that we can get command line arguments passed from Finsemble.
 /// </summary>
 /// <param name="args"></param>
 public MainWindow(string[] args)
 {
     // Trigger actions on close when requested by Finsemble, e.g.:
     this.Closing += MainWindow_Closing;
     // If your window should support a transparency, AllowsTransparency and WindowStyle must be setted before EnsureHandle() call
     this.AllowsTransparency = true;
     this.WindowStyle        = WindowStyle.None;
     // Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble.
     new WindowInteropHelper(this).EnsureHandle();
     FSBL            = new Finsemble(args, this);  // Finsemble needs the command line arguments to connect and also this Window to manage snapping, docking etc.
     FSBL.Connected += Finsemble_Connected;
     FSBL.Connect("FDC3WPFExample", JWK);
 }
Esempio n. 9
0
        static void Main(string[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif

            // Initialize Finsemble
            FSBL               = new Finsemble(args, null);
            FSBL.Connected    += OnConnected;
            FSBL.Disconnected += OnShutdown;
            FSBL.Connect();

            // Block main thread until worker is finished.
            autoEvent.WaitOne();
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif

            // Initialize Finsemble
            //Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble.
            FSBL               = new Finsemble(args, null);
            FSBL.Connected    += OnConnected;
            FSBL.Disconnected += OnShutdown;
            FSBL.Connect();

            // Block main thread until worker is finished.
            autoEvent.WaitOne();
        }
Esempio n. 11
0
        public FormExample(String[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif
            InitializeComponent();

            this.input.KeyPress += new System.Windows.Forms.KeyPressEventHandler(handleKeyPresses);

            //connect to Finsemble
            //Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble.
            FSBL = new Finsemble(args, this);

            // Use handle
            // FSBL = new Finsemble(args, this.Handle);
            //----

            FSBL.Connected += FinsembleConnected;
            FSBL.Connect();
        }
Esempio n. 12
0
            public ApplicationContext(string[] args)
            {
                var    nonFSBLArgs = GetNonFinsembleArgs(args);
                string name        = nonFSBLArgs.FirstOrDefault();
                Form   form        = CreateForm(name);

                if (form == null)
                {
                    MessageBox.Show($"\"{name}\" unknown name of form!");
                    return;
                }

                var fsbl = new Finsemble(args.ToArray(), form);

                fsbl.Connected += (s, e) =>
                {
                    Debug.WriteLine("FSBL connected");

                    IIntegratable fsblForm = form as IIntegratable;
                    if (fsblForm != null)
                    {
                        fsblForm.SetFinsemble(fsbl);
                    }
                };

                // Dispose of Finsemble object when window is closed.
                form.Closed += (s, e) =>
                {
                    Debug.WriteLine("disposing window from app.xaml");
                    fsbl.Dispose();
                    Debug.WriteLine("dispose completed");
                };
                fsbl.Connect("WinformMultiWindowExample", JWK);
                this.MainForm         = form;
                this.IsSingleInstance = true;
            }
Esempio n. 13
0
 protected override void OnStart(string[] args)
 {
     FSBL.Connect();
     FSBL.Connected += FSBL_Connected;
 }
Esempio n. 14
0
 public MainWindow(string[] args)
 {
     finsemble = new Finsemble(args, this);
     finsemble.Connect();
     finsemble.Connected += Finsemble_Connected;
 }
Esempio n. 15
0
        public static void Main(string[] args)
        {
#if DEBUG
            Debugger.Launch();
#endif
            // create a global mutex
            using (var mutex = new Mutex(false, "Finsemble"))
            {
                var mutexAcquired = false;
                try
                {
                    // acquire the mutex (or timeout after 60 seconds)
                    // will return false if it timed out
                    mutexAcquired = mutex.WaitOne(60000);
                }
                catch (AbandonedMutexException)
                {
                    // abandoned mutexes are still acquired, we just need
                    // to handle the exception and treat it as acquisition
                    mutexAcquired = true;
                }

                // if it wasn't acquired, it timed out, so can handle that how ever we want
                if (!mutexAcquired)
                {
                    Console.WriteLine("I have timed out acquiring the mutex and can handle that somehow");
                    return;
                }

                // otherwise, we've acquired the mutex and should do what we need to do,
                // then ensure that we always release the mutex
                if (SingleInstance <App> .InitializeAsFirstInstance(Unique))
                {
                    application = new App();

                    // If window type passed for initial launch, add listener to launch window when connected.
                    var argsList = args.ToList();
                    IEnumerable <string> nonFSBLArgs = GetNonFinsembleArgs(argsList);
                    if ((nonFSBLArgs != null) && nonFSBLArgs.Any())
                    {
                        // Non-finsemble arguments passed, launch window
                        LaunchWindow(args.ToList());
                    }
                    else
                    {
                        // Register with Finsemble as a windowless component so the application will close when Finsemble is closed.
                        //Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble.
                        var fsbl = new Finsemble(args.ToArray(), null);

                        fsbl.Connect("MultiWindowExample", JWK);
                    }

                    application.InitializeComponent();
                    mutex.ReleaseMutex();
                    application.Run();

                    // Allow single instance code to perform cleanup operations
                    SingleInstance <App> .Cleanup();
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Launches a Finsemble aware window with the passed arguments.
        /// </summary>
        /// <param name="args">The arguments passed to the process.</param>
        /// <returns>Always true?</returns>
        private static bool LaunchWindow(IList <string> args)
        {
#if DEBUG
            Debugger.Launch();
#endif

            if (!args.Any())
            {
                // Invalid number of arguments
                return(true);
            }

            var nonFSBLArgs = GetNonFinsembleArgs(args);
            if ((nonFSBLArgs == null) || !nonFSBLArgs.Any())
            {
                // no non-finsemble arguments. Cannot launch window.
                return(true);
            }

            string name = nonFSBLArgs.First();

            // handle command line arguments of second instance
            Window window = null;
            Current.Dispatcher.Invoke(() =>
            {
                window = CreateWindow(name);
            });

            if (window == null)
            {
                Debug.Print($"Could not create window: {name}");
            }
            else
            {
                // Register with Finsemble
                //Ensure that your window has been created (so that its window handle exists) before connecting to Finsemble.
                var fsbl = new Finsemble(args.ToArray(), window);
                fsbl.Connected += (s, e) =>
                {
                    IIntegratable fsblWin = window as IIntegratable;
                    if (fsblWin == null)
                    {
                        Debug.Print($"The window \"{name}\" is not a window that can be integrated into Finsemble.");
                    }
                    else
                    {
                        fsblWin.SetFinsemble(fsbl);
                    }

                    Current.Dispatcher.Invoke(window.Show);
                };

                // Dispose of Finsemble object when window is closed.
                window.Closed += (s, e) =>
                {
                    Debug.WriteLine("disposing window from app.xaml");
                    fsbl.Dispose();
                    Debug.WriteLine("dispose completed");
                };

                fsbl.Connect("MultiWindowExample", JWK);
            }

            return(true);
        }
 /// <summary>
 /// The MainWindow is created by the App so that we can get command line arguments passed from Finsemble.
 /// </summary>
 /// <param name="args"></param>
 public MainWindow(string[] args)
 {
     FSBL = new Finsemble(args, this); // Finsemble needs the command line arguments to connect and also this Window to manage snapping, docking etc.
     FSBL.Connect();
     FSBL.Connected += Finsemble_Connected;
 }