Example #1
0
        bool Initialize()
        {
            if (!m_initialized)
            {
                m_configManager  = new ConfigManager();
                m_sfmlManager    = new SfmlManager();
                m_vrManager      = new VRManager(this);
                m_leapManager    = new LeapManager(this);
                m_controlManager = new ControlManager(this);

                m_configManager.Load();
                m_initialized = (m_vrManager.Initialize() && m_sfmlManager.Initialize() && m_leapManager.Initialize() && m_controlManager.Initialize());

                if (m_initialized)
                {
                    m_trayThread = new System.Threading.Thread(() =>
                    {
                        try
                        {
                            m_trayIcon         = new System.Windows.Forms.NotifyIcon();
                            m_trayIcon.Icon    = new System.Drawing.Icon("icon.ico");
                            m_trayIcon.Text    = "Driver Leap Control";
                            m_trayIcon.Visible = true;

                            m_trayIcon.ContextMenu = new System.Windows.Forms.ContextMenu();
                            var l_reloadItem       = new System.Windows.Forms.MenuItem();
                            l_reloadItem.Text      = "Reload settings";
                            l_reloadItem.Click    += new EventHandler((o, e) =>
                            {
                                m_tasksMutex.WaitOne();
                                m_tasks.Add(ReloadSettings);
                                m_tasksMutex.ReleaseMutex();
                            });
                            m_trayIcon.ContextMenu.MenuItems.Add(l_reloadItem);

                            System.Windows.Forms.Application.Run();
                        }
                        catch (ThreadAbortException)
                        {
                            System.Windows.Forms.Application.Exit();
                        }
                        catch (Exception) { }
                    });
                    m_trayThread.Start();
                }

                m_active = m_initialized;
            }

            return(m_initialized);
        }
Example #2
0
        void Terminate()
        {
            m_controlManager?.Terminate();
            m_controlManager = null;

            m_leapManager?.Terminate();
            m_leapManager = null;

            m_sfmlManager?.Terminate();
            m_sfmlManager = null;

            m_vrManager?.Terminate();
            m_vrManager = null;

            m_trayThread?.Abort();
            m_trayThread = null;

            m_trayIcon?.Dispose();
            m_trayIcon = null;

            m_initialized = false;
        }