Beispiel #1
0
 public SetShellStatePacket(Guid clientUniqueId, Guid shellUniqueId, ShellState shellState)
 {
     ClientUniqueId = clientUniqueId;
     ShellUniqueId  = shellUniqueId;
     ShellState     = shellState;
     Type           = "SetShellStatePacket";
 }
Beispiel #2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            if (_isFullScreen)
            {
                ToggleFullscreen();
            }

            ShellState state = new ShellState();

            SaveShellState(ref state);

            try
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    BinaryFormatter bin = new BinaryFormatter();
                    bin.Serialize(stream, state);
                    var data = stream.ToArray();
                    Utils.BblRegistryKey.GetKey().SetValue("WindowCoords", data, RegistryValueKind.Binary);
                }
            }
            catch (IOException)
            {
            }

            base.OnClosing(e);
        }
Beispiel #3
0
        protected override void OnExit(ExitEventArgs e)
        {
            var apiServer = _containerProvider.Resolve <IApiServer>();

            apiServer.Stop();

            if (_shell != null)
            {
                var state = new ShellState
                {
                    Width  = _shell.Width,
                    Height = _shell.Height,
                    Top    = _shell.Top,
                    Left   = _shell.Left,
                    State  = _shell.WindowState
                };

                var settingsService = _containerProvider.Resolve <ISettingsService>();
                settingsService.SetSettingAsync(AppGlobals.SettingKeys.ShellState, state).GetAwaiter().GetResult();

                _shell = null;
            }

            base.OnExit(e);

            Logger.Info("Exiting...");
        }
Beispiel #4
0
        public void Suggest(string commandText, params string[] expectedResults)
        {
            HttpState        httpState      = GetHttpState(out MockedFileSystem fileSystem, out _);
            ICoreParseResult parseResult    = CreateCoreParseResult(commandText);
            IConsoleManager  consoleManager = new LoggingConsoleManagerDecorator(new NullConsoleManager());
            DefaultCommandDispatcher <HttpState> commandDispatcher = DefaultCommandDispatcher.Create((ss) => { }, httpState);

            commandDispatcher.AddCommand(new ClearCommand());
            commandDispatcher.AddCommand(new ChangeDirectoryCommand());
            commandDispatcher.AddCommand(new RunCommand(fileSystem));
            IShellState shellState = new ShellState(commandDispatcher, consoleManager: consoleManager);

            HelpCommand helpCommand = new HelpCommand();

            IEnumerable <string> result = helpCommand.Suggest(shellState, httpState, parseResult);

            Assert.NotNull(result);

            List <string> resultList = result.ToList();

            Assert.Equal(expectedResults.Length, resultList.Count);

            for (int index = 0; index < expectedResults.Length; index++)
            {
                Assert.Contains(expectedResults[index], resultList, StringComparer.OrdinalIgnoreCase);
            }
        }
Beispiel #5
0
 public ShellStateSetPacket(Guid clientUniqueId, Guid shellUniqueId, ShellState shellState, bool success)
 {
     ClientUniqueId = clientUniqueId;
     ShellUniqueId = shellUniqueId;
     ShellState = shellState;
     Success = success;
     Type = "ShellStateSetPacket";
 }
Beispiel #6
0
        /// <summary>
        /// Shows the view within the region and for the specified state.
        /// </summary>
        /// <typeparam name="T">The view to activate</typeparam>
        /// <param name="region">The region.</param>
        /// <param name="state">The state.</param>
        private void ShowView <T>(string region, ShellState state) where T : IStatefulView
        {
            var view = regionManager.Regions[region].Views.Where(aView => aView is T).FirstOrDefault(bView => ((T)bView).RegionToken == state);

            if (view != null)
            {
                regionManager.Regions[region].Activate(view);
            }
        }
