I’ve been writing an extensive project in C# replacing an entire software library here at work.
One of my main pushes has been for dynamic user interfaces with “widgets”.
I write A LOT of different data visualization screens, and being able to contain them in a panel, and add them to any project like an OCX would be GREAT. The biggest problem i had was resizing the panel, and moving the panel around on the screen to allow a true dynamic panel.
It sounds stupid, but it was hard because i over thought it.
So, for those interested…
void pnlWidget_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right) { mnuContext.Show(new Point(e.X,e.Y + 75)); }
if (e.Button == MouseButtons.Left)
{
pnl_mousedown = true;
aCurrently.X = e.X;
aCurrently.Y = e.Y;
_mouseposX = aCurrently.X;
_mouseposY = aCurrently.Y;
pnlWidget.BorderStyle = BorderStyle.FixedSingle;
}
}
void pnlWidget_MouseMove(object sender, MouseEventArgs e)
{
if (pnl_mousedown == true && Locked == false)
{
this.Location = new Point(MousePosition.X - _mouseposX, MousePosition.Y - _mouseposY);
}
}
I can’t believe how stupid i was. I was writing it much harder before….
gah!
