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


C# Direction类代码示例

本文整理汇总了C#中Direction的典型用法代码示例。如果您正苦于以下问题:C# Direction类的具体用法?C# Direction怎么用?C# Direction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Init

        public static void Init(Control control, Control container, Direction direction)
        {
            bool Dragging = false;
            Point DragStart = Point.Empty;

            control.MouseDown += delegate(object sender, MouseEventArgs e)
            {
                Dragging = true;
                DragStart = new Point(e.X, e.Y);
                control.Capture = true;

            };
            control.MouseUp += delegate(object sender, MouseEventArgs e)
            {
                Dragging = false;
                control.Capture = false;

            };
            control.MouseMove += delegate(object sender, MouseEventArgs e)
            {
                if (Dragging)
                {
                    if (direction != Direction.Vertical)
                        container.Left = Math.Max(0, e.X + container.Left - DragStart.X);
                    if (direction != Direction.Horizontal)
                        container.Top = Math.Max(0, e.Y + container.Top - DragStart.Y);
                }
            };
        }
开发者ID:aAmitSengar,项目名称:WindowsEditor,代码行数:29,代码来源:ControlMover.cs

示例2: SafeMoveTo

 public void SafeMoveTo(Direction direction)
 {
     if (direction == Direction.NORTH)
     {
         SwapTo(X, Y - 1, Z, true);
     }
     else if (direction == Direction.EAST)
     {
         SwapTo(X + 1, Y, Z, true);
     }
     else if (direction == Direction.SOUTH)
     {
         SwapTo(X, Y + 1, Z, true);
     }
     else if (direction == Direction.WEST)
     {
         SwapTo(X - 1, Y, Z, true);
     }
     else if (direction == Direction.NORTHEAST)
     {
         SwapTo(X + 1, Y - 1, Z, true);
     }
     else if (direction == Direction.SOUTHEAST)
     {
         SwapTo(X + 1, Y + 1, Z, true);
     }
     else if (direction == Direction.NORTHWEST)
     {
         SwapTo(X - 1, Y - 1, Z, true);
     }
     else if (direction == Direction.SOUTHWEST)
     {
         SwapTo(X - 1, Y + 1, Z, true);
     }
 }
开发者ID:SuperV1234,项目名称:DRODRoguelike,代码行数:35,代码来源:MovingEntity.cs

示例3: Move

        private bool Move(Direction direction)
        {
            if (Editor.WebEditor.Host == null)
                return false;

            var point = _textView.BufferGraph.MapDownToInsertionPoint(_textView.Caret.Position.BufferPosition, PointTrackingMode.Positive, ts => ts.ContentType.IsOfType(Editor.CssContentTypeDefinition.CssContentType));
            if (point == null)
                return false;

            var tree = CssEditorDocument.FromTextBuffer(point.Value.Snapshot.TextBuffer);
            ParseItem item = tree.StyleSheet.ItemBeforePosition(point.Value.Position);
            if (item == null)
                return false;

            NumericalValue unit = item.FindType<NumericalValue>();
            if (unit != null)
            {
                return HandleUnits(direction, unit, point.Value.Snapshot);
            }

            HexColorValue hex = item.FindType<HexColorValue>();
            if (hex != null)
            {
                return HandleHex(direction, hex, point.Value.Snapshot);
            }

            return false;
        }
开发者ID:NickCraver,项目名称:WebEssentials2013,代码行数:28,代码来源:ArrowsCommandTarget.cs

示例4: BuildRenderer

 public static void BuildRenderer(Chunk chunk, BlockPos pos, MeshData meshData, Direction direction, Vector3 ModelSize, Vector3 ConnMeshSizeX, Vector3 ConnMeshSizeY, Vector3 ConnMeshSizeZ, Direction[] Dir)
 {
     MakeStickFace(chunk, pos, meshData, direction, false, ModelSize);
     Debug.Log(Dir.Length);
     if (Dir.Length > 0)
         MakeFenceFace(chunk, pos, meshData, direction, false, ModelSize, ConnMeshSizeX, ConnMeshSizeY, ConnMeshSizeZ, Dir);
 }
开发者ID:FaizanDurrani,项目名称:Voxelmetric-ConnectedMeshes,代码行数:7,代码来源:ConnectedBuilder.cs

