/// <summary> /// начинаем редактирование точки /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewCalibrationTable_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { needCorrect = false; correctP = false; if (e.ColumnIndex == 0) { correctP = true; } oldValue = Application.ParseDouble(dataGridViewCalibrationTable[e.ColumnIndex, e.RowIndex].Value.ToString()); }
/// <summary> /// парсим /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewCalibrationTable_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { if (Type.GetTypeCode(e.Value.GetType()) == TypeCode.String) { try { newValue = Application.ParseDouble(e.Value.ToString()); if (!double.IsNaN(newValue)) { e.ParsingApplied = true; } else { throw new Exception(); } } catch (Exception) { MessageBox.Show("Введенное значение не является допустимым числом"); newValue = oldValue; } } }
/// <summary> /// Инициализировать формулу из сохраненного раннее узла Xml /// </summary> /// <param name="node">Узел на основе которого выполнить инициализацию макроса</param> public void InstanceMacrosFromXmlNode(XmlNode node) { try { if (arguments != null) { if (arguments[0] != null) { XmlNode[] argsNode = FindArguments(node); if (argsNode != null) { if (argsNode[0] != null) { arguments[0].InstanceFromXml(argsNode[0]); InitDescription(node); } } } // ---- загрузить таблицу калибровочных точек ---- bool xmlError = false; this.table.Clear(); XmlNodeList childs = node.ChildNodes; if (childs != null) { foreach (XmlNode child in childs) { if (child.Name != tableRecordName) { continue; } XmlNodeList parametrs = child.ChildNodes; Boolean bFirst = true; foreach (XmlNode childParametrs in parametrs) { int j; switch (childParametrs.Name) { case tableSignalName: try { if (bFirst) { TCondition newRecord = new TCondition(); this.table.Add(newRecord); bFirst = false; } j = this.table.Count - 1; this.table[j].Signal = Application.ParseDouble(childParametrs.InnerText); } catch { xmlError = true; } break; case tableValueName: try { if (bFirst) { TCondition newRecord = new TCondition(); this.table.Add(newRecord); bFirst = false; } j = this.table.Count - 1; this.table[j].Result = Application.ParseDouble(childParametrs.InnerText); } catch { xmlError = true; } break; case tableShiftName: try { if (bFirst) { TCondition newRecord = new TCondition(); this.table.Add(newRecord); bFirst = false; } j = this.table.Count - 1; this.table[j].Shift = Application.ParseDouble(childParametrs.InnerText); } catch { xmlError = true; } break; case tableMultyName: try { if (bFirst) { TCondition newRecord = new TCondition(); this.table.Add(newRecord); bFirst = false; } j = this.table.Count - 1; this.table[j].Multy = Application.ParseDouble(childParametrs.InnerText); } catch { xmlError = true; } break; } } } if (this.table.Count > 0) { this.table.Sort(Comparison); } } if (xmlError) { this.table.Clear(); } // ----------------------------------------------- } } catch { throw new Exception(); } }