Um unsere Webseite für Sie optimal zu gestalten und fortlaufend verbessern zu können, verwenden wir Cookies. Durch die weitere Nutzung der Webseite stimmen Sie der Verwendung von Cookies zu. Diese Seite zeigt lediglich nicht-personalisierte Werbung an, um der neuen EU-Datenschutzgrundverordnung gerecht zu werden.
Translate
Freitag, 25. Dezember 2015
C#-Jedes Auftreten eines Textes in einer Richtextox farbig markieren
private void ColorAllAppearencesInRichTextBox(RichTextBox richTextBox, string appearence, Color color, int start)
{
int current = 0;
RichTextBoxFinds options = RichTextBoxFinds.MatchCase;
Action action = () => start = richTextBox.Find(appearence, start, options);
richTextBox.Invoke(action);
while (start >= 0)
{
action = () => richTextBox.SelectionStart = start;
richTextBox.Invoke(action);
action = () => richTextBox.SelectionLength = appearence.Length;
richTextBox.Invoke(action);
action = () => richTextBox.SelectionColor = color;
richTextBox.Invoke(action);
current = start + appearence.Length;
int tempRichTextBoxTextLength = 0;
action = () => tempRichTextBoxTextLength = richTextBox.TextLength;
richTextBox.Invoke(action);
if (current < tempRichTextBoxTextLength)
{
action = () => start = richTextBox.Find(appearence, current, options);
richTextBox.Invoke(action);
}
else
{
if(color == Color.Red)
{
currentRed = current;
}
else if (color == Color.Green)
{
currentGreen = current;
}
break;
}
}
}
{
int current = 0;
RichTextBoxFinds options = RichTextBoxFinds.MatchCase;
Action action = () => start = richTextBox.Find(appearence, start, options);
richTextBox.Invoke(action);
while (start >= 0)
{
action = () => richTextBox.SelectionStart = start;
richTextBox.Invoke(action);
action = () => richTextBox.SelectionLength = appearence.Length;
richTextBox.Invoke(action);
action = () => richTextBox.SelectionColor = color;
richTextBox.Invoke(action);
current = start + appearence.Length;
int tempRichTextBoxTextLength = 0;
action = () => tempRichTextBoxTextLength = richTextBox.TextLength;
richTextBox.Invoke(action);
if (current < tempRichTextBoxTextLength)
{
action = () => start = richTextBox.Find(appearence, current, options);
richTextBox.Invoke(action);
}
else
{
if(color == Color.Red)
{
currentRed = current;
}
else if (color == Color.Green)
{
currentGreen = current;
}
break;
}
}
}
Beim ersten Run:
0 als start mitgeben,
sonst Wert in globalen Variablen zwischenspeichern und diese als start mitgeben:
private int currentRed = 0;
private int currentGreen = 0;
C#-IntLength
public static int IntLength(int i)
{
if (i < 0)
{
throw new ArgumentOutOfRangeException();
}
if (i == 0)
{
return 1;
}
return (int)Math.Floor(Math.Log10(i)) + 1;
}
{
if (i < 0)
{
throw new ArgumentOutOfRangeException();
}
if (i == 0)
{
return 1;
}
return (int)Math.Floor(Math.Log10(i)) + 1;
}
C# GUI Invoke
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GHP_MOUNT.Extensions
{
public static class ControlExtensions
{
static public void UIThread(this Control control, Action code)
{
if (control.InvokeRequired)
{
control.BeginInvoke(code);
return;
}
code.Invoke();
}
static public void UIThreadInvoke(this Control control, Action code)
{
if (control.InvokeRequired)
{
control.Invoke(code);
return;
}
code.Invoke();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GHP_MOUNT.Extensions
{
public static class ControlExtensions
{
static public void UIThread(this Control control, Action code)
{
if (control.InvokeRequired)
{
control.BeginInvoke(code);
return;
}
code.Invoke();
}
static public void UIThreadInvoke(this Control control, Action code)
{
if (control.InvokeRequired)
{
control.Invoke(code);
return;
}
code.Invoke();
}
}
}
Jeff Bezos and Elon Musk spar over gravity of Blue Origin rocket landing oder warum Elon Musk besser ist
Jeff Bezos and Elon Musk spar over gravity of Blue Origin rocket landing oder warum Elon Musk besser ist
Kostenloser Usenet-Zugang
http://www.gigaflat.com/signup.php
https://www.reddit.com/r/usenet/comments/37fpae/unlimited_providers_with_account_sharing_multiple/
Mit Alt.Binz:
http://hitnews.com/
Suche:
https://www.nzbindex.com/
https://binsearch.info
http://nzbsearch.info/
Programm:
http://www.altbinz.net/wiki/Quick_Start_Guide
Hitnews settings for Alt.Binz:
http://www.hitnews.com/index.php?group=4
https://www.reddit.com/r/usenet/comments/37fpae/unlimited_providers_with_account_sharing_multiple/
Mit Alt.Binz:
http://hitnews.com/
Suche:
https://www.nzbindex.com/
https://binsearch.info
http://nzbsearch.info/
Programm:
http://www.altbinz.net/wiki/Quick_Start_Guide
Hitnews settings for Alt.Binz:
http://www.hitnews.com/index.php?group=4
Abonnieren
Posts (Atom)