Inheritance: IKeyboardService
        /// <summary>
        /// Write a vote callback query to the stream.
        /// </summary>
        /// <param name="stream">The stream to write to.</param>
        /// <param name="voteType">The type of the vote.</param>
        /// <param name="messageId">The id of the message that the callback was triggered by.</param>
        /// <param name="messageText">The text of the message that the callback was triggered by.</param>
        /// <param name="trackUrl">The url in de original message the bot replied to.</param>
        public Task WriteVoteCallbackQueryToStream(Stream stream, VoteType voteType, int messageId, string messageText, string trackUrl)
        {
            var update = new Telegram.Bot.Types.Update
            {
                CallbackQuery = new Telegram.Bot.Types.CallbackQuery
                {
                    Id      = "testId",
                    Data    = KeyboardService.GetVoteButtonText(voteType),
                    From    = GetTestUser(),
                    Message = new Telegram.Bot.Types.Message()
                    {
                        Text           = messageText,
                        Date           = DateTime.UtcNow,
                        From           = GetTestUser(isBot: true),
                        Chat           = GetTestChat(),
                        Entities       = new Telegram.Bot.Types.MessageEntity[0],
                        ReplyMarkup    = _keyboardService.CreatePostedTrackResponseKeyboard(),
                        ReplyToMessage = new Telegram.Bot.Types.Message
                        {
                            From = GetTestUser(),
                            Chat = GetTestChat(),
                            Date = DateTime.UtcNow,
                            Text = trackUrl
                        },
                        MessageId = messageId,
                    },
                    ChatInstance = "testChatInstance"
                }
            };

            return(WriteUpdateToStream(stream, update));
        }
        public override void Update(GameTime gameTime, Rectangle clientBound)
        {
            Vector2         direction       = Vector2.Zero;
            KeyboardService keyboardService = ServicesHelper.GetService <KeyboardService>();

            if (keyboardService.IsKeyDown(Keys.Left))
            {
                direction.X -= 1;
            }
            if (keyboardService.IsKeyDown(Keys.Right))
            {
                direction.X += 1;
            }
            if (keyboardService.IsKeyDown(Keys.Up))
            {
                direction.Y -= 1;
            }
            if (keyboardService.IsKeyDown(Keys.Down))
            {
                direction.Y += 1;
            }

            _speed = _initialSpeed * direction;
            base.Update(gameTime, clientBound);
        }
Exemplo n.º 3
0
        public static async Task <TelegramBotClient> GetBotClientAsync()
        {
            if (botClient != null)
            {
                return(botClient);
            }

            BotConfig       botConfig = Startup.StaticConfig.GetSection("BotConfig").Get <BotConfig>();
            ActivityContext context   = new ActivityContext((DbContextOptions <ActivityContext>)Startup.DbOptions);

            var repository         = new Repository(context);
            var keyboardService    = new KeyboardService();
            var translatingService = new TranslatingService(botConfig);
            var commandService     = new CommandService(keyboardService, translatingService, repository);

            commandsList = new List <Command>
            {
                new StartCommand(),
                new FilterCommand(keyboardService),
                new RandomCommand(commandService),
                new AccessibilityCommand(commandService),
                new ParticipantsCommand(commandService),
                new PriceCommand(commandService),
                new TypeCommand(commandService)
            };

            botClient = new TelegramBotClient(botConfig.TelegramConfig.Token);
            await botClient.SetWebhookAsync(botConfig.WebsiteUrl + "/bot");

            return(botClient);
        }
Exemplo n.º 4
0
 public override void HandleInput()
 {
     if (KeyboardService.IsAnyKeyPressed() && IsFocused)
     {
         ScreenManager.AddScreen <GameScreen>();
     }
 }
