コード例 #1
0
ファイル: Program.cs プロジェクト: Pupix/Mimic
        static void Main()
        {
            try
            {
                using (new SingleGlobalInstance(500)) // Wait 500 seconds max for other programs to stop
                {
                    var lcuPath = LeagueMonitor.GetLCUPath();
                    if (lcuPath == null)
                    {
                        MessageBox.Show("Could not determine path to LCU!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return; // Abort
                    }

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Program(lcuPath));
                }
            }
            catch (TimeoutException)
            {
                MessageBox.Show("Mimic Conduit is already running!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Pupix/Mimic
        private Program(string lcuPath)
        {
            // Start the websocket server. It will not actually do anything until we add a behavior.
            server = new WebSocketServer(8182);

            try
            {
                server.Start();
            }
            catch (System.Net.Sockets.SocketException e)
            {
                MessageBox.Show($"Error code {e.ErrorCode.ToString()}: '{e.Message}'", "Unable to start server", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            trayIcon = new NotifyIcon()
            {
                Icon            = new Icon(GetType(), "mimic.ico"),
                Visible         = true,
                BalloonTipTitle = "Mimic",
            };

            if (!startsOnBoot) // If starting on boot, boot silently.
            {
                trayIcon.BalloonTipText = "Mimic will run in the background. Right-Click the tray icon for more info.";
                trayIcon.ShowBalloonTip(5000);
            }
            else if (bootKey.GetValue(APP_NAME).ToString() != Application.ExecutablePath) // Was our application moved?
            {
                bootKey.SetValue(APP_NAME, Application.ExecutablePath);                   // Make sure the application startup location is correct
            }
            UpdateMenuItems();

            // Start monitoring league.
            leagueMonitor = new LeagueMonitor(lcuPath, onLeagueStart, onLeagueStop);
        }