private void FillComboGlobalFilter() { if ((GlobalTaskFilterType)PrefC.GetInt(PrefName.TasksGlobalFilterType) == GlobalTaskFilterType.Disabled) { comboGlobalFilter.Visible = false; labelGlobalFilter.Visible = false; return; } comboGlobalFilter.Items.Add(Lan.g(this, GlobalTaskFilterType.Default.GetDescription()), GlobalTaskFilterType.Default); comboGlobalFilter.Items.Add(Lan.g(this, GlobalTaskFilterType.None.GetDescription()), GlobalTaskFilterType.None); if (PrefC.HasClinicsEnabled) { comboGlobalFilter.Items.Add(Lan.g(this, GlobalTaskFilterType.Clinic.GetDescription()), GlobalTaskFilterType.Clinic); if (Defs.GetDefsForCategory(DefCat.Regions).Count > 0) { comboGlobalFilter.Items.Add(Lan.g(this, GlobalTaskFilterType.Region.GetDescription()), GlobalTaskFilterType.Region); } } comboGlobalFilter.SetSelectedEnum(Cur.GlobalTaskFilterType); if (comboGlobalFilter.SelectedIndex == -1) { errorProvider1.SetError(comboGlobalFilter, $"Previous selection \"{Cur.GlobalTaskFilterType.GetDescription()}\" is no longer available. " + "Saving will overwrite previous setting."); comboGlobalFilter.SelectedIndex = 0; } }
///<summary>Fills comboActionObject with the correct type of items based on the comboAction selection and sets labelActionObject text. ///Also handles setting combos/labels/texts visibility based on selected action.</summary> private void comboAction_SelectedIndexChanged(object sender, EventArgs e) { labelActionObject.Text = "Action Object"; //user should never see this text, just to help with troubleshooting in case of bug labelActionObject.Visible = false; comboActionObject.Visible = false; labelMessage.Visible = false; textMessage.Visible = false; if (comboAction.SelectedIndex < 0 || comboAction.SelectedIndex >= _listAutoActions.Count) { return; } comboActionObject.Items.Clear(); switch (_listAutoActions[comboAction.SelectedIndex]) { case AutomationAction.CreateCommlog: labelActionObject.Visible = true; labelActionObject.Text = Lan.g(this, "Commlog Type"); comboActionObject.Visible = true; _listCommLogTypeDefs.ForEach(x => comboActionObject.Items.Add(x.ItemName)); comboActionObject.SelectedIndex = _listCommLogTypeDefs.FindIndex(x => x.DefNum == AutoCur.CommType); labelMessage.Visible = true; textMessage.Visible = true; return; case AutomationAction.PopUp: case AutomationAction.PopUpThenDisable10Min: labelMessage.Visible = true; textMessage.Visible = true; return; case AutomationAction.SetApptASAP: return; case AutomationAction.SetApptType: labelActionObject.Visible = true; labelActionObject.Text = Lan.g(this, "Appointment Type"); comboActionObject.Visible = true; //_listAppointmentType contains 'none' with AppointmentTypeNum of 0 at index 0, just add list to combo and FindIndex will always be valid _listAptTypes.ForEach(x => comboActionObject.Items.Add(x.AppointmentTypeName)); comboActionObject.SelectedIndex = _listAptTypes.FindIndex(x => AutoCur.AppointmentTypeNum == x.AppointmentTypeNum); //should always be >=0 return; case AutomationAction.PrintPatientLetter: case AutomationAction.PrintReferralLetter: case AutomationAction.ShowConsentForm: case AutomationAction.ShowExamSheet: case AutomationAction.PrintRxInstruction: labelActionObject.Visible = true; labelActionObject.Text = Lan.g(this, "Sheet Definition"); comboActionObject.Visible = true; List <SheetDef> listSheetDefs = SheetDefs.GetDeepCopy().FindAll(x => !SheetDefs.IsDashboardType(x)); listSheetDefs.ForEach(x => comboActionObject.Items.Add(x.Description)); comboActionObject.SelectedIndex = listSheetDefs.FindIndex(x => AutoCur.SheetDefNum == x.SheetDefNum); //can be -1 return; case AutomationAction.ChangePatStatus: labelActionObject.Visible = true; labelActionObject.Text = Lan.g(this, "Patient Status"); comboActionObject.Visible = true; //comboActionObject.Items.AddEnums<PatientStatus>();//can't use this because we are not including all the enums List <PatientStatus> listPatStatus = new List <PatientStatus>(); listPatStatus.AddRange(Enum.GetValues(typeof(PatientStatus)).Cast <PatientStatus>()); foreach (PatientStatus patStatus in listPatStatus) { if (patStatus == PatientStatus.Deleted) { continue; //'Deleted' should not be automationAction } comboActionObject.Items.Add(Lan.g("enum" + nameof(PatientStatus), patStatus.GetDescription()), patStatus); } comboActionObject.SetSelectedEnum(AutoCur.PatStatus); return; } }