Example #1
0
    public TextTyper(DisplaySystem screen, TerminalConsole console)
    {
        Screen  = screen;
        Console = console;

        Cursor = new CursorController(screen, borderWidth, borderHeight);
        keys   = new KeysController(this);

        DrawBorder();
    }
        public KeysControllerTests()
        {
            _settingsManager    = ScriptSettingsManager.Instance;
            _testFunctions      = new Collection <FunctionDescriptor>();
            _testFunctionErrors = new Dictionary <string, Collection <string> >();

            string rootScriptPath = @"c:\test\functions";
            var    environment    = new NullScriptHostEnvironment();
            var    eventManager   = new Mock <IScriptEventManager>();
            var    mockRouter     = new Mock <IWebJobsRouter>();

            var settings = new ScriptApplicationHostOptions()
            {
                ScriptPath  = rootScriptPath,
                SecretsPath = _secretsDirectory.Path
            };

            _secretsManagerMock = new Mock <ISecretManager>(MockBehavior.Strict);

            var fileSystem = new Mock <IFileSystem>();
            var fileBase   = new Mock <FileBase>();
            var dirBase    = new Mock <DirectoryBase>();

            fileSystem.SetupGet(f => f.File).Returns(fileBase.Object);
            fileBase.Setup(f => f.ReadAllText(Path.Combine(rootScriptPath, "TestFunction1", ScriptConstants.FunctionMetadataFileName))).Returns("{}");
            fileBase.Setup(f => f.ReadAllText(Path.Combine(rootScriptPath, "TestFunction2", ScriptConstants.FunctionMetadataFileName))).Returns("{}");
            fileBase.Setup(f => f.ReadAllText(Path.Combine(rootScriptPath, "DNE", ScriptConstants.FunctionMetadataFileName))).Throws(new DirectoryNotFoundException());

            _functionsSyncManagerMock = new Mock <IFunctionsSyncManager>(MockBehavior.Strict);
            _functionsSyncManagerMock.Setup(p => p.TrySyncTriggersAsync(false)).ReturnsAsync(new SyncTriggersResult {
                Success = true
            });
            var hostManagerMock = new Mock <IScriptHostManager>(MockBehavior.Strict);

            hostManagerMock.SetupGet(p => p.State).Returns(ScriptHostState.Running);
            _testController = new KeysController(new OptionsWrapper <ScriptApplicationHostOptions>(settings), new TestSecretManagerProvider(_secretsManagerMock.Object), new LoggerFactory(), fileSystem.Object, _functionsSyncManagerMock.Object, hostManagerMock.Object);

            var keys = new Dictionary <string, string>
            {
                { "key1", "secret1" }
            };

            _secretsManagerMock.Setup(p => p.GetFunctionSecretsAsync("TestFunction1", false)).ReturnsAsync(keys);

            keys = new Dictionary <string, string>
            {
                { "key1", "secret1" }
            };
            _secretsManagerMock.Setup(p => p.GetFunctionSecretsAsync("TestFunction2", false)).ReturnsAsync(keys);

            _secretsManagerMock.Setup(p => p.GetFunctionSecretsAsync("DNE", false)).ReturnsAsync((IDictionary <string, string>)null);

            SetHttpContext();
        }
Example #3
0
        public KeysControllerFacts()
        {
            testScheduler = new TestScheduler();
            var messageProvider = Substitute.For <IMessageProvider>();

            messageProvider.GetMessageStream(Arg.Any <IObservable <KeyPress> >()).Returns(_ => messageStream);
            var keyProvider        = Substitute.For <IKeyProvider>();
            var concurrencyService = Substitute.For <IConcurrencyService>();

            concurrencyService.MainThreadScheduler.Returns(testScheduler);
            concurrencyService.Default.Returns(testScheduler);
            messageStream = new Subject <Message>();
            sut           = new KeysController(keysCollection, messageProvider, keyProvider, concurrencyService);
        }
Example #4
0
    public void Start()
    {
        //TEST (AUTO CONFIG)
        //speedDrag =  0.00012f * heigth;
        //speed = 0.004f * heigth;
        //speedRotation = 0.12f * heigth;
        //TEST (AUTO CONFIG)
        //mouseController = controller.GetComponent<GameController>().mouseController;

        //ground = GameObject.Find("Ground").transform; //obtenemos la posicion del terreno
        camera.transform.rotation = Quaternion.Euler(angle, 0, 0);
        key = controller.GetComponent<GameController>().keysController;
        controller.transform.position = new Vector3(controller.transform.position.x, ground.transform.position.y + heigth, controller.transform.position.z);
    }
Example #5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
            // Check if there was instance before this. If there was-close the current one.
            if (ProcessUtilities.ThisProcessIsAlreadyRunning())
            {
                ProcessUtilities.SetFocusToPreviousInstance("Carnac");
                Shutdown();
                return;
            }

            trayIcon = new CarnacTrayIcon();
            trayIcon.OpenPreferences += TrayIconOnOpenPreferences;
            var keyShowViewModel = new KeyShowViewModel(settings);

            keyShowView = new KeyShowView(keyShowViewModel);
            keyShowView.Show();

            carnac = new KeysController(keyShowViewModel.Messages, messageProvider, new ConcurrencyService(), settingsProvider);
            carnac.Start();

#if !DEBUG
            if (settings.AutoUpdate)
            {
                Observable
                .Timer(TimeSpan.FromMinutes(5))
                .Subscribe(async x =>
                {
                    try
                    {
                        using (var mgr = UpdateManager.GitHubUpdateManager(carnacUpdateUrl))
                        {
                            await mgr.Result.UpdateApp();
                        }
                    }
                    catch
                    {
                        // Do something useful with the exception
                    }
                });
            }
