Exemplo n.º 1
0
 public void SetFinsemble(Finsemble fsbl)
 {
     FSBL = fsbl;
     FSBL.RPC("Logger.log", new List <JToken> {
         "Winform example connected to Finsemble. Form3"
     });
 }
Exemplo n.º 2
0
        public void SetFinsemble(Finsemble fsbl)
        {
            this.fsbl = fsbl;

            Application.Current.Dispatcher.Invoke(() =>
            {
                FinsembleHeader.SetBridge(fsbl);                 // The Header Control needs a connected finsemble instance

                //Styling the Finsemble Header
                FinsembleHeader.SetActiveBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#22262F")));
                FinsembleHeader.SetInactiveBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#22262F")));
                FinsembleHeader.SetButtonHoverBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0A8CF4")));
                FinsembleHeader.SetInactiveButtonHoverBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0A8CF4")));
                FinsembleHeader.SetCloseButtonHoverBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F26666")));
                FinsembleHeader.SetInactiveCloseButtonHoverBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F26666")));
                FinsembleHeader.SetDockingButtonDockedBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0A8CF4")));
                FinsembleHeader.SetTitleForeground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ACB2C0")));
                FinsembleHeader.SetButtonForeground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ACB2C0")));

                FinsembleHeader.SetButtonFont(null, 8, FontStyles.Normal, FontWeights.Normal);
                FinsembleHeader.SetTitleFont(null, 12, FontStyles.Normal, FontWeights.SemiBold);

                fsbl.DragAndDropClient.SetScrim(Scrim);                 // The Scrim Label Control is used for drag and drop.

                Show();
            });
        }
Exemplo n.º 3
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>
        /// Handles Finsemble shutdown event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnShutdown(object sender, EventArgs e)
        {
            shutdown = true;
            if (FSBL != null)
            {
                lock (lockObj)
                {
                    if (FSBL != null)
                    {
                        try
                        {
                            removeResponders();

                            // Dispose of Finsemble.
                            FSBL.Dispose();
                        }
                        catch { }
                        finally
                        {
                            FSBL = null;
                            //Environment.Exit(0);
                        }
                    }
                }
            }
            // Release main thread so application can exit.
            autoEvent.Set();
        }
Exemplo n.º 5
0
        private static void OnShutdown(object sender, EventArgs e)
        {
            if (FSBL != null)
            {
                lock (lockObj)
                {
                    if (FSBL != null)
                    {
                        try
                        {
                            // Dispose of Finsemble.
                            FSBL.Dispose();
                        }
                        catch { }
                        finally
                        {
                            FSBL = null;
                        }
                    }
                }
            }

            try
            {
                // Release main thread so application can exit.
                Current.Dispatcher.Invoke(application.Shutdown);
            }
            catch
            {
                // An error occurred, but I don't care as long as it exits.
                ;
            }
        }
Exemplo n.º 6
0
        private static void OnShutdown(object sender, EventArgs e)
        {
            if (FSBL != null)
            {
                lock (lockObj)
                {
                    // Disable log timer
                    timer.Stop();

                    if (FSBL != null)
                    {
                        try
                        {
                            // Dispose of Finsemble.
                            FSBL.Dispose();
                        }
                        catch { }
                        finally
                        {
                            FSBL = null;
                        }
                    }
                }
            }

            // Release main thread so application can exit.
            autoEvent.Set();
        }
Exemplo n.º 7
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;
            }
        /// <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();
        }
Exemplo n.º 9
0
        public void SetFinsemble(Finsemble fsbl)
        {
            this.fsbl = fsbl;

            Application.Current.Dispatcher.Invoke(() =>
            {
                FinsembleHeader.SetBridge(fsbl);                 // The Header Control needs a connected finsemble instance

                // Styling the Finsemble Header
                FinsembleHeader.SetActiveBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3C4C58")));
                FinsembleHeader.SetInactiveBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#303D47")));
                FinsembleHeader.SetButtonHoverBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#005BC5")));
                FinsembleHeader.SetInactiveButtonHoverBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#004BA3")));
                FinsembleHeader.SetCloseButtonHoverBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D30E2D")));
                FinsembleHeader.SetInactiveCloseButtonHoverBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D30E2D")));
                FinsembleHeader.SetDockingButtonDockedBackground(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#005BC5")));
                FinsembleHeader.SetTitleForeground(new SolidColorBrush(Colors.White));
                FinsembleHeader.SetButtonForeground(new SolidColorBrush(Colors.White));

                FinsembleHeader.SetButtonFont(null, 14, FontStyles.Normal, FontWeights.Normal);
                FinsembleHeader.SetTitleFont(null, 14, FontStyles.Normal, FontWeights.Normal);

                fsbl.DragAndDropClient.SetScrim(Scrim);                 // The Scrim Label Control is used for drag and drop.

                Show();
            });
        }
 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;
 }
