public TableEditor(Configuration cfg, UniqueTable udt) { this.udt = udt; if (udt.TableName != null) { this.Title = $"{udt.TableName} - sqlcon"; } else this.Title = "View only - sqlcon"; this.Width = 800; this.Height = 600; this.Content = grid; var evenRowColor = cfg.GetColor("gui.table.editor.AlternatingRowBackground", Colors.DimGray); var fkColor = cfg.GetColor("gui.table.editor.Foreground", Colors.LightGray); var bkColor = cfg.GetColor("gui.table.editor.RowBackground", Colors.Black); dataGrid = new DataGrid { AlternationCount = 2, AlternatingRowBackground = new SolidColorBrush(evenRowColor), Foreground = new SolidColorBrush(fkColor), RowBackground = new SolidColorBrush(bkColor) }; if (udt.TableName != null) dataGrid.FrozenColumnCount = 1; else dataGrid.IsReadOnly = true; grid.Children.Add(dataGrid); //dataGrid.DataContext = dt.DefaultView; dataGrid.ItemsSource = udt.Table.DefaultView; dataGrid.AutoGeneratingColumn += DataGrid_AutoGeneratingColumn; dataGrid.CellEditEnding += DataGrid_CellEditEnding; udt.Table.RowChanged += Table_RowChanged; udt.Table.ColumnChanged += Table_ColumnChanged; }
private static void _DisplayTable(UniqueTable udt, bool more, Command cmd) { DataTable table = udt.Table; if (table == null) return; if (cmd.ToJson) { stdio.WriteLine(ToJson(table)); return; } if (cmd.ToCSharp) { string clss = cmd.GetValue("class"); stdio.WriteLine(ToCSharp(table, clss)); return; } if (cmd.Has("edit")) { var editor = new Windows.TableEditor(cmd.Configuration, udt); editor.ShowDialog(); return; } if (cmd.IsVertical) table.ToVConsole(more); else table.ToConsole(more); }
private bool Display(Command cmd, DataTable table, int top) { try { rTable = new UniqueTable(tname, table); _DisplayTable(rTable, top > 0 && table.Rows.Count == top, cmd); } catch (Exception ex) { stdio.ErrorFormat(ex.Message); return false; } return true; }
private SqlBuilder ParsePhysLocStatement(UniqueTable table, string text) { if (string.IsNullOrEmpty(text)) return null; text = text.Trim(); Memory ds = new Memory(); Script.Evaluate(text, ds); if (ds.Names.Count() == 0) return null; SqlBuilder sum = null; foreach (VAR name in ds.Names) { string column = (string)name; VAL val = ds[name]; if (!val.IsList) continue; for (int i = 0; i < val.Size; i++) { VAL s = val[i]; if (s.IsNull) continue; SqlBuilder builder = table.WriteValue(column, i, s.HostValue); if (sum == null) sum = builder; else sum += builder; } } return sum; }