public async Task UpdateDirection()
        {
            DirectionViewModel previouslySelected = SelectedDirection;

            SelectedDirection = null;

            AvailableDirections =
                (await DatabaseManager.Instance.GetDictionaries())
                .SelectMany(dict => new[] { new DirectionViewModel(dict, false), new DirectionViewModel(dict, true) })
                .OrderBy(dvm => dvm.OriginLanguage)
                .ToArray();

            SelectedDirection = null;

            if (previouslySelected != null)
            {
                SelectedDirection = AvailableDirections.FirstOrDefault(dvm => dvm.Equals(previouslySelected));
            }

            if (SelectedDirection == null)
            {
                SelectedDirection = AvailableDirections.FirstOrDefault();
            }

            await UpdateJumpList();
        }
        private void SwitchDirectionOfTranslation()
        {
            if (SelectedDirection == null)
            {
                return;
            }

            SelectedDirection = AvailableDirections.First(dvm => dvm.EqualsReversed(selectedDirection));
        }
        public void LoadSettings()
        {
            Settings.Instance.GetSelectedDirection(out string originLanguageCode, out string destinationLanguageCode);

            SelectedDirection = AvailableDirections.FirstOrDefault(dvm =>
                                                                   dvm.OriginLanguageCode == originLanguageCode &&
                                                                   dvm.DestinationLanguageCode == destinationLanguageCode);

            if (SelectedDirection == null)
            {
                SelectedDirection = AvailableDirections.FirstOrDefault();
            }
        }
Exemplo n.º 4
0
        public Rover(Plataeu plataeu, string roverStartCommand)
        {
            this.plataeu                = plataeu;
            this.commandSplitter        = new RoverPositionCommandSplitter();
            this.controlCommandSplitter = new RoverControlCommandSplitter();
            this.StartPosition          = commandSplitter.Split(roverStartCommand);

            if (this.IsRoverInPlateau(this.StartPosition.X, this.StartPosition.Y) == false)
            {
                throw new RoverOutsidePlateauException("Rover outside of bounds");
            }

            this.direction       = AvailableDirections.List().Single(x => x.Direction == StartPosition.Direction);
            this.CurrentPosition = StartPosition;
        }
Exemplo n.º 5
0
 public void SetValue(AvailableDirections availableDirections)
 {
     Value = availableDirections.Value;
 }
Exemplo n.º 6
0
 private Tuple <Pos, char>[] GetAvailablePositions()
 {
     return(AvailableDirections.Select(c => new Tuple <Pos, char>(Pos.Move(c), c))
            .Where(a => a.Item1.X >= 0 && a.Item1.X <= 3 && a.Item1.Y >= 0 && a.Item1.Y <= 3)
            .ToArray());
 }