Ejemplo n.º 1
0
        public ASTNode ParseBody()
        {
            do
            {
                if (Tokens.CurrentItem.StartPosition.Equals(Body.StartPos))
                {
                    break;
                }
                Tokens.Advance();
            } while (!Tokens.AtEnd());

            if (Tokens.AtEnd())
            {
                return(Error("Could not find the code body for the current node, please contact the maintainers of this compiler!"));
            }

            var body = TryParseBody(false);

            if (body == null)
            {
                return(null);
            }
            Body.Statements = body.Statements;

            if (!Tokens.CurrentItem.StartPosition.Equals(Body.EndPos))
            {
                return(Error("Could not parse a valid statement, even though the current code body has supposedly not ended yet.",
                             CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
            }

            return(Body);
        }
Ejemplo n.º 2
0
        public Statement TryParseInnerStatement(bool throwError = false)
        {
            Func <ASTNode> statementParser = () =>
            {
                var statement = TryParseLocalVarDecl() ??
                                TryParseAssignStatement() ??
                                TryParseIf() ??
                                TryParseSwitch() ??
                                TryParseWhile() ??
                                TryParseFor() ??
                                TryParseDoUntil() ??
                                TryParseContinue() ??
                                TryParseBreak() ??
                                TryParseStop() ??
                                TryParseReturn() ??
                                TryParseCase() ??
                                TryParseDefault() ??
                                TryParseExpressionOnlyStatement() ??
                                (Statement)null;

                if (statement == null && throwError)
                {
                    return(Error("Expected a valid statement!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                }

                return(statement);
            };

            return((Statement)Tokens.TryGetTree(statementParser));
        }
Ejemplo n.º 3
0
        public static Tuple <RobotConstructionStatus, IRobotCleaner> GetRobot(RobotParametersDto parameters)
        {
            Orientations.InitializeOrientations();
            //Create a validator in order to do basic verifications
            IRobotCleanerValidator validator = new RobotCleanerValidator();
            var result = Tuple.Create <RobotConstructionStatus, IRobotCleaner>(RobotConstructionStatus.Error, null);

            //if the parameters given are not valid, it will return null with the enum value in Error.
            if (!validator.IsRobotValid(parameters) || !validator.IsMapValid(parameters))
            {
                return(result);
            }

            //Here the dependencies are created and injected in the robot object.
            var                currentPosition   = new CurrentPosition(GetAxis(parameters.Start["X"]), GetAxis(parameters.Start["Y"]));
            IMap               map               = new Map(parameters.Map, currentPosition);
            IReturnAlgorithm   returnAlgorithm   = new ReturnAlgorithm(new FirstStep());
            ICleaningAlgorithm cleaningAlgorithm = new CleaningAlgorithm(parameters.Commands);
            var                movingStrategies  = Orientations.GetMovingStrategies();

            result = Tuple.Create <RobotConstructionStatus, IRobotCleaner>(RobotConstructionStatus.Success,
                                                                           new Implementations.RobotCleaner(currentPosition.X,
                                                                                                            currentPosition.Y,
                                                                                                            Orientations.GetFacingPosition(parameters.Start["facing"]),
                                                                                                            parameters.Battery, map, returnAlgorithm, movingStrategies, cleaningAlgorithm));


            return(result);
        }
Ejemplo n.º 4
0
 public void MergeFrom(AnnounceRollPayload other)
 {
     if (other == null)
     {
         return;
     }
     if (other.Player.Length != 0)
     {
         Player = other.Player;
     }
     if (other.Steps != 0)
     {
         Steps = other.Steps;
     }
     if (other.currentPosition_ != null)
     {
         if (currentPosition_ == null)
         {
             CurrentPosition = new global::Monopoly.Protobuf.Coordinate();
         }
         CurrentPosition.MergeFrom(other.CurrentPosition);
     }
     if (other.MyMoney != 0)
     {
         MyMoney = other.MyMoney;
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
Ejemplo n.º 5
0
        private void OnButtonPressed(object sender, MouseButtonEventArgs msg)
        {
            if (msg.Button == MouseButton.Left)
            {
                IsLeftMouseButtonPress = true;
                if (DispatchPressed(msg.Current.Position.X, msg.Current.Position.Y))
                {
                    return;
                }

                Point p = CozyTiledPositionHelper.ConvertPositionToTiledPosition(CurrentPosition.ToVector2(), NodeContentSize);
                if (Status == S_Add)
                {
                    if (Judge(p))
                    {
                        TempTiles[p] = CurrentTiledId;
                    }
                }
                else if (Status == S_Remove)
                {
                    RemoveTiled(p);
                }
            }
            else if (msg.Button == MouseButton.Right)
            {
                if (CommandHistory.Instance.CanUndo())
                {
                    TiledCommandUndo(this, null);
                }
            }
        }
Ejemplo n.º 6
0
        public CodeBody TryParseBodyOrStatement(bool allowEmpty = false)
        {
            Func <ASTNode> bodyParser = () =>
            {
                CodeBody body   = null;
                var      single = TryParseInnerStatement();
                if (single != null)
                {
                    var content = new List <Statement>();
                    content.Add(single);
                    body = new CodeBody(content, single.StartPos, single.EndPos);
                }
                else
                {
                    body = TryParseBody();
                }
                if (body == null)
                {
                    if (allowEmpty && Tokens.ConsumeToken(TokenType.SemiColon) != null)
                    {
                        body = new CodeBody(null, CurrentPosition.GetModifiedPosition(0, -1, -1), CurrentPosition);
                    }
                    else
                    {
                        return(Error("Expected a code body or single statement!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                    }
                }

                return(body);
            };

            return((CodeBody)Tokens.TryGetTree(bodyParser));
        }
Ejemplo n.º 7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Player.Length != 0)
            {
                hash ^= Player.GetHashCode();
            }
            if (Steps != 0)
            {
                hash ^= Steps.GetHashCode();
            }
            if (currentPosition_ != null)
            {
                hash ^= CurrentPosition.GetHashCode();
            }
            if (MyMoney != 0)
            {
                hash ^= MyMoney.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 8
0
        public override int GetAvailableTime(Vector2 pos)
        {
            if (Missile == null)
            {
                return(Math.Max(0, OwnSpellData.Delay - (Environment.TickCount - TimeDetected) - Game.Ping));
            }

            var proj = pos.ProjectOn(CurrentPosition.To2D(), FixedEndPosition.To2D());

            if (!proj.IsOnSegment)
            {
                return(short.MaxValue);
            }

            var dest       = proj.SegmentPoint;
            var InsidePath = Player.Instance.GetPath(dest.To3D(), true).Where(segment => ToPolygon().IsInside(segment));
            var point      = InsidePath.OrderBy(x => x.Distance(CurrentPosition)).FirstOrDefault();

            if (point == default(Vector3))
            {
                return(short.MaxValue);
            }

            float skillDist = point.Distance(CurrentPosition);

            return(Math.Max(0, (int)(skillDist / OwnSpellData.MissileSpeed * 1000)));
        }
Ejemplo n.º 9
0
        public void HumanPlayerMove(Point to)
        {
            if (IsGameOver ||
                CurrentPosition.Equals(to) ||
                Field.IsStalemate(to, CurrentPosition))
            {
                return;
            }

            var from = CurrentPosition;

            Field.RemoveEdge(Field.Vertex(from), Field.Vertex(to));
            CurrentPosition = to;
            LastMoves.Clear();
            LastMoves.Add(new Move(PlayerTurn, to, from));
            MovesHistory.AddRange(LastMoves);
            VictoryConditions(to);

            if (IsGameOver)
            {
                NumberOfMoves++;
                return;
            }

            if (Field.IsMoveIntoTheVoid(to))
            {
                Flip();
                NumberOfMoves++;
            }
        }
Ejemplo n.º 10
0
        public override void Execute(CurrentPosition currentPosition, WayPoint wayPoint)
        {
            var currentWayPoint = wayPoint.Clone();

            switch (Units)
            {
            case 90:
            {
                wayPoint.NorthSouth = -currentWayPoint.EastWest;
                wayPoint.EastWest   = currentWayPoint.NorthSouth;
                break;
            }

            case 180:
            {
                wayPoint.NorthSouth = -currentWayPoint.NorthSouth;
                wayPoint.EastWest   = -currentWayPoint.EastWest;
                break;
            }

            case 270:
            {
                wayPoint.NorthSouth = currentWayPoint.EastWest;
                wayPoint.EastWest   = -currentWayPoint.NorthSouth;
                break;
            }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Calcul des sommes md5 et update de la fenetre de progression
        /// </summary>
        /// <param name="images"></param>
        /// <returns></returns>
        public async Task Calculate_MD5(ExtImageDetails[] images, int retardateur)
        {
            ITrace.Indent++;
            ExtImageDetails[] extImages = new ExtImageDetails[images.Length];

            int i = 1;

            foreach (ExtImageDetails image in images)
            {
                ITrace.WriteLine($"[Md5] {image.ImageType} | {image.Region}");
                ITrace.WriteLine($"[Md5] {image.FilePath}");
                //extImages[i].Md5Sum =
                image.Md5Sum = await GetMD5HashFromFile(image.FilePath);

                // Pour permettre un affichage lisible retarde le calcul
                await Task.Delay(retardateur);

                ITrace.WriteLine($"[Md5] Somme: {image.Md5Sum} \n");

                CurrentFile?.Invoke(image.FilePath);
                CurrentPosition?.Invoke(i);

                i++;
            }

            ITrace.Indent--;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets the creature's next move to its intended destination.
        /// </summary>
        /// <returns></returns>
        public Direction GetNextMove()
        {
            Position dest = CurrentWalkSettings.Destination;

            if (dest == null)
            {
                return(Direction.NONE);
            }

            if (!CurrentWalkSettings.IntendingToReachDes &&
                IsNextTo(dest))
            {
                CurrentWalkSettings.Destination = null;
            }
            else if (CurrentWalkSettings.IntendingToReachDes &&
                     CurrentPosition.Equals(dest))
            {
                CurrentWalkSettings.Destination = null;
            }
            else if (ExistsPathToDest())
            {
                return((Direction)dirList[0]);
            }

            return(Direction.NONE);
        }
Ejemplo n.º 13
0
            public void Move()
            {
                IfMustBeMoved(() =>
                {
                    if (!_currentTrainNetwork.Contains(CurrentPosition))
                    {
                        Trail.Enqueue(_currentTrainNetwork.First());
                    }
                    else
                    {
                        var queryNext = CurrentPosition
                                        .GetNorthEastSouthWest()
                                        .OrderBy(x => Random.Next())
                                        .Where(x => x.HasMatch)
                                        .Select(x => x.MatchingObject)
                                        .Where(_currentTrainNetwork.Contains)
                                        .AsQueryable();

                        var next = queryNext
                                   .FirstOrDefault(x => x != PreviousPosition && x != CurrentPosition)
                                   ?? queryNext.FirstOrDefault();

                        Move(next);
                    }
                });
            }
Ejemplo n.º 14
0
        public VariableDeclaration TryParseVarDecl()
        {
            Func <ASTNode> declarationParser = () =>
            {
                if (Tokens.ConsumeToken(TokenType.InstanceVariable) == null)
                {
                    return(null);
                }

                var specs = ParseSpecifiers(GlobalLists.VariableSpecifiers);

                var type = TryParseEnum() ?? TryParseStruct() ?? TryParseType();
                if (type == null)
                {
                    return(Error("Expected variable type or struct/enum type declaration!",
                                 CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                }

                var vars = ParseVariableNames();
                if (vars == null)
                {
                    return(Error("Malformed variable names!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                }

                if (Tokens.ConsumeToken(TokenType.SemiColon) == null)
                {
                    return(Error("Expected semi-colon!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                }

                return(new VariableDeclaration(type, specs, vars, vars.First().StartPos, vars.Last().EndPos));
            };

            return((VariableDeclaration)Tokens.TryGetTree(declarationParser));
        }
Ejemplo n.º 15
0
        public FunctionParameter TryParseParameter()
        {
            Func <ASTNode> paramParser = () =>
            {
                var paramSpecs = ParseSpecifiers(GlobalLists.ParameterSpecifiers);

                var type = Tokens.ConsumeToken(TokenType.Word);
                if (type == null)
                {
                    return(Error("Expected parameter type!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                }

                var variable = TryParseVariable();
                if (variable == null)
                {
                    return(Error("Expected parameter name!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                }

                return(new FunctionParameter(
                           new VariableType(type.Value, type.StartPosition, type.EndPosition),
                           paramSpecs, variable, variable.StartPos, variable.EndPos));
            };

            return((FunctionParameter)Tokens.TryGetTree(paramParser));
        }
Ejemplo n.º 16
0
        protected override void ManageLongPosition()
        {
            double value;
            string maType;

            switch (MaCrossRule)
            {
            case MaCrossRuleValues.CloseOnSlowMaCross:
                value  = _slowMA.Result.LastValue;
                maType = "slow";
                break;

            case MaCrossRuleValues.CloseOnMediumMaCross:
                value  = _mediumMA.Result.LastValue;
                maType = "medium";
                break;

            case MaCrossRuleValues.CloseOnFastMaCross:
                value  = _fastMA.Result.LastValue;
                maType = "fast";
                break;

            default:
                return;
            }

            var exit = value - 2 * Symbol.PipSize;

            if (Bars.ClosePrices.Last(1) < exit)
            {
                Print("Closing position now that the price closed below {0} (i.e. the {1} MA)", exit, maType);
                CurrentPosition.Close();
            }
        }
Ejemplo n.º 17
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((CurrentPosition != null ? CurrentPosition.GetHashCode() : 0) * 397) ^ (DataPosition != null ? DataPosition.GetHashCode() : 0));
     }
 }
Ejemplo n.º 18
0
        /// ------------------------------------------------------------------------------------
        private void ProcessPlaybackPositionMessage(float newCurrentTime)
        {
            if (IsPaused)
            {
                IsPaused = false;
                if (PlaybackResumed != null)
                {
                    PlaybackResumed();
                }
            }

            CurrentPosition = Math.Max(0, newCurrentTime);

            if (CurrentPosition.Equals(0) || CurrentPosition.Equals(_prevPostion))
            {
                return;
            }

            _prevPostion = CurrentPosition;

            var endPosition = GetPlayBackEndPosition();

            if (CurrentPosition > endPosition)
            {
                CurrentPosition = endPosition;
            }

            if (PlaybackPositionChanged != null)
            {
                PlaybackPositionChanged(CurrentPosition);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Advances the algorithm and updates the current step property.
        /// </summary>
        public void AdvanceAlgorithm()
        {
            if (!timerStarted)
            {
                timerStarted = true;
                Timer.initTimer(1000, OnTimerElapsed, true);
                Timer.startTimer();
            }

            if (CurrentPosition.Equals(Algorithm.FirstStep))
            {
                if (CurrentPosition.NextStep.RythmStyle == RythmStyle.Shockable)
                {
                    History.AddItem("Rytme vurderet - Stødbar");
                }
                else
                {
                    History.AddItem("Rytme vurderet - Ikke-Stødbar");
                }
            }
            else
            {
                History.AddItem(CurrentPosition.Name);
            }

            Algorithm.AdvanceOneStep();
            CurrentPosition = Algorithm.CurrentStep;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Bind the current position for the primary CP result (there should only be one allowed by the program)
        /// </summary>
        private void DataBindCurrentPositionInformation()
        {
            if (!currentApplication.AppliedPosition.Steps.Contains(ApplicationStepType.CurrentPosition))
            {
                pnlCurrentPosition.Visible = false;
                return;
            }

            //Only databindd if there is a current position available
            if (currentApplication.CurrentPositions.Count == 0)
            {
                return;
            }

            CurrentPosition currentPosition = currentApplication.CurrentPositions[0];

            txtCurrentPositionTitle.Text       = currentPosition.Title;
            txtCurrentPositionDepartment.Text  = currentPosition.Department;
            txtCurrentPositionInstitution.Text = currentPosition.Institution;

            txtCurrentPositionAddress1.Text = currentPosition.Address1;
            txtCurrentPositionAddress2.Text = currentPosition.Address2;
            txtCurrentPositionCity.Text     = currentPosition.City;
            txtCurrentPositionState.Text    = currentPosition.State;
            txtCurrentPositionZip.Text      = currentPosition.Zip;
            txtCurrentPositionCountry.Text  = currentPosition.Country;
        }
Ejemplo n.º 21
0
        private void CheckForDeath()
        {
            var firstSegmentX = this.CurrentPosition.Peek()[0];
            var firstSegmentY = this.CurrentPosition.Peek()[1];

            var currentCount = CurrentPosition.Count;

            for (int i = 0; i < currentCount; i++)
            {
                var checkSegment = CurrentPosition.Dequeue();
                if (i != 0 && checkSegment[0] == firstSegmentX && checkSegment[1] == firstSegmentY)
                {
                    this.IsDead = true;
                }

                CurrentPosition.Enqueue(checkSegment);
            }

            if (firstSegmentX >= this.SnakeBoardWidth || firstSegmentX < 0)
            {
                this.IsDead = true;
            }

            if (firstSegmentY >= this.SnakeBoardHeight || firstSegmentY < 0)
            {
                this.IsDead = true;
            }
        }
Ejemplo n.º 22
0
        public IEnumerable <ITradingResult> TradingResults()
        {
            //assume buy and sell pairs are store next to each other in the list.
            var list = new List <ITradingResult>();

            foreach (var position in CurrentPosition.Where(x => x.Ticker != "btc"))
            {
                var trades = position.Trades.ToList();
                for (int i = 0; i < trades.Count(); i++)
                {
                    try
                    {
                        list.Add(new TradingResult(trades[i], trades[++i]));
                    }
                    catch {}
                }
            }

            //for(int i =1; i<CurrentPosition.Trades.Count;i+=2)
            //{
            //    var buyTrade = CurrentPosition.Trades[i - 1];
            //    var sellTrade = CurrentPosition.Trades[i];

            //    list.Add(new TradingResult(buyTrade,sellTrade));
            //}
            return(list);
        }
Ejemplo n.º 23
0
        public override void Execute(CurrentPosition currentPosition)
        {
            var currentDirection = Directions.Single(x => x.Value == currentPosition.Direction).Key;
            var newDirection     = (currentDirection + 4 - (Units / 90)) % 4;

            currentPosition.Direction = Directions[newDirection];
        }
Ejemplo n.º 24
0
        public void CreateTrade(IAlgorthmResults results)
        {
            var ticker           = results.Ticker.Replace("btc", "");
            var currentPosistion = CurrentPosition.Where(x => x.Ticker == ticker);

            if (currentPosistion.Count() == 0)
            {
                CurrentPosition.Add(new Position(ticker, 0));
            }
            if (CurrentPosition.First(x => x.Ticker == ticker).Open)
            {
                return;
            }
            //check BTC amount.
            if (BtcPosition.Open && BtcPosition.Quantity >= _request.TradingAmount)
            {
                var transactionPair = broker.MakeTransaction(results.Action, results.Ticker, _request.TradingAmount, results.LastPrice);
                var pos             = CurrentPosition.First(x => x.Ticker == ticker);
                pos.Add(transactionPair.First());
                pos.StopPrice   = results.LastPrice * 0.97m;
                pos.BoughtPrice = results.LastPrice;
                BtcPosition.Add(transactionPair.Last());
                Log?.Invoke(new TradingLog(transactionPair, results.CloseDateTime));
            }
        }
Ejemplo n.º 25
0
        Vector2[] GetBeginEdgePoints(Vector2[] edges)
        {
            if (FixedStartPosition.Distance(CurrentPosition) <= 50)
            {
                return new [] { CurrentPosition.To2D() }
            }
            ;

            var endEdges = edges;

            Vector2 direction    = (FixedEndPosition - FixedStartPosition).To2D();
            var     perpVecStart = CurrentPosition.To2D() + direction.Normalized().Perpendicular();
            var     perpVecEnd   = CurrentPosition.To2D() + direction.Normalized().Perpendicular() * 1500;

            //right side is not the same?
            var perpVecStart2 = CurrentPosition.To2D() + direction.Normalized().Perpendicular2();
            var perpVecEnd2   = CurrentPosition.To2D() + direction.Normalized().Perpendicular2() * 1500;


            Geometry.Polygon.Line leftEdgeLine  = new Geometry.Polygon.Line(FixedStartPosition.To2D(), endEdges[1]);
            Geometry.Polygon.Line rightEdgeLine = new Geometry.Polygon.Line(FixedStartPosition.To2D(), endEdges[0]);

            var     inters = leftEdgeLine.GetIntersectionPointsWithLineSegment(perpVecStart, perpVecEnd);
            var     inters2 = rightEdgeLine.GetIntersectionPointsWithLineSegment(perpVecStart2, perpVecEnd2);
            Vector2 p1 = Vector2.Zero, p2 = Vector2.Zero;



            if (inters.Any())
            {
                var closestInter = inters.OrderBy(x => x.Distance(CurrentPosition)).First();

                p2 = closestInter;
            }
            if (inters2.Any())
            {
                var closestInter = inters2.OrderBy(x => x.Distance(CurrentPosition)).First();
                p1 = closestInter;
            }

            if (!p1.IsZero && !p2.IsZero)
            {
                return new[] { p1, p2 }
            }
            ;


            return(new[] { CurrentPosition.To2D() });
        }

        Vector2 RotateAroundPoint(Vector2 start, Vector2 end, float theta)
        {
            float px = end.X, py = end.Y;
            float ox = start.X, oy = start.Y;

            float x = (float)Math.Cos(theta) * (px - ox) - (float)Math.Sin(theta) * (py - oy) + ox;
            float y = (float)Math.Sin(theta) * (px - ox) + (float)Math.Cos(theta) * (py - oy) + oy;

            return(new Vector2(x, y));
        }
Ejemplo n.º 26
0
 public void UseItem(Player player)
 {
     if (CurrentPosition.TotalDistance2D(player.CurrentPosition) <= 3)
     {
         player.Kill();
     }
 }
Ejemplo n.º 27
0
        public CodeBody TryParseBody(bool requireBrackets = true)
        {
            Func <ASTNode> codeParser = () =>
            {
                if (requireBrackets && Tokens.ConsumeToken(TokenType.LeftBracket) == null)
                {
                    return(Error("Expected '{'!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                }

                var statements = new List <Statement>();
                var startPos   = CurrentPosition;
                var current    = TryParseInnerStatement();
                while (current != null)
                {
                    if (!SemiColonExceptions.Contains(current.Type) && Tokens.ConsumeToken(TokenType.SemiColon) == null)
                    {
                        return(Error("Expected semi-colon after statement!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                    }
                    statements.Add(current);
                    current = TryParseInnerStatement();
                }

                var endPos = CurrentPosition;
                if (requireBrackets && Tokens.ConsumeToken(TokenType.RightBracket) == null)
                {
                    return(Error("Expected '}'!", CurrentPosition, CurrentPosition.GetModifiedPosition(0, 1, 1)));
                }

                return(new CodeBody(statements, startPos, endPos));
            };

            return((CodeBody)Tokens.TryGetTree(codeParser));
        }
Ejemplo n.º 28
0
 public void Move_Instant(int x, int y, int z, int facing)
 {
     m_MoveEvents.ResetMoveSequence();
     Facing = (Direction)facing;
     CurrentPosition.Set(x, y, z);
     GoalPosition = null;
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Checks status of flight and sets the IsActive property
 /// </summary>
 public void CheckFlightStatus()
 {
     if (CurrentPosition.CompareTo(FlightPlan.ArrivalAirport.Coordinates) == 0)
     {
         IsActive = false;
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Transforms the pattern item
        /// </summary>
        /// <param name="type">Transformation axis</param>
        public void Transform(CubeFlag rotationLayer)
        {
            if (CurrentPosition.HasFlag(rotationLayer))
            {
                CubeFlag oldFlags = this.CurrentPosition.Flags;
                CurrentPosition.NextFlag(rotationLayer, true);


                Orientation newOrientation = this.CurrentOrientation;
                if (CubePosition.IsCorner(CurrentPosition.Flags) && !CubeFlagService.IsYFlag(rotationLayer))
                {
                    if (new CubePosition(oldFlags).Y == new CubePosition(CurrentPosition.Flags).Y)
                    {
                        newOrientation = (Orientation)(((int)newOrientation + 2) % 3);
                    }
                    else
                    {
                        newOrientation = (Orientation)(((int)newOrientation + 1) % 3);
                    }
                }
                else if (CubePosition.IsEdge(CurrentPosition.Flags) && CubeFlagService.IsZFlag(rotationLayer))
                {
                    newOrientation = (Orientation)((int)newOrientation ^ 0x1);
                }

                this.CurrentOrientation = newOrientation;
            }
            if (TargetPosition.HasFlag(rotationLayer))
            {
                TargetPosition = CubeFlagService.NextFlags(TargetPosition, rotationLayer, true);
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Writes the specified expression.
        /// </summary>
        /// <param name="expression">The expression to write.</param>
        /// <returns>The number of written characters.</returns>
        private int WriteExpression(CurrentPosition expression)
        {
            #region Contract
            if (expression == null) return 0;
            #endregion

            Writer.Write("$");

            return 1;
        }
Ejemplo n.º 32
0
 private void _marlinCommunication_M114GetCurrentPosition(object sender, CurrentPosition e)
 {
     DelegateText(txtBxX, MarlinCommunication.CurrentPosition.Xstring);
     DelegateText(txtBxY, MarlinCommunication.CurrentPosition.Ystring);
     DelegateText(txtBxZ, MarlinCommunication.CurrentPosition.Zstring);
 }
Ejemplo n.º 33
0
        protected void btnCurrentPositionSave_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
                return; //Error message

            //Grab the existing current position if available, else create a new one
            CurrentPosition currentPosition = new CurrentPosition();

            if (currentApplication.CurrentPositions.Count != 0) //if there is an existing result
                currentPosition = currentApplication.CurrentPositions[0];

            //Now set all of the fields
            currentPosition.Title = txtCurrentPositionTitle.Text;
            currentPosition.Department = txtCurrentPositionDepartment.Text;
            currentPosition.Institution = txtCurrentPositionInstitution.Text;

            currentPosition.Address1 = txtCurrentPositionAddress1.Text;
            currentPosition.Address2 = txtCurrentPositionAddress2.Text;
            currentPosition.City = txtCurrentPositionCity.Text;
            currentPosition.State = txtCurrentPositionState.Text;
            currentPosition.Zip = txtCurrentPositionZip.Text;
            currentPosition.Country = txtCurrentPositionCountry.Text;

            //Associate with the current application and set to complete
            currentPosition.AssociatedApplication = currentApplication;
            currentPosition.Complete = true;

            using (var ts = new TransactionScope())
            {
                CurrentPositionBLL.EnsurePersistent(currentPosition);
                currentApplication.CurrentPositions.Add(currentPosition);

                ts.CommitTransaction();
            }

            ReloadStepListAndSelectHome(STR_CurrentPosition, true);
        }
Ejemplo n.º 34
0
        public override void LoadData()
        {
            base.LoadData();

            var application = ApplicationBLL.GetByID(StaticProperties.ExistingApplicationID);

            //Add some applications info
            CurrentPosition currentPosition = new CurrentPosition
                                                  {
                                                      Address1 = StaticProperties.TestString,
                                                      City = StaticProperties.TestString,
                                                      Country = StaticProperties.TestString,
                                                      Department = StaticProperties.TestString,
                                                      Institution = StaticProperties.TestString,
                                                      Title = StaticProperties.TestString,
                                                      Zip = StaticProperties.TestString,
                                                      State = StaticProperties.TestString,
                                                      ApplicationStepType = ApplicationStepType.CurrentPosition,
                                                      AssociatedApplication = application
                                                  };

            Education education = new Education
                                      {
                                          ApplicationStepType = ApplicationStepType.Education,
                                          AssociatedApplication = application,
                                          Date = DateTime.Now,
                                          Discipline = StaticProperties.TestString,
                                          Institution = StaticProperties.TestString
                                      };

            Reference reference = new Reference {AssociatedApplication = application};

            Survey survey = new Survey {AssociatedApplication = application, Other = StaticProperties.TestString};

            File file = new File
                            {
                                FileName = StaticProperties.TestString,
                            };

            FileType fileType = new FileType {ApplicationFile = true, FileTypeName = StaticProperties.TestString};
            file.FileType = fileType;

            using (var ts = new TransactionScope())
            {
                FileTypeBLL.EnsurePersistent(fileType);
                FileBLL.EnsurePersistent(file);

                application.CurrentPositions = new List<CurrentPosition> {currentPosition};
                application.Education = new List<Education> {education};
                application.References = new List<Reference> {reference};
                application.Surveys = new List<Survey> {survey};
                application.Files = new List<File>{file};

                ApplicationBLL.EnsurePersistent(application);

                ts.CommitTransaction();
            }
        }