Пример #1
0
        private void btnGroupsEdit_Click(object sender, EventArgs e)
        {
            Dictionary <int, FormGroup> updatedList = new Dictionary <int, FormGroup>();

            foreach (DataGridViewRow row in dataGridViewGroup.Rows)
            {
                if (row.Cells[0].Value != null &&
                    (bool)row.Cells[0].Value)
                {
                    // show the form user
                    int       groupId   = (int)row.Cells[1].Value;
                    string    groupName = (string)row.Cells[2].Value;
                    FormGroup formGroup = new FormGroup(groupName);
                    formGroup.Text = "Edit Group";
                    formGroup.SetMonitorList(groupPresenter.GetMonitorsList());
                    formGroup.SetApplicationList(groupPresenter.GetApplicationList());

                    formGroup.GroupName          = groupName;
                    formGroup.WholeDesktop       = (bool)row.Cells[3].Value;
                    formGroup.AllowMaintenance   = (bool)row.Cells[4].Value;
                    formGroup.AllowRemoteControl = (bool)row.Cells[5].Value;
                    formGroup.SetSelectedApplications(groupPresenter.GetApplicationsId(groupId));
                    int currentMonitorId = groupPresenter.GetMonitorId(groupId);
                    if (currentMonitorId != -1)
                    {
                        formGroup.MonitorId = currentMonitorId;
                    }


                    if (formGroup.ShowDialog(this) == System.Windows.Forms.DialogResult.OK &&
                        formGroup.IsDirty)
                    {
                        updatedList.Add(groupId, formGroup);
                    }
                }
            }

            foreach (KeyValuePair <int, FormGroup> data in updatedList)
            {
                // add to database
                groupPresenter.EditGroup(
                    data.Key,
                    data.Value.GroupName,
                    data.Value.WholeDesktop,
                    data.Value.AllowMaintenance,
                    data.Value.AllowRemoteControl,
                    data.Value.MonitorId,
                    data.Value.GetSelectedApplicationsId());
            }
        }
Пример #2
0
        private void btnGroupsAdd_Click(object sender, EventArgs e)
        {
            // show the form user
            FormGroup formGroup = new FormGroup(String.Empty);

            formGroup.Text = "Add Group";
            formGroup.SetMonitorList(groupPresenter.GetMonitorsList());
            formGroup.SetApplicationList(groupPresenter.GetApplicationList());
            if (formGroup.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                // add to database
                groupPresenter.AddGroup(
                    formGroup.GroupName,
                    formGroup.WholeDesktop,
                    formGroup.AllowMaintenance,
                    formGroup.AllowRemoteControl,
                    formGroup.MonitorId,
                    formGroup.GetSelectedApplicationsId());
            }
        }