public RemarksBlock(NuGenCustomTypeEditorServiceContext serviceContext) { if (serviceContext == null) { throw new ArgumentNullException("serviceContext"); } _pictureBox = new EditorPictureBox(serviceContext); _remarksHeaderTextBox = new HeaderTextBox(); _remarksHeaderTextBox.Dock = DockStyle.Fill; _remarksHeaderTextBox.TabIndex = 0; _remarksTextBox = new ContentTextBox(); _remarksTextBox.Dock = DockStyle.Fill; _remarksTextBox.TabIndex = 1; _layoutPanel = new EditorTableLayoutPanel(); _layoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 30)); _layoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); _layoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 26)); _layoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); _layoutPanel.Controls.Add(_pictureBox, 0, 0); _layoutPanel.Controls.Add(_remarksHeaderTextBox, 1, 0); _layoutPanel.Controls.Add(_remarksTextBox, 1, 1); _layoutPanel.Parent = this; this.Dock = DockStyle.Bottom; }
void FaceGridView_ItemClick(object sender, ItemClickEventArgs e) { var data = (FaceItemModel)e.ClickedItem; if (data == null) { return; } string faceText = data.Text; int occurences = 0; string originalContent = ContentTextBox.Text; for (var i = 0; i < ContentTextBox.SelectionStart + occurences; i++) { if (originalContent[i] == '\r' && originalContent[i + 1] == '\n') { occurences++; } } int cursorPosition = ContentTextBox.SelectionStart + occurences; ContentTextBox.Text = ContentTextBox.Text.Insert(cursorPosition, faceText); ContentTextBox.SelectionStart = cursorPosition + faceText.Length; ContentTextBox.Focus(FocusState.Pointer); }
private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Tab) { if (NameTextBox.IsFocused) { DateTextBox.Focus(); } else if (DateTextBox.IsFocused) { PublicDocumentRadioButton.Focus(); } else if (PublicDocumentRadioButton.IsFocused) { HiddenDocumentRadioButton.Focus(); } else if (HiddenDocumentRadioButton.IsFocused) { ContentTextBox.Focus(); } else { NameTextBox.Focus(); } e.Handled = true; } }
public MainBlock(NuGenCustomTypeEditorServiceContext serviceContext) { if (serviceContext == null) { throw new ArgumentNullException("serviceContext"); } _pictureBox = new EditorPictureBox(serviceContext); _pictureBox.Paint += _pictureBox_Paint; _headerTextBox = new HeaderTextBox(); _headerTextBox.Dock = DockStyle.Fill; _headerTextBox.TabIndex = 0; _textTextBox = new ContentTextBox(); _textTextBox.Dock = DockStyle.Fill; _textTextBox.TabIndex = 1; _layoutPanel = new EditorTableLayoutPanel(); _layoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 130)); _layoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); _layoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 26)); _layoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); _layoutPanel.Controls.Add(_headerTextBox, 0, 0); _layoutPanel.Controls.Add(_pictureBox, 0, 1); _layoutPanel.Controls.Add(_textTextBox, 1, 1); _layoutPanel.SetColumnSpan(_headerTextBox, 2); _layoutPanel.Parent = this; this.Dock = DockStyle.Fill; }
private void DetailGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { int idx = 0; int len = 0; Color selBrush = Colors.LightBlue; foreach (var o in e.AddedItems) { if (o is Match mt) { idx = mt.Index; len = mt.Length; selBrush = Colors.DarkGreen; break; } else if (o is Group grp) { idx = grp.Index; len = grp.Length; selBrush = Colors.DarkGoldenrod; break; } } ContentTextBox.SelectionBrush = new SolidColorBrush(selBrush); ContentTextBox.SelectionTextBrush = new SolidColorBrush(len > 0 ? Colors.White : Colors.Black); ContentTextBox.Focus(); ContentTextBox.Select(idx, len); }
//Ctrl+A実装 private void ContentTextBox_KeyDown(object sender, KeyEventArgs e) { //Ctrl + A if (e.Control && e.KeyCode == Keys.A) { e.SuppressKeyPress = true; //beep disabled ContentTextBox.SelectAll(); } }
public void ScrollToSearchResult(FileContentSearchResult searchResult) { ContentTextBox.ScrollToLine(searchResult.Line); var index = LineCounter.GetCharacterIndex(ContentTextBox.Text, searchResult.Line, searchResult.Column); var contentLength = ContentTextBox.Text.Length; ContentTextBox.Select(index, searchResult.Query.Expression.Length); ContentTextBox.Focus(); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (Opened != null) { Opened(this, new PopupEventArgs()); } ContentTextBox.Focus(); ContentTextBox.SelectionStart = ContentTextBox.Text.Length; AddNewItem(" "); }
private async Task ExecuteCommand(string command) { ContentTextBox.Document.Blocks.Add(new Paragraph(new Run(command))); ContentTextBox.ScrollToEnd(); var result = await _console.ExecuteCommandAndCaptureOutputAsync(command); _historyManager.LogCommand(command, result); AppendDmlOutput(result); }
private void SpeechState_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (ContentTextBox.IsReadOnly && e.PropertyName == nameof(SpeechState.SpeakingTextIndex)) { // A fix to simulate TextBox.HideSelection = False in Windows Forms // Set FocusManager.IsFocusScope = true on StackPanel // Then, the following Keyboard.Focus() statements can set logical focus on TextBox, but actual focus on StackPanel Keyboard.Focus(ContentTextBox); Keyboard.Focus(VoiceControlStackPanel); ContentTextBox.Select(SpeechState.Current.SpeakingTextIndex, SpeechState.Current.SpeakingText.Length); } }
private void HighLightText(List <string> wordList, Color color) { foreach (string word in wordList) { Regex r = new Regex(word, RegexOptions.IgnoreCase); foreach (Match m in r.Matches(ContentTextBox.Text)) { ContentTextBox.Select(m.Index, m.Length); ContentTextBox.SelectionColor = color; ContentTextBox.Select(0, 0); } } }
private void ResultTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <Object> e) { RegexMatch regexMatch = ResultTreeView.SelectedItem as RegexMatch; if (regexMatch != null) { // A fix to simulate TextBox.HideSelection = False in Windows Forms // Set FocusManager.IsFocusScope = true on TreeView // Then, the following Keyboard.Focus() statements can set logical focus on TextBox, but actual focus on TreeView Keyboard.Focus(ContentTextBox); Keyboard.Focus(ResultTreeView); ContentTextBox.Select(regexMatch.Index, regexMatch.Value.Length); } }
private void AddDraftForm_Load(object sender, EventArgs e) { int left = Df.Left - Width; int top = Screen.PrimaryScreen.WorkingArea.Height - Height; DesktopBounds = new Rectangle(left, top, Width, Height); MaximumSize = Size; if (Properties.Settings.Default.IsBlackTheme) { ChangeThemeToBlack(); } ContentTextBox.Focus(); }
public void AddLine(string line, SolidColorBrush colorBrush) { var tp = ContentTextBox.Document.ContentEnd; var tr = new TextRange(tp, tp) { Text = line + '\r' }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, colorBrush); if (!VM.ScrollLock) { ContentTextBox.ScrollToEnd(); } }
private void Location_Click(object sender, EventArgs e) { ContentTextBox.Focus(); int rowIndex = Utils.TryToInt(LocationTextBox.Text, 0); int startIndex = 0; if (rowIndex > 0) { for (int i = 0; i < rowIndex - 1; i++) { startIndex += ContentTextBox.Lines[i].Length + "\n".Length; } } ContentTextBox.SelectionStart = startIndex; ContentTextBox.ScrollToCaret(); }
void InsertFileCodeIntoContextTextBox(string fileCode) { int occurences = 0; string originalContent = ContentTextBox.Text; for (var i = 0; i < ContentTextBox.SelectionStart + occurences; i++) { if (originalContent[i] == '\r' && originalContent[i + 1] == '\n') { occurences++; } } int cursorPosition = ContentTextBox.SelectionStart + occurences; ContentTextBox.Text = ContentTextBox.Text.Insert(cursorPosition, fileCode); ContentTextBox.SelectionStart = cursorPosition + fileCode.Length; ContentTextBox.Focus(FocusState.Programmatic); }
/// <summary> /// Click event, Send a mail on the contact section. /// </summary> private void ContactSendButton_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(NameTextBox.Text) || String.IsNullOrEmpty(MailTextBox.Text) || String.IsNullOrEmpty(SubjectTextBox.Text) || String.IsNullOrEmpty(ContentTextBox.Text)) { Alert.AlertCreation("Fill Every Field!", AlertType.error); return; } else { string emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\." + "[a-zA-Z0-9_+&*-]+)*@" + "(?:[a-zA-Z0-9-]+\\.)+[a-z" + "A-Z]{2,7}$"; bool isEmail = Regex.IsMatch(MailTextBox.Text, emailRegex); if (isEmail) { bool result = informationParser.SendMail(mailSender, log, SubjectTextBox.Text, "Mail sender Name: " + NameTextBox.Text + "<br>" + "Mail Sender Address: " + MailTextBox.Text + "<br>" + ContentTextBox.Text, null); if (result) { Alert.AlertCreation("Mail has been sent.", AlertType.success); NameTextBox.Clear(); MailTextBox.Clear(); SubjectTextBox.Clear(); ContentTextBox.Clear(); } else { Alert.AlertCreation("Mail Problem. (Check SMTP)", AlertType.error); return; } } else { Alert.AlertCreation("Mail Address Format Problem.", AlertType.error); return; } } }
private void functionContainer1_ClickButton(FunctionInfo functionInfo) { int startIndex = ContentTextBox.SelectionStart; string content = functionInfo.Name; RichTextBox tempRtb = new RichTextBox(); Dictionary <int, int> dict = new Dictionary <int, int>(); content = replace(dict, content); tempRtb.AppendText(content); foreach (KeyValuePair <int, int> pair in dict) { tempRtb.Select(pair.Key, pair.Value - pair.Key); tempRtb.SelectionColor = Color.Red; } ContentTextBox.SelectionStart = startIndex; ContentTextBox.SelectedRtf = tempRtb.Rtf; ContentTextBox.Focus(); }
public void AppendText(string text) { ContentTextBox.AppendText(text); }
private void Window_ContentRendered(object sender, EventArgs e) { ContentTextBox.SelectAll(); ContentTextBox.Focus(); }
public void AppendLine(string text) { ContentTextBox.AppendText(text + ControlChars.CrLf); }
void AddTaskPage_Loaded(object sender, RoutedEventArgs e) { ContentTextBox.Focus(); }
private void FocusTextBox() { ContentTextBox.Focus(); }
private bool CheckingWhetherAllFieldsFilledCorrectly() { if (NameTextBox.Text == defaultDocumentName) { MessageBox.Show("Укажите название документа.", "Ошибка"); NameTextBox.Focus(); return(false); } if (DateTextBox.Text == defaultDocumentDate || DateTextBox.Text == "") { MessageBox.Show("Укажите дату создания документа в формате ДД.ММ.ГГГГ либо нажмите на кнопку 'Cегодня', чтобы задать в качестве даты создания сегодняшний день.", "Ошибка"); DateTextBox.Focus(); return(false); } if (PublicDocumentRadioButton.IsChecked == false && HiddenDocumentRadioButton.IsChecked == false) { MessageBox.Show("Укажите уровень доступности документа.", "Ошибка"); PublicDocumentRadioButton.Focus(); return(false); } if (ContentTextBox.Text == defaultDocumentText) { MessageBox.Show("Документ не может быть пустым.", "Ошибка"); ContentTextBox.Focus(); return(false); } if (_storage.Documents.Items.Count(doc => doc.Name == NameTextBox.Text && doc != _document) > 0) { MessageBox.Show("В системе уже существует документ с таким названием.", "Ошибка"); NameTextBox.Text = ""; NameTextBox.Focus(); return(false); } if (!HelpingMethods.TryParsingTheDate(DateTextBox.Text)) { MessageBox.Show("Дата в полях должна задаваться в формате ДД.ММ.ГГГГ — например: 25.05.2017 . Оформите дату создания документа корректно либо воспользуйтесь кнопкой 'Сегодня', чтобы быстро указать сегодняшний день.", "Ошибка"); DateTextBox.Text = ""; DateTextBox.Focus(); return(false); } if (DateTime.Parse(DateTextBox.Text) > DateTime.Now) { MessageBox.Show("Некорректная дата. Этот день еще не наступил.", "Ошибка"); DateTextBox.Text = ""; DateTextBox.Focus(); return(false); } if (DateTime.Parse(DateTextBox.Text) < DateTime.Parse(foundationStringDate)) { MessageBox.Show("Некорректная дата. В это время нашей компании еще не существовало.", "Ошибка"); DateTextBox.Text = ""; DateTextBox.Focus(); return(false); } if (_document.Id != -1 && DateTime.Parse(DateTextBox.Text) > _document.Versions[0].Date) { MessageBox.Show("Некорректная дата создания документа. К моменту наступления этого дня, некоторые версии уже были зарегистрированы в системе.", "Ошибка"); DateTextBox.Text = ""; DateTextBox.Focus(); return(false); } return(true); }
private void ContentTextBox_Loaded(object sender, RoutedEventArgs e) { ContentTextBox.Focus(FocusState.Keyboard); }
private void SelectText(Models.SearchResult result, int length) { ScrollListBox(result.NoteIndex); FocusTextBox(); ContentTextBox.Select(result.ContentIndex, length); }
private void Window_Loaded(object sender, RoutedEventArgs e) { ContentTextBox.Text = Text; ContentTextBox.Focus(); ContentTextBox.SelectAll(); }