示例5: ConvertDirectionToDestinationPoint

 public static Point ConvertDirectionToDestinationPoint(Point initial, Direction direction)
 {
     Point destPoint;
     switch (direction)
     {
         case Direction.North:
             destPoint = new Point(initial.X, initial.Y - 1);
             break;
         case Direction.South:
             destPoint = new Point(initial.X, initial.Y + 1);
             break;
         case Direction.West:
             destPoint = new Point(initial.X - 1, initial.Y);
             break;
         case Direction.East:
             destPoint = new Point(initial.X + 1, initial.Y);
             break;
         case Direction.Northeast:
             destPoint = new Point(initial.X + 1, initial.Y - 1);
             break;
         case Direction.Northwest:
             destPoint = new Point(initial.X - 1, initial.Y - 1);
             break;
         case Direction.Southeast:
             destPoint = new Point(initial.X + 1, initial.Y + 1);
             break;
         case Direction.Southwest:
             destPoint = new Point(initial.X - 1, initial.Y + 1);
             break;
         default:
             throw new ArgumentException("ConvertDirectionToDestinationPoint - Invalid Direction");
     }
     return destPoint;
 }
开发者ID:donblas,项目名称:magecrawl,代码行数:34,代码来源:PointDirectionUtils.cs

示例6: CommandRemoveByPosition

        /// <summary>
        /// Removes the specified number of characters in the position defined by startIndex and endIndex.
        /// </summary>
        /// <param name="startIndex">Where to start removing characters. Base 0.</param>
        /// <param name="direction">Which direction the removal of characters goes.</param>
        /// <param name="nrOfCharacters">The number of characters to remove. 0 to make it until the end/beginning.</param>
        /// <param name="textFound">The text at which to stop removing characters. Null or empty to not search for text to stop.</param>
        /// <param name="applyTo">Whether the removal of characters applies only to the filename or only to the extension or both.
        ///                       In order to apply to both, two separate commands need to be issued.</param>
        public CommandRemoveByPosition(int startIndex, Direction direction, int nrOfCharacters, string textFound = "", CommandApplyTo applyTo = CommandApplyTo.Filename)
        {
            if (IsUntilBeginningOrEnd())
                description = string.Format("Remove characters starting at {0} until {1}",
                    startIndex,
                    direction == Direction.Forward ? "the end" : "the beginning");
            else
                description = string.Format("Remove {0} character{1} {2} starting at {3}",
                    nrOfCharacters,
                    nrOfCharacters == 1 ? "" : "s",
                    direction == Direction.Forward ? "forwards" : "backwards",
                    startIndex);

            if (!string.IsNullOrEmpty(textFound))
            {
                description += string.Format(" or the text \"{0}\" is found, whichever comes first", textFound);
            }

            description += string.Format(" applying to {0}",
                applyTo == CommandApplyTo.Filename ? "the filename" : "the extension");

            this.startIndex = startIndex;
            this.nrOfCharacters = nrOfCharacters;
            this.direction = direction;
            this.textFound = textFound;
            this.applyTo = applyTo;
        }
开发者ID:joaonc,项目名称:j-rename,代码行数:36,代码来源:CommandRemoveByPosition.cs

示例7: EntryAlertCreate

		public Alert EntryAlertCreate(Bar entryBar, double stopOrLimitPrice, string entrySignalName,
			Direction direction, MarketLimitStop entryMarketLimitStop) {

			this.checkThrowEntryBarIsValid(entryBar);

			double priceScriptOrStreaming = stopOrLimitPrice;
			OrderSpreadSide orderSpreadSide = OrderSpreadSide.Unknown;
			if (entryMarketLimitStop == MarketLimitStop.Market) {
				priceScriptOrStreaming = this.getStreamingPriceForMarketOrder(entryMarketLimitStop, direction, out orderSpreadSide);
			}

			PositionLongShort longShortFromDirection = MarketConverter.LongShortFromDirection(direction);
			// ALREADY_ALIGNED_AFTER GetAlignedBidOrAskForTidalOrCrossMarketFromStreaming
			double entryPriceScript = entryBar.ParentBars.SymbolInfo.RoundAlertPriceToPriceLevel(
				priceScriptOrStreaming, true, longShortFromDirection, entryMarketLimitStop);

			double shares = this.executor.PositionSizeCalculate(entryBar, entryPriceScript);

			Alert alert = new Alert(entryBar, shares, entryPriceScript, entrySignalName,
				direction, entryMarketLimitStop, orderSpreadSide,
				//this.executor.Script,
				this.executor.Strategy);
			alert.AbsorbFromExecutor(executor);

			return alert;
		}
