Added:
trunk/MySql.VisualStudio/Editors/ColumnWithTypeDescriptor.cs
trunk/MySql.VisualStudio/Editors/MyDataGridViewRowHeaderCell.cs
trunk/MySql.VisualStudio/Resources/ArrowKey.bmp
trunk/MySql.VisualStudio/Resources/Key.bmp
Modified:
trunk/MySql.VisualStudio/DbObjects/Column.cs
trunk/MySql.VisualStudio/Editors/TableEditor.cs
trunk/MySql.VisualStudio/Editors/TableEditor.resx
trunk/MySql.VisualStudio/MySql.VisualStudio.csproj
trunk/MySql.VisualStudio/Properties/Resources.Designer.cs
trunk/MySql.VisualStudio/Properties/Resources.resx
Log:
got primary key toggle working just like with sql server.
Modified: trunk/MySql.VisualStudio/DbObjects/Column.cs
===================================================================
--- trunk/MySql.VisualStudio/DbObjects/Column.cs 2008-12-05 16:29:19 UTC (rev 1473)
+++ trunk/MySql.VisualStudio/DbObjects/Column.cs 2008-12-08 20:32:15 UTC (rev 1474)
@@ -9,16 +9,18 @@
namespace MySql.Data.VisualStudio
{
- internal class Column : ICustomTypeDescriptor
+ class Column : Object
{
private Table owningTable;
private string characterSet;
+ private string name;
+ private string dataType;
public Column()
{
}
- public Column(DataRow row)
+ public Column(DataRow row) : this()
{
if (row != null)
ParseColumnInfo(row);
@@ -33,14 +35,21 @@
set { owningTable = value; }
}
- [Category("General")]
- public string ColumnName { get; set; }
+ [Category("General")]
+ public string ColumnName
+ {
+ get { return name; }
+ set { name = value; }
+ }
[Category("General")]
[DisplayName("Data Type")]
[TypeConverter(typeof(DataTypeConverter))]
[RefreshProperties(RefreshProperties.All)]
- public string DataType { get; set; }
+ public string DataType {
+ get { return dataType; }
+ set { dataType = value; }
+ }
[Category("Options")]
[DisplayName("Allow Nulls")]
@@ -90,6 +99,9 @@
[Category("Miscellaneous")]
public string Comment { get; set; }
+ [Browsable(false)]
+ public bool IsPrimaryKey { get; set; }
+
#endregion
/* dt.Columns.Add("ORDINAL_POSITION", typeof (long));
@@ -126,91 +138,5 @@
unsigned = columnType.EndsWith("unsigned"); */
}
- #region ICustomTypeDescriptor Members
-
- public TypeConverter GetConverter()
- {
- return TypeDescriptor.GetConverter(this, true);
- }
-
- public EventDescriptorCollection GetEvents(Attribute[] attributes)
- {
- return TypeDescriptor.GetEvents(this, attributes, true);
- }
-
- EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents()
- {
- return TypeDescriptor.GetEvents(this, true);
- }
-
- public string GetComponentName()
- {
- return TypeDescriptor.GetComponentName(this, true);
- }
-
- public object GetPropertyOwner(PropertyDescriptor pd)
- {
- return this;
- }
-
- public AttributeCollection GetAttributes()
- {
- return TypeDescriptor.GetAttributes(this, true);
- }
-
- public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
- {
- PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(this, attributes, true);
-
- List<PropertyDescriptor> props = new List<PropertyDescriptor>();
-
- foreach (PropertyDescriptor pd in coll)
- {
- if (!pd.IsBrowsable) continue;
-
- if (pd.Name == "Precision" || pd.Name == "Scale")
- {
- if (DataType != null && DataType.ToLowerInvariant() == "decimal")
- props.Add(pd);
- }
- else if (pd.Name == "CharacterSet" || pd.Name == "Collation")
- {
- CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
- newPd.SetReadOnly(DataType == null || !Metadata.IsStringType(DataType));
- props.Add(newPd);
- }
- else
- props.Add(pd);
- }
- return new PropertyDescriptorCollection(props.ToArray());
- }
-
- PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties()
- {
- return TypeDescriptor.GetProperties(this, true);
- }
-
- public object GetEditor(Type editorBaseType)
- {
- return TypeDescriptor.GetEditor(this, editorBaseType, true);
- }
-
- public PropertyDescriptor GetDefaultProperty()
- {
- return TypeDescriptor.GetDefaultProperty(this, true);
- }
-
- public EventDescriptor GetDefaultEvent()
- {
- return TypeDescriptor.GetDefaultEvent(this, true);
- }
-
- public string GetClassName()
- {
- return TypeDescriptor.GetClassName(this, true);
- }
-
- #endregion
-
}
}
Added: trunk/MySql.VisualStudio/Editors/ColumnWithTypeDescriptor.cs
===================================================================
--- trunk/MySql.VisualStudio/Editors/ColumnWithTypeDescriptor.cs (rev 0)
+++ trunk/MySql.VisualStudio/Editors/ColumnWithTypeDescriptor.cs 2008-12-08 20:32:15 UTC (rev 1474)
@@ -0,0 +1,99 @@
+using System.ComponentModel;
+using System;
+using System.Collections.Generic;
+using MySql.Data.VisualStudio.DbObjects;
+
+namespace MySql.Data.VisualStudio.Editors
+{
+ class ColumnWithTypeDescriptor : Column, ICustomTypeDescriptor
+ {
+ #region ICustomTypeDescriptor Members
+
+ public TypeConverter GetConverter()
+ {
+ return TypeDescriptor.GetConverter(this, true);
+ }
+
+ public EventDescriptorCollection GetEvents(Attribute[] attributes)
+ {
+ return TypeDescriptor.GetEvents(this, attributes, true);
+ }
+
+ EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents()
+ {
+ return TypeDescriptor.GetEvents(this, true);
+ }
+
+ public string GetComponentName()
+ {
+ return TypeDescriptor.GetComponentName(this, true);
+ }
+
+ public object GetPropertyOwner(PropertyDescriptor pd)
+ {
+ return this;
+ }
+
+ public AttributeCollection GetAttributes()
+ {
+ return TypeDescriptor.GetAttributes(this, true);
+ }
+
+ public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
+ {
+ PropertyDescriptorCollection coll =
+ TypeDescriptor.GetProperties(this, attributes, true);
+
+ List<PropertyDescriptor> props = new List<PropertyDescriptor>();
+
+ foreach (PropertyDescriptor pd in coll)
+ {
+ if (!pd.IsBrowsable) continue;
+
+ if (pd.Name == "Precision" || pd.Name == "Scale")
+ {
+ if (DataType != null &&
+ DataType.ToLowerInvariant() == "decimal")
+ props.Add(pd);
+ }
+ else if (pd.Name == "CharacterSet" || pd.Name == "Collation")
+ {
+ CustomPropertyDescriptor newPd = new CustomPropertyDescriptor(pd);
+ newPd.SetReadOnly(DataType == null ||
+ !Metadata.IsStringType(DataType));
+ props.Add(newPd);
+ }
+ else
+ props.Add(pd);
+ }
+ return new PropertyDescriptorCollection(props.ToArray());
+ }
+
+ PropertyDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetProperties()
+ {
+ return TypeDescriptor.GetProperties(this, true);
+ }
+
+ public object GetEditor(Type editorBaseType)
+ {
+ return TypeDescriptor.GetEditor(this, editorBaseType, true);
+ }
+
+ public PropertyDescriptor GetDefaultProperty()
+ {
+ return TypeDescriptor.GetDefaultProperty(this, true);
+ }
+
+ public EventDescriptor GetDefaultEvent()
+ {
+ return TypeDescriptor.GetDefaultEvent(this, true);
+ }
+
+ public string GetClassName()
+ {
+ return TypeDescriptor.GetClassName(this, true);
+ }
+
+ #endregion
+ }
+}
Added: trunk/MySql.VisualStudio/Editors/MyDataGridViewRowHeaderCell.cs
===================================================================
--- trunk/MySql.VisualStudio/Editors/MyDataGridViewRowHeaderCell.cs (rev 0)
+++ trunk/MySql.VisualStudio/Editors/MyDataGridViewRowHeaderCell.cs 2008-12-08 20:32:15 UTC (rev 1474)
@@ -0,0 +1,50 @@
+using System.Windows.Forms;
+using System.Drawing;
+using System.Collections.Generic;
+using MySql.Data.VisualStudio.Properties;
+
+namespace MySql.Data.VisualStudio.Editors
+{
+ class MyDataGridViewRowHeaderCell : DataGridViewRowHeaderCell
+ {
+ TableNode tableNode;
+
+ private List<Column> Columns
+ {
+ get { return (DataGridView.DataSource as BindingSource).DataSource as List<Column>; }
+ }
+
+ protected override void Paint(Graphics graphics, Rectangle clipBounds,
+ Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState,
+ object value, object formattedValue, string errorText,
+ DataGridViewCellStyle cellStyle,
+ DataGridViewAdvancedBorderStyle advancedBorderStyle,
+ DataGridViewPaintParts paintParts)
+ {
+ if (Columns.Count > rowIndex)
+ {
+ Column c = Columns[rowIndex];
+ if (c.IsPrimaryKey)
+ {
+ Bitmap bmp = rowIndex == DataGridView.CurrentRow.Index ?
+ Resources.ArrowKey : Resources.Key;
+ bmp.MakeTransparent();
+ paintParts &= ~DataGridViewPaintParts.ContentBackground;
+ base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
+ value, formattedValue, errorText, cellStyle, advancedBorderStyle,
+ paintParts);
+ Rectangle r = cellBounds;
+ r.Offset(bmp.Width / 2, bmp.Height / 2);
+ r.Width = bmp.Width;
+ r.Height = bmp.Height;
+ graphics.DrawImage(bmp, r);
+ return;
+ }
+ }
+
+ base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState,
+ value, formattedValue, errorText, cellStyle, advancedBorderStyle,
+ paintParts);
+ }
+ }
+}
Modified: trunk/MySql.VisualStudio/Editors/TableEditor.cs
===================================================================
--- trunk/MySql.VisualStudio/Editors/TableEditor.cs 2008-12-05 16:29:19 UTC (rev 1473)
+++ trunk/MySql.VisualStudio/Editors/TableEditor.cs 2008-12-08 20:32:15 UTC (rev 1474)
@@ -17,75 +17,120 @@
namespace MySql.Data.VisualStudio
{
class TableEditor : UserControl
- {
- private DataGridView columnGrid;
+ {
private TableNode tableNode;
- private BindingSource columnBindingSource;
private System.ComponentModel.IContainer components;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private DataGridViewComboBoxColumn dataGridViewComboBoxColumn1;
- private DataGridViewTextBoxColumn NameColumn;
- private DataGridViewComboBoxColumn TypeColumn;
- private DataGridViewCheckBoxColumn AllowNullColumn;
- private MySplitter splitter1;
private TabControl tabControl1;
private TabPage tabPage1;
private VS2005PropertyGrid columnProperties;
private Panel panel1;
+ private DataGridView columnGrid;
private TableEditorPane pane;
+ private MySplitter splitter1;
+ private DataGridViewTextBoxColumn NameColumn;
+ private DataGridViewComboBoxColumn TypeColumn;
+ private DataGridViewCheckBoxColumn AllowNullColumn;
+ private BindingSource columnBindingSource;
public TableEditor(TableEditorPane pane, TableNode node)
{
this.pane = pane;
tableNode = node;
InitializeComponent();
- columnGrid.AutoGenerateColumns = false;
string[] types = Metadata.GetDataTypes(false);
TypeColumn.Items.AddRange((object[])types); //Metadata.GetDataTypes(false));
- columnGrid.EditingPanel.BackColor = Color.Red;
tableNode.DataLoaded += new EventHandler(OnDataLoaded);
-
+ columnGrid.RowTemplate.HeaderCell = new MyDataGridViewRowHeaderCell();
SetupCommands();
}
void OnDataLoaded(object sender, EventArgs e)
{
- columnBindingSource.DataSource = tableNode.Table;
- columnBindingSource.DataMember = "Columns";
- columnGrid.DataSource = columnBindingSource;
+ columnBindingSource.DataSource = tableNode.Table.Columns;
+ columnBindingSource.AddingNew += new AddingNewEventHandler(columnBindingSource_AddingNew);
pane.SelectObject(tableNode.Table);
}
+ void columnBindingSource_AddingNew(object sender, AddingNewEventArgs e)
+ {
+ e.NewObject = new ColumnWithTypeDescriptor();
+ }
+
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
- this.columnGrid = new System.Windows.Forms.DataGridView();
- this.NameColumn = new DataGridViewTextBoxColumn();
- this.TypeColumn = new DataGridViewComboBoxColumn();
- this.AllowNullColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
- this.columnBindingSource = new System.Windows.Forms.BindingSource(this.components);
- this.splitter1 = new MySql.Data.VisualStudio.Editors.MySplitter();
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.columnProperties = new MySql.Data.VisualStudio.Editors.VS2005PropertyGrid();
this.panel1 = new System.Windows.Forms.Panel();
+ this.columnGrid = new System.Windows.Forms.DataGridView();
+ this.NameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.TypeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
+ this.AllowNullColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+ this.columnBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewComboBoxColumn1 = new System.Windows.Forms.DataGridViewComboBoxColumn();
- ((System.ComponentModel.ISupportInitialize)(this.columnGrid)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.columnBindingSource)).BeginInit();
+ this.splitter1 = new MySql.Data.VisualStudio.Editors.MySplitter();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.panel1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.columnGrid)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.columnBindingSource)).BeginInit();
this.SuspendLayout();
//
+ // tabControl1
+ //
+ this.tabControl1.Controls.Add(this.tabPage1);
+ this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.tabControl1.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.tabControl1.Location = new System.Drawing.Point(6, 10);
+ this.tabControl1.Name = "tabControl1";
+ this.tabControl1.SelectedIndex = 0;
+ this.tabControl1.Size = new System.Drawing.Size(612, 308);
+ this.tabControl1.TabIndex = 1;
+ //
+ // tabPage1
+ //
+ this.tabPage1.BackColor = System.Drawing.SystemColors.Control;
+ this.tabPage1.Controls.Add(this.columnProperties);
+ this.tabPage1.Location = new System.Drawing.Point(4, 24);
+ this.tabPage1.Name = "tabPage1";
+ this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
+ this.tabPage1.Size = new System.Drawing.Size(604, 280);
+ this.tabPage1.TabIndex = 0;
+ this.tabPage1.Text = "Column Properties";
+ //
+ // columnProperties
+ //
+ this.columnProperties.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.columnProperties.Location = new System.Drawing.Point(3, 3);
+ this.columnProperties.Name = "columnProperties";
+ this.columnProperties.Size = new System.Drawing.Size(598, 274);
+ this.columnProperties.TabIndex = 0;
+ //
+ // panel1
+ //
+ this.panel1.BackColor = System.Drawing.SystemColors.Control;
+ this.panel1.Controls.Add(this.tabControl1);
+ this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel1.Location = new System.Drawing.Point(0, 103);
+ this.panel1.Name = "panel1";
+ this.panel1.Padding = new System.Windows.Forms.Padding(6, 10, 6, 6);
+ this.panel1.Size = new System.Drawing.Size(624, 324);
+ this.panel1.TabIndex = 9;
+ //
// columnGrid
//
this.columnGrid.AllowUserToResizeRows = false;
+ this.columnGrid.AutoGenerateColumns = false;
this.columnGrid.BackgroundColor = System.Drawing.SystemColors.Window;
this.columnGrid.BorderStyle = System.Windows.Forms.BorderStyle.None;
- this.columnGrid.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
+ this.columnGrid.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@@ -94,114 +139,69 @@
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.columnGrid.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
- this.columnGrid.ColumnHeadersHeight = 24;
- this.columnGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
+ this.columnGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.columnGrid.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.NameColumn,
this.TypeColumn,
this.AllowNullColumn});
+ this.columnGrid.DataSource = this.columnBindingSource;
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
- dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ dataGridViewCellStyle2.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
- dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.ActiveCaption;
+ dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.GradientActiveCaption;
dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
this.columnGrid.DefaultCellStyle = dataGridViewCellStyle2;
this.columnGrid.Dock = System.Windows.Forms.DockStyle.Top;
this.columnGrid.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
- this.columnGrid.GridColor = System.Drawing.SystemColors.Control;
+ this.columnGrid.GridColor = System.Drawing.SystemColors.ControlLight;
this.columnGrid.Location = new System.Drawing.Point(0, 0);
- this.columnGrid.Margin = new System.Windows.Forms.Padding(0);
- this.columnGrid.MultiSelect = false;
this.columnGrid.Name = "columnGrid";
- this.columnGrid.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
- this.columnGrid.RowHeadersWidth = 24;
- this.columnGrid.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
- this.columnGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
- this.columnGrid.Size = new System.Drawing.Size(624, 130);
- this.columnGrid.TabIndex = 1;
+ this.columnGrid.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
+ dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
+ dataGridViewCellStyle3.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
+ dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.columnGrid.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
+ this.columnGrid.RowHeadersWidth = 25;
+ this.columnGrid.ShowCellErrors = false;
+ this.columnGrid.ShowEditingIcon = false;
+ this.columnGrid.ShowRowErrors = false;
+ this.columnGrid.Size = new System.Drawing.Size(624, 103);
+ this.columnGrid.TabIndex = 2;
this.columnGrid.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(this.columnGrid_EditingControlShowing);
//
// NameColumn
//
this.NameColumn.DataPropertyName = "ColumnName";
this.NameColumn.HeaderText = "Column Name";
+ this.NameColumn.MinimumWidth = 200;
this.NameColumn.Name = "NameColumn";
- this.NameColumn.Width = 150;
+ this.NameColumn.Width = 200;
//
// TypeColumn
//
this.TypeColumn.DataPropertyName = "DataType";
+ this.TypeColumn.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox;
this.TypeColumn.DisplayStyleForCurrentCellOnly = true;
this.TypeColumn.HeaderText = "Data Type";
this.TypeColumn.Name = "TypeColumn";
//
// AllowNullColumn
//
- this.AllowNullColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
this.AllowNullColumn.DataPropertyName = "AllowNull";
this.AllowNullColumn.HeaderText = "Allow Nulls";
this.AllowNullColumn.Name = "AllowNullColumn";
- this.AllowNullColumn.Width = 74;
//
// columnBindingSource
//
- this.columnBindingSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(this.columnBindingSource_ListChanged);
+ this.columnBindingSource.DataSource = typeof(MySql.Data.VisualStudio.Column);
+ this.columnBindingSource.CurrentChanged += new System.EventHandler(this.columnBindingSource_CurrentChanged);
//
- // splitter1
- //
- this.splitter1.BackColor = System.Drawing.SystemColors.Control;
- this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
- this.splitter1.Location = new System.Drawing.Point(0, 130);
- this.splitter1.MaximumSize = new System.Drawing.Size(0, 6);
- this.splitter1.MinimumSize = new System.Drawing.Size(0, 6);
- this.splitter1.Name = "splitter1";
- this.splitter1.Size = new System.Drawing.Size(624, 6);
- this.splitter1.TabIndex = 8;
- this.splitter1.TabStop = false;
- //
- // tabControl1
- //
- this.tabControl1.Controls.Add(this.tabPage1);
- this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.tabControl1.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.tabControl1.Location = new System.Drawing.Point(6, 6);
- this.tabControl1.Name = "tabControl1";
- this.tabControl1.SelectedIndex = 0;
- this.tabControl1.Size = new System.Drawing.Size(612, 279);
- this.tabControl1.TabIndex = 1;
- //
- // tabPage1
- //
- this.tabPage1.BackColor = System.Drawing.SystemColors.Control;
- this.tabPage1.Controls.Add(this.columnProperties);
- this.tabPage1.Location = new System.Drawing.Point(4, 24);
- this.tabPage1.Name = "tabPage1";
- this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
- this.tabPage1.Size = new System.Drawing.Size(604, 251);
- this.tabPage1.TabIndex = 0;
- this.tabPage1.Text = "Column Properties";
- //
- // columnProperties
- //
- this.columnProperties.Dock = System.Windows.Forms.DockStyle.Fill;
- this.columnProperties.Location = new System.Drawing.Point(3, 3);
- this.columnProperties.Name = "columnProperties";
- this.columnProperties.Size = new System.Drawing.Size(598, 245);
- this.columnProperties.TabIndex = 0;
- //
- // panel1
- //
- this.panel1.BackColor = System.Drawing.SystemColors.Control;
- this.panel1.Controls.Add(this.tabControl1);
- this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
- this.panel1.Location = new System.Drawing.Point(0, 136);
- this.panel1.Name = "panel1";
- this.panel1.Padding = new System.Windows.Forms.Padding(6);
- this.panel1.Size = new System.Drawing.Size(624, 291);
- this.panel1.TabIndex = 9;
- //
// dataGridViewTextBoxColumn1
//
this.dataGridViewTextBoxColumn1.DataPropertyName = "ColumnName";
@@ -217,20 +217,29 @@
this.dataGridViewComboBoxColumn1.HeaderText = "Data Type";
this.dataGridViewComboBoxColumn1.Name = "dataGridViewComboBoxColumn1";
//
+ // splitter1
+ //
+ this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
+ this.splitter1.Location = new System.Drawing.Point(0, 103);
+ this.splitter1.Name = "splitter1";
+ this.splitter1.Size = new System.Drawing.Size(624, 6);
+ this.splitter1.TabIndex = 10;
+ this.splitter1.TabStop = false;
+ //
// TableEditor
//
this.BackColor = System.Drawing.SystemColors.Window;
- this.Controls.Add(this.panel1);
this.Controls.Add(this.splitter1);
+ this.Controls.Add(this.panel1);
this.Controls.Add(this.columnGrid);
this.Margin = new System.Windows.Forms.Padding(0);
this.Name = "TableEditor";
this.Size = new System.Drawing.Size(624, 427);
- ((System.ComponentModel.ISupportInitialize)(this.columnGrid)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.columnBindingSource)).EndInit();
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.columnGrid)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.columnBindingSource)).EndInit();
this.ResumeLayout(false);
}
@@ -251,12 +260,30 @@
private void OnQueryPrimaryKey(object sender, EventArgs e)
{
- OleMenuCommand cmd = sender as OleMenuCommand;
- cmd.Enabled = false;
+ bool allKeys = columnGrid.SelectedRows.Count == 0 ? false : true;
+
+ foreach (DataGridViewRow row in columnGrid.SelectedRows)
+ if (!tableNode.Table.Columns[row.Index].IsPrimaryKey)
+ {
+ allKeys = false;
+ break;
+ }
+
+ OleMenuCommand primaryKey = sender as OleMenuCommand;
+ primaryKey.Checked = allKeys;
}
private void OnPrimaryKey(object sender, EventArgs e)
{
+ OleMenuCommand primaryKey = sender as OleMenuCommand;
+
+ foreach (Column c in tableNode.Table.Columns)
+ c.IsPrimaryKey = false;
+ // if not checked then we are setting the key columns
+ if (!primaryKey.Checked)
+ foreach (DataGridViewRow row in columnGrid.SelectedRows)
+ tableNode.Table.Columns[row.Index].IsPrimaryKey = true;
+ columnGrid.Refresh();
}
private void OnIndexesAndKeys(object sender, EventArgs e)
@@ -279,16 +306,6 @@
#endregion
- private void columnGrid_SelectionChanged(object sender, EventArgs e)
- {
- if (columnGrid.SelectedCells.Count == 0) return;
-
- if (columnGrid.SelectedCells.Count > 1)
- columnProperties.SelectedObject = null;
-// columnProperties.SelectedObject =
-// tableNode.Columns[columnGrid.SelectedCells[0].RowIndex];
- }
-
private void columnGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
Type t = e.Control.GetType();
@@ -399,43 +416,11 @@
columnProperties.SelectedObject = c;
}
*/
- /// <summary>
- /// This notifies us that we have added a column to our table. We do it this way
- /// because we have to set the owning table of new columns and handling the
- /// adding new event handler doesn't *seem* to work.
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void columnBindingSource_ListChanged(object sender, ListChangedEventArgs e)
- {
- if (e.ListChangedType != ListChangedType.ItemAdded) return;
- Column c = tableNode.Table.Columns[e.NewIndex];
- c.OwningTable = tableNode.Table;
- }
- private void columnGrid_CellValueChanged(object sender, DataGridViewCellEventArgs e)
+ private void columnBindingSource_CurrentChanged(object sender, EventArgs e)
{
-
+ Column currentObject = columnBindingSource.Current as Column;
+ columnProperties.SelectedObject = currentObject;
}
-
- private void columnGrid_CellValidated(object sender, DataGridViewCellEventArgs e)
- {
-
- }
-
- private void columnGrid_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
- {
-
- }
-
- private void columnGrid_CurrentCellDirtyStateChanged(object sender, EventArgs e)
- {
-
- }
-
- private void columnGrid_CellEnter(object sender, DataGridViewCellEventArgs e)
- {
-
- }
}
}
Modified: trunk/MySql.VisualStudio/Editors/TableEditor.resx
===================================================================
--- trunk/MySql.VisualStudio/Editors/TableEditor.resx 2008-12-05 16:29:19 UTC (rev 1473)
+++ trunk/MySql.VisualStudio/Editors/TableEditor.resx 2008-12-08 20:32:15 UTC (rev 1474)
@@ -117,17 +117,11 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
- <metadata name="NameColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
<metadata name="TypeColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
- <metadata name="AllowNullColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
- <value>True</value>
- </metadata>
<metadata name="columnBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
- <value>122, 17</value>
+ <value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>52</value>
Modified: trunk/MySql.VisualStudio/MySql.VisualStudio.csproj
===================================================================
--- trunk/MySql.VisualStudio/MySql.VisualStudio.csproj 2008-12-05 16:29:19 UTC (rev 1473)
+++ trunk/MySql.VisualStudio/MySql.VisualStudio.csproj 2008-12-08 20:32:15 UTC (rev 1474)
@@ -113,6 +113,7 @@
<Compile Include="DDEX\MySqlDataSourceInformation.cs" />
<Compile Include="DDEX\MySqlDataViewCommandHandler.cs" />
<Compile Include="DDEX\MySqlDataViewSupport.cs" />
+ <Compile Include="Editors\ColumnTypeDescriptor.cs" />
<Compile Include="Editors\CustomPropertyDescriptor.cs" />
<Compile Include="Editors\ForeignKeyDialog.cs">
<SubType>Form</SubType>
@@ -130,6 +131,7 @@
<Compile Include="Editors\MyComboBox.cs">
<SubType>Component</SubType>
</Compile>
+ <Compile Include="Editors\MyDataGridViewRowHeaderCell.cs" />
<Compile Include="Editors\MyDescriptionAttribute.cs" />
<Compile Include="Editors\MySplitter.cs">
<SubType>Component</SubType>
@@ -218,6 +220,8 @@
<DependentUpon>UDFEditor.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
+ <None Include="Resources\ArrowKey.bmp" />
+ <None Include="Resources\Key.bmp" />
<Content Include="Resources\Package.ico" />
</ItemGroup>
<ItemGroup>
@@ -226,6 +230,8 @@
</CtcFile>
<None Include="CtcComponents\Guids.h" />
<None Include="CtcComponents\PkgCmdID.h" />
+ <None Include="Properties\DataSources\Column.datasource" />
+ <None Include="Properties\DataSources\MySql.Data.VisualStudio.Editors.MyColumn.datasource" />
<None Include="Properties\DataSources\TableNode.datasource" />
</ItemGroup>
<PropertyGroup>
Modified: trunk/MySql.VisualStudio/Properties/Resources.Designer.cs
===================================================================
--- trunk/MySql.VisualStudio/Properties/Resources.Designer.cs 2008-12-05 16:29:19 UTC (rev 1473)
+++ trunk/MySql.VisualStudio/Properties/Resources.Designer.cs 2008-12-08 20:32:15 UTC (rev 1474)
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.3053
+// Runtime Version:2.0.50727.3521
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -67,6 +67,13 @@
}
}
+ public static System.Drawing.Bitmap ArrowKey {
+ get {
+ object obj = ResourceManager.GetObject("ArrowKey", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
/// <summary>
/// Looks up a localized string similar to Advanced.
/// </summary>
@@ -2416,6 +2423,13 @@
}
}
+ public static System.Drawing.Bitmap Key {
+ get {
+ object obj = ResourceManager.GetObject("Key", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
/// <summary>
/// Looks up a localized string similar to Stored Functions.
/// </summary>
Modified: trunk/MySql.VisualStudio/Properties/Resources.resx
===================================================================
--- trunk/MySql.VisualStudio/Properties/Resources.resx 2008-12-05 16:29:19 UTC (rev 1473)
+++ trunk/MySql.VisualStudio/Properties/Resources.resx 2008-12-08 20:32:15 UTC (rev 1474)
@@ -1038,4 +1038,10 @@
<data name="ErrorAttemptingToCreateDB" xml:space="preserve">
<value>There was an error attempting to create the database '{0}'</value>
</data>
+ <data name="ArrowKey" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\ArrowKey.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
+ <data name="Key" type="System.Resources.ResXFileRef, System.Windows.Forms">
+ <value>..\Resources\Key.bmp;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
+ </data>
</root>
\ No newline at end of file
Added: trunk/MySql.VisualStudio/Resources/ArrowKey.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/MySql.VisualStudio/Resources/ArrowKey.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/MySql.VisualStudio/Resources/Key.bmp
===================================================================
(Binary files differ)
Property changes on: trunk/MySql.VisualStudio/Resources/Key.bmp
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
| Thread |
|---|
| • Connector/NET commit: r1474 - in trunk/MySql.VisualStudio: . DbObjects Editors Properties Resources | rburnett | 8 Dec |