Beispiel #7
0
 protected override void GetHit()
 {
     _body.SetActive(false);
     _shell.SetActive(true);
     anim           = _shellAnim;
     curStage       = CurStage.shell;
     shellState     = ShellState.idle;
     _isShellMoving = false;
     StartCoroutine("OnRecover");
 }
 /// <summary>
 /// Registers a view with a region and a shell state
 /// </summary>
 /// <typeparam name="T">The view that will be registered</typeparam>
 /// <param name="mainScreenRegion">The main screen region.</param>
 /// <param name="regionToken">The region token.</param>
 public static void RegisterWithRegionAndState <T>(string mainScreenRegion, ShellState regionToken) where T : IStatefulView
 {
     regionManager.RegisterViewWithRegion(mainScreenRegion,
                                          () =>
     {
         var a         = unityContainer.Resolve <T>(regionToken.ToString());
         a.RegionToken = regionToken;
         return(a);
     });
 }
Beispiel #9
0
 private void RestoreShellState(ref ShellState state)
 {
     WindowStyle = state.windowStyle;
     ResizeMode  = state.resizeMode;
     WindowState = state.windowState;
     Width       = state.size.Width;
     Height      = state.size.Height;
     Left        = state.position.X;
     Top         = state.position.Y;
     SetValue(WindowChrome.WindowChromeProperty, state.windowChrome);
 }
Beispiel #10
0
 private void SaveShellState(ref ShellState state)
 {
     state.position.X   = Left;
     state.position.Y   = Top;
     state.size.Width   = Width;
     state.size.Height  = Height;
     state.windowState  = WindowState;
     state.resizeMode   = ResizeMode;
     state.windowStyle  = WindowStyle;
     state.windowChrome = GetValue(WindowChrome.WindowChromeProperty) as WindowChrome;
 }
Beispiel #11
0
        private void OnEnterShell(Collider2D col)
        {
            if (_shellState == ShellState.availabe)
            {
                haveIsOwnShell = !haveIsOwnShell;

                _shellState = ShellState.taken;
                Shell.SwapWithPlayer();
                _save.SetFriendship((int)_initialShell - 1, haveIsOwnShell);
            }
        }
Beispiel #12
0
        public MockedShellState()
        {
            DefaultCommandDispatcher<object> defaultCommandDispatcher = DefaultCommandDispatcher.Create(x => { }, new object());
            Mock<IConsoleManager> mockedConsoleManager = new Mock<IConsoleManager>();
            Mock<IWritable> mockedErrorWritable = new Mock<IWritable>();
            mockedErrorWritable.Setup(x => x.WriteLine(It.IsAny<string>())).Callback((string s) => ErrorMessage = s);
            mockedConsoleManager.Setup(x => x.Error).Returns(mockedErrorWritable.Object);
            mockedConsoleManager.Setup(x => x.Write(It.IsAny<string>())).Callback((string s) => _output.Append(s));
            mockedConsoleManager.Setup(x => x.WriteLine(It.IsAny<string>())).Callback((string s) => _output.AppendLine(s));

            _shellState = new ShellState(defaultCommandDispatcher, consoleManager: mockedConsoleManager.Object);
        }
Beispiel #13
0
        public async Task ExecuteAsync_CallsConsoleManagerClear()
        {
            HttpState        httpState   = GetHttpState(out _, out _);
            ICoreParseResult parseResult = CreateCoreParseResult("clear");
            DefaultCommandDispatcher <HttpState> dispatcher     = DefaultCommandDispatcher.Create((ss) => { }, httpState);
            LoggingConsoleManagerDecorator       consoleManager = new LoggingConsoleManagerDecorator(new NullConsoleManager());
            IShellState shellState = new ShellState(dispatcher, consoleManager: consoleManager);

            ClearCommand clearCommand = new ClearCommand();

            await clearCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None);

            Assert.True(consoleManager.WasClearCalled);
        }
Beispiel #14
0
        protected void Awake()
        {
            Shell.OnEnterShell = OnEnterShell;
            _shellState        = ShellState.notAvailable;

            _audioSource = this.GetComponent <AudioSource>();

            savedPosition = this.transform.position;
            savedRotation = this.transform.rotation;

            _save = GameObject.Find("SaveController").GetComponent <Save>();

            system = this.GetComponentsInChildren <ParticleSystem>();

            _initialShell = Shell.Type;
        }