开发者ID:sanyaade-fintechnology,项目名称:SquareOne,代码行数:26,代码来源:MarketRealStreaming.cs

示例8: ControlPage

        public ControlPage()
        {
            this.InitializeComponent();

            turn = Turn.none;
            direction = Direction.none;

            accelerometer = App.accelerometer;
            bluetooth = App.bluetooth;
            arduino = App.arduino;

            if( accelerometer == null || bluetooth == null || arduino == null )
            {
                Frame.Navigate( typeof( MainPage ) );
                return;
            }

            startButton.IsEnabled = true;
            stopButton.IsEnabled = true;
            disconnectButton.IsEnabled = true;

            bluetooth.ConnectionLost += Bluetooth_ConnectionLost;

            keepScreenOnRequest = new DisplayRequest();
            keepScreenOnRequest.RequestActive();

            App.arduino.pinMode( LR_DIRECTION_CONTROL_PIN, PinMode.OUTPUT );
            App.arduino.pinMode( FB_DIRECTION_CONTROL_PIN, PinMode.OUTPUT );
            App.arduino.pinMode( LR_MOTOR_CONTROL_PIN, PinMode.PWM );
            App.arduino.pinMode( FB_MOTOR_CONTROL_PIN, PinMode.PWM );

            App.arduino.pinMode(HEARTBEAT_LED_PIN, PinMode.OUTPUT);
        }
开发者ID:DavidShoe,项目名称:windows-remote-arduino-samples,代码行数:33,代码来源:ControlPage.xaml.cs

示例9: NeighborInDirection

        public Coords NeighborInDirection(Direction dir)
        {
            switch (dir)
            {
                case (Direction.Northeast):
                    return new Coords(this.Type, this.X + 1, this.Y - 1);
                case (Direction.East):
                    return new Coords(this.Type, this.X + 1, this.Y);
                case (Direction.Southeast):
                    return new Coords(this.Type, this.X + 1, this.Y + 1);
                case (Direction.South):
                    return new Coords(this.Type, this.X, this.Y + 1);
                case (Direction.Southwest):
                    return new Coords(this.Type, this.X - 1, this.Y + 1);
                case (Direction.West):
                    return new Coords(this.Type, this.X - 1, this.Y);
                case (Direction.Northwest):
                    return new Coords(this.Type, this.X - 1, this.Y - 1);
                case (Direction.North):
                    return new Coords(this.Type, this.X, this.Y - 1);
            }

            // This code should be unreachable. Added because compiler wants it.
            return this;
        }
开发者ID:rtm907,项目名称:C-Sharp-XNA-RTS_Game-Project,代码行数:25,代码来源:Structs.cs

示例10: Convert

        //! Convert Map.Direction to LookDirection.
        public static LookDirection Convert(Direction Dir)
        {
            LookDirection direction = LookDirection.EAST;

            switch(Dir)
            {
                case he.Direction.EAST:
                    direction = LookDirection.EAST;
                    break;
                case he.Direction.NORTH:
                    direction = LookDirection.NORTH;
                    break;
                case he.Direction.NORTH_EAST:
                    direction = LookDirection.NORTHEAST;
                    break;
                case he.Direction.NORTH_WEST:
                    direction = LookDirection.NORTHWEST;
                    break;
                case he.Direction.SOUTH:
                    direction = LookDirection.SOUTH;
                    break;
                case he.Direction.SOUTH_EAST:
                    direction = LookDirection.SOUTHEAST;
                    break;
                case he.Direction.SOUTH_WEST:
                    direction = LookDirection.SOUTHWEST;
                    break;
                case he.Direction.WEST:
                    direction = LookDirection.WEST;
                    break;
            }

            return direction;
        }
开发者ID:Trigve,项目名称:he_unity,代码行数:35,代码来源:LookDirection.cs

