private void BtnStop_Click(object sender, EventArgs e)
        {
            ServiceLoader.ServiceInfo info = GetCurrentServiceInfo();
            if (info != null)
            {
                ServiceLoader.CallMethodOnServiceInfo(ServiceLoader.ServiceOperation.Stop, info);
            }

            UpdateItemInfo();
        }
        private void BtnPlayPause_Click(object sender, EventArgs e)
        {
            ServiceLoader.ServiceInfo info = GetCurrentServiceInfo();
            if (info != null)
            {
                if (info.State == ServiceLoader.ServiceState.Running)
                {
                    ServiceLoader.CallMethodOnServiceInfo(ServiceLoader.ServiceOperation.Pause, info);
                }
                else if (info.State == ServiceLoader.ServiceState.Stopped)
                {
                    ServiceLoader.CallMethodOnServiceInfo(ServiceLoader.ServiceOperation.Start, info);
                }
                else                 //Paused
                {
                    ServiceLoader.CallMethodOnServiceInfo(ServiceLoader.ServiceOperation.Continue, info);
                }
            }

            UpdateItemInfo();
        }
        private void RefreshToolbar()
        {
            ServiceLoader.ServiceInfo info = GetCurrentServiceInfo();
            if (info != null)
            {
                switch (info.State)
                {
                case ServiceLoader.ServiceState.Stopped:
                    btnPlayPause.Image   = ImageResource.Play;
                    btnPlayPause.Text    = "Start";
                    btnPlayPause.Enabled = true;
                    btnStop.Enabled      = false;
                    btnRestart.Enabled   = false;
                    break;

                case ServiceLoader.ServiceState.Running:
                    btnPlayPause.Image   = ImageResource.Pause;
                    btnPlayPause.Text    = "Pause";
                    btnPlayPause.Enabled = info.Service.CanPauseAndContinue;
                    btnStop.Enabled      = true;
                    btnRestart.Enabled   = true;
                    break;

                case ServiceLoader.ServiceState.Paused:
                    btnPlayPause.Image   = ImageResource.Play;
                    btnPlayPause.Text    = "Un-Pause, De-Pause, Play ... Go!";
                    btnPlayPause.Enabled = true;
                    btnStop.Enabled      = true;
                    btnRestart.Enabled   = true;
                    break;

                default:
                    break;
                }
            }
        }
 private void UpdateItemInfo()
 {
     ServiceLoader.ServiceInfo info = GetCurrentServiceInfo();
     lvServices.SelectedItems[0].SubItems[1].Text = Enum.GetName(typeof(ServiceLoader.ServiceState), info.State);
     RefreshToolbar();
 }