示例#1
0
        //Event trên Shape
        void shape_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            TableShape shape = (TableShape)sender;
            int  indexColumn =0;

            //Bật trạng thái rename lên
            renamedShape = true;

            //Click vào Table Name
            if (e.Y > 0 && e.Y < ShapeSetting.heightPieceShape)
            {
                renamedTableName = true;
                txtRename = new TextBox();
                txtRename.Location = new Point(0, (indexColumn * ShapeSetting.heightPieceShape));
                txtRename.Width = shape.Width;
                txtRename.Text = shape.table.name;
                shape.Controls.Add(txtRename);
                tShapeRenamed = shape;
                txtRename.Focus();
                txtRename.SelectAll();
                txtRename.KeyDown += new KeyEventHandler(txtRename_KeyDown);
            }
            //Duyệt tất cả các Columns
            for (int i = 1; i <= shape.table.columns.Count; i++)
            {
                if (e.Y > (i * ShapeSetting.heightPieceShape) && e.Y < ((i + 1) * ShapeSetting.heightPieceShape))
                {
                    indexColumn = i;
                    break;
                }
            }
            if (indexColumn > 0)
            {
                //Tạo TextBox Rename
                txtRename = new TextBox();
                txtRename.Location= new Point(0, (indexColumn * ShapeSetting.heightPieceShape));
                txtRename.Width = shape.Width;
                txtRename.Text = shape.table.columns[indexColumn - 1].Name;
                shape.Controls.Add(txtRename);
                txtRename.Focus();
                txtRename.SelectAll();
                colRenamed = shape.table.columns[indexColumn - 1]; //Lấy Column đang được Rename

                //Tạo Combox DataType
                cbxDataType = new DataDescription();
                cbxDataType.Location = new Point(shape.Location.X + shape.Width, shape.Location.Y+(indexColumn*ShapeSetting.heightPieceShape));
                this.Controls.Add(cbxDataType);

                this.Controls.SetChildIndex(cbxDataType, 0);

                cbxDataType.cboDataType.SelectedItem = shape.table.columns[indexColumn - 1].DataType;
                cbxDataType.txtLength.Text = shape.table.columns[indexColumn - 1].Length.ToString();
                cbxDataType.chkNull.Checked = shape.table.columns[indexColumn - 1].AlowNull;
                if (shape.table.columns[indexColumn - 1].PrimaryKey)
                {
                    cbxDataType.chkNull.Enabled = false;
                    cbxDataType.chkNull.Checked = false;
                }
                cbxDataType.txtDescription.Text = shape.table.columns[indexColumn - 1].Description;

                //Sinh Event KeyDown trên textBox
                txtRename.KeyDown += new KeyEventHandler(txtRename_KeyDown);
                cbxDataType.btnOK.Click +=new EventHandler(btnOK_Click);
            }
        }
示例#2
0
        //Event trên Shape
        void shape_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            TableShape shape       = (TableShape)sender;
            int        indexColumn = 0;

            //Bật trạng thái rename lên
            renamedShape = true;

            //Click vào Table Name
            if (e.Y > 0 && e.Y < ShapeSetting.heightPieceShape)
            {
                renamedTableName   = true;
                txtRename          = new TextBox();
                txtRename.Location = new Point(0, (indexColumn * ShapeSetting.heightPieceShape));
                txtRename.Width    = shape.Width;
                txtRename.Text     = shape.table.name;
                shape.Controls.Add(txtRename);
                tShapeRenamed = shape;
                txtRename.Focus();
                txtRename.SelectAll();
                txtRename.KeyDown += new KeyEventHandler(txtRename_KeyDown);
            }
            //Duyệt tất cả các Columns
            for (int i = 1; i <= shape.table.columns.Count; i++)
            {
                if (e.Y > (i * ShapeSetting.heightPieceShape) && e.Y < ((i + 1) * ShapeSetting.heightPieceShape))
                {
                    indexColumn = i;
                    break;
                }
            }
            if (indexColumn > 0)
            {
                //Tạo TextBox Rename
                txtRename          = new TextBox();
                txtRename.Location = new Point(0, (indexColumn * ShapeSetting.heightPieceShape));
                txtRename.Width    = shape.Width;
                txtRename.Text     = shape.table.columns[indexColumn - 1].Name;
                shape.Controls.Add(txtRename);
                txtRename.Focus();
                txtRename.SelectAll();
                colRenamed = shape.table.columns[indexColumn - 1]; //Lấy Column đang được Rename

                //Tạo Combox DataType
                cbxDataType          = new DataDescription();
                cbxDataType.Location = new Point(shape.Location.X + shape.Width, shape.Location.Y + (indexColumn * ShapeSetting.heightPieceShape));
                this.Controls.Add(cbxDataType);

                this.Controls.SetChildIndex(cbxDataType, 0);

                cbxDataType.cboDataType.SelectedItem = shape.table.columns[indexColumn - 1].DataType;
                cbxDataType.txtLength.Text           = shape.table.columns[indexColumn - 1].Length.ToString();
                cbxDataType.chkNull.Checked          = shape.table.columns[indexColumn - 1].AlowNull;
                if (shape.table.columns[indexColumn - 1].PrimaryKey)
                {
                    cbxDataType.chkNull.Enabled = false;
                    cbxDataType.chkNull.Checked = false;
                }
                cbxDataType.txtDescription.Text = shape.table.columns[indexColumn - 1].Description;

                //Sinh Event KeyDown trên textBox
                txtRename.KeyDown       += new KeyEventHandler(txtRename_KeyDown);
                cbxDataType.btnOK.Click += new EventHandler(btnOK_Click);
            }
        }
示例#3
0
        public virtual void doDoubleClick(PanelDoubleBuffered pn, ShapeBase ns)
        {
            parentPanel = pn;
            namingShape = ns;

            if (parentPanel.isNaming)
            {
                parentPanel.AffectingShape.endEditName();
                return;
            }

            parentPanel.AffectingShape = ns;
            parentPanel.isNaming = true;

            txtName = new TextBox();

            //cho class con định vị xong rồi add lên shape theo vị trí đó
            dinhviTextBox(txtName);

            txtName.Text = sName; //hiện tên cũ

            sName = "";
            this.Invalidate();

            this.Controls.Add(txtName);
            txtName.SelectAll();
            txtName.Focus();
            txtName.KeyPress += new System.Windows.Forms.KeyPressEventHandler(txtName_KeyPress);

            //Data type cho attribute
            if (this is AttributeShape)
            {
                if (((AttributeShape)this).attributeChilds.Count == 0)
                {
                    ucDataDescription = new DataDescription();
                    ucDataDescription.Location = new Point(this.Location.X + this.Width + 5, this.Location.Y);
                    parentPanel.Controls.Add(ucDataDescription);

                    //Cho USC nằm lên trên.
                    parentPanel.Controls.SetChildIndex(ucDataDescription, 0);

                    if (((AttributeShape)this).type == AttributeType.Key)
                        ucDataDescription.chkNull.Enabled = false;

                    if (((AttributeShape)this).dataType != null)
                        ucDataDescription.cboDataType.SelectedItem = ((AttributeShape)this).dataType;
                    if (((AttributeShape)this).dataLength != 0)
                        ucDataDescription.txtLength.Text = ((AttributeShape)this).dataLength.ToString();

                    ucDataDescription.chkNull.Checked = ((AttributeShape)this).allowNull;

                    if (((AttributeShape)this).description != "")
                        ucDataDescription.txtDescription.Text = ((AttributeShape)this).description;

                    ucDataDescription.btnOK.Click += new EventHandler(btnOK_Click);
                }
            }
        }