This commit is contained in:
@@ -51,23 +51,26 @@ namespace Accentra.Controls
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// TablePicker
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
this.BackColor = System.Drawing.Color.WhiteSmoke;
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.BackColor = System.Drawing.Color.LightYellow;
|
||||
this.ClientSize = new System.Drawing.Size(304, 256);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "TablePicker";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "TablePicker";
|
||||
this.Click += new System.EventHandler(this.TablePicker_Click);
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.TablePicker_Paint);
|
||||
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TablePicker_MouseMove);
|
||||
this.MouseEnter += new System.EventHandler(this.TablePicker_MouseEnter);
|
||||
this.MouseLeave += new System.EventHandler(this.TablePicker_MouseLeave);
|
||||
this.Deactivate += new System.EventHandler(this.TablePicker_Deactivate);
|
||||
this.Paint += new System.Windows.Forms.PaintEventHandler(this.TablePicker_Paint);
|
||||
this.MouseEnter += new System.EventHandler(this.TablePicker_MouseEnter);
|
||||
this.Click += new System.EventHandler(this.TablePicker_Click);
|
||||
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TablePicker_KeyPress);
|
||||
this.MouseLeave += new System.EventHandler(this.TablePicker_MouseLeave);
|
||||
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.TablePicker_MouseMove);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
@@ -77,11 +80,17 @@ namespace Accentra.Controls
|
||||
private Brush GrayBrush = System.Drawing.Brushes.Gray;
|
||||
private Brush BlackBrush = System.Drawing.Brushes.Black;
|
||||
private Brush WhiteBrush = System.Drawing.Brushes.White;
|
||||
|
||||
private Brush Jbrush = System.Drawing.Brushes.LightBlue;
|
||||
//private Brush Jbrush = System.Drawing.Brushes.LightSteelBlue;
|
||||
//private Brush Jbrush = System.Drawing.Brushes.SteelBlue;
|
||||
//private Brush Jbrush = System.Drawing.Brushes.PowderBlue;
|
||||
|
||||
private Pen BorderPen = new Pen(SystemColors.ControlDark);
|
||||
private Pen BluePen = new Pen(Color.SlateGray, 1);
|
||||
|
||||
private string DispText = "Cancel"; // Display text
|
||||
private int DispHeight = 20; // Display ("Table 1x1", "Cancel")
|
||||
private string DispText = "Esc to Cancel"; // Display text
|
||||
private int DispHeight = 40;//20; // Display ("Table 1x1", "Cancel")
|
||||
private Font DispFont = new Font("Tahoma", 8.25F);
|
||||
private int SquareX = 20; // Width of squares
|
||||
private int SquareY = 20; // Height of squares
|
||||
@@ -133,7 +142,10 @@ namespace Accentra.Controls
|
||||
// number of visible squares.
|
||||
if (SelQX > SquareQX - 1) SquareQX = SelQX + 1;
|
||||
if (SelQY > SquareQY - 1) SquareQY = SelQY + 1;
|
||||
|
||||
|
||||
if (SquareQX < 7) SquareQX = 7;
|
||||
if (SquareQY < 5) SquareQY = 5;
|
||||
|
||||
// Second, expand the dimensions of this form according to the
|
||||
// number of visible squares.
|
||||
this.Width = (SquareX * (SquareQX)) + 5;
|
||||
@@ -146,11 +158,14 @@ namespace Accentra.Controls
|
||||
// the text is left-justified, only the Y (vertical) position
|
||||
// is calculated.
|
||||
int dispY = ((SquareY - 1) * SquareQY) + SquareQY + 4;
|
||||
if (this.Cancel) {
|
||||
DispText = "Cancel";
|
||||
} else {
|
||||
DispText = SelQX.ToString() + " by " + SelQY.ToString() + " Table";
|
||||
}
|
||||
//if (this.Cancel) {
|
||||
// DispText = "Esc Key to Cancel";
|
||||
//} else {
|
||||
// DispText = SelQX.ToString() + " by " + SelQY.ToString() + " Table";
|
||||
//}
|
||||
//DispText = SelQX.ToString() + " by " + SelQY.ToString() + " Table\nEsc Key to Cancel";
|
||||
//DispText = SelQY.ToString() + " Row"+((SelQY>1)?"s by ":" by ") + SelQX.ToString() + " Column"+((SelQX>1)?"s\nEsc Key to Cancel":"\nEsc Key to Cancel");
|
||||
DispText = SelQY.ToString() + " Row" + ((SelQY > 1) ? "s" : "") + " " + SelQX.ToString() + " Column" + ((SelQX > 1) ? "s" : "")+ "\nEsc to Cancel";
|
||||
g.DrawString(DispText, DispFont, BlackBrush, 3, dispY + 2);
|
||||
|
||||
// Draw each of the squares and fill with the default color.
|
||||
@@ -164,8 +179,9 @@ namespace Accentra.Controls
|
||||
// Go back and paint the squares with selection colors.
|
||||
for (int x=0; x<SelQX; x++) {
|
||||
for (int y=0; y<SelQY; y++) {
|
||||
g.FillRectangle(BeigeBrush, (x*SquareX) + 3, (y*SquareY) + 3, SquareX - 2, SquareY - 2);
|
||||
g.DrawRectangle(BluePen, (x*SquareX) + 3, (y*SquareY) + 3, SquareX - 2, SquareY - 2);
|
||||
//g.FillRectangle(BeigeBrush, (x*SquareX) + 3, (y*SquareY) + 3, SquareX - 2, SquareY - 2);
|
||||
g.FillRectangle(Jbrush, (x * SquareX) + 3, (y * SquareY) + 3, SquareX - 2, SquareY - 2);
|
||||
g.DrawRectangle(BluePen, (x * SquareX) + 3, (y * SquareY) + 3, SquareX - 2, SquareY - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +195,7 @@ namespace Accentra.Controls
|
||||
// and DialogResult = DialogResult.Cancel
|
||||
// were previously already set in MouseLeave.
|
||||
|
||||
this.Hide();
|
||||
//this.Hide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -207,18 +223,20 @@ namespace Accentra.Controls
|
||||
/// escaped (canceling) state.
|
||||
/// </summary>
|
||||
private void TablePicker_MouseLeave(object sender, System.EventArgs e) {
|
||||
if (!bHiding) bCancel = true;
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Invalidate();
|
||||
//if (!bHiding) bCancel = true;
|
||||
//this.DialogResult = DialogResult.Cancel;
|
||||
//this.Invalidate();
|
||||
if (this.DialogResult == DialogResult.None)
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the prior cancellation caused by MouseLeave.
|
||||
/// </summary>
|
||||
private void TablePicker_MouseEnter(object sender, System.EventArgs e) {
|
||||
bHiding = false;
|
||||
bCancel = false;
|
||||
this.DialogResult = DialogResult.OK;
|
||||
//bHiding = false;
|
||||
//bCancel = false;
|
||||
//this.DialogResult = DialogResult.OK;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
@@ -226,10 +244,23 @@ namespace Accentra.Controls
|
||||
/// Detects that the user made a selection by clicking.
|
||||
/// </summary>
|
||||
private void TablePicker_Click(object sender, System.EventArgs e) {
|
||||
bHiding = true; // Not the same as Visible == false
|
||||
// because bHiding suggests that the control
|
||||
// is still "active" (not canceled).
|
||||
this.Hide();
|
||||
//bHiding = true; // Not the same as Visible == false
|
||||
// // because bHiding suggests that the control
|
||||
// // is still "active" (not canceled).
|
||||
//this.Hide();
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void TablePicker_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (e.KeyChar == (char)Keys.Escape)
|
||||
{
|
||||
//bHiding = true; // Not the same as Visible == false
|
||||
//// because bHiding suggests that the control
|
||||
//// is still "active" (not canceled).
|
||||
//this.Hide();
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user