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


C# ScrollDirection.Set方法代码示例

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


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

示例1: HandleKeyPress

 public override bool HandleKeyPress(KeyInput e)
 {
     switch (e.KeyName)
     {
         case "up": Keyboard = Keyboard.Set(ScrollDirection.Up, (e.Event == KeyInputEvent.Down)); return true;
         case "down": Keyboard = Keyboard.Set(ScrollDirection.Down, (e.Event == KeyInputEvent.Down)); return true;
         case "left": Keyboard = Keyboard.Set(ScrollDirection.Left, (e.Event == KeyInputEvent.Down)); return true;
         case "right": Keyboard = Keyboard.Set(ScrollDirection.Right, (e.Event == KeyInputEvent.Down)); return true;
     }
     return false;
 }
开发者ID:maruchinu,项目名称:OpenRA,代码行数:11,代码来源:ViewportScrollControllerWidget.cs

示例2: Tick

        public override void Tick()
        {
            Edge = ScrollDirection.None;
            if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus && Widget.MouseOverWidget == this)
            {
                // Check for edge-scroll
                if (Viewport.LastMousePos.X < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Left, true);
                if (Viewport.LastMousePos.Y < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Up, true);
                if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Right, true);
                if (Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Down, true);
            }

            if(Keyboard != ScrollDirection.None || Edge != ScrollDirection.None)
            {
                var scroll = new float2(0, 0);

                // Modified to use the ViewportEdgeScrollStep setting - Gecko
                if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
                    scroll += new float2(0, -1);
                if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))
                    scroll += new float2(1, 0);
                if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down))
                    scroll += new float2(0, 1);
                if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left))
                    scroll += new float2(-1, 0);

                float length = Math.Max(1, scroll.Length);
                scroll.X = (scroll.X / length) * Game.Settings.Game.ViewportEdgeScrollStep;
                scroll.Y = (scroll.Y / length) * Game.Settings.Game.ViewportEdgeScrollStep;

                Game.viewport.Scroll(scroll);
            }

            base.Tick();
        }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:39,代码来源:CncWorldInteractionControllerWidget.cs

示例3: HandleKeyPress

		public override bool HandleKeyPress(KeyInput e)
		{
			switch (e.Key)
			{
				case Keycode.UP: keyboardDirections = keyboardDirections.Set(ScrollDirection.Up, e.Event == KeyInputEvent.Down); return true;
				case Keycode.DOWN: keyboardDirections = keyboardDirections.Set(ScrollDirection.Down, e.Event == KeyInputEvent.Down); return true;
				case Keycode.LEFT: keyboardDirections = keyboardDirections.Set(ScrollDirection.Left, e.Event == KeyInputEvent.Down); return true;
				case Keycode.RIGHT: keyboardDirections = keyboardDirections.Set(ScrollDirection.Right, e.Event == KeyInputEvent.Down); return true;
			}

			return false;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:12,代码来源:ViewportControllerWidget.cs

示例4: Tick

        public override void Tick(World world)
        {
            Edge = ScrollDirection.None;
            if (Game.Settings.Game.ViewportEdgeScroll && Game.HasInputFocus)
            {
                // Check for edge-scroll
                if (Viewport.LastMousePos.X < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Left, true);
                if (Viewport.LastMousePos.Y < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Up, true);
                if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Right, true);
                if (Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Down, true);
            }

            if(Keyboard != ScrollDirection.None || Edge != ScrollDirection.None)
            {
                var scroll = new float2(0, 0);

                // Modified to use the ViewportEdgeScrollStep setting - Gecko
                if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
                    scroll += new float2(0, -(Game.Settings.Game.ViewportEdgeScrollStep * 100));
                if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))
                    scroll += new float2((Game.Settings.Game.ViewportEdgeScrollStep * 100), 0);
                if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down))
                    scroll += new float2(0, (Game.Settings.Game.ViewportEdgeScrollStep * 100));
                if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left))
                    scroll += new float2(-(Game.Settings.Game.ViewportEdgeScrollStep * 100), 0);

                Game.viewport.Scroll(scroll);
            }
        }
开发者ID:subspace,项目名称:OpenRA,代码行数:33,代码来源:ViewportScrollControllerWidget.cs

示例5: Tick

        public override void Tick(World world)
        {
            Edge = ScrollDirection.None;
            if (Game.Settings.Game.ViewportEdgeScroll)
            {
                // Check for edge-scroll
                if (Viewport.LastMousePos.X < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Left, true);
                if (Viewport.LastMousePos.Y < EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Up, true);
                if (Viewport.LastMousePos.X >= Game.viewport.Width - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Right, true);
                if (Viewport.LastMousePos.Y >= Game.viewport.Height - EdgeScrollThreshold)
                    Edge = Edge.Set(ScrollDirection.Down, true);
            }
            var scroll = new float2(0,0);
            if (Keyboard.Includes(ScrollDirection.Up) || Edge.Includes(ScrollDirection.Up))
                scroll += new float2(0, -10);
            if (Keyboard.Includes(ScrollDirection.Right) || Edge.Includes(ScrollDirection.Right))
                scroll += new float2(10, 0);
            if (Keyboard.Includes(ScrollDirection.Down) || Edge.Includes(ScrollDirection.Down))
                scroll += new float2(0, 10);
            if (Keyboard.Includes(ScrollDirection.Left) || Edge.Includes(ScrollDirection.Left))
                scroll += new float2(-10, 0);

            Game.viewport.Scroll(scroll);
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:27,代码来源:ViewportScrollControllerWidget.cs


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