Exemplo n.º 5
0
 public CommandService(KeyboardService keyboardService,
                       TranslatingService translatingService, Repository repository)
 {
     _keyboardService    = keyboardService;
     _translatingService = translatingService;
     _repository         = repository;
 }
        public override void Update(GameTime gameTime, Rectangle clientBound)
        {
            Vector2 direction = Vector2.Zero;

            if (CurrentState != State.Jumping)
            {
                spriteEffect     = SpriteEffects.None;
                currentAnimation = originalAnimation;
                CurrentState     = State.Standing;
                KeyboardService keyboardService = ServicesHelper.GetService <KeyboardService>();

                if (keyboardService.IsKeyDown(Keys.Left))
                {
                    direction.X     -= 1;
                    CurrentState     = State.WalkingLeft;
                    currentAnimation = walkingAnimation;
                    spriteEffect     = SpriteEffects.None;
                }
                if (keyboardService.IsKeyDown(Keys.Right))
                {
                    direction.X     += 1;
                    CurrentState     = State.WalkingRight;
                    currentAnimation = walkingAnimation;
                    spriteEffect     = SpriteEffects.FlipHorizontally;
                }

                _speed = _initialSpeed * direction;

                if (keyboardService.IsKeyDown(Keys.Space))
                {
                    CurrentState     = State.Jumping;
                    currentAnimation = jumpingAnimation;
                    _speed.Y         = -3f;
                    _initialSpeed.Y  = _speed.Y;
                    direction.Y      = 1;
                }
            }
            else
            {
                _speed.Y = _speed.Y + _acceleration;

                if (_speed.Y > _initialSpeed.Y * -1)
                {
                    CurrentState = State.Standing;
                    _position.Y  = _initialPosition.Y;
                    jumpingAnimation.End();
                }
            }

            _position += _speed;
            currentAnimation.Update(gameTime);
            if (_position.X < 0)
            {
                _position.X = 0;
            }
            if (_position.X + currentAnimation.GetNextFrame().SourceRectangle.Width > clientBound.Width)
            {
                _position.X = clientBound.Width - currentAnimation.GetNextFrame().SourceRectangle.Width;
            }
        }
Exemplo n.º 7
0
        private static void Main(string[] args)
        {
            var cmd = args.Length > 0 ? args[0] : string.Empty;

            if (string.IsNullOrEmpty(cmd))
            {
                return;
            }

            var keyboardService = new KeyboardService();

            switch (cmd)
            {
            case "media-play": keyboardService.Send(VirtualKey.MEDIA_PLAY_PAUSE); break;

            case "media-pause": keyboardService.Send(VirtualKey.MEDIA_PLAY_PAUSE); break;

            case "media-next-track": keyboardService.Send(VirtualKey.MEDIA_NEXT_TRACK); break;

            case "media-previous-track": keyboardService.Send(VirtualKey.MEDIA_PREV_TRACK); break;

            case "volume-mute": keyboardService.Send(VirtualKey.VOLUME_MUTE); break;

            case "volume-up": keyboardService.Send(VirtualKey.VOLUME_UP); break;

            case "volume-down": keyboardService.Send(VirtualKey.VOLUME_DOWN); break;

            default: break;
            }
        }
Exemplo n.º 8
0
        public override async Task Initialize()
        {
            KeyboardService.HideKeyboard();
            Messenger.Publish(new ProgressBarActivator(this, true));
            var comingSoonGames = await _gameService.GetGames(HomeGamesCategory.ComingSoon);

            foreach (var game in comingSoonGames)
            {
                ComingSoonGames.Add(new GameWithImageRowModel(game));
            }

            var brandNewGames = await _gameService.GetGames(HomeGamesCategory.BrandNew);

            foreach (var game in brandNewGames)
            {
                BrandNewGames.Add(new GameWithImageRowModel(game));
            }

            var hottestGames = await _gameService.GetGames(HomeGamesCategory.Hottest);

            foreach (var game in hottestGames)
            {
                HottestGames.Add(new GameWithImageRowModel(game));
            }

            var onSaleGames = await _gameService.GetGames(HomeGamesCategory.OnSale);

            foreach (var game in onSaleGames)
            {
                OnSaleGames.Add(new GameWithImageRowModel(game));
            }
            Messenger.Publish(new ProgressBarActivator(this, false));
        }
