7,765
社区成员
发帖
与我相关
我的任务
分享
this.goHome();
this.BackUp();
BaseElement bElement = this.SelElements[0];
float bw = bElement.getWidth() + bElement.FPenWidth;
float bh = bElement.getHeight() + bElement.FPenWidth;
Size size = this.Parent.ClientSize;
float tw = size.Width - 25;//(空余出滚动条的所占的空间)
float th = size.Height - 25;
float scale = Math.Min(tw / bw, th / bh);
scale = (float)Math.Round(scale, 2, MidpointRounding.AwayFromZero);
this.isAutoSize = false;
this.fScaleX = scale;
this.fScaleY = scale;
this.fScaleX = (float)Math.Round(fScaleX, 2, MidpointRounding.AwayFromZero);
this.fScaleY = (float)Math.Round(fScaleY, 2, MidpointRounding.AwayFromZero);
this.Scale();
tw = tw / 2;
th = th / 2;
PointF bLocation = new PointF(bElement.location.X, bElement.location.Y);
float tx = bLocation.X - tw;
float ty = bLocation.Y - th;
tx = tx <= 0 ? this.Location.X : tx;
ty = ty <= 0 ? this.Location.Y : ty;
tx = (float)Math.Round(tx, 0, MidpointRounding.AwayFromZero);
ty = (float)Math.Round(ty, 0, MidpointRounding.AwayFromZero);
//(this.Parent as PanelEx).HorizontalScroll.Value = (int)tx;
//(this.Parent as PanelEx).VerticalScroll.Value = (int)ty;
//(this.Parent as PanelEx).AutoScrollOffset = new Point((int)tx, (int)ty);
(this.Parent as PanelEx).AutoScrollPosition = new Point((int)tx, (int)ty);
this.postInvalidate(false);
//==============
WndProc中:
try
{
base.WndProc(ref m);
}
catch (System.InvalidOperationException ex)
{
}
catch (InsufficientMemoryException ex)
{
}
catch (System.ComponentModel.Win32Exception Win32Ex)
{
//int WM_PAINT = 0xf;
//int WM_NCPAINT = 0x85;
//if (m.Msg == WM_PAINT)
//{
// m.Msg = WM_NCPAINT;
// m.HWnd = new IntPtr(0x30bd4);
// m.WParam = new IntPtr(0x1);
// m.LParam = new IntPtr(0x0);
// m.Result = new IntPtr(0x0);
//}
base.WndProc(ref m);
}