當前位置: 首頁>>代碼示例>>C#>>正文


C# Rect.GetType方法代碼示例

本文整理匯總了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);
        }
開發者ID:improvedk,項目名稱:Multi-Table-Helper,代碼行數:30,代碼來源:EditQuadrant.cs

示例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;
 }
開發者ID:jpmofo,項目名稱:exp-site,代碼行數:35,代碼來源:Drawing.cs


注:本文中的System.Drawing.Rect.GetType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。