Exemplo n.º 9
0
 public override void HandleInput()
 {
     if (KeyboardService.IsKeyDown(Keys.Space) && IsFocused)
     {
         ScreenManager.AddScreen <GameScreen>();
         Unload();
     }
 }
        public StudentProfileView(string studentID)
        {
            InitializeComponent();
            KeyboardService.HideKeyboard();

            BindingContext = vm = new StudentProfileViewModel(studentID);
            vm.Nav         = this;
        }
Exemplo n.º 11
0
 public DebugScreen(Game game)
     : base(game)
 {
     Name            = "Debug";
     HasGrabFocus    = false;
     State           = ScreenState.Hidden;
     keyboardService = ServicesHelper.GetService <KeyboardService>();
 }
Exemplo n.º 12
0
 public override void Press()
 {
     // This is a bit tricky because we can only get the state of a toggling key after the input has been
     // read off the MessagePump.  Ergo if we make that assumption that in the time it takes to run this method
     // we will be toggling the state of the key, set IsInEffect to the new state and then press the key.
     IsInEffect = !KeyboardService.IsTogglingKeyInEffect(KeyCode);
     base.Press();
 }
Exemplo n.º 13
0
        /// <summary>
        /// Check if an update contains a Vote.
        /// </summary>
        /// <returns>True if the update is a Vote callback.</returns>
        private bool IsVoteCallback(UpdateDto updateDto, VoteType voteType)
        {
            if (string.IsNullOrEmpty(updateDto.ParsedData))
            {
                return(false);
            }

            return(updateDto.ParsedData.Equals(KeyboardService.GetVoteButtonText(voteType)));
        }
        public StudentProfileView(StudentDetails details)
        {
            InitializeComponent();
            KeyboardService.HideKeyboard();
            BindingContext = vm = new StudentProfileViewModel(details);
            vm.Nav         = this;

            //this.SizeChanged += StudentProfileView_SizeChanged;
        }
Exemplo n.º 15
0
 public override void HandleInput()
 {
     if (KeyboardService.IsKeyPressed(Keys.L) && IsFocused)
     {
         Unload();
     }
     if (KeyboardService.IsKeyPressed(Keys.Escape) && State != ScreenState.Pause)
     {
         this.State = ScreenState.Pause;
     }
     else if (KeyboardService.IsKeyPressed(Keys.Escape) && State == ScreenState.Pause)
     {
         this.State = ScreenState.Active;
     }
 }
