本文整理匯總了C#中System.Drawing.Rect.GetType方法的典型用法代碼示例。如果您正苦於以下問題:C# Rect.GetType方法的具體用法?C# Rect.GetType怎麽用?C# Rect.GetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Rect
的用法示例。
在下文中一共展示了Rect.GetType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WndProc
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_SIZING && m.HWnd.Equals(this.Handle))
{
Rect r = new Rect();
r = (Rect)Marshal.PtrToStructure(m.LParam, r.GetType());
double width = r.Right - r.Left;
double height = r.Bottom - r.Top;
if (height / width > aspect_ratio((int)width))
width = height / aspect_ratio((int)width);
else
height = width * aspect_ratio((int)width);
if (m.WParam.ToInt32() == WMSZ_TOP || m.WParam.ToInt32() == WMSZ_TOPLEFT || m.WParam.ToInt32() == WMSZ_TOPRIGHT)
r.Top = r.Bottom - (int)height;
else
r.Bottom = r.Top + (int)height;
if (m.WParam.ToInt32() == WMSZ_LEFT || m.WParam.ToInt32() == WMSZ_TOPLEFT || m.WParam.ToInt32() == WMSZ_BOTTOMLEFT)
r.Left = r.Right - (int)width;
else
r.Right = r.Left + (int)width;
Marshal.StructureToPtr(r, m.LParam, true);
}
base.WndProc(ref m);
}
示例2: copy
public void copy(Shape s)
{
Shape temp;
if (s!=null)
{
temp = new Rect(0,0,1,1,Color.Black);
//is s a rectangle...?
if (temp.GetType() == s.GetType()) temp = new Rect((Rect)s);
else
{
//is it an oval...?
temp = new Oval(0,0,1,1,Color.Black);
if (temp.GetType() == s.GetType()) temp = new Oval((Oval)s);
else
{
//is it a line...?
temp = new Segment(0,0,1,1,Color.Black,1);
if (temp.GetType() == s.GetType()) temp = new Segment((Segment)s);
else
{
//is it a triangle...?
Point p1 = new Point();
Point p2 = new Point();
Point p3 = new Point();
temp = new Triangle(p1,p2,p3,Color.Black);
if (temp.GetType() == s.GetType()) temp = new Triangle((Triangle)s);
}
}
}
//put the brand new copy into myShapes right after(above in the picture) the original
myShapes.Insert(myShapes.IndexOf(s)+1,temp);
}
//if s is null, do nothing
return;
}