/// <summary> /// Initializes a new instance of the <see cref="BDDSharp.BDDManager"/> class. /// </summary> /// <param name="n">The number of variables</param> public BDDManager(int n) { this.Zero = Create(n, false); this.One = Create(n, true); _n = n; _ite_cache = new Dictionary <Tuple <int, int, int>, WeakReference>(); _variable_order = new List <int>(Enumerable.Range(0, n)); if (_variable_order.Count() != n) { throw new ArgumentException(); } GetVariableString = (x) => x.ToString(); lock (unique_table_lock) { int size = (n > MIN_INIT_SIZE) ? n : MIN_INIT_SIZE; unique_table = new UniqueTable[size]; for (int i = 0; i < unique_table.Length; i++) { unique_table[i] = new UniqueTable(); } } }
private static void _DisplayTable(UniqueTable udt, bool more, ApplicationCommand cmd) { DataTable table = udt.Table; if (table == null) { return; } if (cmd.Has("json")) { cout.WriteLine(table.WriteJson(JsonStyle.Normal, excludeTableName: false)); return; } #if WINDOWS if (cmd.Has("edit")) { var editor = new Windows.TableEditor(udt); editor.ShowDialog(); return; } #endif int maxColumnWidth = Config.console.table.grid.MaxColumnWidth; table.ToConsole(vertical: cmd.IsVertical, more: more, outputDbNull: true, maxColumnWidth); }
public bool Display(ApplicationCommand cmd) { string[] columns = cmd.Columns; if (cmd.Has("dup")) { DuplicatedTable dup = new DuplicatedTable(tname, columns); if (dup.group.Rows.Count == 0) { cout.WriteLine("no duplicated record found"); return(true); } if (cmd.IsSchema) { Display(cmd, dup.group, 0); } else { dup.Dispaly(dt => Display(cmd, dt, 0)); } return(true); } SqlBuilder builder; int top = cmd.Top; if (tname.Provider.DpType == DbProviderType.Sqlite) { top = 0; } bool hasRowId = cmd.HasRowId; Locator locator = Locator.Empty; if (cmd.wildcard != null) { locator = LikeExpr(cmd.wildcard, cmd.Columns); } else if (cmd.where != null) { locator = new Locator(cmd.where); } builder = new SqlBuilder().SELECT().TOP(top); if (hasRowId) { builder.COLUMNS(UniqueTable.ROWID_COLUMN(tname)); } builder.COLUMNS(columns).FROM(tname).WHERE(locator); return(Display(cmd, builder, tname, top)); }
private bool Display(ApplicationCommand cmd, DataTable table, int top) { try { uniqueTable = new UniqueTable(tname, table); _DisplayTable(uniqueTable, top > 0 && table.Rows.Count == top, cmd); } catch (Exception ex) { cerr.WriteLine(ex.Message); return(false); } return(true); }
public TableEditor(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; dataGrid = new DataGrid { AlternationCount = 2, AlternatingRowBackground = Themes.TableEditor.AlternatingRowBackground, Foreground = Themes.TableEditor.Foreground, RowBackground = Themes.TableEditor.RowBackground, }; 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.RowDeleted += Table_RowChanged; udt.Table.ColumnChanged += Table_ColumnChanged; }
/// <summary> /// Resizes the unique table to the new specified size. /// </summary> /// <param name="new_size">New size of the unique table.</param> void ResizeUniqueTable(int new_size) { lock (unique_table_lock) { var n = new UniqueTable[new_size]; for (int i = 0; i < new_size; i++) { if (i < unique_table.Length) { n[i] = unique_table[i]; } else { n[i] = new UniqueTable(); } } unique_table = n; } }