Exemplo n.º 16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            OverridePendingTransition(0, 0);

            SetTheme(StyleHelper.Style.CommonActivityStyle);

            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_chat_create);

            _navigationBarView = FindViewById <NavigationBarView>(Resource.Id.activity_chat_create_navigation_bar);
            _navigationBarView.SetLeftButton(StyleHelper.Style.NavigationBarBackButtonIcon, ViewModel.BackCommand);
            _navigationBarView.SetTitle(ViewModel.LocalizedStrings.CreateGroup);
            _navigationBarView.SetRightButton(ViewModel.LocalizedStrings.Create, new RelayCommand(() =>
            {
                KeyboardService.HideSoftKeyboard(_chatNameEditTextView);

                ViewModel.SaveCommand.Execute(_imagePicker.GetStreamFunc());
            }));
            _navigationBarView.RightTextButton.SetBackgroundColor(Color.Transparent);

            _chatPhotoImageView       = FindViewById <MvxCachedImageView>(Resource.Id.iv_chat_photo);
            _chatEditedPhotoImageView = FindViewById <MvxCachedImageView>(Resource.Id.iv_chat_photo_edited);
            _chatNameEditTextView     = FindViewById <EditText>(Resource.Id.et_chat_name);
            _contactsRecyclerView     = FindViewById <RecyclerView>(Resource.Id.rv_contacts_list);
            _membersCountTextView     = FindViewById <TextView>(Resource.Id.tv_members_count);
            _changeChatPhotoButton    = FindViewById <Button>(Resource.Id.b_chat_change_photo);
            _changeChatPhotoButton.SetCommand(new RelayCommand(ChangePhoto));
            _changeChatPhotoButton.Text = ViewModel.LocalizedStrings.ChangePhoto;

            InitializeContactsRecyclerView();

            _imagePicker = new ImagePicker(Dependencies.PermissionsManager, Dependencies.Container.Resolve <IImagePickerService>())
            {
                MaxImageWidth = 300
            };

            _chatPhotoImageView.SetImageResource(StyleHelper.Style.ChatGroupNoAvatarIcon);
            _chatEditedPhotoImageView.Visibility = ViewStates.Gone;

            _addMembers      = FindViewById <Button>(Resource.Id.activity_chat_create_add_member);
            _addMembers.Text = ViewModel.LocalizedStrings.AddMembers;
            _addMembers.SetCommand(ViewModel.AddMembersCommand);

            _chatNameEditTextView.Hint = ViewModel.LocalizedStrings.ChatName;

            _busyOverlayView = FindViewById <BusyOverlayView>(Resource.Id.activity_chat_create_busy_view);
        }
Exemplo n.º 17
0
        public void BindViewModel(ChatMessageInputViewModel viewModel)
        {
            _viewModelRef = new WeakReferenceEx <ChatMessageInputViewModel>(viewModel);

            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.MessageBody, () => _messageEditText.Text, BindingMode.TwoWay));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.IsInEditMessageMode).WhenSourceChanges(() =>
            {
                if (_viewModelRef.Target.IsInEditMessageMode)
                {
                    _editingMessageBodyTextView.Text = _viewModelRef.Target.EditedMessageOriginalBody;

                    KeyboardService.ShowSoftKeyboard(_messageEditText);
                }
                else
                {
                    KeyboardService.HideSoftKeyboard(_messageEditText);
                }

                _editingMessageLayout.Visibility = BoolToViewStateConverter.ConvertGone(_viewModelRef.Target.IsInEditMessageMode);
            }));
            _bindings.Add(this.SetBinding(() => _viewModelRef.Target.ImageObject).WhenSourceChanges(() =>
            {
                if (_viewModelRef.Target.ImageObject == null)
                {
                    _imagePreview.SetImageBitmap(null);
                    _editImageContainer.Visibility = ViewStates.Gone;
                }
                else
                {
                    _imagePreview.SetImageBitmap((Android.Graphics.Bitmap)_viewModelRef.Target.ImageObject);
                    _editImageContainer.Visibility = ViewStates.Visible;
                }
            }));

            if (!_inited)
            {
                _messageEditText.Hint      = _viewModelRef.Target.EnterMessagePlaceholderString;
                _editingMessageHeader.Text = _viewModelRef.Target.EditMessageHeaderString;

                _takeAttachmentButton.SetCommand(_viewModelRef.Target.OpenCameraCommand);
                _addAttachmentButton.SetCommand(_viewModelRef.Target.OpenGalleryCommand);
                _sendButton.SetCommand(_viewModelRef.Target.SendMessageCommand);
                _removeImageButton.SetCommand(_viewModelRef.Target.DeleteImageCommand);
                _editingMessageCloseButton.SetCommand(_viewModelRef.Target.CancelEditingCommand);
                _inited = true;
            }
        }
Exemplo n.º 18
0
        public override void Press()
        {
            if (IsInEffect)
            {
                KeyboardService.SimulateKeyUp(KeyCode);
            }
            else
            {
                KeyboardService.SimulateKeyDown(KeyCode);
            }

            // We need to use IsKeyDownAsync here so we will know exactly what state the key will be in
            // once the active windows read the input from the MessagePump.  IsKeyDown will only report
            // the correct value after the input has been read from the MessagePump and will not be correct
            // by the time we set IsInEffect.
            IsInEffect = KeyboardService.IsKeyDownAsync(KeyCode);
            OnKeyPressed();
        }