Beispiel #15
0
        public async Task <ShellState> GetShellStateAsync()
        {
            if (_shellState != null)
            {
                return(_shellState);
            }

            _shellState = await _session.QueryAsync <ShellState>().FirstOrDefault();

            if (_shellState == null)
            {
                _shellState = new ShellState();
                UpdateShellState();
            }

            return(_shellState);
        }
Beispiel #16
0
        private IShellState GetShellState(string inputBuffer, HttpState httpState)
        {
            DefaultCommandDispatcher <HttpState> defaultCommandDispatcher = DefaultCommandDispatcher.Create(x => { }, httpState);

            defaultCommandDispatcher.AddCommand(new SetHeaderCommand(new NullTelemetry()));

            Mock <IConsoleManager> mockConsoleManager = new Mock <IConsoleManager>();
            MockInputManager       mockInputManager   = new MockInputManager(inputBuffer);

            ShellState shellState = new ShellState(defaultCommandDispatcher,
                                                   consoleManager: mockConsoleManager.Object,
                                                   commandHistory: new CommandHistory(),
                                                   inputManager: mockInputManager);

            Shell shell = new Shell(shellState);

            return(shell.ShellState);
        }
Beispiel #17
0
        public async Task <ShellState> GetShellStateAsync()
        {
            if (_shellState != null)
            {
                return(_shellState);
            }

            _shellState = await new ValueTask <ShellState>(_context.Set <ShellState>().FirstOrDefault());

            if (_shellState == null)
            {
                _shellState = new ShellState();
                _context.Set <ShellState>().Add(_shellState);
                _context.SaveChanges();
            }

            return(_shellState);
        }
        private ShellFeatureState GetOrAddFeatureState(string featureName)
        {
            var shellState = GetShellState();

            var feature = shellState.Features.SingleOrDefault(f => f.Name == featureName);

            if (feature == null)
            {
                feature = new ShellFeatureState {
                    Name = featureName
                };
                shellState.Features = shellState.Features.Union(new[] { feature });
            }

            ShellState = shellState;

            return(feature);
        }
        /// <summary>
        /// Called when [shell state changed].
        /// dependind on <see cref="ShellState" /> a specific module is visible
        /// </summary>
        /// <param name="shellState">State of the shell.</param>
        private void OnShellStateChanged(ShellState shellState)
        {
            switch (shellState)
            {
            case ShellState.DentalRecords:
                // Parent.IsLoginVisible = Visibility.Collapsed;
//Parent.IsContentVisible = Visibility.Visible;
                eventAggregator.GetEvent <UpdateDentalRecordsEvent>().Publish(null);
                //Parent.HorizontalTabsViewModel.OnSelectReportsTab("Pacienti");
                ShowView <IWorkAreaView>(MainScreenRegions.WorkRegion, shellState);
                break;

            case ShellState.Settings:
                eventAggregator.GetEvent <UpdateSettingsEvent>().Publish(null);
                ShowView <IWorkAreaView>(MainScreenRegions.WorkRegion, shellState);
                break;

            case ShellState.Filters:
                eventAggregator.GetEvent <UpdateFiltersEvent>().Publish(null);
                ShowView <IWorkAreaView>(MainScreenRegions.WorkRegion, shellState);
                break;

            case ShellState.Reports:
                eventAggregator.GetEvent <UpdateReportsEvent>().Publish(null);
                ShowView <IWorkAreaView>(MainScreenRegions.WorkRegion, shellState);
                break;

            case ShellState.Financial:
                eventAggregator.GetEvent <UpdateFinancialEvent>().Publish(null);
                ShowView <IWorkAreaView>(MainScreenRegions.WorkRegion, shellState);
                break;

            case ShellState.PersonalData:
                eventAggregator.GetEvent <UpdatePersonalInfoEvent>().Publish(null);
                ShowView <IWorkAreaView>(MainScreenRegions.WorkRegion, shellState);
                break;

            case ShellState.Login:
                Parent.IsLoginVisible   = Visibility.Visible;
                Parent.IsContentVisible = Visibility.Collapsed;
                ShowView <ILoginView>(MainScreenRegions.LoginRegion, shellState);
                break;
            }
        }
