当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.IntersectsMouse方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.IntersectsMouse方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.IntersectsMouse方法的具体用法?C# Rectangle.IntersectsMouse怎么用?C# Rectangle.IntersectsMouse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Rectangle的用法示例。


在下文中一共展示了Rectangle.IntersectsMouse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

 internal virtual bool Update()
 {
     int height = (int)GUIHelper.StrSize(text).Y + 8;
     Rectangle option = new Rectangle(owner.position.X, owner.position.Y + yOff, height + width, height);
     if (option.IntersectsMouse() && Input.LeftR)
     {
         if (onClick != null)
         {
             onClick.Invoke(this, new EventArgs());
         }
         return true;
     }
     return false;
 }
开发者ID:DaGamesta,项目名称:XNAForms,代码行数:14,代码来源:ContextMenuOption.cs

示例2: Draw

 internal virtual void Draw()
 {
     int height = (int)GUIHelper.StrSize(text).Y + 8;
     Rectangle option = new Rectangle(owner.position.X, owner.position.Y + yOff, height + width, height);
     GUIHelper.FillRect(option, new Color(29, 29, 29, alpha));
     GUIHelper.OutlineRect(option, new Color(0, 0, 0, alpha));
     if (option.IntersectsMouse())
     {
         option.Inflate(-3, -3);
         GUIHelper.sb.Draw(SelectedTexture, option, new Color(255, 255, 255, alpha));
         GUIHelper.OutlineRect(option, new Color(0, 0, 0, alpha));
     }
     GUIHelper.DrawStr(text, owner.position + new Position(4 + height, 4 + yOff), new Color(255, 255, 255, alpha));
     GUIHelper.DrawLn(owner.position + new Position(height, yOff), owner.position + new Position(height, height + yOff), new Color(0, 0, 0, alpha));
 }
开发者ID:DaGamesta,项目名称:XNAForms,代码行数:15,代码来源:ContextMenuOption.cs

