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


C# ButtonState.Equals方法代码示例

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


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

示例1: OnRendererTabPageItem

        public virtual void OnRendererTabPageItem(Graphics gfx, Rectangle tabPageItemRct, string tabPageText, int index, ButtonState btnState)
        {
            Rectangle itemRct = tabPageItemRct;

            using (StringFormat format = new StringFormat(StringFormatFlags.LineLimit))
            {
                format.Alignment = StringAlignment.Center;
                format.LineAlignment = StringAlignment.Center;
                format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;

                //背景色
                Color backColor = Color.Empty;

                //边框颜色
                Color borderColor = Color.Empty;

                //前景色
                Color foreColor = Color.Empty;

                //图标
                Image image = null;

                //边框宽度
                int borderWidth = 0;

                if (btnState.Equals(ButtonState.Hover))
                {
                    //设置背景色,如果没有指定悬浮背景色,则使用正常选项卡的
                    if (TabControl.TabItemHoverBackColor != null && !TabControl.TabItemHoverBackColor.Equals(Color.Empty))
                        backColor = TabControl.TabItemHoverBackColor;
                    else if (TabControl.TabItemBackColor != null && !TabControl.TabItemBackColor.Equals(Color.Empty))
                        backColor = TabControl.TabItemBackColor;

                    //设置图标,如果没有指定悬浮图标,则使用正常选项卡的
                    if (TabControl.TabItemStyle.Equals(TabItemStyle.Image) || TabControl.TabItemStyle.Equals(TabItemStyle.TextAndImage))
                    {
                        NeoTabPage page = TabControl.TabPages[index] as NeoTabPage;

                        if (page != null)
                        {
                            if (page.TabHoverImage != null)
                                image = page.TabHoverImage;
                            else if (page.TabImage != null)
                                image = page.TabImage;
                        }
                    }

                    //设置边框样式,如果没有指定悬浮样式,则使用正常选项卡的
                    if (TabControl.TabItemHoverBorderStyle != null)
                    {
                        if (!TabControl.TabItemHoverBorderStyle.Color.Equals(Color.Empty))
                            borderColor = TabControl.TabItemHoverBorderStyle.Color;

                        borderWidth = TabControl.TabItemHoverBorderStyle.Width;
                    }
                    else if (TabControl.TabItemBorderStyle != null)
                    {
                        if (!TabControl.TabItemBorderStyle.Color.Equals(Color.Empty))
                            borderColor = TabControl.TabItemBorderStyle.Color;

                        borderWidth = TabControl.TabItemBorderStyle.Width;
                    }

                    //设置前景色,如果没有指定悬浮前景色,则使用正常选项卡的
                    if (TabControl.TabItemHoverForeColor != null && !TabControl.TabItemHoverForeColor.Equals(Color.Empty))
                        foreColor = TabControl.TabItemHoverForeColor;
                    else if (TabControl.TabItemForeColor != null && !TabControl.TabItemForeColor.Equals(Color.Empty))
                        foreColor = TabControl.TabItemForeColor;

                    DrawTabItem(gfx, itemRct, tabPageText, backColor, borderColor, borderWidth, foreColor, image, format);
                }
                else if (btnState.Equals(ButtonState.Normal))
                {
                    //设置背景色
                    if (TabControl.TabItemBackColor != null && !TabControl.TabItemBackColor.Equals(Color.Empty))
                        backColor = TabControl.TabItemBackColor;

                    //设置图标,如果没有指定悬浮图标,则使用正常选项卡的
                    if (TabControl.TabItemStyle.Equals(TabItemStyle.Image) || TabControl.TabItemStyle.Equals(TabItemStyle.TextAndImage))
                    {
                        NeoTabPage page = TabControl.TabPages[index] as NeoTabPage;

                        if (page != null && page.TabImage != null)
                        {
                            image = page.TabImage;
                        }
                    }

                    //设置边框样式
                    if (TabControl.TabItemBorderStyle != null)
                    {
                        if (!TabControl.TabItemBorderStyle.Color.Equals(Color.Empty))
                            borderColor = TabControl.TabItemBorderStyle.Color;

                        borderWidth = TabControl.TabItemBorderStyle.Width;
                    }

                    //设置前景色,如果没有指定悬浮前景色,则使用正常选项卡的
                    if (TabControl.TabItemForeColor != null && !TabControl.TabItemForeColor.Equals(Color.Empty))
                        foreColor = TabControl.TabItemForeColor;
//.........这里部分代码省略.........
开发者ID:wxll1120,项目名称:c585b99f,代码行数:101,代码来源:RendererBase.cs

示例2: update


//.........这里部分代码省略.........
                    {
                        Console.WriteLine("u wanna go east? nty");
                    }
                }
                if (kbs.IsKeyDown(Keys.Space))
                {
                    double totalMilliseconds = time.TotalGameTime.TotalMilliseconds;
                    if (player.getLastFired() == -1 || totalMilliseconds - player.getLastFired() >= player.getProjectile().getCooldown())
                    {
                        level.addProjectile(player.createProjectile(totalMilliseconds));
                    }
                    /*foreach (Entity e in level.getNpcs()) {
                        if (e != null) {
                            npc.deriveHealth(-50);
                            // handle projectile interaction with npcs
                            // if hit, derive npc health by -1 * skilltree power
                            Console.WriteLine("Health: " + npc.getHealth());
                        }
                    }*/
                }
                else if (kbs.IsKeyDown(Keys.X))
                {
                    //switch to telekinesis-select mode (player clicks a liftable object to select it)
                    screenManager.setActiveScreen(2);
                    Console.WriteLine("Entered telekinesis mode!");
                }
            }

            /* Just entered telekinesis mode (player uses mouse to select a liftable object)*/
            else if (screenManager.getActiveScreen().getName() == "Telekinesis-Select")
            {
                lastState = state;
                state = Mouse.GetState().LeftButton;
                if (lastState.Equals(ButtonState.Pressed) && state.Equals(ButtonState.Released))
                {
                    foreach (GameObject obj in level.getObjects())
                    {
                        if (obj != null && obj.isLiftable())
                        {
                            Point p = new Point(Mouse.GetState().X, Mouse.GetState().Y);
                            if (p != null && obj.getBounds().Contains(p))
                            {
                                //select object
                                obj.setSelected(true);
                                selectedObject = obj;
                                //switch screen state to telekinesis-move (control over selected object)
                                screenManager.setActiveScreen(3);
                                Console.WriteLine("obj contains mouse!");
                            }
                        }
                    }
                    Console.WriteLine("Mouse pressed");
                }
                else if (kbs.IsKeyDown(Keys.X))
                {
                    //switch to telekinesis-select mode (player clicks a liftable object to select it)
                    screenManager.setActiveScreen(1);
                    Console.WriteLine("Entered telekinesis mode!");
                }
            }

            /* Telekinetic lifting mode (player controls the selected object's movement)*/
            else if (screenManager.getActiveScreen().getName() == "Telekinesis-Move")
            {
                if (kbs.IsKeyDown(Keys.Escape))
                {
开发者ID:ripark,项目名称:Kinetic-Camp,代码行数:67,代码来源:InputManager.cs

示例3: UpdateMouse

        protected void UpdateMouse()
        {
            MouseState current_mouse = Mouse.GetState();

            // The mouse x and y positions are returned relative to the
            // upper-left corner of the game window.
            mouseX = current_mouse.X;
            mouseY = current_mouse.Y;

            int x = mouseX / 64, y = mouseY / 64;

            bool mouseOutOfBounds = false;

            if ((x > 7 || x < 0 || y > 7 || y < 0) && activePiece != 0 && activePiece != 99)
            {
                mouseOutOfBounds = true;
                Board[origX, origY] = activePiece;
                activePiece = 0;
                x = 0; y = 0;
            }
            else if (x > 7 || x < 0 || y > 7 || y < 0)
            {
                x = 0; y = 0;
            }

            LastMouseState = CurrentMouseState;
            CurrentMouseState = current_mouse.LeftButton;

            //OnClick
            if (current_mouse.LeftButton.Equals(ButtonState.Pressed) && LastMouseState.Equals(ButtonState.Released) && !mouseOutOfBounds)
            {
                if (Board[x, y] == turn || Board[x,y] == 2*turn)
                {
                    activePiece = Board[x, y];
                    origX = x; origY = y;
                    Board[x, y] = 0;
                }
            }

            //OnRelease
            if (current_mouse.LeftButton.Equals(ButtonState.Released) && LastMouseState.Equals(ButtonState.Pressed) && !mouseOutOfBounds)
            {
                if (isLegalMove(origX, origY, x, y, activePiece))
                {
                    Move(x, y);
                    if (!multiJump)
                        turn = -turn;
                }
                else if (activePiece != 0 && activePiece != 99)
                    Board[origX, origY] = activePiece;
                activePiece = 0;
            }
        }
开发者ID:delfino,项目名称:Checkers,代码行数:53,代码来源:Game1.cs


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