예제 #1
0
        //
        //
        // ****             ContextMenuItem_Click()             ****
        //
        private void ContextMenuItem_Click(object sender, EventArgs e)
        {
            Type eventType  = e.GetType();
            Type senderType = sender.GetType();

            if (senderType == typeof(MenuItem))
            {
                MenuItem menuItem     = (MenuItem)sender;
                string   selectedMenu = menuItem.Text;
                switch (selectedMenu)
                {
                case "Exit":
                    BeginShutDown();
                    break;

                case "Hide":
                    this.WindowState = FormWindowState.Minimized;
                    break;

                case "Restore":
                    this.WindowState = FormWindowState.Normal;
                    break;

                case "Status":
                    StringBuilder s         = new StringBuilder();              // Create status report
                    int           nServices = 0;
                    foreach (IService iService in AppServices.GetInstance().GetServices())
                    {
                        /*
                         * if (iService is TTServices.TTApiService)
                         * {
                         *  TTServices.TTApiService ttApi = (TTServices.TTApiService)iService;
                         *  if (ttApi.IsRunning)
                         *  {
                         *      s.AppendFormat("TT Api: connected.\r\n");
                         *      s.AppendFormat("TT Login: {0}\r\n", ttApi.LoginUserName);
                         *  }
                         *  else
                         *      s.Append("TT Api: disconnected.\r\n");
                         * }
                         */
                        nServices++;
                    }
                    s.AppendFormat("Services running: {0}.", nServices);     // note the lack of \r\n (keep this message as last in summary.)
                    ControlTools.SetBalloonTip(this, this.notifyIcon, s.ToString());
                    break;

                case "Services":
                    StringBuilder s1 = new StringBuilder();                      // Create status report
                    nServices = 0;
                    foreach (IService iService in AppServices.GetInstance().GetServices())
                    {
                        /*
                         * if (iService is TTServices.TTApiService)
                         * {
                         *  TTServices.TTApiService ttApi = (TTServices.TTApiService)iService;
                         *  if (ttApi.IsRunning)
                         *  {
                         *      s1.AppendFormat("TT Api: connected.\r\n");
                         *      s1.AppendFormat("TT Login: {0}\r\n", ttApi.LoginUserName);
                         *  }
                         *  else
                         *      s1.Append("TT Api: disconnected.\r\n");
                         * }
                         * else
                         * {
                         *  s1.AppendFormat("Service: {0}\r\n", iService.ServiceName);
                         * }
                         */
                        nServices++;
                    }
                    s1.AppendFormat("Services running: {0}.", nServices);     // note the lack of \r\n (keep this message as last in summary.)
                    ControlTools.SetBalloonTip(this, this.notifyIcon, s1.ToString());
                    break;

                default:
                    break;
                }
            }
        }//ContextMenuItem_Click()