Ejemplo n.º 1
0
        private void AddRowToSelectedServicesGrid(KeepServiceStatus data)
        {
            var index = dgvSelectedServices.Rows.Add();

            dgvSelectedServices.Rows[index].Cells["ColServiceName"].Value = data.Service.Name;
            (dgvSelectedServices.Rows[index].Cells["ColKeepServiceStatusOn"] as DataGridViewComboBoxCell).Value = (int)data.KeepStatusOn;
        }
Ejemplo n.º 2
0
        void dgvServices_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            foreach (DataGridViewRow row in dgvServices.Rows)
            {
                if (row.Cells["Selected"].Value == DBNull.Value)
                {
                    continue;
                }

                var serviceName = row.Cells["Name"].Value?.ToString();
                var isSelected  =
                    _setting.CoveredServices.Any(x => x.Service.Name == serviceName);

                if ((bool?)row.Cells["Selected"].Value == true && !isSelected)
                {
                    var serv = row.ToObject <ServiceInfo>();
                    var kss  = new KeepServiceStatus()
                    {
                        Service = serv
                    };
                    _setting.CoveredServices.Add(kss);
                    AddRowToSelectedServicesGrid(kss);
                }
                else if ((bool?)row.Cells["Selected"].Value == false && isSelected)
                {
                    // Remove from setting object
                    _setting.CoveredServices.RemoveAll(x => x.Service.Name == serviceName);
                    //
                    // Remove from Selected Services Grid
                    RemoveRowToSelectedServicesGrid(row.ToObject <ServiceInfo>());
                }
            }
        }
 public ServiceNotifyEventArgs(KeepServiceStatus kss, ServiceControllerStatus newStatus)
 {
     KeepService = kss;
     NewStatus   = newStatus;
     OldStatus   = KeepService.Service.Status;
 }