public static Dictionary<int, TabCell> ReadXMLCells(string FileName) { Dictionary<int, TabCell> TabCells = new Dictionary<int, TabCell>(); XDocument xdoc = XDocument.Load(FileName); int row = 1; int col = 0; string RowName = ""; string RowNumber = ""; foreach (XElement el in xdoc.Root.Elements("TabRow")) { if (el.HasAttributes) { RowName = el.Attribute("Name").Value; RowNumber = el.Attribute("Number").Value; } else { RowName = " "; RowNumber = " "; } foreach (XElement elem in el.Elements()) { TabCell temp = new TabCell(); Coords coordinate = new Coords(row, col); temp.tabCellAlign = elem.Attribute("Align").Value; temp.tabCellParametr = elem.Attribute("Parametr").Value; temp.tabCellPrecision = elem.Attribute("Precision").Value; temp.Name = RowName; temp.Number = RowNumber; TabCells.Add(coordinate.GetHashCode(), temp); col++; temp = null; } col = 0; row++; } return TabCells; }
public static bool EqualCells(TabCell first, TabCell Second) { return (first.Name == Second.Name && first.Number == Second.Number && first.tabCellAlign == Second.tabCellAlign && first.tabCellParametr == Second.tabCellParametr && first.tabCellPrecision == Second.tabCellPrecision); }
public static void SaveCell(EditTableCell w,ObjectXML objectXML) { TabCell t = new TabCell( w.AlignField.Text, w.PrecisionField.Text, w.ParametrField.Text); objectXML.cells[new Coords(int.Parse(w.row.Text), int.Parse(w.col.Text)).GetHashCode()] = t; MainWindow.objectXML = objectXML; save(); }
public static Dictionary<int, TabCell> ReadXMLCells(string FileName) { Dictionary<int, TabCell> TabCells = new Dictionary<int, TabCell> (); XDocument xdoc = XDocument.Load(FileName); int row = 1; int col = 0; string RowName = ""; string RowNumber = ""; foreach (XElement el in xdoc.Root.Elements("TabRow")) { try { RowName = el.Attribute("Name").Value; RowNumber = el.Attribute("Number").Value; } catch { RowName = " "; RowNumber = " "; } foreach (XElement elem in el.Elements()) { TabCell temp = new TabCell(); Coords coordinate = new Coords(row, col); temp.tabCellAlign = elem.Attribute("Align").Value; temp.tabCellParametr = elem.Attribute("Parametr").Value; temp.tabCellPrecision = elem.Attribute("Precision").Value; temp.Name = RowName; temp.Number = RowNumber; try { TabCells.Add(coordinate.GetHashCode(), temp); } catch (ArgumentException) { Console.WriteLine("An element with Key = \"txt\" already exists."); } col++; temp = null; } col = 0; row++; } return TabCells; }
public static void OpenEditTableCellWindow( EditTableCell w, TabCell cell, Coords coord) { w.ParametrField.Text = cell.tabCellParametr; w.AlignField.Text = cell.tabCellAlign; w.PrecisionField.Text = cell.tabCellPrecision; w.col.Text = coord.colCoord.ToString(); w.row.Text = coord.rowCoord.ToString(); w.ShowDialog(); }
public static void EditCellClick(object sender, RoutedEventArgs e) { Coords t = new Coords(); EditTableCell w = new EditTableCell(); ObjectXML xml = new ObjectXML(); TabCell cell = new TabCell(); t = GetCoords((sender as Button).Name.ToString()); xml = MainWindow.GetObjectXML(); cell=xml.cells[t.GetHashCode()]; OpenEditTableCellWindow(w, cell, t); }