|
@@ -14,8 +14,7 @@ namespace UICatalog.Scenarios {
|
|
|
[ScenarioCategory ("Dialogs")]
|
|
|
[ScenarioCategory ("Text and Formatting")]
|
|
|
[ScenarioCategory ("Top Level Windows")]
|
|
|
- public class TableEditor : Scenario
|
|
|
- {
|
|
|
+ public class TableEditor : Scenario {
|
|
|
TableView tableView;
|
|
|
private MenuItem miAlwaysShowHeaders;
|
|
|
private MenuItem miHeaderOverline;
|
|
@@ -35,7 +34,7 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
public override void Setup ()
|
|
|
{
|
|
|
- Win.Title = this.GetName();
|
|
|
+ Win.Title = this.GetName ();
|
|
|
Win.Y = 1; // menu
|
|
|
Win.Height = Dim.Fill (1); // status bar
|
|
|
Application.Top.LayoutSubviews ();
|
|
@@ -93,43 +92,43 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
Win.Add (tableView);
|
|
|
|
|
|
- var selectedCellLabel = new Label(){
|
|
|
+ var selectedCellLabel = new Label () {
|
|
|
X = 0,
|
|
|
- Y = Pos.Bottom(tableView),
|
|
|
+ Y = Pos.Bottom (tableView),
|
|
|
Text = "0,0",
|
|
|
- Width = Dim.Fill(),
|
|
|
+ Width = Dim.Fill (),
|
|
|
TextAlignment = TextAlignment.Right
|
|
|
-
|
|
|
+
|
|
|
};
|
|
|
|
|
|
- Win.Add(selectedCellLabel);
|
|
|
+ Win.Add (selectedCellLabel);
|
|
|
|
|
|
tableView.SelectedCellChanged += (e) => { selectedCellLabel.Text = $"{tableView.SelectedRow},{tableView.SelectedColumn}"; };
|
|
|
tableView.CellActivated += EditCurrentCell;
|
|
|
tableView.KeyPress += TableViewKeyPress;
|
|
|
|
|
|
- SetupScrollBar();
|
|
|
+ SetupScrollBar ();
|
|
|
|
|
|
- redColorScheme = new ColorScheme(){
|
|
|
+ redColorScheme = new ColorScheme () {
|
|
|
Disabled = Win.ColorScheme.Disabled,
|
|
|
HotFocus = Win.ColorScheme.HotFocus,
|
|
|
Focus = Win.ColorScheme.Focus,
|
|
|
- Normal = Application.Driver.MakeAttribute(Color.Red,Win.ColorScheme.Normal.Background)
|
|
|
+ Normal = Application.Driver.MakeAttribute (Color.Red, Win.ColorScheme.Normal.Background)
|
|
|
};
|
|
|
|
|
|
- alternatingColorScheme = new ColorScheme(){
|
|
|
+ alternatingColorScheme = new ColorScheme () {
|
|
|
|
|
|
Disabled = Win.ColorScheme.Disabled,
|
|
|
HotFocus = Win.ColorScheme.HotFocus,
|
|
|
Focus = Win.ColorScheme.Focus,
|
|
|
- Normal = Application.Driver.MakeAttribute(Color.White,Color.BrightBlue)
|
|
|
+ Normal = Application.Driver.MakeAttribute (Color.White, Color.BrightBlue)
|
|
|
};
|
|
|
- redColorSchemeAlt = new ColorScheme(){
|
|
|
+ redColorSchemeAlt = new ColorScheme () {
|
|
|
|
|
|
Disabled = Win.ColorScheme.Disabled,
|
|
|
HotFocus = Win.ColorScheme.HotFocus,
|
|
|
Focus = Win.ColorScheme.Focus,
|
|
|
- Normal = Application.Driver.MakeAttribute(Color.Red,Color.BrightBlue)
|
|
|
+ Normal = Application.Driver.MakeAttribute (Color.Red, Color.BrightBlue)
|
|
|
};
|
|
|
|
|
|
// if user clicks the mouse in TableView
|
|
@@ -139,7 +138,7 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
if (clickedCol != null) {
|
|
|
if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button1Clicked)) {
|
|
|
-
|
|
|
+
|
|
|
// left click in a header
|
|
|
SortColumn (clickedCol);
|
|
|
} else if (e.MouseEvent.Flags.HasFlag (MouseFlags.Button3Clicked)) {
|
|
@@ -153,7 +152,7 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
private void ShowAllColumns ()
|
|
|
{
|
|
|
- foreach(var colStyle in tableView.Style.ColumnStyles) {
|
|
|
+ foreach (var colStyle in tableView.Style.ColumnStyles) {
|
|
|
colStyle.Value.Visible = true;
|
|
|
}
|
|
|
tableView.Update ();
|
|
@@ -181,7 +180,7 @@ namespace UICatalog.Scenarios {
|
|
|
foreach (DataColumn col in tableView.Table.Columns) {
|
|
|
|
|
|
// remove any lingering sort indicator
|
|
|
- col.ColumnName = TrimArrows(col.ColumnName);
|
|
|
+ col.ColumnName = TrimArrows (col.ColumnName);
|
|
|
|
|
|
// add a new one if this the one that is being sorted
|
|
|
if (col == clickedCol) {
|
|
@@ -250,8 +249,7 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
private void SetMinAcceptableWidthToOne ()
|
|
|
{
|
|
|
- foreach (DataColumn c in tableView.Table.Columns)
|
|
|
- {
|
|
|
+ foreach (DataColumn c in tableView.Table.Columns) {
|
|
|
var style = tableView.Style.GetOrCreateColumnStyle (c);
|
|
|
style.MinAcceptableWidth = 1;
|
|
|
}
|
|
@@ -259,7 +257,7 @@ namespace UICatalog.Scenarios {
|
|
|
private void SetMinAcceptableWidth ()
|
|
|
{
|
|
|
var col = GetColumn ();
|
|
|
- RunColumnWidthDialog (col, "MinAcceptableWidth", (s,v)=>s.MinAcceptableWidth = v,(s)=>s.MinAcceptableWidth);
|
|
|
+ RunColumnWidthDialog (col, "MinAcceptableWidth", (s, v) => s.MinAcceptableWidth = v, (s) => s.MinAcceptableWidth);
|
|
|
}
|
|
|
|
|
|
private void SetMinWidth ()
|
|
@@ -274,7 +272,7 @@ namespace UICatalog.Scenarios {
|
|
|
RunColumnWidthDialog (col, "MaxWidth", (s, v) => s.MaxWidth = v, (s) => s.MaxWidth);
|
|
|
}
|
|
|
|
|
|
- private void RunColumnWidthDialog (DataColumn col, string prompt, Action<ColumnStyle,int> setter,Func<ColumnStyle,int> getter)
|
|
|
+ private void RunColumnWidthDialog (DataColumn col, string prompt, Action<ColumnStyle, int> setter, Func<ColumnStyle, int> getter)
|
|
|
{
|
|
|
var accepted = false;
|
|
|
var ok = new Button ("Ok", is_default: true);
|
|
@@ -292,7 +290,7 @@ namespace UICatalog.Scenarios {
|
|
|
};
|
|
|
|
|
|
var tf = new TextField () {
|
|
|
- Text = getter(style).ToString (),
|
|
|
+ Text = getter (style).ToString (),
|
|
|
X = 0,
|
|
|
Y = 2,
|
|
|
Width = Dim.Fill ()
|
|
@@ -306,7 +304,7 @@ namespace UICatalog.Scenarios {
|
|
|
if (accepted) {
|
|
|
|
|
|
try {
|
|
|
- setter (style, int.Parse (tf.Text.ToString()));
|
|
|
+ setter (style, int.Parse (tf.Text.ToString ()));
|
|
|
} catch (Exception ex) {
|
|
|
MessageBox.ErrorQuery (60, 20, "Failed to set", ex.Message, "Ok");
|
|
|
}
|
|
@@ -336,35 +334,32 @@ namespace UICatalog.Scenarios {
|
|
|
};*/
|
|
|
|
|
|
tableView.DrawContent += (e) => {
|
|
|
- _scrollBar.Size = tableView.Table?.Rows?.Count ??0;
|
|
|
+ _scrollBar.Size = tableView.Table?.Rows?.Count ?? 0;
|
|
|
_scrollBar.Position = tableView.RowOffset;
|
|
|
- // _scrollBar.OtherScrollBarView.Size = _listView.Maxlength - 1;
|
|
|
- // _scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
|
|
|
+ // _scrollBar.OtherScrollBarView.Size = _listView.Maxlength - 1;
|
|
|
+ // _scrollBar.OtherScrollBarView.Position = _listView.LeftItem;
|
|
|
_scrollBar.Refresh ();
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void TableViewKeyPress (View.KeyEventEventArgs e)
|
|
|
{
|
|
|
- if(e.KeyEvent.Key == Key.DeleteChar){
|
|
|
+ if (e.KeyEvent.Key == Key.DeleteChar) {
|
|
|
|
|
|
- if(tableView.FullRowSelect)
|
|
|
- {
|
|
|
+ if (tableView.FullRowSelect) {
|
|
|
// Delete button deletes all rows when in full row mode
|
|
|
- foreach(int toRemove in tableView.GetAllSelectedCells().Select(p=>p.Y).Distinct().OrderByDescending(i=>i))
|
|
|
- tableView.Table.Rows.RemoveAt(toRemove);
|
|
|
- }
|
|
|
- else{
|
|
|
+ foreach (int toRemove in tableView.GetAllSelectedCells ().Select (p => p.Y).Distinct ().OrderByDescending (i => i))
|
|
|
+ tableView.Table.Rows.RemoveAt (toRemove);
|
|
|
+ } else {
|
|
|
|
|
|
// otherwise set all selected cells to null
|
|
|
- foreach(var pt in tableView.GetAllSelectedCells())
|
|
|
- {
|
|
|
- tableView.Table.Rows[pt.Y][pt.X] = DBNull.Value;
|
|
|
+ foreach (var pt in tableView.GetAllSelectedCells ()) {
|
|
|
+ tableView.Table.Rows [pt.Y] [pt.X] = DBNull.Value;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- tableView.Update();
|
|
|
+ tableView.Update ();
|
|
|
e.Handled = true;
|
|
|
}
|
|
|
|
|
@@ -373,85 +368,85 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
private void ClearColumnStyles ()
|
|
|
{
|
|
|
- tableView.Style.ColumnStyles.Clear();
|
|
|
- tableView.Update();
|
|
|
+ tableView.Style.ColumnStyles.Clear ();
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
|
|
|
private void ToggleAlwaysShowHeader ()
|
|
|
{
|
|
|
miAlwaysShowHeaders.Checked = !miAlwaysShowHeaders.Checked;
|
|
|
- tableView.Style.AlwaysShowHeaders = miAlwaysShowHeaders.Checked;
|
|
|
- tableView.Update();
|
|
|
+ tableView.Style.AlwaysShowHeaders = (bool)miAlwaysShowHeaders.Checked;
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
|
|
|
private void ToggleOverline ()
|
|
|
{
|
|
|
miHeaderOverline.Checked = !miHeaderOverline.Checked;
|
|
|
- tableView.Style.ShowHorizontalHeaderOverline = miHeaderOverline.Checked;
|
|
|
- tableView.Update();
|
|
|
+ tableView.Style.ShowHorizontalHeaderOverline = (bool)miHeaderOverline.Checked;
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
private void ToggleHeaderMidline ()
|
|
|
{
|
|
|
miHeaderMidline.Checked = !miHeaderMidline.Checked;
|
|
|
- tableView.Style.ShowVerticalHeaderLines = miHeaderMidline.Checked;
|
|
|
- tableView.Update();
|
|
|
+ tableView.Style.ShowVerticalHeaderLines = (bool)miHeaderMidline.Checked;
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
private void ToggleUnderline ()
|
|
|
{
|
|
|
miHeaderUnderline.Checked = !miHeaderUnderline.Checked;
|
|
|
- tableView.Style.ShowHorizontalHeaderUnderline = miHeaderUnderline.Checked;
|
|
|
- tableView.Update();
|
|
|
+ tableView.Style.ShowHorizontalHeaderUnderline = (bool)miHeaderUnderline.Checked;
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
private void ToggleHorizontalScrollIndicators ()
|
|
|
{
|
|
|
miShowHorizontalScrollIndicators.Checked = !miShowHorizontalScrollIndicators.Checked;
|
|
|
- tableView.Style.ShowHorizontalScrollIndicators = miShowHorizontalScrollIndicators.Checked;
|
|
|
- tableView.Update();
|
|
|
+ tableView.Style.ShowHorizontalScrollIndicators = (bool)miShowHorizontalScrollIndicators.Checked;
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
private void ToggleFullRowSelect ()
|
|
|
{
|
|
|
miFullRowSelect.Checked = !miFullRowSelect.Checked;
|
|
|
- tableView.FullRowSelect= miFullRowSelect.Checked;
|
|
|
- tableView.Update();
|
|
|
+ tableView.FullRowSelect = (bool)miFullRowSelect.Checked;
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
|
|
|
- private void ToggleExpandLastColumn()
|
|
|
+ private void ToggleExpandLastColumn ()
|
|
|
{
|
|
|
miExpandLastColumn.Checked = !miExpandLastColumn.Checked;
|
|
|
- tableView.Style.ExpandLastColumn = miExpandLastColumn.Checked;
|
|
|
+ tableView.Style.ExpandLastColumn = (bool)miExpandLastColumn.Checked;
|
|
|
|
|
|
- tableView.Update();
|
|
|
+ tableView.Update ();
|
|
|
|
|
|
}
|
|
|
- private void ToggleSmoothScrolling()
|
|
|
+ private void ToggleSmoothScrolling ()
|
|
|
{
|
|
|
miSmoothScrolling.Checked = !miSmoothScrolling.Checked;
|
|
|
- tableView.Style.SmoothHorizontalScrolling = miSmoothScrolling.Checked;
|
|
|
+ tableView.Style.SmoothHorizontalScrolling = (bool)miSmoothScrolling.Checked;
|
|
|
|
|
|
tableView.Update ();
|
|
|
|
|
|
}
|
|
|
- private void ToggleCellLines()
|
|
|
+ private void ToggleCellLines ()
|
|
|
{
|
|
|
miCellLines.Checked = !miCellLines.Checked;
|
|
|
- tableView.Style.ShowVerticalCellLines = miCellLines.Checked;
|
|
|
- tableView.Update();
|
|
|
+ tableView.Style.ShowVerticalCellLines = (bool)miCellLines.Checked;
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
- private void ToggleAllCellLines()
|
|
|
+ private void ToggleAllCellLines ()
|
|
|
{
|
|
|
tableView.Style.ShowHorizontalHeaderOverline = true;
|
|
|
tableView.Style.ShowVerticalHeaderLines = true;
|
|
|
tableView.Style.ShowHorizontalHeaderUnderline = true;
|
|
|
tableView.Style.ShowVerticalCellLines = true;
|
|
|
-
|
|
|
+
|
|
|
miHeaderOverline.Checked = true;
|
|
|
miHeaderMidline.Checked = true;
|
|
|
miHeaderUnderline.Checked = true;
|
|
|
miCellLines.Checked = true;
|
|
|
|
|
|
- tableView.Update();
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
- private void ToggleNoCellLines()
|
|
|
+ private void ToggleNoCellLines ()
|
|
|
{
|
|
|
tableView.Style.ShowHorizontalHeaderOverline = false;
|
|
|
tableView.Style.ShowVerticalHeaderLines = false;
|
|
@@ -463,29 +458,27 @@ namespace UICatalog.Scenarios {
|
|
|
miHeaderUnderline.Checked = false;
|
|
|
miCellLines.Checked = false;
|
|
|
|
|
|
- tableView.Update();
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
|
|
|
- private void ToggleAlternatingColors()
|
|
|
+ private void ToggleAlternatingColors ()
|
|
|
{
|
|
|
//toggle menu item
|
|
|
miAlternatingColors.Checked = !miAlternatingColors.Checked;
|
|
|
|
|
|
- if(miAlternatingColors.Checked){
|
|
|
- tableView.Style.RowColorGetter = (a)=> {return a.RowIndex%2==0 ? alternatingColorScheme : null;};
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ if (miAlternatingColors.Checked == true) {
|
|
|
+ tableView.Style.RowColorGetter = (a) => { return a.RowIndex % 2 == 0 ? alternatingColorScheme : null; };
|
|
|
+ } else {
|
|
|
tableView.Style.RowColorGetter = null;
|
|
|
}
|
|
|
- tableView.SetNeedsDisplay();
|
|
|
+ tableView.SetNeedsDisplay ();
|
|
|
}
|
|
|
|
|
|
private void ToggleInvertSelectedCellFirstCharacter ()
|
|
|
{
|
|
|
//toggle menu item
|
|
|
miCursor.Checked = !miCursor.Checked;
|
|
|
- tableView.Style.InvertSelectedCellFirstCharacter = miCursor.Checked;
|
|
|
+ tableView.Style.InvertSelectedCellFirstCharacter = (bool)miCursor.Checked;
|
|
|
tableView.SetNeedsDisplay ();
|
|
|
}
|
|
|
private void CloseExample ()
|
|
@@ -500,11 +493,11 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
private void OpenExample (bool big)
|
|
|
{
|
|
|
- tableView.Table = BuildDemoDataTable(big ? 30 : 5, big ? 1000 : 5);
|
|
|
- SetDemoTableStyles();
|
|
|
+ tableView.Table = BuildDemoDataTable (big ? 30 : 5, big ? 1000 : 5);
|
|
|
+ SetDemoTableStyles ();
|
|
|
}
|
|
|
|
|
|
- private void OpenUnicodeMap()
|
|
|
+ private void OpenUnicodeMap ()
|
|
|
{
|
|
|
tableView.Table = BuildUnicodeMap ();
|
|
|
tableView.Update ();
|
|
@@ -515,7 +508,7 @@ namespace UICatalog.Scenarios {
|
|
|
var dt = new DataTable ();
|
|
|
|
|
|
// add cols called 0 to 9
|
|
|
- for (int i = 0; i < 10;i++) {
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
|
|
|
var col = dt.Columns.Add (i.ToString (), typeof (uint));
|
|
|
var style = tableView.Style.GetOrCreateColumnStyle (col);
|
|
@@ -523,9 +516,9 @@ namespace UICatalog.Scenarios {
|
|
|
}
|
|
|
|
|
|
// add cols called a to z
|
|
|
- for (int i = 'a'; i < 'a'+26; i++) {
|
|
|
-
|
|
|
- var col =dt.Columns.Add (((char)i).ToString (), typeof (uint));
|
|
|
+ for (int i = 'a'; i < 'a' + 26; i++) {
|
|
|
+
|
|
|
+ var col = dt.Columns.Add (((char)i).ToString (), typeof (uint));
|
|
|
var style = tableView.Style.GetOrCreateColumnStyle (col);
|
|
|
style.RepresentationGetter = (o) => new Rune ((uint)o).ToString ();
|
|
|
}
|
|
@@ -533,19 +526,19 @@ namespace UICatalog.Scenarios {
|
|
|
// now add table contents
|
|
|
List<uint> runes = new List<uint> ();
|
|
|
|
|
|
- foreach(var range in Ranges) {
|
|
|
- for(uint i=range.Start;i<=range.End;i++) {
|
|
|
+ foreach (var range in Ranges) {
|
|
|
+ for (uint i = range.Start; i <= range.End; i++) {
|
|
|
runes.Add (i);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
DataRow dr = null;
|
|
|
|
|
|
- for(int i = 0; i<runes.Count;i++) {
|
|
|
- if(dr == null || i% dt.Columns.Count == 0) {
|
|
|
+ for (int i = 0; i < runes.Count; i++) {
|
|
|
+ if (dr == null || i % dt.Columns.Count == 0) {
|
|
|
dr = dt.Rows.Add ();
|
|
|
}
|
|
|
- dr [i % dt.Columns.Count] = runes [i].ToString();
|
|
|
+ dr [i % dt.Columns.Count] = runes [i].ToString ();
|
|
|
}
|
|
|
|
|
|
return dt;
|
|
@@ -716,52 +709,52 @@ namespace UICatalog.Scenarios {
|
|
|
|
|
|
var dateFormatStyle = new TableView.ColumnStyle () {
|
|
|
Alignment = TextAlignment.Right,
|
|
|
- RepresentationGetter = (v)=> v is DateTime d ? d.ToString("yyyy-MM-dd"):v.ToString()
|
|
|
+ RepresentationGetter = (v) => v is DateTime d ? d.ToString ("yyyy-MM-dd") : v.ToString ()
|
|
|
};
|
|
|
|
|
|
var negativeRight = new TableView.ColumnStyle () {
|
|
|
-
|
|
|
+
|
|
|
Format = "0.##",
|
|
|
MinWidth = 10,
|
|
|
- AlignmentGetter = (v)=>v is double d ?
|
|
|
+ AlignmentGetter = (v) => v is double d ?
|
|
|
// align negative values right
|
|
|
- d < 0 ? TextAlignment.Right :
|
|
|
+ d < 0 ? TextAlignment.Right :
|
|
|
// align positive values left
|
|
|
- TextAlignment.Left:
|
|
|
+ TextAlignment.Left :
|
|
|
// not a double
|
|
|
TextAlignment.Left,
|
|
|
-
|
|
|
- ColorGetter = (a)=> a.CellValue is double d ?
|
|
|
+
|
|
|
+ ColorGetter = (a) => a.CellValue is double d ?
|
|
|
// color 0 and negative values red
|
|
|
- d <= 0.0000001 ? a.RowIndex%2==0 && miAlternatingColors.Checked ? redColorSchemeAlt: redColorScheme :
|
|
|
+ d <= 0.0000001 ? a.RowIndex % 2 == 0 && miAlternatingColors.Checked == true ? redColorSchemeAlt : redColorScheme :
|
|
|
// use normal scheme for positive values
|
|
|
- null:
|
|
|
+ null :
|
|
|
// not a double
|
|
|
null
|
|
|
};
|
|
|
-
|
|
|
- tableView.Style.ColumnStyles.Add(tableView.Table.Columns["DateCol"],dateFormatStyle);
|
|
|
- tableView.Style.ColumnStyles.Add(tableView.Table.Columns["DoubleCol"],negativeRight);
|
|
|
- tableView.Style.ColumnStyles.Add(tableView.Table.Columns["NullsCol"],alignMid);
|
|
|
- tableView.Style.ColumnStyles.Add(tableView.Table.Columns["IntCol"],alignRight);
|
|
|
-
|
|
|
- tableView.Update();
|
|
|
+
|
|
|
+ tableView.Style.ColumnStyles.Add (tableView.Table.Columns ["DateCol"], dateFormatStyle);
|
|
|
+ tableView.Style.ColumnStyles.Add (tableView.Table.Columns ["DoubleCol"], negativeRight);
|
|
|
+ tableView.Style.ColumnStyles.Add (tableView.Table.Columns ["NullsCol"], alignMid);
|
|
|
+ tableView.Style.ColumnStyles.Add (tableView.Table.Columns ["IntCol"], alignRight);
|
|
|
+
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
|
|
|
private void OpenSimple (bool big)
|
|
|
{
|
|
|
- tableView.Table = BuildSimpleDataTable(big ? 30 : 5, big ? 1000 : 5);
|
|
|
+ tableView.Table = BuildSimpleDataTable (big ? 30 : 5, big ? 1000 : 5);
|
|
|
}
|
|
|
|
|
|
private void EditCurrentCell (TableView.CellActivatedEventArgs e)
|
|
|
{
|
|
|
- if(e.Table == null)
|
|
|
+ if (e.Table == null)
|
|
|
return;
|
|
|
var o = e.Table.Rows [e.Row] [e.Col];
|
|
|
|
|
|
- var title = o is uint u ? GetUnicodeCategory(u) + $"(0x{o:X4})" : "Enter new value";
|
|
|
+ var title = o is uint u ? GetUnicodeCategory (u) + $"(0x{o:X4})" : "Enter new value";
|
|
|
|
|
|
- var oldValue = e.Table.Rows[e.Row][e.Col].ToString();
|
|
|
+ var oldValue = e.Table.Rows [e.Row] [e.Col].ToString ();
|
|
|
bool okPressed = false;
|
|
|
|
|
|
var ok = new Button ("Ok", is_default: true);
|
|
@@ -770,35 +763,33 @@ namespace UICatalog.Scenarios {
|
|
|
cancel.Clicked += () => { Application.RequestStop (); };
|
|
|
var d = new Dialog (title, 60, 20, ok, cancel);
|
|
|
|
|
|
- var lbl = new Label() {
|
|
|
+ var lbl = new Label () {
|
|
|
X = 0,
|
|
|
Y = 1,
|
|
|
- Text = e.Table.Columns[e.Col].ColumnName
|
|
|
+ Text = e.Table.Columns [e.Col].ColumnName
|
|
|
};
|
|
|
|
|
|
- var tf = new TextField()
|
|
|
- {
|
|
|
- Text = oldValue,
|
|
|
- X = 0,
|
|
|
- Y = 2,
|
|
|
- Width = Dim.Fill()
|
|
|
- };
|
|
|
-
|
|
|
- d.Add (lbl,tf);
|
|
|
- tf.SetFocus();
|
|
|
+ var tf = new TextField () {
|
|
|
+ Text = oldValue,
|
|
|
+ X = 0,
|
|
|
+ Y = 2,
|
|
|
+ Width = Dim.Fill ()
|
|
|
+ };
|
|
|
+
|
|
|
+ d.Add (lbl, tf);
|
|
|
+ tf.SetFocus ();
|
|
|
|
|
|
Application.Run (d);
|
|
|
|
|
|
- if(okPressed) {
|
|
|
+ if (okPressed) {
|
|
|
|
|
|
try {
|
|
|
- e.Table.Rows[e.Row][e.Col] = string.IsNullOrWhiteSpace(tf.Text.ToString()) ? DBNull.Value : (object)tf.Text;
|
|
|
- }
|
|
|
- catch(Exception ex) {
|
|
|
- MessageBox.ErrorQuery(60,20,"Failed to set text", ex.Message,"Ok");
|
|
|
+ e.Table.Rows [e.Row] [e.Col] = string.IsNullOrWhiteSpace (tf.Text.ToString ()) ? DBNull.Value : (object)tf.Text;
|
|
|
+ } catch (Exception ex) {
|
|
|
+ MessageBox.ErrorQuery (60, 20, "Failed to set text", ex.Message, "Ok");
|
|
|
}
|
|
|
-
|
|
|
- tableView.Update();
|
|
|
+
|
|
|
+ tableView.Update ();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -813,27 +804,27 @@ namespace UICatalog.Scenarios {
|
|
|
/// <param name="cols"></param>
|
|
|
/// <param name="rows"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static DataTable BuildDemoDataTable(int cols, int rows)
|
|
|
+ public static DataTable BuildDemoDataTable (int cols, int rows)
|
|
|
{
|
|
|
- var dt = new DataTable();
|
|
|
+ var dt = new DataTable ();
|
|
|
|
|
|
int explicitCols = 6;
|
|
|
- dt.Columns.Add(new DataColumn("StrCol",typeof(string)));
|
|
|
- dt.Columns.Add(new DataColumn("DateCol",typeof(DateTime)));
|
|
|
- dt.Columns.Add(new DataColumn("IntCol",typeof(int)));
|
|
|
- dt.Columns.Add(new DataColumn("DoubleCol",typeof(double)));
|
|
|
- dt.Columns.Add(new DataColumn("NullsCol",typeof(string)));
|
|
|
- dt.Columns.Add(new DataColumn("Unicode",typeof(string)));
|
|
|
-
|
|
|
- for(int i=0;i< cols -explicitCols; i++) {
|
|
|
- dt.Columns.Add("Column" + (i+explicitCols));
|
|
|
+ dt.Columns.Add (new DataColumn ("StrCol", typeof (string)));
|
|
|
+ dt.Columns.Add (new DataColumn ("DateCol", typeof (DateTime)));
|
|
|
+ dt.Columns.Add (new DataColumn ("IntCol", typeof (int)));
|
|
|
+ dt.Columns.Add (new DataColumn ("DoubleCol", typeof (double)));
|
|
|
+ dt.Columns.Add (new DataColumn ("NullsCol", typeof (string)));
|
|
|
+ dt.Columns.Add (new DataColumn ("Unicode", typeof (string)));
|
|
|
+
|
|
|
+ for (int i = 0; i < cols - explicitCols; i++) {
|
|
|
+ dt.Columns.Add ("Column" + (i + explicitCols));
|
|
|
}
|
|
|
-
|
|
|
- var r = new Random(100);
|
|
|
|
|
|
- for(int i=0;i< rows;i++) {
|
|
|
-
|
|
|
- List<object> row = new List<object>(){
|
|
|
+ var r = new Random (100);
|
|
|
+
|
|
|
+ for (int i = 0; i < rows; i++) {
|
|
|
+
|
|
|
+ List<object> row = new List<object> (){
|
|
|
"Some long text that is super cool",
|
|
|
new DateTime(2000+i,12,25),
|
|
|
r.Next(i),
|
|
@@ -841,12 +832,12 @@ namespace UICatalog.Scenarios {
|
|
|
DBNull.Value,
|
|
|
"Les Mise" + Char.ConvertFromUtf32(Int32.Parse("0301", NumberStyles.HexNumber)) + "rables"
|
|
|
};
|
|
|
-
|
|
|
- for(int j=0;j< cols -explicitCols; j++) {
|
|
|
- row.Add("SomeValue" + r.Next(100));
|
|
|
+
|
|
|
+ for (int j = 0; j < cols - explicitCols; j++) {
|
|
|
+ row.Add ("SomeValue" + r.Next (100));
|
|
|
}
|
|
|
|
|
|
- dt.Rows.Add(row.ToArray());
|
|
|
+ dt.Rows.Add (row.ToArray ());
|
|
|
}
|
|
|
|
|
|
return dt;
|
|
@@ -858,24 +849,24 @@ namespace UICatalog.Scenarios {
|
|
|
/// <param name="cols"></param>
|
|
|
/// <param name="rows"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static DataTable BuildSimpleDataTable(int cols, int rows)
|
|
|
+ public static DataTable BuildSimpleDataTable (int cols, int rows)
|
|
|
{
|
|
|
- var dt = new DataTable();
|
|
|
+ var dt = new DataTable ();
|
|
|
|
|
|
- for(int c = 0; c < cols; c++) {
|
|
|
- dt.Columns.Add("Col"+c);
|
|
|
+ for (int c = 0; c < cols; c++) {
|
|
|
+ dt.Columns.Add ("Col" + c);
|
|
|
}
|
|
|
-
|
|
|
- for(int r = 0; r < rows; r++) {
|
|
|
- var newRow = dt.NewRow();
|
|
|
|
|
|
- for(int c = 0; c < cols; c++) {
|
|
|
- newRow[c] = $"R{r}C{c}";
|
|
|
+ for (int r = 0; r < rows; r++) {
|
|
|
+ var newRow = dt.NewRow ();
|
|
|
+
|
|
|
+ for (int c = 0; c < cols; c++) {
|
|
|
+ newRow [c] = $"R{r}C{c}";
|
|
|
}
|
|
|
|
|
|
- dt.Rows.Add(newRow);
|
|
|
+ dt.Rows.Add (newRow);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return dt;
|
|
|
}
|
|
|
}
|