Exemplo n.º 19
0
        internal void Initialize(D3D11Host host)
        {
            Services = new GameServiceContainer();

            ServiceLocator.Initialize(Services);

            Artemis.System.EntitySystem.BlackBoard.SetEntry("GraphicsDevice", host.GraphicsDevice);
            Artemis.System.EntitySystem.BlackBoard.SetEntry("ServiceProvider", Services);

            Services.AddService<IGraphicsDeviceService>(host);
            Services.AddService(host.GraphicsDevice);

            _mouse = new MouseService(host);
            Services.AddService<IMouseService>(_mouse);
            _mouse.ButtonDown += OnMouseButtonDown;
            _keyboard = new KeyboardService(host);
            Services.AddService<IKeyboardService>(_keyboard);
            _timer = new TimerService();
            Services.AddService<ITimerService>(_timer);
            Services.AddService(new FastSpriteBatch(host.GraphicsDevice));

            _timer.LastFrameUpdateTime = _gameTime;
            _timer.LastFrameRenderTime = _gameTime;

            SpriteBatch = new SpriteBatch(host.GraphicsDevice);
            Services.AddService(SpriteBatch);

            Content = new ContentManager(Services);
            Content.RootDirectory = Environment.CurrentDirectory;

            SpriteManager = new SpriteManagerService(Content);
            Services.AddService<ISpriteManagerService>(SpriteManager);

            SpriteManager.LoadSpriteSheet("Textures/Hulls.json");

            Host = host;
            World = new EntityWorld(false, false, false);
            int drawDepth = 0;
            World.CreateComponentPool<Transform>(200, 200);
            World.SystemManager.SetSystem(new GridRendererSystem(), Artemis.Manager.GameLoopType.Draw, drawDepth++);
            World.InitializeAll();
            World.CreateCamera(Constants.ActiveCameraTag, Host.GraphicsDevice);
            Emitter = new ParticleEmitterComponent();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Add the VoteType if it was missing.
        /// </summary>
        /// <returns>The text for the VoteType.</returns>
        private static string AddNewVoteText(VoteType voteType, bool?shouldIncrement)
        {
            var useNegativeOperator = UseNegativeOperator(voteType);

            if (shouldIncrement.Value && useNegativeOperator)
            {
                throw new NotSupportedException("A negative voteType cannot be incremented when it isn't added yet.");
            }
            else if (!shouldIncrement.Value && !useNegativeOperator)
            {
                throw new NotSupportedException("A positive voteTypecannot be decremented when it isn't added yet.");
            }

            var       voteCountOperator = useNegativeOperator ? "-" : "+";
            const int voteCount         = 1;

            // Add a space, then the voteTypeText and operator, then the count.
            return($" {KeyboardService.GetVoteButtonText(voteType)}{voteCountOperator}{voteCount}");
        }
Exemplo n.º 21
0
        protected IServiceProvider RegisterServices(IServiceCollection services)
        {
            var utilityService = new UtilityService();

            services.AddSingleton <IUtilityService>(utilityService);
            services.AddSingleton <IStatsService, StatsService>();
            _keyboard = new KeyboardService();
            services.AddSingleton <IKeyboardService>(_keyboard);
            services.AddSingleton <IWorldController>(new WorldController(new WorldGenerator()));
            services.AddSingleton <GameUpdateService>();
            services.AddSingleton <IGameUpdateService>(provider => provider.GetRequiredService <GameUpdateService>());

            services.AddSingleton <EntityController>();

            services.AddSingleton <HUDController>();
            services.AddSingleton <ScreensController>();

            return(services.BuildServiceProvider().CreateScope().ServiceProvider);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;
                NavigationService.Configure(rootFrame);

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                NavigationService.NavigateTo(Pages.MainPage, e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();

            KeyboardService keyboard = new KeyboardService();
        }
Exemplo n.º 23
0
        public RenderingEngine()
        {
            LoadSettings();

            MouseService     = new MouseService(this);
            KeyboardService  = new KeyboardService(this);
            SelectionService = new SelectionService(this);

            SelectionService.Completed  += SelectionServiceOnCompleted;
            SelectionService.InComplete += SelectionServiceOnInComplete;

            MouseService.MouseMove += MouseServiceOnMouseMove;
            MouseService.MouseDown += MouseServiceOnMouseDown;
            MouseService.MouseUp   += MouseServiceOnMouseUp;

            _tickerProvider.Tick += TickerProviderOnTick;

            ProcessorCompiler.CompileStart += ProcessorCompilerOnCompileStart;
            ProcessorCompiler.Finished     += ProcessorCompilerOnFinished;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Create a Regex to match with at least one VoteType.
        /// </summary>
        private Regex GetRegex(List <VoteType> voteTypes)
        {
            // Match the textstring and at least one vote.
            var pattern = "(.+?)(?!$)";

            foreach (var voteType in voteTypes)
            {
                // Some voteTypes use a negative operator.
                var voteCountOperator = UseNegativeOperator(voteType)
                    ? "-"
                    : "\\+";

                var voteTypeText = KeyboardService.GetVoteButtonText(voteType);

                // Match a space, then the voteTypeText and operator, then the count.
                pattern += $"(?:(\\s{voteTypeText}{voteCountOperator})(\\d+))?";
            }

            pattern += "$";

            return(new Regex(pattern));
        }
Exemplo n.º 25
0
        protected override void DoAttachBindings()
        {
            base.DoAttachBindings();

            Bindings.Add(this.SetBinding(() => ViewModel.HeaderViewModel.ChatName, () => _chatNameEditText.Text, BindingMode.TwoWay));
            Bindings.Add(this.SetBinding(() => ViewModel.HeaderViewModel.ChatName, () => _chatNameText.Text));
            Bindings.Add(this.SetBinding(() => ViewModel.MembersCountText, () => _chatMembersCountTextView.Text));
            Bindings.Add(this.SetBinding(() => ViewModel.HeaderViewModel.AvatarUrl).WhenSourceChanges(() =>
            {
                Execute.BeginOnUIThread(() =>
                {
                    _chatPhotoImageView.LoadImageWithTextPlaceholder(
                        ViewModel.HeaderViewModel.AvatarUrl,
                        ViewModel.HeaderViewModel.ChatName,
                        new AvatarPlaceholderDrawable.AvatarStyles
                    {
                        BackgroundHexColors = StyleHelper.Style.ChatAvatarStyles.BackgroundHexColors,
                        Size = new System.Drawing.Size(64, 64)
                    },
                        x => x.Transform(new CircleTransformation()));
                });
            }));
            Bindings.Add(this.SetBinding(() => _imagePicker.ViewModel.ImageCacheKey).WhenSourceChanges(() =>
            {
                var newImageCacheKey = _imagePicker.ViewModel.ImageCacheKey;

                if (string.IsNullOrEmpty(newImageCacheKey) || newImageCacheKey == _previewImageKey)
                {
                    return;
                }

                _previewImageKey = newImageCacheKey;

                Execute.BeginOnUIThread(() =>
                {
                    ViewModel.HeaderViewModel.StartEditingCommand.Execute(null);
                });

                ImageService.Instance
                .LoadFile(_previewImageKey)
                .DownSampleInDip(95, 95)
                .Transform(new CircleTransformation())
                .IntoAsync(_chatEditedPhotoImageView);
            }));
            Bindings.Add(this.SetBinding(() => ViewModel.HeaderViewModel.IsMuted, () => _muteNotificationsSwitch.Checked)
                         .ConvertSourceToTarget(x => !x));
            Bindings.Add(this.SetBinding(() => ViewModel.IsBusy, () => _muteNotificationsSwitch.Clickable)
                         .ConvertSourceToTarget(x => !x));
            Bindings.Add(this.SetBinding(() => ViewModel.IsLoading).WhenSourceChanges(() =>
            {
                _busyOverlayView.Visibility          = BoolToViewStateConverter.ConvertGone(ViewModel.IsLoading);
                _chatMembersCountTextView.Visibility = BoolToViewStateConverter.ConvertGone(!ViewModel.IsLoading);
            }));
            Bindings.Add(this.SetBinding(() => ViewModel.CanEdit, BindingMode.OneTime).WhenSourceChanges(() =>
            {
                if (ViewModel.CanEdit)
                {
                    _changeChatPhotoButton.Visibility = ViewStates.Visible;

                    _chatNameEditText.Visibility = ViewStates.Visible;
                    _chatNameText.Visibility     = ViewStates.Gone;
                }
                else
                {
                    _changeChatPhotoButton.Visibility = ViewStates.Gone;

                    _chatNameEditText.Visibility = ViewStates.Gone;
                    _chatNameText.Visibility     = ViewStates.Visible;

                    _chatNameText.Selected = true;
                }
            }));
            Bindings.Add(this.SetBinding(() => ViewModel.HeaderViewModel.IsInEditMode).WhenSourceChanges(() =>
            {
                if (ViewModel.HeaderViewModel.IsInEditMode)
                {
                    _navigationBarView.RightTextButton.Visibility = ViewStates.Visible;
                    _chatEditedPhotoImageView.Visibility          = ViewStates.Visible;
                }
                else
                {
                    _previewImageKey = null;
                    _navigationBarView.RightTextButton.Visibility = ViewStates.Gone;

                    _chatNameEditText.ClearFocus();
                    _chatNameEditText.ClearComposingText();

                    KeyboardService.HideSoftKeyboard(_chatNameEditText);
                }
            }));

            _chatNameEditText.FocusChange += OnEditTextFocusChanged;
            _addMemberContainer.Click     += OnAddMemberClick;
        }
Exemplo n.º 26
0
 public override void Press()
 {
     KeyboardService.SimulateModifiedKeyStroke(ModifierKeys, Keys);
     base.Press();
 }
Exemplo n.º 27
0
 public void Configure()
 {
     KeyboardService = new KeyboardService(this);
     //LocalizationService = new LocalizationService(this);
 }
Exemplo n.º 28
0
        internal void Initialize(D3D11Host host)
        {
            if (IsInitialized) return;
            IsInitialized = true;

            Services = new GameServiceContainer();

            ServiceLocator.Initialize(Services);
            _host = host;

            Artemis.System.EntitySystem.BlackBoard.SetEntry("GraphicsDevice", _host.GraphicsDevice);
            Artemis.System.EntitySystem.BlackBoard.SetEntry("ServiceProvider", Services);

            Services.AddService<IGraphicsDeviceService>(host);
            Services.AddService(host.GraphicsDevice);

            _mouse = new MouseService(host);
            Services.AddService<IMouseService>(_mouse);
            _mouse.ButtonDown += OnMouseButtonDown;
            _keyboard = new KeyboardService(host);
            Services.AddService<IKeyboardService>(_keyboard);
            _timer = new TimerService();
            Services.AddService<ITimerService>(_timer);
            Services.AddService(new FastSpriteBatch(host.GraphicsDevice));

            _timer.LastFrameUpdateTime = _gameTime;
            _timer.LastFrameRenderTime = _gameTime;

            SpriteBatch = new SpriteBatch(host.GraphicsDevice);
            Services.AddService(SpriteBatch);

            Content = new ContentManager(Services);
            Content.RootDirectory = Environment.CurrentDirectory;

            SpriteManager = new SpriteManagerService(Content);
            Services.AddService<ISpriteManagerService>(SpriteManager);

            //LoadHullSprites("textures/hulls.json");

            Artemis.System.EntitySystem.BlackBoard.SetEntry("ContentManager", Content);

            World = new EntityWorld(false, false, false);

            World.CreateComponentPool<Transform>(200, 200);

            _gridSystem = new GridRendererSystem();
            _gridSystem.IsEnabled = false;
            World.SystemManager.SetSystem(_gridSystem, Artemis.Manager.GameLoopType.Draw, 1);
            //World.SystemManager.SetSystem(new ShipRendererSystem(), Artemis.Manager.GameLoopType.Draw, 2);
            World.SystemManager.SetSystem(new SceneGraphRendererSystem<StandardShipModelRenderer>(new StandardShipModelRenderer()), Artemis.Manager.GameLoopType.Draw, 3);
            World.SystemManager.SetSystem(new BoundingBoxRendererSystem(), Artemis.Manager.GameLoopType.Draw, 4);
            World.SystemManager.SetSystem(new GenericDrawableRendererSystem(), Artemis.Manager.GameLoopType.Draw, 5);
            _hardpointRendererSystem = new HardpointRendererSystem();
            _hardpointRendererSystem.IsEnabled = false;
            World.SystemManager.SetSystem(_hardpointRendererSystem, Artemis.Manager.GameLoopType.Draw, 6);

            World.SystemManager.SetSystem(new CameraControlSystem(), Artemis.Manager.GameLoopType.Update, 1);
            _transformSystem = new MouseControlledTransformSystem();
            World.SystemManager.SetSystem(_transformSystem, Artemis.Manager.GameLoopType.Update, 2);
            World.SystemManager.SetSystem(new ShipUpdateSystem(), Artemis.Manager.GameLoopType.Update, 3);
            World.SystemManager.SetSystem(new BoundingBoxSelectionSystem(), Artemis.Manager.GameLoopType.Update, 4);
            World.SystemManager.SetSystem(new ShowThrusterTrailsOverrideSystem(), Artemis.Manager.GameLoopType.Update, 5);

            World.InitializeAll();

            CameraEntity = World.CreateCamera(Constants.ActiveCameraTag, _host.GraphicsDevice);
            CameraEntity.Tag = Constants.ActiveCameraTag;
            Camera = CameraEntity.GetComponent<Camera>();

            GridEntity = World.CreateGrid(new Vector2(50, 50), GridColor);

            World.CreateCircle(Vector2.Zero, 10, 8, XnaColor.Red * 0.4f);

            host.PreviewKeyDown += HandleKeyboardInput;

            EditorService = new ShipEditorService(_mouse, World);
            CreateNewShipModelCommand.Execute(null);
            EditorService.SelectedPartEntities.CollectionChanged += (o, e) =>
            {
                if (e.NewItems != null && e.NewItems.Count > 0) {
                    var color = e.NewItems.Cast<Entity>().First().GetComponent<IShipPartComponent>().Part.Color;
                    _selectedColor = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B);
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SelectedColor)));
                }
            };

            
            _mouse.WheelChanged += OnWheelChanged;
            IsHardpointsVisible = false;
            LoadHullSprites("textures/hulls.json");
            IsGridVisible = true;
        }
Exemplo n.º 29
0
 public override void Press()
 {
     KeyboardService.SimulateKeyPress(KeyCode);
     base.Press();
 }
Exemplo n.º 30
0
 internal void HideKeyboard()
 {
     KeyboardService.HideSoftKeyboard(_messageEditText);
 }
Exemplo n.º 31
0
 public App()
 {
     KeyboardService = new KeyboardService(ChromaService);
 }
Exemplo n.º 32
0
 public override void SynchroniseKeyState()
 {
     IsInEffect = KeyboardService.IsKeyDownAsync(KeyCode);
 }