private void LogStateChanged(object sender, Servers.ServerStateEventArgs e)
        {
            string messageLabel = "Logger";
            string message      = string.Empty;

            switch (e.state)
            {
            case Servers.ServerState.Begin:
                message = "Log Started";

                MainForm.AppendMessage("Log Started", messageLabel);

                if (Properties.Settings.Default.Logger_LoggingNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }

                ControlUtils.AsyncSafeInvoke(this, () =>
                {
                    this.StartLogButton.Text = "Stop Log";
                    this.StartLogButton.Icon = Properties.Resources.stop;
                });
                break;

            case Servers.ServerState.Stop:
                message = "Log Stopped";

                if (string.IsNullOrWhiteSpace(Server.LogServer.LogFilePath) == false)
                {
                    message += string.Format(". Saved to \"{0}\"", Server.LogServer.LogFilePath);
                }

                MainForm.AppendMessage(message, messageLabel);

                if (Properties.Settings.Default.Logger_LoggingNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }

                ControlUtils.AsyncSafeInvoke(this, () =>
                {
                    this.StartLogButton.Text = "Start Log";
                    this.StartLogButton.Icon = Properties.Resources.play;
                });
                break;
            }
        }
        private void ServerStateChanged(object sender, Servers.ServerStateEventArgs e)
        {
            string messageLabel = "Serial Port";
            string message      = string.Empty;

            switch (e.state)
            {
            case Servers.ServerState.Begin:
                message = "Server started";

                if (Properties.Settings.Default.SerialPort_ServerNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }

                MainForm.AppendMessage(message, messageLabel);

                ControlUtils.AsyncSafeInvoke(this, () =>
                {
                    this.StartServerButton.Text  = "Stop Server";
                    this.StartServerButton.Icon  = Properties.Resources.stop;
                    this.ParametersPanel.Enabled = false;
                    this.TargetPortField.Enabled = false;
                });
                break;

            case Servers.ServerState.Waiting:
                message = "Waiting for connection...";
                MainForm.AppendMessage(message, messageLabel);
                break;

            case Servers.ServerState.Connected:
                if (string.IsNullOrWhiteSpace(Server.OpenPort))
                {
                    message = "Connected";
                }
                else
                {
                    message = "Connected to " + Server.OpenPort;
                }

                if (Properties.Settings.Default.SerialPort_ServerNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }

                MainForm.AppendMessage(message, messageLabel);
                break;

            case Servers.ServerState.Reconnect:
                message = "Reconnecting";

                if (Properties.Settings.Default.SerialPort_ServerNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }

                MainForm.AppendMessage(message, messageLabel);
                break;

            case Servers.ServerState.Stop:
                message = "Server stopped";

                if (Properties.Settings.Default.SerialPort_ServerNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }

                MainForm.AppendMessage(message, messageLabel);

                ControlUtils.AsyncSafeInvoke(this, () =>
                {
                    this.StartServerButton.Text  = "Start Server";
                    this.StartServerButton.Icon  = Properties.Resources.play;
                    this.ParametersPanel.Enabled = true;
                    this.TargetPortField.Enabled = true;
                });
                break;
            }
        }
        private void ServerStateChanged(object sender, Servers.ServerStateEventArgs e)
        {
            string messageLabel = "Logger";
            string message      = string.Empty;

            switch (e.state)
            {
            case Servers.ServerState.Begin:
                message = "Server started";

                MainForm.AppendMessage(message, messageLabel);

                if (Properties.Settings.Default.Logger_ServerNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }

                ControlUtils.AsyncSafeInvoke(this, () =>
                {
                    this.StartServerButton.Text  = "Stop Server";
                    this.StartServerButton.Icon  = Properties.Resources.stop;
                    this.ParametersPanel.Enabled = false;
                });
                break;

            case Servers.ServerState.Waiting:
                MainForm.AppendMessage("Waiting app...", messageLabel);
                break;

            case Servers.ServerState.Connected:
                message = string.Empty;

                if (Server.Settings.UseFrametimeMode == true)
                {
                    message = "Connected to ";

                    try
                    {
                        message += Path.GetFileNameWithoutExtension(Server.FrametimeServer.ConnectedApp);
                    }
                    catch
                    {
                        message += Server.FrametimeServer.ConnectedApp ?? string.Empty;
                    }
                }
                else
                {
                    message = "Connected";
                }

                MainForm.AppendMessage(message, messageLabel);

                if (Properties.Settings.Default.Logger_ServerNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }
                break;

            case Servers.ServerState.Reconnect:
                message = "Reconnecting";

                MainForm.AppendMessage(message, messageLabel);

                if (Properties.Settings.Default.Logger_ServerNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }
                break;

            case Servers.ServerState.Stop:
                message = "Server stopped";

                MainForm.AppendMessage(message, messageLabel);

                if (Properties.Settings.Default.Logger_ServerNotifications == true)
                {
                    MainForm.ShowNotification(message, messageLabel);
                }

                ControlUtils.AsyncSafeInvoke(this, () =>
                {
                    this.StartServerButton.Text  = "Start Server";
                    this.StartServerButton.Icon  = Properties.Resources.play;
                    this.ParametersPanel.Enabled = true;
                });
                break;
            }

            ControlUtils.AsyncSafeInvoke(this, () =>
            {
                if (Server.Settings.UseFrametimeMode == true &&
                    Server.ServerState != Servers.ServerState.Connected ||
                    Server.ServerState == Servers.ServerState.Stop)
                {
                    this.StartLogButton.Enabled = false;
                    StartLogHotkey.Disable();
                }
                else
                {
                    Server.LogDirectory         = Properties.Settings.Default.Logger_LogPath;
                    Server.LogName              = Properties.Settings.Default.Logger_LogName;
                    this.StartLogButton.Enabled = true;
                    StartLogHotkey.Enable();
                }
            });
        }