Beispiel #20
0
        private IEnumerator Bump(Collision2D col)
        {
            Col.isTrigger = true;
            var start = Time.time;

            yield return(YieldPlay(ANIM_HIT));

            _shellState = ShellState.availabe;

            yield return(new WaitForSeconds(HitIdle));

            yield return(YieldPlay(ANIM_BACK));

            _shellState = ShellState.notAvailable;

            Vector3    position = transform.position;
            Quaternion rotation = transform.rotation;
            float      time     = 0f;

            while (transform.position.x != savedPosition.x)
            {
                time += 0.02f;

                transform.position = Vector3.Lerp(position, savedPosition, time / timePositionReset);
                transform.rotation = Quaternion.Lerp(rotation, savedRotation, time / timePositionReset);

                yield return(new WaitForSeconds(0.02f));
            }

            if (dialogueMad != null)
            {
                if (!haveIsOwnShell)
                {
                    currentDialogue = Instantiate(dialogueMad, this.transform);
                }
                else
                {
                    currentDialogue = Instantiate(dialogueHappy, this.transform);
                }
            }
            Col.isTrigger = false;
            _bumping      = null;
        }
Beispiel #21
0
 protected override void OnInitialized(EventArgs e)
 {
     base.OnInitialized(e);
     byte[] data = Utils.BblRegistryKey.GetKey().GetValue("WindowCoords") as byte[];
     if (data != null)
     {
         using (MemoryStream stream = new MemoryStream(data))
         {
             BinaryFormatter bin = new BinaryFormatter();
             try
             {
                 ShellState state = new ShellState();
                 state              = (ShellState)bin.Deserialize(stream);
                 state.resizeMode   = ResizeMode.CanResize;
                 state.windowStyle  = WindowStyle.SingleBorderWindow;
                 state.windowChrome = this._defaultChrome;
                 RestoreShellState(ref state);
             }
             catch { Console.WriteLine("Failed to restore main window state on Initialisation."); }
         }
     }
 }
Beispiel #22
0
    private void _EnterShellMove()
    {
        var temp = this.transform.position - _player.transform.position;

        if (temp.x > 0)
        {
            dir.x = 1;
        }
        else
        {
            dir.x = -1;
        }

        _isCheck = true;
        isHit    = false;

        shellState = ShellState.move;

        speed = _shellSpeed;

        anim.Play("Shell", 0, 0);
        StopCoroutine("OnRecover");
    }
Beispiel #23
0
        private Shell CreateShell(ConsoleKeyInfo consoleKeyInfo,
                                  string previousCommand,
                                  string nextCommand,
                                  out CancellationTokenSource cancellationTokenSource)
        {
            var defaultCommandDispatcher = DefaultCommandDispatcher.Create(x => { }, new object());

            cancellationTokenSource = new CancellationTokenSource();
            MockConsoleManager mockConsoleManager = new MockConsoleManager(consoleKeyInfo, cancellationTokenSource);

            Mock <ICommandHistory> mockCommandHistory = new Mock <ICommandHistory>();

            mockCommandHistory.Setup(s => s.GetPreviousCommand())
            .Returns(previousCommand);
            mockCommandHistory.Setup(s => s.GetNextCommand())
            .Returns(nextCommand);

            ShellState shellState = new ShellState(defaultCommandDispatcher,
                                                   consoleManager: mockConsoleManager,
                                                   commandHistory: mockCommandHistory.Object);

            return(new Shell(shellState));
        }
Beispiel #24
0
        public async Task <ShellState> GetShellStateAsync()
        {
            _shellState = await Store.GetOrCreateAsync(CancellationToken);

            return(_shellState);
        }
Beispiel #25
0
 /// <summary>
 /// Called when [shell state changed].
 /// dependind on <see cref="ShellState" /> a specific module is visible
 /// </summary>
 /// <param name="shellState">State of the shell.</param>
 private void OnShellStateChanged(ShellState shellState)
 {
 }