/// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }
            if (this.dataGridView[e.ColumnIndex, e.RowIndex].OwningColumn.Name.Equals(ColumnNames.colSvcBtnStatus.ToString()) && e.RowIndex >= 0)
            {
                DataGridViewRow currentrow        = dataGridView.CurrentRow;
                String          svcName           = Convert.ToString(currentrow.Cells[ColumnNames.colSvcName.ToString()].Value);
                String          displayedSvcState = Convert.ToString(currentrow.Cells[ColumnNames.colSvcDisplay.ToString()].Value);
                MattimonAgentLibrary.Tools.MyServiceController.ServiceState querySvcState = MattimonAgentLibrary.Tools.MyServiceController.GetServiceStatus(svcName);

                // Update the grid if the sercice's state have actually changed
                // And do not trigger any ServiceStateChanged event.
                if (displayedSvcState.Equals(querySvcState.ToString()))
                {
                    RefreshDataGridViewEntry(svcName);
                    return;
                }

                // The service state is not actually updated here.
                // Let the Parent decide what to do with this by triggering a ServiceStateChanged event.
                if (ServiceStateChanged != null)
                {
                    Delegate[] delegates = ServiceStateChanged.GetInvocationList();
                    foreach (ServiceStateChangedEventHandler handle in delegates)
                    {
                        handle(this, new ServiceStateChangedEventArgs(svcName));
                    }
                }
            }
        }
Пример #2
0
        private void DefineVersionLabelText(MattimonAgentLibrary.Tools.MyServiceController.ServiceState svcState)
        {
            try
            {
                MattimonAgentLibrary.Tools.GUITools.SetControlPropertyThreadSafe(lblVersion, "Text",
                                                                                 "App version: " + new MattimonAgentLibrary.Tools.ProjectAssemblyAtrributes(

                                                                                     Application.ExecutablePath).GetAssemblyVersion().ToString() +
                                                                                 String.Format(" (Automatic update service {0}",
                                                                                               svcState == MyServiceController.ServiceState.NotFound ? "unavailable" :
                                                                                               (svcState == MyServiceController.ServiceState.Running ? "is running" : "is not running - Status: " + svcState)) + ")"
                                                                                 );
            }
            catch
            {
                MattimonAgentLibrary.Tools.GUITools.SetControlPropertyThreadSafe(lblVersion, "Text", "Assembly not found!");
            }
        }