private void ConditionControlDeleted(object sender, EventArgs e) { EngineMonitoringControlItem control = (EngineMonitoringControlItem)sender; EngineCondition cond = control.Condition; if (cond.ItemId > 0 && MessageBox.Show("Do you really want to delete engine condition?", "Deleting confirmation", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { //если информация о состоянии сохранена в БД //и получен положительный ответ на ее удаление try { GlobalObjects.CasEnvironment.NewKeeper.Delete(cond); } catch (Exception ex) { Program.Provider.Logger.Log("Error while removing data", ex); } flowLayoutPanelEngineConditions.Controls.Remove(control); } else if (cond.ItemId <= 0) { flowLayoutPanelEngineConditions.Controls.Remove(control); } }
/// <summary> /// Проверяет введенные данные. /// Если какое-либо поле не подходит по формату, следует сразу кидать MessageBox, ставить курсор в необходимое поле и возвращать false в качестве результата метода /// </summary> /// <returns></returns> public override bool CheckData() { // Проверяем общие данные проверки // Проверка на дату и ввод правильных дробных чисел //TimeSpan time; //if (!TimeSpan.TryParse(textBoxGMT.Text, out time)) //{ // Visible = true; // SimpleBalloon.Show(textBoxGMT, ToolTipIcon.Warning, "Incorrect time format", "Please enter the time in the following format: HH:MM"); // return false; //} //if (!checkBoxClear.Checked && !checkBoxClouds.Checked && !checkBoxRainShow.Checked && !checkBoxTurb.Checked) //{ // SimpleBalloon.Show(checkBoxClear.Text, ToolTipIcon.Warning, "Incorrect time format", "Please enter the time in the following format: HH:MM"); // return false; //} for (int i = 0; i < flowLayoutPanelEngineConditions.Controls.Count; i++) { EngineMonitoringControlItem c = flowLayoutPanelEngineConditions.Controls[i] as EngineMonitoringControlItem; if (c != null) { if (!c.CheckData()) { Visible = true; return(false); } } } // return(true); }
/* * Перегружаемые методы */ #region public override void ApplyChanges() /// <summary> /// Применить к объекту сделанные изменения на контроле. /// Если не все данные удовлетворяют формату ввода (например при вводе чисел), свойства объекта не изменяются, возвращается false /// Вызов base.ApplyChanges() обязателен /// </summary> /// <returns></returns> public override void ApplyChanges() { EngineGeneral.PressALT = numericUpDownPressALT.Value.ToString(); EngineGeneral.TimeGMT = dateTimePickerGMT.Value.TimeOfDay; EngineGeneral.GrossWeight = (double)numericUpDownGrossWeight.Value; EngineGeneral.IAS = (double)numericUpDownIAS.Value; EngineGeneral.Mach = (double)numericUpDownMach.Value; EngineGeneral.TAT = (double)numericUpDownTAT.Value; EngineGeneral.OAT = (double)numericUpDownOAT.Value; EngineGeneral.FlightRegime = comboBoxFlightRegime.SelectedItem != null ? (FlightRegime)comboBoxFlightRegime.SelectedItem : FlightRegime.UNK; EngineGeneral.GroundAir = comboBoxGroundAir.SelectedItem != null ? (GroundAir)comboBoxGroundAir.SelectedItem : GroundAir.Ground; for (int i = 0; i < flowLayoutPanelEngineConditions.Controls.Count; i++) { EngineMonitoringControlItem c = flowLayoutPanelEngineConditions.Controls[i] as EngineMonitoringControlItem; if (c == null) { continue; } c.ApplyChanges(); c.Condition.AddInformation(EngineGeneral); if (EngineGeneral != null && EngineGeneral.EngineConditions != null && !ConditionExists(c.Condition)) { EngineGeneral.EngineConditions.Add(c.Condition); } } base.ApplyChanges(); }
/// <summary> /// Обновляет значения полей /// </summary> public override void FillControls() { BeginUpdate(); if (EngineGeneral.EngineConditions.Count > 0) { flowLayoutPanelEngineConditions.Controls.Clear(); List <EngineCondition> orderedList = EngineGeneral.EngineConditions.OrderBy(e => e.Engine).ToList(); for (int i = 0; i < orderedList.Count; i++) { // Добавляем контрол для ввода данных по маслу EngineMonitoringControlItem c = new EngineMonitoringControlItem(_currentAircraft, orderedList[i]); c.Deleted += ConditionControlDeleted; c.ComponentChanget += ItemComponentChanget; if (i > 0) { c.ShowHeaders = false; } flowLayoutPanelEngineConditions.Controls.Add(c); } flowLayoutPanelEngineConditions.Controls.Add(panelAdd); } int pressAlt; numericUpDownPressALT.Value = int.TryParse(EngineGeneral.PressALT, out pressAlt) ? pressAlt : 0; numericUpDownGrossWeight.Value = (decimal)EngineGeneral.GrossWeight; numericUpDownIAS.Value = (decimal)EngineGeneral.IAS; numericUpDownMach.Value = (decimal)EngineGeneral.Mach; numericUpDownTAT.Value = (decimal)EngineGeneral.TAT; numericUpDownOAT.Value = (decimal)EngineGeneral.OAT; dateTimePickerGMT.Value = EngineGeneral.EngineConditions[0].ItemId > 0 ? DateTime.Today.Add(EngineGeneral.TimeGMT) : DateTime.Today; comboBoxFlightRegime.Items.Clear(); comboBoxFlightRegime.Items.AddRange(FlightRegime.Items.ToArray()); comboBoxFlightRegime.SelectedItem = EngineGeneral.FlightRegime; comboBoxGroundAir.Items.Clear(); foreach (object o in Enum.GetValues(typeof(GroundAir))) { comboBoxGroundAir.Items.Add(o); } comboBoxGroundAir.SelectedItem = EngineGeneral.GroundAir; checkBoxClear.Checked = (EngineGeneral.Weather & WeatherCondition.Clear) != 0; checkBoxClouds.Checked = (EngineGeneral.Weather & WeatherCondition.Clouds) != 0; checkBoxTurb.Checked = (EngineGeneral.Weather & WeatherCondition.Turb) != 0; checkBoxRainShow.Checked = (EngineGeneral.Weather & WeatherCondition.RainSnow) != 0; EndUpdate(); }
private void LinkLabelAddNewLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { EngineMonitoringControlItem performance = new EngineMonitoringControlItem(_currentAircraft, new EngineCondition()); if (performance.PowerUnit != null && _componentOilFlow.ContainsKey(performance.PowerUnit.ItemId)) { performance.OilFlow = _componentOilFlow[performance.PowerUnit.ItemId]; } performance.Deleted += ConditionControlDeleted; if (flowLayoutPanelEngineConditions.Controls.Count > 1) { performance.ShowHeaders = false; } flowLayoutPanelEngineConditions.Controls.Remove(panelAdd); flowLayoutPanelEngineConditions.Controls.Add(performance); flowLayoutPanelEngineConditions.Controls.Add(panelAdd); }