/// <summary> /// Provied Textbox object to the constructor /// </summary> /// <param name="logTb"></param> /// public Log(ExRichTextBox logTb) { settings = Properties.Settings.Default; lockWriteLine = new object(); tb = logTb; tb.Clear(); }
/*internal void _CreateInstance() * { * Action func = _CreateInstance2; * func(); * }*/ internal void _CreateInstance(bool checkfornullsubitems) { if (SubItems == null) { if (checkfornullsubitems) { SubItems = new Control[Parent.Columns.Length]; } else { return; } } for (int i = 0; i < Parent.Columns.Length; i++) { if (SubItems[i] == null) { SubItems[i] = new ExRichTextBox(); SubItems[i].Cursor = Cursors.Arrow; //SubItems[i].Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; //2014.10.09. - Egyelőre nem tudtam megoldani } //Console.WriteLine("this.Parent=" + this.Parent); //Console.WriteLine("SubItems[i].Parent=" + SubItems[i].Parent); SubItems[i].Parent = this.Parent; if (SubItems[i].GetType().IsSubclassOf(typeof(TextBoxBase))) //If it's a TextBox, set it to read-only { ((TextBoxBase)SubItems[i]).ReadOnly = true; ((TextBoxBase)SubItems[i]).BorderStyle = BorderStyle.None; //((TextBoxBase)SubItems[i]). } /*if (SubItems[i].GetType()==typeof(ExExRichTextBox)) * { * ((ExExRichTextBox)SubItems[i]).SetTransparent(true); * //SubItems[i] = ((ExExRichTextBox)SubItems[i]).SetTransparent(true); * }*/ bool success = true; Control parent = this.Parent; do { success = true; try { this.SubItems[i].BackColor = parent.BackColor; } catch (ArgumentException) { Console.WriteLine("RichListView: Transparency is not supported. Using container BackColor."); this.SubItems[i].BackColor = this.Parent.Parent.BackColor; success = false; parent = parent.Parent; } } while (!success); this.SubItems[i].ForeColor = this.Parent.ForeColor; SubItems[i].Click += _ItemClicked; SubItems[i].DoubleClick += _ItemDoubleClicked; //SubItems[i].MouseClick += _ItemMouseClicked; SubItems[i].MouseUp += _ItemMouseClicked; } }
internal void _CreateInstance() { /*if (Control == null) * Control = new ExRichTextBox(); * ((ExRichTextBox)Control).ReadOnly = true;*/ if (SubItems == null) { SubItems = new Control[Parent.Columns.Length]; } for (int i = 0; i < Parent.Columns.Length; i++) { if (SubItems[i] == null) { SubItems[i] = new ExRichTextBox(); SubItems[i].Parent = this.Parent; } if (SubItems[i].GetType().IsSubclassOf(typeof(TextBoxBase))) //If it's a TextBox, set it to read-only { ((TextBoxBase)SubItems[i]).ReadOnly = true; ((TextBoxBase)SubItems[i]).BorderStyle = BorderStyle.None; ((TextBoxBase)SubItems[i]).Cursor = Cursors.Arrow; } this.SubItems[i].BackColor = this.Parent.BackColor; this.SubItems[i].ForeColor = this.Parent.ForeColor; SubItems[i].Click += _ItemClicked; SubItems[i].DoubleClick += _ItemDoubleClicked; } }
private void AddRichTextBox() { rtbChat = new ExRichTextBox(); panel3.Controls.Add(rtbChat); rtbChat.Dock = DockStyle.Fill; rtbChat.BackColor = Color.DimGray;// ColorTranslator.FromHtml("#4b4a45"); rtbChat.ReadOnly = true; }
//private int _findex = 0; //private Color bgcolour = Color.White; //[System.Runtime.InteropServices.DllImport("user32.dll")] //private static extern IntPtr SendMessage(IntPtr window, int message, int wparam, int lparam); //const int WM_VSCROLL = 0x115; //const int SB_BOTTOM = 7; ////[System.Runtime.InteropServices.DllImport("user32.dll")] ////static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, Int32 wParam, Int32 lParam); ////const int WM_USER = 0x400; ////const int EM_HIDESELECTION = WM_USER + 63; public RichTextBoxPrinter(METAboltInstance instance, ExRichTextBox textBox) { rtb = textBox; this.instance = instance; config = this.instance.Config; hideSmileys = config.CurrentConfig.ChatSmileys; config.ConfigApplied += new EventHandler <ConfigAppliedEventArgs>(Config_ConfigApplied); //rtb.BackColor = bgcolour = config.CurrentConfig.BgColour; if (config.CurrentConfig.HeaderFont != null) { headerfont = config.CurrentConfig.HeaderFont; headerfontstyle = config.CurrentConfig.HeaderFontStyle; headerfontsize = config.CurrentConfig.HeaderFontSize; bkcolour = config.CurrentConfig.HeaderBackColour; } switch (headerfontstyle.ToLower(CultureInfo.CurrentCulture)) { case "bold": fontsy = FontStyle.Bold; break; case "italic": fontsy = FontStyle.Italic; break; default: fontsy = FontStyle.Regular; break; } if (config.CurrentConfig.TextFont != null) { textfont = config.CurrentConfig.TextFont; textfontstyle = config.CurrentConfig.TextFontStyle; textfontsize = config.CurrentConfig.TextFontSize; } switch (textfontstyle.ToLower(CultureInfo.CurrentCulture)) { case "bold": fontst = FontStyle.Bold; break; case "italic": fontst = FontStyle.Italic; break; default: fontst = FontStyle.Regular; break; } }
private void ClearEditBinding() { if (_EditControl != null) { //BindingOperations.ClearAllBindings((ExRichTextBox)_EditControl.Content); //BindingOperations.ClearAllBindings(_EditControl); ExRichTextBox rich = (ExRichTextBox)_EditControl.Content; rich.RemoveHandler(LostFocusEvent, new RoutedEventHandler(RichControl_LostFocus)); } }
void AddEmotions(ExRichTextBox richTextBox) { foreach (string emote in _emotions.Keys) { while (richTextBox.Text.Contains(emote)) { int ind = richTextBox.Text.IndexOf(emote, StringComparison.Ordinal); richTextBox.Select(ind, emote.Length); richTextBox.InsertImage((Image)_emotions[emote]); } } }
public static (int start, int length) StopAutoScrollingAlways(this ExRichTextBox textBox) { textBox.StopUpdating(); var(start, length) = textBox.Selection; if (textBox.Focused) { textBox.Parent.Focus(); } User32.SendMessage(textBox.Handle, User32.Messages.HideSelection, true, 0); return(start, length); }
internal void _CreateInstance() { /*if (Control == null) * Control = new ExRichTextBox(); * ((ExRichTextBox)Control).ReadOnly = true;*/ if (SubItems == null) { SubItems = new Control[Parent.Columns.Length]; } for (int i = 0; i < Parent.Columns.Length; i++) { if (SubItems[i] == null) { SubItems[i] = new ExRichTextBox(); SubItems[i].Cursor = Cursors.Arrow; } SubItems[i].Parent = this.Parent; if (SubItems[i].GetType().IsSubclassOf(typeof(TextBoxBase))) //If it's a TextBox, set it to read-only { ((TextBoxBase)SubItems[i]).ReadOnly = true; ((TextBoxBase)SubItems[i]).BorderStyle = BorderStyle.None; //((TextBoxBase)SubItems[i]). } /*if (SubItems[i].GetType()==typeof(ExExRichTextBox)) * { * ((ExExRichTextBox)SubItems[i]).SetTransparent(true); * //SubItems[i] = ((ExExRichTextBox)SubItems[i]).SetTransparent(true); * }*/ bool success = true; Control parent = this.Parent; do { success = true; try { this.SubItems[i].BackColor = parent.BackColor; } catch (ArgumentException) { Console.WriteLine("RichListView: Transparency is not supported. Using container BackColor."); this.SubItems[i].BackColor = this.Parent.Parent.BackColor; success = false; parent = parent.Parent; } } while (!success); this.SubItems[i].ForeColor = this.Parent.ForeColor; SubItems[i].Click += _ItemClicked; SubItems[i].DoubleClick += _ItemDoubleClicked; } }
public static void Main() { ExRichTextBox xr = new ExRichTextBox(); xr.Undo(); ((IUndoable)xr).Undo(); //((ExTextBox)xr).Undo(); // Now I think it makes sense? System.Console.WriteLine(); ImRichTextBox ir = new ImRichTextBox(); ir.Undo(); ((IUndoable)ir).Undo(); ((ImTextBox)ir).Undo(); // Re-Implementation only works when a member is called through the interface, and not through the base class. }
private void AddEditMenu(ExRichTextBox control) { if (control.ContextMenu == null) { control.ContextMenu = new ContextMenu(); } control.ContextMenu.Items.Clear(); MenuItem Item = new MenuItem(); Item.InputGestureText = "Ctrl+X"; Item.Command = System.Windows.Input.ApplicationCommands.Cut; Item.CommandTarget = control; Item.Header = GlobalData.FindResource("Menu_File_Cut"); Item.Style = Application.Current.Resources["topLevel"] as Style; control.ContextMenu.Items.Add(Item); Item = new MenuItem(); Item.InputGestureText = "Ctrl+C"; Item.Command = System.Windows.Input.ApplicationCommands.Copy; Item.CommandTarget = control; Item.Header = GlobalData.FindResource("Menu_File_Copy"); Item.Style = Application.Current.Resources["topLevel"] as Style; control.ContextMenu.Items.Add(Item); Item = new MenuItem(); Item.InputGestureText = "Ctrl+V"; Item.Command = System.Windows.Input.ApplicationCommands.Paste; Item.CommandTarget = control; Item.Header = GlobalData.FindResource("Menu_File_Paste"); Item.Style = Application.Current.Resources["topLevel"] as Style; control.ContextMenu.Items.Add(Item); control.ContextMenu.Items.Add(new Separator()); Item = new MenuItem(); Item.InputGestureText = "Ctrl+A"; Item.Command = System.Windows.Input.ApplicationCommands.SelectAll; Item.CommandTarget = control; Item.Header = GlobalData.FindResource("Menu_File_SelectAll"); Item.Style = Application.Current.Resources["topLevel"] as Style; control.ContextMenu.Items.Add(Item); }
public static void ResumeAutoScrollingAlways(this ExRichTextBox textBox, (int start, int length) state)
private Label GetEditDateControl() { #region RichTextBox Define if (_EditControl == null) { _EditControl = new Label(); _EditControl.SetValue(Label.BackgroundProperty, null); _EditControl.SetValue(Label.ClipToBoundsProperty, false); _EditControl.SetValue(Label.UseLayoutRoundingProperty, true); _EditControl.SetValue(Label.PaddingProperty, new Thickness(0)); _EditControl.SetValue(Label.MarginProperty, new Thickness(0, 5, 0, -1)); _EditControl.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased); _EditControl.SetValue(Label.RenderTransformOriginProperty, new Point(0.5, 0.5)); ExRichTextBox temprich = new ExRichTextBox(); temprich.SetValue(ExRichTextBox.PaddingProperty, new Thickness(0)); temprich.SetValue(ExRichTextBox.MarginProperty, new Thickness(0)); temprich.SetValue(ExRichTextBox.BorderThicknessProperty, new Thickness(0)); temprich.SetValue(ExRichTextBox.BackgroundProperty, null);//new SolidColorBrush(Color.FromRgb(255,0,0)) temprich.SetValue(ExRichTextBox.BorderBrushProperty, null); _EditControl.Content = temprich; } else if (_EditControl.Parent != null) { SmallEditText ParentUI = _EditControl.Parent as SmallEditText; if (ParentUI != null) { ParentUI.RemoveContent(_EditControl); } } #endregion AddEditMenu((ExRichTextBox)_EditControl.Content); #region InitBinding and Handler Binding bind = new Binding("TextRotate"); bind.Source = DataContext; bind.Mode = BindingMode.OneWay; bind.Converter = new RotateTransConverter(); _EditControl.SetBinding(Label.RenderTransformProperty, bind); bind = new Binding("vTextVerAligen"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.Converter = new VerticalAlignDataConverter(); _EditControl.SetBinding(Label.VerticalContentAlignmentProperty, bind); ExRichTextBox rich = (ExRichTextBox)_EditControl.Content; rich.AddHandler(LostFocusEvent, new RoutedEventHandler(RichControl_LostFocus)); bind = new Binding("vFontSize"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.NotifyOnTargetUpdated = true; rich.SetBinding(ExRichTextBox.SectionFontsizeProperty, bind); bind = new Binding("vFontColor"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.NotifyOnTargetUpdated = true; rich.SetBinding(ExRichTextBox.SectionFontcolorProperty, bind); bind = new Binding("vFontFamily"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.NotifyOnTargetUpdated = true; rich.SetBinding(ExRichTextBox.SectionFontFamilyProperty, bind); bind = new Binding("vFontBold"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.NotifyOnTargetUpdated = true; rich.SetBinding(ExRichTextBox.SectionFontBoldProperty, bind); bind = new Binding("vFontItalic"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.NotifyOnTargetUpdated = true; rich.SetBinding(ExRichTextBox.SectionFontItalicProperty, bind); bind = new Binding("vFontUnderLine"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.NotifyOnTargetUpdated = true; rich.SetBinding(ExRichTextBox.SectionFontUnderlineProperty, bind); bind = new Binding("vFontStrickeThrough"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.NotifyOnTargetUpdated = true; rich.SetBinding(ExRichTextBox.SectionFontStrikeThoughProperty, bind); bind = new Binding("vTextHorAligen"); bind.Source = DataContext; bind.Mode = BindingMode.TwoWay; bind.NotifyOnTargetUpdated = true; bind.Converter = new DocmentAlignDataConverter(); rich.SetBinding(ExRichTextBox.FontAlignmentProperty, bind); bind = new Binding("vTextBulletStyle"); bind.Source = DataContext; bind.NotifyOnTargetUpdated = true; bind.Mode = BindingMode.TwoWay; rich.SetBinding(ExRichTextBox.TextBulletStyleProperty, bind); bind = new Binding("vTextContent"); bind.Source = DataContext; bind.NotifyOnTargetUpdated = true; bind.Mode = BindingMode.TwoWay; rich.SetBinding(ExRichTextBox.TextProperty, bind); #endregion return(_EditControl); }
public RichTextViewBackend() { Widget = new ExRichTextBox(); Widget.BorderThickness = new System.Windows.Thickness(0); }
public RichTextViewBackend() { Widget = new ExRichTextBox(); }
public static void ShowMessage(String message, ExRichTextBox richTextControl, RtfColor foreColor, RtfColor backGround, FontStyle textStyle, HorizontalAlignment textAlignment = HorizontalAlignment.Left, Single textSize = 10, String textFont = "Tahoma", int crlf = 1, Control setFocusTo = null, bool isMessage = true) { if (richTextControl != null && !richTextControl.IsDisposed) { //cleaning left-over RTF characters (avoid breaking RTB) if (message.IndexOf(@"\") > -1) { message = message.Replace(@"\", @"\\"); } if (message.IndexOf("{") > -1) { message = message.Replace("{", @"\{"); } if (message.IndexOf("}") > -1) { message = message.Replace("}", @"\}"); } if (message.IndexOf(Environment.NewLine) > -1) { message = message.Replace(Environment.NewLine, Environment.NewLine + @"\par "); } //we deal with the emoticons only if it is a chat message (ignore emoticons on system message) if (isMessage) { foreach (var icon in EmoticonsHelper.GetEmoticons()) { if (icon.Key.IndexOf(",") > -1) { var optionalToken = icon.Key.Split(','); foreach (var opt in optionalToken) { if (message.IndexOf(opt) > -1) { //replace the token with its RTF equivalent ;) message = message.Replace(opt, icon.Value); } } } else if (message.IndexOf(icon.Key) > -1) { message = message.Replace(icon.Key, icon.Value); } } } FontStyle extraStyles = new FontStyle(); if (message.IndexOf("") > -1) { extraStyles |= FontStyle.Bold; } Font extraFonts = new Font(textFont, textSize, textStyle | extraStyles, GraphicsUnit.Point); //add extra carriage returns if (crlf > 0) { for (int i = 0; i < crlf; i++) { message += Environment.NewLine; } } RTFFractionMessage messageFractions = new RTFFractionMessage(message, foreColor, backGround); try { if (message.IndexOf("\u0003") > -1) { string[] formattedParts = message.Split(new string[] { "\u0003" }, StringSplitOptions.None); for (int i = 0; i <= formattedParts.Count() - 1; i++) { if (formattedParts[i].Length > 1) { if (IntegerHelper.IsNumeric(formattedParts[i].Substring(0, 1))) { messageFractions = (ReturnRTFColor(formattedParts[i])); if (i < formattedParts.Length - 1) richTextControl.AppendTextAsRtf(messageFractions.Message, extraFonts, messageFractions.Forecolor, messageFractions.BackgroundColor); } else { messageFractions = new RTFFractionMessage(formattedParts[i], RtfColor.Black, RtfColor.White); richTextControl.AppendTextAsRtf(messageFractions.Message, extraFonts, messageFractions.Forecolor, messageFractions.BackgroundColor); } } } } } catch { //TODO: Handle } //write any extra text left richTextControl.AppendTextAsRtf(messageFractions.Message, extraFonts, messageFractions.Forecolor, messageFractions.BackgroundColor); //scroll to bottom of the RTB richTextControl.ScrollToCaret(); //if something else needs to be focused, focus that if (setFocusTo != null) { if (setFocusTo.CanFocus) { setFocusTo.Focus(); } } } }
public ChatControler(ExRichTextBox chatbox, ChatMessage.MsgType type, RtfColor color) { ChatBox = chatbox; Type = type; Color = color; }
public RichTextViewBackend() { Widget = new ExRichTextBox(); defaultSelectionOpacity = Widget.SelectionOpacity; Widget.BorderThickness = new System.Windows.Thickness(0); }
public static void ShowMessage(this ExRichTextBox box, string userName, string message) { ShowMessage(userName + ": ", box, RtfColor.Navy, RtfColor.White, FontStyle.Bold, crlf: 0); ShowMessage(message, (ExRichTextBox)box, RtfColor.Black, RtfColor.White, FontStyle.Regular, HorizontalAlignment.Left, crlf: 1); }
public TextBoxInterface(Form form, ExRichTextBox textBox) { console = new TextBoxConsole(form, textBox); writer = console.Writer(); reader = console.Reader(); }
public static void ShowMessage(String message, ExRichTextBox richTextControl, RtfColor foreColor, RtfColor backGround, FontStyle textStyle, HorizontalAlignment textAlignment = HorizontalAlignment.Left, Single textSize = 10, String textFont = "Tahoma", int crlf = 1, Control setFocusTo = null, bool isMessage = true) { if (richTextControl != null && !richTextControl.IsDisposed) { //cleaning left-over RTF characters (avoid breaking RTB) if (message.IndexOf(@"\") > -1) { message = message.Replace(@"\", @"\\"); } if (message.IndexOf("{") > -1) { message = message.Replace("{", @"\{"); } if (message.IndexOf("}") > -1) { message = message.Replace("}", @"\}"); } if (message.IndexOf(Environment.NewLine) > -1) { message = message.Replace(Environment.NewLine, Environment.NewLine + @"\par "); } //we deal with the emoticons only if it is a chat message (ignore emoticons on system message) if (isMessage) { foreach (var icon in EmoticonsHelper.GetEmoticons()) { if (icon.Key.IndexOf(",") > -1) { var optionalToken = icon.Key.Split(','); foreach (var opt in optionalToken) { if (message.IndexOf(opt) > -1) { //replace the token with its RTF equivalent ;) message = message.Replace(opt, icon.Value); } } } else if (message.IndexOf(icon.Key) > -1) { message = message.Replace(icon.Key, icon.Value); } } } FontStyle extraStyles = new FontStyle(); if (message.IndexOf("") > -1) { extraStyles |= FontStyle.Bold; } Font extraFonts = new Font(textFont, textSize, textStyle | extraStyles, GraphicsUnit.Point); //add extra carriage returns if (crlf > 0) { for (int i = 0; i < crlf; i++) { message += Environment.NewLine; } } RTFFractionMessage messageFractions = new RTFFractionMessage(message, foreColor, backGround); try { if (message.IndexOf("\u0003") > -1) { string[] formattedParts = message.Split(new string[] { "\u0003" }, StringSplitOptions.None); for (int i = 0; i <= formattedParts.Count() - 1; i++) { if (formattedParts[i].Length > 1) { if (IntegerHelper.IsNumeric(formattedParts[i].Substring(0, 1))) { messageFractions = (ReturnRTFColor(formattedParts[i])); if (i < formattedParts.Length - 1) { richTextControl.AppendTextAsRtf(messageFractions.Message, extraFonts, messageFractions.Forecolor, messageFractions.BackgroundColor); } } else { messageFractions = new RTFFractionMessage(formattedParts[i], RtfColor.Black, RtfColor.White); richTextControl.AppendTextAsRtf(messageFractions.Message, extraFonts, messageFractions.Forecolor, messageFractions.BackgroundColor); } } } } } catch { //TODO: Handle } //write any extra text left richTextControl.AppendTextAsRtf(messageFractions.Message, extraFonts, messageFractions.Forecolor, messageFractions.BackgroundColor); //scroll to bottom of the RTB richTextControl.ScrollToCaret(); //if something else needs to be focused, focus that if (setFocusTo != null) { if (setFocusTo.CanFocus) { setFocusTo.Focus(); } } } }