Exemplo n.º 11
0
 internal MyService(String[] args)
 {
     this.ServiceName         = "MyService";
     this.CanStop             = true;
     this.CanPauseAndContinue = false;
     this.AutoLog             = false;
     FSBL = new Finsemble(args, null);
 }
Exemplo n.º 12
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
#if DEBUG
            Debugger.Launch();
#endif
            Finsemble.DispatcherUnhandledException(mainWindow, e);
            Logger.Error("An Unhandled Exception has occurred. Please Check your event Logs.", e.Exception);
            Shutdown();
        }
        /// <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();
        }
Exemplo n.º 14
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();
        }
Exemplo n.º 15
0
        public FormExample(String[] args)
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif
            InitializeComponent();

            FSBL            = new Finsemble(args, this);
            FSBL.Connected += FinsembleConnected;
            FSBL.Connect();
        }
Exemplo n.º 16
0
        private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
#if DEBUG
            Debugger.Launch();
#endif

            Finsemble.DispatcherUnhandledException(mainWindow, e);

            Debug.Print($"An Unhandled Exception has occurred. Exception: {e.Exception}");
            Shutdown();
        }
Exemplo n.º 17
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);
 }
Exemplo n.º 18
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();
        }
Exemplo n.º 19
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();
        }
Exemplo n.º 20
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();
        }
Exemplo n.º 21
0
        public void SetFinsemble(Finsemble fsbl)
        {
            this.fsbl = fsbl;

            Application.Current.Dispatcher.Invoke(() =>
            {
                FinsembleHeader.SetBridge(fsbl);                 // The Header Control needs a connected finsemble instance

                //Styling the Finsemble Header
                FinsembleHeader.GetHandlingService().ActiveBackground                   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#22262F"));
                FinsembleHeader.GetHandlingService().InactiveBackground                 = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#22262F"));
                FinsembleHeader.GetHandlingService().ButtonHoverBackground              = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0A8CF4"));
                FinsembleHeader.GetHandlingService().InactiveButtonHoverBackground      = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0A8CF4"));
                FinsembleHeader.GetHandlingService().CloseButtonHoverBackground         = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F26666"));
                FinsembleHeader.GetHandlingService().InactiveCloseButtonHoverBackground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F26666"));
                FinsembleHeader.GetHandlingService().DockingButtonDockedBackground      = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0A8CF4"));
                FinsembleHeader.GetHandlingService().TitleForeground  = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ACB2C0"));
                FinsembleHeader.GetHandlingService().ButtonForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ACB2C0"));

                FinsembleHeader.GetHandlingService().ButtonFont = new TitlebarFontConfiguration()
                {
                    FontFamily = null,
                    FontSize   = 8,
                    FontStyle  = FontStyles.Normal,
                    FontWeight = FontWeights.Normal
                };
                FinsembleHeader.GetHandlingService().TitleFont = new TitlebarFontConfiguration()
                {
                    FontFamily = null,
                    FontSize   = 12,
                    FontStyle  = FontStyles.Normal,
                    FontWeight = FontWeights.SemiBold
                };

                fsbl.DragAndDropClient.SetScrim(Scrim);                 // The Scrim Label Control is used for drag and drop.

                Show();
            });
        }
Exemplo n.º 22
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;
            }
Exemplo n.º 23
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;
 }
Exemplo n.º 25
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();
                }
            }
        }
Exemplo n.º 26
0
 public MainWindow(string[] args)
 {
     finsemble = new Finsemble(args, this);
     finsemble.Connect();
     finsemble.Connected += Finsemble_Connected;
 }
Exemplo n.º 27
0
 public void SetFinsemble(Finsemble fsbl)
 {
     FSBL = fsbl;
     FSBL.Logger.Log(new JToken[] { "Winform example connected to Finsemble. Form1" });
 }