#endif

            base.OnStartup(e);
        }
Example #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // Check if there was instance before this. If there was-close the current one.
            if (ProcessUtilities.ThisProcessIsAlreadyRunning())
            {
                ProcessUtilities.SetFocusToPreviousInstance("Carnac");
                Shutdown();
                return;
            }

            trayIcon = new CarnacTrayIcon();
            trayIcon.OpenPreferences += TrayIconOnOpenPreferences;
            keyCollection             = new ObservableCollection <Message>();
            keyShowView = new KeyShowView(new KeyShowViewModel(keyCollection, settings));
            keyShowView.Show();

            carnac = new KeysController(keyCollection, messageProvider, keyProvider, new ConcurrencyService());
            carnac.Start();

            base.OnStartup(e);
        }
Example #7
0
        public KeysControllerTests()
        {
            _settingsManager    = ScriptSettingsManager.Instance;
            _testFunctions      = new Collection <FunctionDescriptor>();
            _testFunctionErrors = new Dictionary <string, Collection <string> >();

            var config       = new ScriptHostConfiguration();
            var environment  = new NullScriptHostEnvironment();
            var eventManager = new Mock <IScriptEventManager>();
            var mockRouter   = new Mock <IWebJobsRouter>();

            _hostMock = new Mock <ScriptHost>(MockBehavior.Strict, new object[] { environment, eventManager.Object, config, null, null, null });
            _hostMock.Setup(p => p.Functions).Returns(_testFunctions);
            _hostMock.Setup(p => p.FunctionErrors).Returns(_testFunctionErrors);

            WebHostSettings settings = new WebHostSettings();

            settings.SecretsPath = _secretsDirectory.Path;
            _secretsManagerMock  = new Mock <ISecretManager>(MockBehavior.Strict);

            _managerMock = new Mock <WebScriptHostManager>(MockBehavior.Strict, new object[] { config, new TestSecretManagerFactory(_secretsManagerMock.Object), eventManager.Object, _settingsManager, settings, mockRouter.Object, NullLoggerFactory.Instance });

            _managerMock.SetupGet(p => p.Instance).Returns(_hostMock.Object);

            _testController = new KeysController(_managerMock.Object, _secretsManagerMock.Object, new LoggerFactory());

            // setup some test functions
            string errorFunction = "ErrorFunction";
            var    errors        = new Collection <string>();

            errors.Add("A really really bad error!");
            _testFunctionErrors.Add(errorFunction, errors);

            var keys = new Dictionary <string, string>
            {
                { "key1", "secret1" }
            };

            _secretsManagerMock.Setup(p => p.GetFunctionSecretsAsync(errorFunction, false)).ReturnsAsync(keys);
        }
Example #8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            // Check if there was instance before this. If there was-close the current one.
            if (ProcessUtilities.ThisProcessIsAlreadyRunning())
            {
                ProcessUtilities.SetFocusToPreviousInstance("Carnac");
                Shutdown();
                return;
            }

            trayIcon = new CarnacTrayIcon();
            trayIcon.OpenPreferences += TrayIconOnOpenPreferences;
            var keyShowViewModel = new KeyShowViewModel(settings);

            keyShowView = new KeyShowView(keyShowViewModel);
            keyShowView.Show();

            carnac = new KeysController(keyShowViewModel.Messages, messageProvider, new ConcurrencyService(), settingsProvider);
            carnac.Start();

            MouseWatcher.OnMouseInput += (s, me) =>
            {
                if (!keyShowView.IsVisible)
                {
                    return;
                }
                var msg     = me.Message;
                var needAct = msg == MouseMessages.WM_LBUTTONUP || msg == MouseMessages.WM_RBUTTONUP;
                if (!needAct)
                {
                    return;
                }

                Dispatcher.Invoke(() =>
                {
                    keyShowViewModel.CursorPosition = keyShowView.PointFromScreen(new System.Windows.Point(me.Point.x, me.Point.y));
                    if (msg == MouseMessages.WM_LBUTTONUP)
                    {
                        keyShowView.LeftClick();
                    }
                    if (msg == MouseMessages.WM_RBUTTONUP)
                    {
                        keyShowView.RightClick();
                    }
                });
            };

            if (settings.ShowMouseClicks)
            {
                MouseWatcher.Start();
            }
            settings.PropertyChanged += (s, se) => {
                switch (se.PropertyName)
                {
                case "ShowMouseClicks":
                    if (this.settings.ShowMouseClicks)
                    {
                        MouseWatcher.Start();
                    }
                    else
                    {
                        MouseWatcher.Stop();
                    }
                    break;
                }
            };

#if !DEBUG
            if (settings.AutoUpdate)
            {
                Observable
                .Timer(TimeSpan.FromMinutes(5))
                .Subscribe(async x =>
                {
                    try
                    {
                        using (var mgr = UpdateManager.GitHubUpdateManager(carnacUpdateUrl))
                        {
                            await mgr.Result.UpdateApp();
                        }
                    }
                    catch
                    {
                        // Do something useful with the exception
                    }
                });
            }
#endif

            base.OnStartup(e);
        }
Example #9
0
 private void SetKeys(KeysController keys, int keysCount, int amberCount)
 {
     keys.SetKeys(keysCount, amberCount);
 }
Example #10
0
 public void Start()
 {
     key = controller.GetComponent<GameController>().keysController; //obtenesmos las teclas configuradas
     goController = controller.GetComponent<GameController>().GOController;
 }