示例11: DrawMouse

 public void DrawMouse(Position position, Direction direction)
 {
     MousePosition = position;
     MouseDirection = direction;
     PrepareMouse();
     Invalidate();
 }
开发者ID:julienadam,项目名称:alt-net-fr-katas,代码行数:7,代码来源:MazeDrawer.cs

示例12: OnMoveInto

		public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation )
		{
			if ( m.AccessLevel > AccessLevel.Player || Contains( oldLocation ) )
				return true;

            // do they have enough faction to enter?
            XmlMobFactions a = (XmlMobFactions)XmlAttach.FindAttachment(m, typeof(XmlMobFactions));
            
            if(a == null) return false;
            
            int fac = a.GetFactionLevel(m_FactionType);
            
            if(fac < FactionLevel)
            {
                // throttle message display
                if(DateTime.Now - m_lastmsg > TimeSpan.FromSeconds(1))
                {
                    m.SendMessage("Your {0} faction is too low to enter here", FactionType);
                    m_lastmsg = DateTime.Now;
                }
                return false;
            }

			return true;
		}
开发者ID:jamison654321,项目名称:xmlspawner,代码行数:25,代码来源:MobFactionRegion.cs

示例13: MoveScreen

        public void MoveScreen(Direction dd)
        {
            using (var w = Window.ForegroundWindow())
            {
                var currentScreenRect = w.ScreenRect();
                var hw = currentScreenRect.Width / 2;
                var hh = currentScreenRect.Height / 2;
                var nextPoint = currentScreenRect.Location;
                switch (dd)
                {
                    case Direction.Left:
                        nextPoint.Offset(-1, hh);
                        break;
                    case Direction.Up:
                        nextPoint.Offset(hw, -1);
                        break;
                    case Direction.Right:
                        nextPoint.Offset(currentScreenRect.Width + 1, hh);
                        break;
                    case Direction.Down:
                        nextPoint.Offset(hw, currentScreenRect.Height + 1);
                        break;
                }

                var newScreen = Screen.FromPoint(nextPoint);

                var newOffset = RepositionPoint(w.NormalRectangle.Location, currentScreenRect.Location, newScreen.WorkingArea.Location);

                w.MoveTo(newOffset);
            }
        }
开发者ID:i-e-b,项目名称:WindowsJedi,代码行数:31,代码来源:WindowArranger.cs

示例14: OnMoveInto

        public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
        {
            if (m.Player && Factions.Sigil.ExistsOn(m))
            {
                m.SendMessage(0x22, "You are holding a sigil and cannot enter this zone.");
                return false;
            }

            PlayerMobile pm = m as PlayerMobile;

            if (pm == null && m is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)m;

                if (bc.Summoned)
                    pm = bc.SummonMaster as PlayerMobile;
            }

            if (pm != null && pm.DuelContext != null && pm.DuelContext.StartedBeginCountdown)
                return true;

            if (DuelContext.CheckCombat(m))
            {
                m.SendMessage(0x22, "You have recently been in combat and cannot enter this zone.");
                return false;
            }

            return base.OnMoveInto(m, d, newLocation, oldLocation);
        }
开发者ID:FreeReign,项目名称:forkuo,代码行数:29,代码来源:SafeZone.cs

示例15: CheckCollisionDirection

    public bool CheckCollisionDirection(Direction direction)
    {
        bool directionResult = false;

        float extraSize = 0.025f;

        float ownerHalfWidth = gameObject.rigidbody2D.renderer.bounds.size.x / 2 + extraSize;
        float ownerHalfHeight = gameObject.rigidbody2D.renderer.bounds.size.y / 2 + extraSize;

        switch(direction)
        {
            case Direction.UP:
                directionResult = CheckRayTrace(Vector2.up, ownerHalfHeight);
                break;
            case Direction.DOWN:
                directionResult = CheckRayTrace(-Vector2.up, ownerHalfHeight);
                break;
            case Direction.LEFT:
                directionResult = CheckRayTrace(-Vector2.right, ownerHalfWidth);
                break;
            case Direction.RIGHT:
                directionResult = CheckRayTrace(Vector2.right, ownerHalfWidth);
                break;
        }
        return directionResult;
    }
开发者ID:ToaLetan,项目名称:Unity_Platformer,代码行数:26,代码来源:PlatformerCollision.cs


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