示例#1
0
        /// <summary>
        /// Set the connection status in the status bar
        /// </summary>
        /// <param name="connected"></param>
        public static void ConnectionStatus(MogMainForm mainForm, bool connected)
        {
            bool problemLoadingIcon = false;

            if (connected)
            {
                if (mainForm.StatusBarImageList.Images.Count > 0)
                {
                    Bitmap home = new Bitmap(mainForm.StatusBarImageList.Images[0]);
                    mainForm.MOGStatusBarConnectionStatusBarPanel.Icon = System.Drawing.Icon.FromHandle(home.GetHicon());
                }
                else
                {
                    problemLoadingIcon = true;
                }
                mainForm.MOGStatusBarConnectionStatusBarPanel.Text = "Connected";

                mainForm.MOGStatusBarConnectionStatusBarPanel.ToolTipText = mainForm.RefreshConnectionToolText();
                MOG_ControllerSystem.GoOnline();
            }
            else
            {
                if (mainForm.StatusBarImageList.Images.Count > 1)
                {
                    Bitmap home = new Bitmap(mainForm.StatusBarImageList.Images[1]);
                    mainForm.MOGStatusBarConnectionStatusBarPanel.Icon = System.Drawing.Icon.FromHandle(home.GetHicon());
                }
                else
                {
                    problemLoadingIcon = true;
                }
                mainForm.MOGStatusBarConnectionStatusBarPanel.Text        = "Disconnected";
                mainForm.MOGStatusBarConnectionStatusBarPanel.ToolTipText = string.Concat("Could not connect to ", MOG_ControllerSystem.GetServerComputerName(), " IP:", MOG_ControllerSystem.GetServerComputerIP());
                MOG_ControllerSystem.GoOffline();
            }

            if (problemLoadingIcon)
            {
                MOG_Prompt.PromptMessage("Project Error", "Programmer: Please rebuild MOG_Client to have all the appropriate *.resx "
                                         + "\r\nfiles correctly included in this project.");
            }
        }