示例3: Update

        internal override void Update()
        {
            Rectangle minRect = new Rectangle(rectangle.Right - tBarHeight + 6, position.Y - tBarHeight + 6, tBarHeight - 12, tBarHeight - 12);
            Rectangle titleRect = new Rectangle(position.X, position.Y - tBarHeight, size.width, tBarHeight);
            if (!Input.LeftD)
            {
                moving = false;
                res = new ResizeInfo();
            }

            bool lResize = new Rectangle(rectangle.X, rectangle.Y, 6, tBarHeight + (minimized ? 0 : size.height)).IntersectsMouse();
            bool rResize = new Rectangle(rectangle.Right - 6, rectangle.Y, 6, tBarHeight + (minimized ? 0 : size.height)).IntersectsMouse();
            bool tResize = new Rectangle(rectangle.X, rectangle.Y, size.width, 6).IntersectsMouse();
            bool bResize = new Rectangle(rectangle.X, rectangle.Bottom - 6, size.width, 6).IntersectsMouse();
            if (res.dir != Direction.NONE)
            {
                lResize = (res.dir & Direction.LEFT) != 0;
                rResize = (res.dir & Direction.RIGHT) != 0;
                tResize = (res.dir & Direction.UP) != 0;
                bResize = (res.dir & Direction.DOWN) != 0;
            }
            if (minimized)
            {
                tResize = bResize = false;
            }
            if (moving || !canResize)
            {
                lResize = rResize = tResize = bResize = false;
            }

            if (runClicks)
            {
                if (lResize || rResize)
                {
                    GUI.SetCursor(CursorType.RESIZE_HORIZONTAL);
                    if (Input.LeftC)
                    {
                        res.pt.X = Input.mX - position.X - (rResize ? size.width : 0);
                        res.dir |= rResize ? Direction.RIGHT : Direction.LEFT;
                    }
                }
                if (tResize || bResize)
                {
                    GUI.SetCursor((lResize || rResize) ? CursorType.RESIZE_DIAGONAL : CursorType.RESIZE_VERTICAL);
                    if ((rResize && tResize) || (bResize && lResize))
                    {
                        GUI.FlipCursor(true);
                    }
                    if (Input.LeftC)
                    {
                        res.pt.Y = Input.mY - position.Y - (bResize ? size.height : 0);
                        res.dir |= bResize ? Direction.DOWN : Direction.UP;
                    }
                }
                if (minRect.IntersectsMouse())
                {
                    if (Input.LeftR)
                    {
                        minimized = !minimized;
                    }
                }
                else if (titleRect.IntersectsMouse() && res.dir == Direction.NONE && Input.LeftC)
                {
                    moving = true;
                }
                if (rectangle.IntersectsMouse() && Input.LeftC)
                {
                    GUI.formOrder.Remove(index);
                    GUI.formOrder.Add(index);
                }
            }

            if (moving)
            {
                position += new Position(Input.mDX, Input.mDY);
            }
            #region Resizing
            if ((res.dir & Direction.LEFT) != 0)
            {
                if (size.width - Input.mDX < minSize.width)
                {
                    res.mOff |= Direction.LEFT;
                    position.X += size.width - minSize.width;
                    size.width = minSize.width;
                }
                if ((res.mOff & Direction.LEFT) == 0)
                {
                    size.width -= Input.mDX;
                    position.X += Input.mDX;
                }
                if (Input.mX - position.X < res.pt.X && (res.mOff & Direction.LEFT) != 0)
                {
                    res.mOff &= ~Direction.LEFT;
                    int disp = res.pt.X - Input.mX + position.X;
                    position.X -= disp;
                    size.width += disp;
                }
            }
            if ((res.dir & Direction.RIGHT) != 0)
            {
//.........这里部分代码省略.........
开发者ID:DaGamesta,项目名称:XNAForms,代码行数:101,代码来源:Form.cs

示例4: Draw

        internal override void Draw()
        {
            alpha += minimized ? -20 : 20;
            alpha = alpha.Clamp(150, 255);

            Rectangle titlebar = new Rectangle(position.X, position.Y - tBarHeight, size.width, tBarHeight);
            GUIHelper.sb.Draw(tbTex, titlebar, new Color(255, 255, 255, alpha));
            GUIHelper.OutlineRect(titlebar, new Color(0, 0, 0, alpha));
            GUIHelper.DrawStr(text, position + new Position(6, -tBarHeight + 6), new Color(255, 255, 255, alpha));

            Rectangle minimize = new Rectangle(position.X + size.width - tBarHeight + 6, position.Y - tBarHeight + 6, tBarHeight - 12, tBarHeight - 12);
            Color minTint = minimize.IntersectsMouse() ? (Input.LeftD ? new Color(120, 120, 120, alpha)
                : new Color(135, 135, 135, alpha)) : new Color(150, 150, 150, alpha);
            GUIHelper.sb.Draw(ContextMenuOption.SelectedTexture, minimize, minTint);
            GUIHelper.OutlineRect(minimize, new Color(0, 0, 0, alpha));
            Rectangle minShape = new Rectangle(minimize.X + 3, minimize.Bottom - 5, minimize.Width - 6, 2);
            GUIHelper.OutlineRect(minShape, new Color(0, 0, 0, alpha));
            GUIHelper.FillRect(minShape, new Color(60, 60, 60, alpha));
            if (!minimized)
            {
                Rectangle window = new Rectangle(position.X, position.Y, size.width, size.height);
                GUIHelper.FillRect(window, new Color(16, 16, 16, alpha));
                GUIHelper.OutlineRect(window, new Color(0, 0, 0, alpha));
                window.Inflate(-6, -6);
                GUIHelper.FillRect(window, new Color(23, 23, 23, alpha));
                GUIHelper.OutlineRect(window, new Color(0, 0, 0, alpha));
                foreach (Control c in controls)
                {
                    c.alpha = alpha;
                }
                base.Draw();
            }
        }
开发者ID:DaGamesta,项目名称:XNAForms,代码行数:33,代码来源:Form.cs

示例5: Update

 internal override void Update()
 {
     Rectangle rectangle;
     for (int i = 0; i < items.Count; i++)
     {
         rectangle = new Rectangle(position.X + controls[i].position.X - 4,
             position.Y + controls[i].position.Y - vValue, size.width - (vScrollbar.active ? 15 : 0), controls[i].size.height);
         if (rectangle.IntersectsMouse() && base.rectangle.IntersectsMouse() && Input.LeftC)
         {
             if (selected.Exists(b => b) && !Input.Control)
             {
                 for (int j = 0; j < selected.Count; j++)
                 {
                     selected[j] = false;
                 }
             }
             selected[i] = true;
             break;
         }
     }
     base.Update();
 }
开发者ID:DaGamesta,项目名称:XNAForms,代码行数:22,代码来源:ListBox.cs


注:本文中的Microsoft.Xna.Framework.Rectangle.IntersectsMouse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。