refactor: Replace outdated DataGrid refs w/ DataGridView
Windows replaced the former with the latter in dotnet core 3.1
This commit is contained in:
1 parent
80c4542942
commit
d09c6ba543
3 files changed
+57
-63
No files matched your search
+10
-10
@@ -124,23 +124,23 @@
|
||||
//
|
||||
this.myDataGrid.BackgroundColor = System.Drawing.Color.Gainsboro;
|
||||
this.myDataGrid.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.myDataGrid.CaptionBackColor = System.Drawing.Color.Wheat;
|
||||
this.myDataGrid.CaptionFont = new System.Drawing.Font("Comic Sans MS", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.myDataGrid.CaptionForeColor = System.Drawing.Color.Black;
|
||||
// this.myDataGrid.CaptionBackColor = System.Drawing.Color.Wheat;
|
||||
// this.myDataGrid.CaptionFont = new System.Drawing.Font("Comic Sans MS", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
// this.myDataGrid.CaptionForeColor = System.Drawing.Color.Black;
|
||||
this.myDataGrid.DataMember = "";
|
||||
this.myDataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.myDataGrid.FlatMode = true;
|
||||
this.myDataGrid.GridLineColor = System.Drawing.Color.Gainsboro;
|
||||
this.myDataGrid.HeaderBackColor = System.Drawing.Color.Gainsboro;
|
||||
this.myDataGrid.HeaderFont = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.myDataGrid.HeaderForeColor = System.Drawing.Color.Black;
|
||||
// this.myDataGrid.FlatMode = true;
|
||||
// this.myDataGrid.GridLineColor = System.Drawing.Color.Gainsboro;
|
||||
// this.myDataGrid.HeaderBackColor = System.Drawing.Color.Gainsboro;
|
||||
// this.myDataGrid.HeaderFont = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
// this.myDataGrid.HeaderForeColor = System.Drawing.Color.Black;
|
||||
this.myDataGrid.HorizScrollBarValue = 0;
|
||||
this.myDataGrid.Location = new System.Drawing.Point(0, 0);
|
||||
this.myDataGrid.Name = "myDataGrid";
|
||||
this.myDataGrid.PreferredRowHeight = 20;
|
||||
// this.myDataGrid.PreferredRowHeight = 20;
|
||||
this.myDataGrid.ReadOnly = true;
|
||||
this.myDataGrid.RowHeadersVisible = false;
|
||||
this.myDataGrid.RowHeaderWidth = 0;
|
||||
// this.myDataGrid.RowHeaderWidth = 0;
|
||||
this.myDataGrid.Size = new System.Drawing.Size(896, 305);
|
||||
this.myDataGrid.TabIndex = 0;
|
||||
this.myDataGrid.MouseEnter += new System.EventHandler(this.myDataGrid_MouseEnter);
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace BCG
|
||||
myDataGrid.DataSource = null;
|
||||
myTabControl.SelectedIndex = 0;
|
||||
myErrorTextBox.Text = "";
|
||||
myDataGrid.CaptionText = "";
|
||||
// myDataGrid.CaptionText = "";
|
||||
|
||||
if (myCurrentStream != null)
|
||||
myCurrentStream.onChange -= new BCG.DataStream.ChangeDelegate(myCallback);
|
||||
@@ -306,6 +306,22 @@ namespace BCG
|
||||
myCSharpText.Text += "}";
|
||||
}
|
||||
|
||||
static DataGridViewColumn _column_factory(ColumnInfo ci) {
|
||||
return new DataGridViewTextBoxColumn {
|
||||
HeaderText = ci.colName,
|
||||
Width = get_col_width(ci)
|
||||
};
|
||||
|
||||
static int get_col_width(ColumnInfo ci) {
|
||||
const int CHAR_WIDTH = 10;
|
||||
const int MIN_WIDTH = 50;
|
||||
const int MIN_DATE_WIDTH = 200;
|
||||
var header_width = ci.colName.Length * CHAR_WIDTH;
|
||||
var min_width = ci.colType == typeof(DateTime) ? MIN_DATE_WIDTH : MIN_WIDTH;
|
||||
return Math.Max(header_width, min_width);
|
||||
}
|
||||
}
|
||||
|
||||
private void myCallback(object o)
|
||||
{
|
||||
DataPacket dp = o as DataPacket;
|
||||
@@ -327,34 +343,12 @@ namespace BCG
|
||||
if (myChangeStyle)
|
||||
{
|
||||
myChangeStyle = false;
|
||||
DataGridTableStyle tabStyle = new DataGridTableStyle ();
|
||||
DataGridColumnStyle colStyle;
|
||||
foreach (ColumnInfo ci in dp.schema.columnInfo)
|
||||
{
|
||||
colStyle = new DataGridTextBoxColumn ();
|
||||
colStyle.MappingName = ci.colName;
|
||||
colStyle.HeaderText = ci.colName;
|
||||
colStyle.Width = Math.Max(ci.colName.Length * 10, 50);
|
||||
if (ci.colType.Equals (typeof(DateTime)))
|
||||
{
|
||||
colStyle.Width = 200;
|
||||
// (colStyle as DataGridTextBoxColumn).Format =
|
||||
// System.Globalization.DateTimeFormatInfo.CurrentInfo.TimeSeparator;
|
||||
}
|
||||
tabStyle.GridColumnStyles.Add (colStyle);
|
||||
}
|
||||
tabStyle.HeaderFont =
|
||||
new Font ("Courier New", 9, FontStyle.Bold);
|
||||
tabStyle.GridLineStyle = System.Windows.Forms.DataGridLineStyle.Solid;
|
||||
tabStyle.GridLineColor = Color.Black;
|
||||
tabStyle.RowHeadersVisible = false;
|
||||
tabStyle.MappingName = "SimpleBindableCollection";
|
||||
myDataGrid.TableStyles.Clear ();
|
||||
myDataGrid.TableStyles.Add (tabStyle);
|
||||
myDataGrid.Columns.Clear();
|
||||
myDataGrid.Columns.AddRange(Array.ConvertAll(dp.schema.columnInfo, _column_factory));
|
||||
}
|
||||
myCrono.start();
|
||||
myDataGrid.CaptionText = myCrono.time.TotalMilliseconds + " ms ";
|
||||
myDataGrid.CaptionText += dp.newRows.Count.ToString () + " records";
|
||||
// myDataGrid.CaptionText = myCrono.time.TotalMilliseconds + " ms ";
|
||||
// myDataGrid.CaptionText += dp.newRows.Count.ToString () + " records";
|
||||
|
||||
|
||||
myDataGrid.HorizScrollBarValue = hscrollval;
|
||||
@@ -481,15 +475,15 @@ namespace BCG
|
||||
private void myDataGrid_MouseEnter(object sender, System.EventArgs e)
|
||||
{
|
||||
//myDataGrid.TableStyles[0].GridLineColor = Color.LightSteelBlue;
|
||||
if (myDataGrid.TableStyles.Count > 0)
|
||||
myDataGrid.TableStyles[0].HeaderBackColor = Color.LightSteelBlue;
|
||||
// if (myDataGrid.TableStyles.Count > 0)
|
||||
// myDataGrid.TableStyles[0].HeaderBackColor = Color.LightSteelBlue;
|
||||
}
|
||||
|
||||
private void myDataGrid_MouseLeave(object sender, System.EventArgs e)
|
||||
{
|
||||
//myDataGrid.TableStyles[0].GridLineColor = Color.Gainsboro;
|
||||
if (myDataGrid.TableStyles.Count > 0)
|
||||
myDataGrid.TableStyles[0].HeaderBackColor = Color.Gainsboro;
|
||||
// if (myDataGrid.TableStyles.Count > 0)
|
||||
// myDataGrid.TableStyles[0].HeaderBackColor = Color.Gainsboro;
|
||||
}
|
||||
|
||||
private void myCSharpText_MouseEnter(object sender, System.EventArgs e)
|
||||
|
||||
@@ -116,12 +116,12 @@ namespace BCG
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.myDataGrid = new System.Windows.Forms.DataGrid();
|
||||
this.myDataGrid = new System.Windows.Forms.DataGridView();
|
||||
// this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
|
||||
this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
|
||||
this.dataGridTextBoxColumn3 = new System.Windows.Forms.DataGridTextBoxColumn();
|
||||
this.dataGridTextBoxColumn4 = new System.Windows.Forms.DataGridTextBoxColumn();
|
||||
this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
|
||||
dataGridTextBoxColumn2 = new();
|
||||
dataGridTextBoxColumn3 = new();
|
||||
dataGridTextBoxColumn4 = new();
|
||||
dataGridTextBoxColumn1 = new();
|
||||
((System.ComponentModel.ISupportInitialize)(this.myDataGrid)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -144,10 +144,10 @@ namespace BCG
|
||||
// myDataGrid
|
||||
//
|
||||
this.myDataGrid.BackgroundColor = System.Drawing.Color.LightGoldenrodYellow;
|
||||
this.myDataGrid.CaptionText = "PubSub Routes";
|
||||
// this.myDataGrid.CaptionText = "PubSub Routes";
|
||||
this.myDataGrid.DataMember = "";
|
||||
this.myDataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.myDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
|
||||
// this.myDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this.myDataGrid.Location = new System.Drawing.Point(0, 0);
|
||||
this.myDataGrid.Name = "myDataGrid";
|
||||
this.myDataGrid.Size = new System.Drawing.Size(392, 480);
|
||||
@@ -168,37 +168,37 @@ namespace BCG
|
||||
//
|
||||
// dataGridTextBoxColumn2
|
||||
//
|
||||
this.dataGridTextBoxColumn2.Format = "";
|
||||
this.dataGridTextBoxColumn2.FormatInfo = null;
|
||||
// this.dataGridTextBoxColumn2.Format = "";
|
||||
// this.dataGridTextBoxColumn2.FormatInfo = null;
|
||||
this.dataGridTextBoxColumn2.HeaderText = "Tag Regexp";
|
||||
this.dataGridTextBoxColumn2.MappingName = "tagRegexp";
|
||||
this.dataGridTextBoxColumn2.NullText = "";
|
||||
// this.dataGridTextBoxColumn2.MappingName = "tagRegexp";
|
||||
// this.dataGridTextBoxColumn2.NullText = "";
|
||||
this.dataGridTextBoxColumn2.Width = 112;
|
||||
//
|
||||
// dataGridTextBoxColumn3
|
||||
//
|
||||
this.dataGridTextBoxColumn3.Format = "";
|
||||
this.dataGridTextBoxColumn3.FormatInfo = null;
|
||||
// this.dataGridTextBoxColumn3.Format = "";
|
||||
// this.dataGridTextBoxColumn3.FormatInfo = null;
|
||||
this.dataGridTextBoxColumn3.HeaderText = "PubSub IP";
|
||||
this.dataGridTextBoxColumn3.MappingName = "ip";
|
||||
this.dataGridTextBoxColumn3.NullText = "";
|
||||
// this.dataGridTextBoxColumn3.MappingName = "ip";
|
||||
// this.dataGridTextBoxColumn3.NullText = "";
|
||||
this.dataGridTextBoxColumn3.Width = 110;
|
||||
//
|
||||
// dataGridTextBoxColumn4
|
||||
//
|
||||
this.dataGridTextBoxColumn4.Format = "";
|
||||
this.dataGridTextBoxColumn4.FormatInfo = null;
|
||||
// this.dataGridTextBoxColumn4.Format = "";
|
||||
// this.dataGridTextBoxColumn4.FormatInfo = null;
|
||||
this.dataGridTextBoxColumn4.HeaderText = "Queue Name";
|
||||
this.dataGridTextBoxColumn4.MappingName = "queue";
|
||||
this.dataGridTextBoxColumn4.NullText = "";
|
||||
// this.dataGridTextBoxColumn4.MappingName = "queue";
|
||||
// this.dataGridTextBoxColumn4.NullText = "";
|
||||
this.dataGridTextBoxColumn4.Width = 80;
|
||||
//
|
||||
// dataGridTextBoxColumn1
|
||||
//
|
||||
this.dataGridTextBoxColumn1.Format = "";
|
||||
this.dataGridTextBoxColumn1.FormatInfo = null;
|
||||
// this.dataGridTextBoxColumn1.Format = "";
|
||||
// this.dataGridTextBoxColumn1.FormatInfo = null;
|
||||
this.dataGridTextBoxColumn1.HeaderText = "Order";
|
||||
this.dataGridTextBoxColumn1.MappingName = "order";
|
||||
// this.dataGridTextBoxColumn1.MappingName = "order";
|
||||
this.dataGridTextBoxColumn1.Width = 40;
|
||||
//
|
||||
// RouteInput
|
||||
|
||||
Reference in new issue
Block a user