public void SpeekCurrentFieldLabel() { if (this.emu.IsConnected) { ScreenField xf = null; xf = GetCurrentField(); if (xf != null) { ScreenField xf1 = GetPreviousField(xf); if (xf1 != null && !String.IsNullOrEmpty(xf1.Text.Trim()) && xf1.Location.top == xf.Location.top) { Tolk.Speak(xf1.Text.Trim().Replace("|", "")); } else { if (!String.IsNullOrEmpty(ScreenText)) { ScreenField xf2 = GetNextUnprotectedField(xf); if (xf2 != null && xf2.Location.top == xf.Location.top) { Tolk.Speak(ScreenText.Substring(xf.Location.position + xf.Location.top + xf.Location.length, (xf2.Location.position + xf2.Location.top) - (xf.Location.position + xf.Location.top + xf.Location.length)).Replace("|", "")); } else { Tolk.Speak(ScreenText.Substring(xf.Location.position + xf.Location.top + xf.Location.length, 80 - (xf.Location.left + xf.Location.length)).Trim().Replace("|", "")); } } } } } }
public void update(GameTime gt) { if (this.firstCall) { this.IsInDialog = true; Tolk.Speak(this.parts[index], true); engine.Play2D("sounds/UI/menuconfirm.mp3"); this.firstCall = false; } if (Input.WasKeyPressed(Keys.E)) { Tolk.Speak(this.parts[index], true); } if (Input.WasKeyPressed(Keys.Enter)) { if (index < parts.Length - 1) { index += 1; Tolk.Speak(parts[index], true); engine.Play2D("sounds/UI/menumove.mp3"); } else { Tolk.Speak("dieron enter"); engine.Play2D("sounds/UI/menuback.mp3"); this.IsInDialog = false; } } }
/// <summary> /// Sends text to the terminal. /// This is used for typical alphanumeric text entry. /// </summary> /// <param name="text">The text to send</param> internal void SendText(string text, bool automated = false) { try { if (this.emu.IsConnected) { enterKeyPressed = false; textKeyPressed = true; if (!automated) { ScreenField xf = GetCurrentField(); if (xf.Attributes.FieldType == "Hidden" && xf.Attributes.Protected == false) { Tolk.Silence(); Tolk.Speak("", true); } } this.emu.SetText(text); if (!automated) { Refresh(); textKeyPressed = false; } } } catch (TNHostException tnHostException) { log.Warn("Exceção TNHostException em terminal.SendText", tnHostException); } catch (Exception e) { log.Error("Exceção não esperada em terminal.Sendtext", e); emu_Disconnected(emu, e.Message); } }
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { this.IsConnecting = false; this.IsConnected = emu.IsConnected; if (this.IsConnected) { Tolk.Speak("Conectado"); } }
public MainWindow() { InitializeComponent(); //This odd event handler is needed because the TextBox control eats that spacebar, so we have to intercept an already-handled event. //this.Console.AddHandler(TextBox.KeyDownEvent, new KeyEventHandler(Console_KeyDown), true); this.Console.AddHandler(TextBox.PreviewKeyDownEvent, new KeyEventHandler(Console_KeyDown), true); Tolk.Load(); Tolk.TrySAPI(false); Tolk.DetectScreenReader(); Tolk.Speak("Bem-vindo ao terminal 3270!", true); Tolk.Speak("Pressione Alt + E para conectar, ou Alt + Q para sair."); }
void ExecuteSpeakCommand(object sender, ExecutedRoutedEventArgs args) { ScreenField xf = null; switch ((String)args.Parameter) { case "A": Tolk.Speak(Console.Text.Trim(), true); break; case "S": Tolk.Silence(); break; case "D": Tolk.Speak(Console.Text.Substring((Terminal.GetCaretIndex() / 81) * 81, 80).Trim().Replace("|", "")); break; case "X": xf = Terminal.GetCurrentField(); if (xf != null) { Tolk.Speak(Console.Text.Substring(xf.Location.position + xf.Location.top, xf.Location.length).Trim().Replace("|", "")); } break; case "Z": xf = Terminal.GetCurrentField(); if (xf != null) { ScreenField xf1 = Terminal.GetPreviousField(xf); if (xf1 != null && xf1.Text != null && xf1.Location.top == xf.Location.top) { Tolk.Speak(xf1.Text.Trim().Replace("|", "")); } else { ScreenField xf2 = Terminal.GetNextUnprotectedField(xf); if (xf2 != null && xf2.Location.top == xf.Location.top) { Tolk.Speak(Console.Text.Substring(xf.Location.position + xf.Location.top + xf.Location.length, (xf2.Location.position + xf2.Location.top) - (xf.Location.position + xf.Location.top + xf.Location.length)).Replace("|", "")); } else { Tolk.Speak(Console.Text.Substring(xf.Location.position + xf.Location.top + xf.Location.length, 80 - (xf.Location.left + xf.Location.length)).Trim().Replace("|", "")); } } } break; } ; }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } // TODO: Add your update logic here Input.Update(); map.Update(Input.keystate, gameTime); if (Input.WasKeyPressed(Keys.C)) { Tolk.Speak(map.Player.me.X + "," + map.Player.me.Y + "," + map.Player.me.Z, true); } base.Update(gameTime); }
} // End screenreader output event. private void speak(string output, bool useSAPI = false, bool interruptSpeech = false) { if (Properties.Settings.Default.UseSAPIOutput == true || useSAPI == true) { if (interruptSpeech == true) { synth.SpeakAsyncCancelAll(); } synth.Rate = Properties.Settings.Default.SAPISpeechRate; synth.SpeakAsync(output); } else { Tolk.Speak(output, interruptSpeech); } }
void ExecuteGeneralCommand(object sender, ExecutedRoutedEventArgs args) { if (args.Parameter.GetType() == typeof(String)) { if ((String)args.Parameter == "Q") { this.Terminal.Disconnect(); this.Close(); return; } else if ((String)args.Parameter == "E") { if (!this.Terminal.IsConnected && !this.Terminal.IsConnecting) { Tolk.Speak("Conectando"); DoLogin(); } else { Tolk.Speak("Já conectado"); } } } }
public static void NonIntrusiveTextChanged( object sender, DependencyPropertyChangedEventArgs e) { var textBox = sender as TextBox; if (textBox == null) { return; } Terminal t = (Terminal)App.Current.MainWindow.Resources["term"]; LoginAcesso ta = (LoginAcesso)App.Current.MainWindow.Resources["logacesso"]; int oldCaretIndex = textBox.CaretIndex; string newValue = (string)e.NewValue; if (newValue.Contains("TELA 001") && newValue.Contains("CODIGO") && newValue.Contains("SENHA")) { if (!ShouldOnlyExecuteOnceExecuted) { lock (Locker) { if (!ShouldOnlyExecuteOnceExecuted) { if (t.IsTerminalConnected) { t.SendText(ta.Usuario, true); t.SendText(ta.Senha, true); t.SendKey(Open3270.TnKey.Enter); ShouldOnlyExecuteOnceExecuted = true; } } } } return; } if (newValue.Contains("desconect")) { ShouldOnlyExecuteOnceExecuted = false; } if (!String.IsNullOrEmpty(newValue.Trim())) { if (!String.IsNullOrEmpty(textBox.Text)) { if (newValue.Length >= 24 * 80 && textBox.Text.Length >= 24 * 80) { for (int i = 0; i < 24; i++) { String tAnterior = textBox.Text.Substring(i * 81, 80); String tNova = newValue.Substring(i * 81, 80); if (!tAnterior.Equals(tNova)) { int maxindex = tAnterior.Length == 0 || tNova.Length == 0 ? 0 : (tAnterior.Length < tNova.Length ? tAnterior.Length : tNova.Length) - 1; int inicio = 0; while (tAnterior[inicio] == tNova[inicio]) { inicio++; } int fim = maxindex; while (tAnterior[fim] == tNova[fim]) { fim--; } string novoConteudo = (tNova.Substring(inicio, fim + 1 - inicio)).Replace("|", "").Trim(); if (!String.IsNullOrEmpty(novoConteudo) && !t.TextKeyPressed) { if (!String.IsNullOrEmpty(novoConteudo.Replace("O", "").Trim())) { Tolk.Speak(novoConteudo); } } } } string avisoNovo = newValue.Substring(22 * 81, 80).Trim(); string avisoAntigo = textBox.Text.Substring(22 * 81, 80).Trim(); if (!String.IsNullOrEmpty(avisoNovo) && avisoNovo == avisoAntigo && t.EnterKeyPressed) { Tolk.Speak(avisoAntigo); } } else { Tolk.Speak(newValue); } } else { Tolk.Speak(newValue); } } textBox.Text = (string)e.NewValue; textBox.CaretIndex = t.GetCaretIndex(); if (oldCaretIndex / 81 != textBox.CaretIndex / 81) { t.SpeekCurrentFieldLabel(); } }