本文整理汇总了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;
}