public UserForm(ClientSocket clientSocket) { this.clientSocket = clientSocket; InitializeComponent(); GameMemReader.getInstance().GameStateChanged += GameStateChangedHandler; GameMemReader.getInstance().PlayerChanged += UserForm_PlayerChanged; GameMemReader.getInstance().ChatMessageAdded += OnChatMessageAdded; GameMemReader.getInstance().JoinedLobby += OnJoinedLobby; clientSocket.OnConnected += (sender, e) => { Settings.PersistentSettings.host = e.Uri; }; // Load URL URLTextBox.Text = Settings.PersistentSettings.host; // Connect on Enter AcceptButton = ConnectButton; if (DarkTheme()) { EnableDarkTheme(); } else { metroStyleExtender1.SetApplyMetroTheme(ConsoleTextBox, false); ConsoleTextBox.ResetBackColor(); ConsoleTextBox.ResetForeColor(); } NormalTextColor = DarkTheme() ? Color.White : Color.Black; }
// The IUser stuff is ONLY used by the mod download/install operations. /// <summary> /// Initialize the Screen /// </summary> /// <param name="descrip">Description of the task being done for the header</param> /// <param name="initMsg">Starting string to put in the progress bar</param> public ProgressScreen(string descrip, string initMsg = "") { // A nice frame to take up some of the blank space at the top AddObject(new ConsoleDoubleFrame( 1, 2, -1, -1, 8, () => "Progress", () => "Messages", // Cheating because our IUser handler needs a theme context th => { yesNoTheme = th; return(th.NormalFrameFg); } )); progress = new ConsoleProgressBar( 3, 5, -3, () => topMessage, () => percent ); messages = new ConsoleTextBox( 3, 10, -3, -3 ); AddObject(progress); AddObject(messages); topMessage = initMsg; taskDescription = descrip; }
public AlgebraTextBox() { InitializeComponent(); Type ts = typeof(SymbolicAlgebra.SymbolicVariable); var lib_ver = (AssemblyFileVersionAttribute)ts.Assembly.GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false)[0]; string copyright = @"Silver Algebra " + lib_ver.Version + @" Alpha Edition Copyright (c) 2010-2015 at Lost Particles Network [LPN] All rights reserved for Ahmed Sadek [email protected] Depends on SymbolicAlgebra Open Source Library http://SymbolicAlgebra.CodePlex.com SA> x+x will produce 2*x To Differentiate use '|' operator SA> (sin(x)*cos(x))|x will produce cos(x)^2-sin(x)^2 Enjoy "; ConsoleTextBox.Text = copyright; ConsoleTextBox.Text += (Prompt); ConsoleTextBox.Select(ConsoleTextBox.Text.Length, 0); ConsoleTextBox.Focus(); }
public void WriteColoredText(string ColoredText) { lock (locker) { ConsoleTextBox.BeginInvoke(tb => { var paragraph = new Paragraph(); foreach (var part in TextColor.toParts(ColoredText)) { //Foreground="{DynamicResource MahApps.Brushes.Text}" var run = new Run(part.text); if (part.textColor.ToTextColor() != NormalTextColor.ToTextColor()) { run.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromArgb(part.textColor.A, part.textColor.R, part.textColor.G, part.textColor.B)); } paragraph.Inlines.Add(run); paragraph.LineHeight = 1; //this.AppendText(part.text, part.textColor, false); } tb.Document.Blocks.Add(paragraph); tb.ScrollToEnd(); }); } }
public void updateTextBox(string msg) { // 有調用需求 if (this.InvokeRequired) { // 建立Dalegate 物件 /* * 建立委派物件(TextBoxDalegate)並委派使用"updateTextBox"方法 */ TextBoxDalegate TBDalegate = new TextBoxDalegate(updateTextBox); // 調用委派的方法 this.Invoke(TBDalegate, msg); } else { int lineCount = ConsoleTextBox.GetLineFromCharIndex(ConsoleTextBox.Text.Length); if (lineCount >= 100) { ConsoleTextBox.Text = ConsoleTextBox.Text.Remove(0, (ConsoleTextBox.Lines[0].Length + Environment.NewLine.Length)); } ConsoleTextBox.Text += msg; ConsoleTextBox.Text += Environment.NewLine; ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length; ConsoleTextBox.ScrollToCaret(); } }
private void WriteErrorResult(Exception ex) { ConsoleTextBox.AppendText(string.Format("\r\n****** {0} ******\r\n", ex.GetType().Name)); if (enableVerboseOutputCheckBox.Checked) { ConsoleTextBox.AppendText(string.Format("[ Message ]\r\n\t{0}\r\n", ex)); } else { ConsoleTextBox.AppendText(string.Format("[ Message ]\r\n\t{0}\r\n", ex.Message)); } if (ex is ConfigurationErrorsException) { var cex = ex as ConfigurationErrorsException; ConsoleTextBox.AppendText(string.Format("[ XML Line # ] {0}\r\n", cex.Line)); ConsoleTextBox.AppendText(string.Format("[ {0} Errors ]\r\n", cex.Errors.Count)); // If error count == 1, it's the error we already printed. if (cex.Errors.Count > 1) { foreach (ConfigurationErrorsException err in cex.Errors) { ConsoleTextBox.AppendText(string.Format("\t+ {0}\r\n", err.Message)); } } //cex.Errors if (false && ex.InnerException != null) { ConsoleTextBox.AppendText(string.Format("\r\n------ {0} ------\r\n", cex.GetBaseException().GetType().Name)); ConsoleTextBox.AppendText(string.Format("[ Message ]\r\n\t{0}\r\n", cex.GetBaseException().Message)); } } //ConsoleTextBox.AppendText(string.Format("[ StackTr ]\r\n\t{0}\r\n", ex.StackTrace)); ConsoleTextBox.AppendText("\r\n*****************\r\n\r\n"); }
public GuiConsoleForm(string caption, string cmdPrompt, StringHandler h) { Text = caption; prompt = cmdPrompt; stringHandler = h; textBox = new ConsoleTextBox(this); textBox.Dock = DockStyle.Fill; textBox.Font = new Font("Tahoma", 10, FontStyle.Bold); textBox.WordWrap = false; Width = 750; Size = new Size(467, 400); timer.Interval = 50; timer.Tick += new EventHandler(Execute); this.Controls.Add(textBox); // quick interaction with code, including realtime right mouse drag textBox.MouseDown += Images.Form1.TMouseDownCode; textBox.MouseMove += Images.Form1.TMouseMoveCode; // get changes on screen textBox.MouseMove += (s, e) => { if (e.Button == MouseButtons.Right) { textBox.ExecuteSelectionLine(true); } }; // and executed textBox.DoubleClick += (s, e) => textBox.ExecuteSelectionLine(false); }
// The IUser stuff is ONLY used by the mod download/install operations. /// <summary> /// Initialize the Screen /// </summary> /// <param name="taskDescription">Description of the task being done for the header</param> /// <param name="initMsg">Starting string to put in the progress bar</param> public ProgressScreen(string taskDescription, string initMsg = "") { // A nice frame to take up some of the blank space at the top AddObject(new ConsoleDoubleFrame( 1, 2, -1, -1, 8, () => "Progress", () => "Messages", () => ConsoleTheme.Current.NormalFrameFg )); progress = new ConsoleProgressBar( 3, 5, -3, () => topMessage, () => percent ); messages = new ConsoleTextBox( 3, 10, -3, -3 ); AddObject(progress); AddObject(messages); topMessage = initMsg; LeftHeader = () => $"CKAN {Meta.GetVersion()}"; CenterHeader = () => taskDescription; }
public MainWindow() { InitializeComponent(); var m_vm = (MainViewModel)DataContext; ConsoleTextBox.Focus(); }
public ScriptConsole() { m_consoleBox = new ConsoleTextBox(); m_consoleBox.Control.Dock = DockStyle.Fill; m_consoleBox.CommandHandler = ProcessCommand; m_consoleBox.SuggestionHandler = Suggestions; }
private void ConsoleTextBox_TextChanged(object sender, EventArgs e) { if (AutoScrollMenuItem.Checked) { ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length; ConsoleTextBox.ScrollToCaret(); } }
private void WriteEndResult() { ConsoleTextBox.AppendText(string.Format("\r\n========================")); ConsoleTextBox.AppendText(string.Format("\r\n== {0}", "Demo Complete!")); ConsoleTextBox.AppendText(string.Format("\r\n========================\r\n")); //ConsoleTextBox.AppendText("\r\n*** Demo Complete! **\r\n\r\n"); }
private void ClearConsoleBtn_Click(object sender, RoutedEventArgs e) { this.Dispatcher.Invoke(() => { ConsoleTextBox.Clear(); ConsoleTextBox.ScrollToEnd(); }); }
public void WriteLineToConsole(String line) { if (!(ConsoleTextBox is null)) { ConsoleTextBox.BeginInvoke((MethodInvoker) delegate { ConsoleTextBox.AppendText(line + "\n"); }); } }
private void HandlePasteCommand() { string plainText = Clipboard.GetText(TextDataFormat.UnicodeText); // make sure paste lands at the end ConsoleTextBox.Selection.Select(ConsoleTextBox.Document.ContentEnd, ConsoleTextBox.Document.ContentEnd); ConsoleTextBox.ScrollToEnd(); AddUserText(plainText); }
public void WriteConsole(string text, Color color) { Paragraph para = new Paragraph(); para.Margin = new Thickness(0); para.Foreground = new SolidColorBrush(color); para.Inlines.Add(new Run($"[{DateTime.Now:HH:mm:ss}] {text}")); ConsoleTextBox.Document.Blocks.Add(para); ConsoleTextBox.ScrollToEnd(); }
public MainWindow() { InitializeComponent(); jsExecutor.Initialize((s) => { ConsoleTextBox.AppendText(s + "\n"); }); textEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(textEditor.Options); InitializeTextMarkerService(); }
public void WriteToConsole(string message) { ConsoleTextBox.Text += message + ((message.IndexOf((char)27) != -1)?"":"\n"); if (ConsoleTextBox.Text.Contains((char)27)) { ConsoleTextBox_TextChanged(null, null); } ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length; ConsoleTextBox.ScrollToCaret(); }
/// <summary> /// Initialize the screen /// </summary> public ModListHelpDialog() : base() { SetDimensions(9, 3, -9, -3); int btnW = 10; int btnL = (Console.WindowWidth - btnW) / 2; ConsoleTextBox symbolTb = new ConsoleTextBox( GetLeft() + 2, GetTop() + 2, Console.WindowWidth / 2 - 1, GetBottom() - 4, false, TextAlign.Center, () => ConsoleTheme.Current.PopupBg, () => ConsoleTheme.Current.PopupFg ); AddObject(symbolTb); symbolTb.AddLine("Status Symbols"); symbolTb.AddLine("=============="); symbolTb.AddLine($"{installed} Installed"); symbolTb.AddLine($"{autoInstalled} Auto-installed"); symbolTb.AddLine($"{upgradable} Upgradeable"); symbolTb.AddLine($"{autodetected} Manually installed"); symbolTb.AddLine($"{replaceable} Replaceable"); symbolTb.AddLine($"! Unavailable"); symbolTb.AddLine(" "); symbolTb.AddLine("Basic Keys"); symbolTb.AddLine("=========="); symbolTb.AddLine("Tab Move focus"); symbolTb.AddLine("Cursor keys Select row"); symbolTb.AddLine("Escape Clear search"); ConsoleTextBox searchTb = new ConsoleTextBox( Console.WindowWidth / 2 + 1, GetTop() + 3, GetRight() - 2, GetBottom() - 4, false, TextAlign.Center, () => ConsoleTheme.Current.PopupBg, () => ConsoleTheme.Current.PopupFg ); AddObject(searchTb); searchTb.AddLine("Special Searches"); searchTb.AddLine("================"); searchTb.AddLine("@author Mods by author"); searchTb.AddLine("~i Installed mods"); searchTb.AddLine("~u Upgradeable mods"); searchTb.AddLine("~dname Depend on name"); searchTb.AddLine("~cname Conflict w/ name"); searchTb.AddLine("~n New mods"); AddObject(new ConsoleButton( btnL, GetBottom() - 2, btnL + btnW - 1, "OK", Quit )); }
private void timer1_Tick(object sender, EventArgs e) { int[] List; int nBoards = 0; // with extra FTDI Drivers this can take a long time // so only call occasionally when not connected if (!Connected && ++skip == 10) { skip = 0; // check how many boards connected List = KM.GetBoards(out nBoards); if (nBoards > 0) { Connected = true; this.Text = String.Format("Dynomotion C# Forms App - Connected - USB location {0:X}", List[0]); } else { Connected = false; this.Text = "Dynomotion C# Forms App - Disconnected"; } } if (Connected && KM.WaitToken(100) == KMOTION_TOKEN.KMOTION_LOCKED) { KM_MainStatus MainStatus; try { MainStatus = KM.GetStatus(false); // we already have a lock KM.ReleaseToken(); XPos.Text = String.Format("{0:F1}", MainStatus.Destination[0]); XEnabled.Checked = (MainStatus.Enables & (1 << 0)) != 0; } catch (DMException ex) // in case disconnect in the middle of reading status { KM.ReleaseToken(); MessageBox.Show(ex.InnerException.Message); } } else { Connected = false; } ConsoleMutex.WaitOne(); // make sure we are thread safe if (ConsoleMessageReceived != null && ConsoleMessageReceived != "") { ConsoleTextBox.AppendText(ConsoleMessageReceived); ConsoleMessageReceived = ""; } ConsoleMutex.ReleaseMutex(); }
//private void ConsoleAppendText(String str) //{ // this.ConsoleTextBox.ConsoleAppendText(str); //} private void ConsoleAppendText(String str) { if (this.ConsoleTextBox.InvokeRequired) { this.Invoke(ConsoleAppendTextCallBack, str); } else { ConsoleTextBox.AppendText(str); } }
private void ISLogger_MessageOut(object sender, string text) { if (ConsoleTextBox.InvokeRequired) { ConsoleTextBox.Invoke(new Action(() => ISLogger_MessageOut(null, text))); } else { ConsoleTextBox.AppendText(text); } }
private void OnMouseWheel(object sender, MouseWheelEventArgs e) { if (e.Delta > 0) { ConsoleTextBox.ScrollToVerticalOffset(ConsoleTextBox.VerticalOffset + 1); } else { ConsoleTextBox.ScrollToVerticalOffset(ConsoleTextBox.VerticalOffset - 1); } }
private void WriteStartResult(string resultName) { if (ConsoleTextBox.Text.Length > 0) { // Add space if console has existing text. ConsoleTextBox.AppendText(string.Format("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n")); } ConsoleTextBox.AppendText(string.Format("\r\n========================")); ConsoleTextBox.AppendText(string.Format("\r\n== {0}", resultName)); ConsoleTextBox.AppendText(string.Format("\r\n========================\r\n")); }
private void DoAutoScroll() { if (AutoScrollMenuItem.Checked) { ConsoleTextBox.BeginInvoke((MethodInvoker) delegate { ConsoleTextBox.SelectionStart = ConsoleTextBox.Text.Length; ConsoleTextBox.ScrollToCaret(); }); } }
public void ConsoleWriteLine(params object[] content) { StringBuilder buf = new StringBuilder(); foreach (var itemt in content) { buf.Append(itemt.ToString() + " "); } ConsoleTextBox.Text += "[" + DateTime.Now.ToString("O") + "] " + buf.ToString() + "\n"; ConsoleTextBox.ScrollToEnd(); }
public AddANewCall AddCall() { ConsoleTextBox.Click(); ConsoleTextBox.TextValue = "ac"; ConsoleTextBox.PressKeys("{enter}"); AddANewCall addANewCallForm = new AddANewCall(AddANewCall.getPath()); Validate.Exists(addANewCallForm); return(addANewCallForm); }
public void WriteColoredText(string ColoredText) { lock (locker) { foreach (var part in TextColor.toParts(ColoredText)) { this.AppendText(part.text, part.textColor, false); } this.AppendText("", Color.White, true); } ConsoleTextBox.ScrollToEnd(); }
public void ConsoleWriteCommand(string command) { Paragraph p = new Paragraph(); p.Inlines.Add(new Bold(new Run(command)) { Foreground = ConsoleCommandBrush }); ConsoleTextBox.Document.Blocks.Add(p); ConsoleTextBox.ScrollToEnd(); }
void MyConnectionControl_OnConnection(string server, int port) { ConsoleTextBox.Clear(); ShowTabParent(ConsoleTextBox); isConnected = true; AccountSearch.IsEnabled = true; OnPropertyChanged("siEndPoint"); ShowInfoButton.Visibility = System.Windows.Visibility.Visible; ShowInfo(); }