- Portal
- Community
- Forum Rules
- U-Labs Network
Account-Boerse
Downloade ohne Wartezeit und Geschwindigkeitsbeschränkung von Uploaded.net und Share-Online.biz!U-IMG
Schneller Speicherdienst für Bilder, die in Forenbeiträge eingefügt oder an Freunde gesendet werden können.
- Forum
- Knuddels und die Szene
- Knuddels Programmierung
- Tutorials
- [Tutorial][#3] Chatverlauf
Thema: [Tutorial][#3] Chatverlauf
-
07.02.2012, 18:03 #21
-
20.03.2012, 14:34 #22
- Registriert seit
- 12.02.2012
- Beiträge
- 78
Thanked 11 Times in 5 PostsAW: [Tutorial][#3] Chatverlauf
geht auch damit (ist jetzt für html-code ausgelegt, mit ein paar änderungen kann man damit aber auch machen was man will...):
PHP-Code:private class KCodeItem
{
private int id;
private string code;
private string html;
//Eine Sammlung von Regular-Expressions für die Identifizierung der Knuddels-Links
private Dictionary<string, string> regExCollection = new Dictionary<string, string>();
/// <summary>
/// Konstruktor
/// </summary>
/// <param name="id">Die Nummer des Code-Elements</param>
/// <param name="code">Der Inhalt des Code-Elements</param>
/// <param name="channel">Channelobjekt mit Styleeinstellungen des Channels</param>
public KCodeItem(int id, string code, Channel c)
{
this.id = id;
this.code = code;
#region regexCollection erstellen
//Reihenfolge ist Wichtig!!!
//Bild + Text + WebLink
regExCollection.Add("ImageTextWebLink", "BB>(.+?)\\.(gif)<>(.*?)\\|((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))<");
//Text + WebLink
regExCollection.Add("TextLink", "BB>(.*?)(\\|)((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s\"]*))<");
//Bild + Text + Befehlssatz1 + Linktext + Befehlssatz2
regExCollection.Add("ParameterizedImageChatLink", "BB >(.*?)< >--< >\\|(.*?)\\|(.*?)< >--< >(.*?)\\|(.*?)\\|(.*?)< r");
//Reihenfolge ist Wichtig!!!
//Links ohne Parameter
regExCollection.Add("LinkWithoutParams", ">_h(.*?)\\|(.*?)\\|(.*?)<");
//Links mit Parametern
regExCollection.Add("ParameterizedChatLink", ".*?>_h(.*?)\\|(.*?)\"\\|(.*?)\"<");
//Links mit selbem Parameter auf beiden Maustasten
regExCollection.Add("SimpleParamLink", ">(.*?)\\|(.*?) \\\"<");
//Formatierter Link mit Text = Funktion und nur einer Funktion
regExCollection.Add("SingleParamLink", "(.*?)>(.*?)\\|\"<(.*?)");
//Pics (doppelte)
regExCollection.Add("DoublePicture", ">sm_(.*?)<>sm_(.*?)<");
//Pics (einzelne)
regExCollection.Add("SimplePicture", ">(.+?)<");
#endregion
if (code.Length > 0 && code[0] == '>' || code.StartsWith("BB >") || code.StartsWith("BB>") && code[1] != '{')
{
foreach (KeyValuePair<string, string> kvp in regExCollection)
{
Match m = new Regex(kvp.Value, RegexOptions.IgnoreCase | RegexOptions.Singleline).Match(code);
string fileName = null;
string text = null;
string url = null;
string commandLeftClick = null;
string commandRightClick = null;
string imageName = null;
if (m.Success)
{
switch (kvp.Key)
{
#region LinkWithoutParams
case "LinkWithoutParams":
text = m.Groups[1].ToString();
text = text.Replace("\\<", "<");
text = text.Replace("\\>", ">");
commandLeftClick = m.Groups[2].ToString().Replace("\"", text);
commandRightClick = m.Groups[3].ToString().Replace("\"", text);
this.html = "<a hidefocus=\"hidefocus\" class=\"leading\" href=\"#\" name=\"" + commandLeftClick + "|" + commandRightClick + "\">" + text + "</a>";
break;
#endregion
#region TextLink
case "TextLink":
text = m.Groups[1].ToString();
text = text.Replace("\\<", "<");
text = text.Replace("\\>", ">");
url = m.Groups[3].ToString();
this.html = "<a hidefocus=\"hidefocus\" href=\"#\" name=\"\0" + url + "|\0" + url + "\">" + text + "</a>";
break;
#endregion
#region ParameterizedImageChatLink
case "ParameterizedImageChatLink":
/* <------ NOT USED! ------>
string str = "";
for (int i = 0; i <= m.Groups.Count; i++)
{
str += "[" + i.ToString() + "]" + m.Groups[i].ToString() + "\r\n";
}
MessageBox.Show(str);*/
fileName = m.Groups[1].ToString();
string command1Left = m.Groups[2].ToString();
string command1Right = m.Groups[3].ToString();
text = m.Groups[4].ToString();
text = text.Replace("\\<", "<");
text = text.Replace("\\>", ">");
string command2Left = m.Groups[5].ToString();
string command2Right = m.Groups[6].ToString();
//ClientHelper.imageLoader(fileName, ClientHelper.standartPicsDirectory + '/' + ClientHelper.standartPicsDirectory, rootDomain);
//filePath = new FileInfo(ClientHelper.imageDirectory + @"\" + fileName);
this.html = "<img src=\"" + "http://chat.knuddels.de/" + fileName + "\">" + "<a hidefocus=\"hidefocus\" href=\"#\" name=\"" + command2Left + "|" + command2Right + "\">" + text + "</a>";
break;
#endregion
#region ImageTextWebLink
case "ImageTextWebLink":
imageName = m.Groups[1].ToString();
if (imageName.Contains("..."))
imageName = imageName.Substring(0, imageName.IndexOf("...")) + ".png";
imageName = imageName + "." + m.Groups[2];
text = m.Groups[3].ToString();
text = text.Replace("\\<", "<");
text = text.Replace("\\>", ">");
url = m.Groups[4].ToString();
fileName = imageName;
//ClientHelper.imageLoader(fileName, ClientHelper.standartPicsDirectory + '/' + ClientHelper.standartPicsDirectory, rootDomain);
//filePath = new FileInfo(ClientHelper.imageDirectory + @"\" + fileName);
this.html = "<img src=\"" + "http://chat.knuddels.de/" + url + "\">" + "<a hidefocus=\"hidefocus\" href=\"#\" name=\"\0" + url + "|\0" + url + "\">" + text + "</a>";
break;
#endregion
#region ParameterizedChatLink
case "ParameterizedChatLink":
string param = m.Groups[1].ToString();
commandLeftClick = m.Groups[2].ToString();
commandRightClick = m.Groups[3].ToString();
param = param.Replace("<", "<");
param = param.Replace(">", ">");
this.html = "<a hidefocus=\"hidefocus\" href=\"#\" name=\"" + commandLeftClick + param + "|" + commandRightClick + param + "\">" + param + "</a>";
break;
#endregion
#region SimpleParamLink
case "SimpleParamLink":
text = m.Groups[1].ToString();
text = text.Replace("\\<", "<");
text = text.Replace("\\>", ">");
commandLeftClick = m.Groups[2].ToString();
commandRightClick = m.Groups[2].ToString();
this.html = "<a style=\"text-decoration:underline;\" hidefocus=\"hidefocus\" class=\"leading\" href=\"#\" name=\"" + commandLeftClick + "|" + commandRightClick + "\">" + text + "</a>";
break;
#endregion
#region SingleParamLink
case "SingleParamLink":
//regExCollection.Add("SingleParamLink", "(.*?)>(.*?)\\|\"<(.*?)");
text = m.Groups[2].ToString();
text = text.Replace("\\<", "<");
text = text.Replace("\\>", ">");
commandLeftClick = m.Groups[2].ToString();
commandRightClick = m.Groups[2].ToString();
string add = "";
if (m.Groups[1].ToString() == "BB")
add = "color: " + ColorTranslator.ToHtml(c.blue).Replace("#", "") + ";";
this.html = "<a style=\"text-decoration:underline; font-weight:bold; " + add + "\" hidefocus=\"hidefocus\" class=\"leading\" href=\"#\" name=\"" + commandLeftClick + "|" + commandRightClick + "\">" + text + "</a>";
break;
#endregion
#region DoublePicture
case "DoublePicture":
//ForeGround
string pic1 = "sm_" + m.Groups[1];
//Background
string pic2 = "sm_" + m.Groups[2];
this.html = "<img style =\"background-image:url(file:///" + ImageHandler.LoadImage(pic1).ImagePath + ");\" src=\"file:///" + ImageHandler.LoadImage(pic2).ImagePath + "\">";
break;
#endregion
#region SimplePicture
case "SimplePicture":
fileName = m.Groups[1].ToString();
try
{
this.html = "<img src=\"file:///" + ImageHandler.LoadImage(fileName).ImagePath + "\">";
}
catch
{
this.html = "[RegExNotImplemented]";
File.AppendAllText("unparsed.txt", code + Environment.NewLine);
}
break;
#endregion
}
break;
}
}
if (this.html == null || this.html == "" || this.html == string.Empty)
this.html = code + "\n";
}
else if (code.Length > 3 && code[2] == '{')
{
File.AppendAllText("unparsed.txt", code + Environment.NewLine);
}
#region RGB Color
else if (code.Length != 0 && code[0] == '[')
{
try
{
code = code.Substring(1);
code = code.Remove(code.Length - 1);
string[] rgb = code.Split(new char[] { ',' });
Color color = Color.FromArgb(
int.Parse(rgb[0]),
int.Parse(rgb[1]),
int.Parse(rgb[2]));
this.html =
"<span style=\"color: " +
ColorTranslator.ToHtml(color) +
";\">";
}
catch
{
}
}
#endregion
#region ColorLetter, Size, Fehler
else
{ //ColorLetter / Size
string[] ChatColors = { "W", "E", "R", "O", "P", "A", "D", "G", "K", "Y", "C", "B", "N", "M", "BB", "RR" };
string[] ChatSizes = new string[31];
for (int i = 1; i <= 30; i++)
ChatSizes[i] = i.ToString();
string[] HTMLColors = { "#FFFFFF", "#00AC00", "#FF0000", "#FFC800", "#FFAFAF", "#808080", "#404040", "#00FF00", "#000000", "#FFFF00", "#00FFFF", "#0000FF", "#964A00", "#FF00FF", ColorTranslator.ToHtml(c.blue).Replace("#", ""), ColorTranslator.ToHtml(c.red).Replace("#", "") };
#region Check Colors
for (int i = 1; i <= 16; i++)
if (code == ChatColors[i - 1])
{
this.html = "<span style=\"color: " + HTMLColors[i - 1] + ";\">";
return;
}
#endregion
#region CheckFormatReset
if (code == "r")
{
this.html = "</span></b></i><span style=\"font-size:" + c.fontSize + "px; color: " + ColorTranslator.ToHtml(c.foreColor) + ";\">";
return;
}
#endregion
#region Check Points
if (code == "!")
{
this.html = "<span style=\"letter-spacing: 2px; color: " + ColorTranslator.ToHtml(c.foreColor) + "; font-size:7px;\">.........</span>";
return;
}
#endregion
#region Check Sizes
try
{
int.Parse(code);
this.html = "<span style=\"font-size:" + code + "px\">";
return;
}
catch { }
#endregion
#region Size&Color
try
{
string re1 = "(\\d+)"; // Integer Number 1
string re2 = "([a-z])"; // Any Single Character 1
string size = new Regex(re1, RegexOptions.IgnoreCase | RegexOptions.Singleline).Match(code).Groups[1].ToString();
string color = new Regex(re2, RegexOptions.IgnoreCase | RegexOptions.Singleline).Match(code).Groups[1].ToString();
for (int i = 1; i <= 16; i++)
if (color == ChatColors[i - 1])
color = HTMLColors[i - 1];
this.html = "<span style=\"font-size:" + size + "px; color: " + color + ";\">";
return;
}
catch (Exception ex) { MessageBox.Show(ex.ToString()); }
#endregion
this.html = code;
//Konnte nichts mit anfangen, also erstmal zurück,
//damit man sieht, wenn Fehler auftauchen.
}
#endregion
}
public int Id
{
get { return this.id; }
}
public string Code
{
get { return this.code; }
}
public string HTML
{
get { return this.html; }
}
}
Und wo füge ich jetzt dein Code bei VB ein?
Kapiere leider nicht wo. v.v
Gehe zu:
Tutorials
Nach oben
- Bereiche
- Benutzerkontrollzentrum
- Private Nachrichten
- Abonnements
- Wer ist online
- Foren durchsuchen
- Forum-Startseite
- Foren
- U-Labs Intern
- Talk, Talk, Talk!
- News-Bereich
- Multimedia
- Technikecke
- Programmierung
- Gaming Area
- Knuddels und die Szene
Ähnliche Themen
-
GFX Tutorial's Basic uvm.
Von Ricardo1337 im Forum TutorialsAntworten: 5Letzter Beitrag: 28.08.2013, 17:56 -
Chatverlauf faken
Von UnReal im Forum Fragen & ProblemeAntworten: 5Letzter Beitrag: 29.07.2013, 08:36 -
C++ Tutorial: Hello World
Von x failstar im Forum C++Antworten: 11Letzter Beitrag: 04.07.2012, 14:48 -
(.bat) Batch Tutorial
Von MC Phlegmatisch im Forum TutorialsAntworten: 0Letzter Beitrag: 31.03.2012, 13:35 -
[VB] - Chatverlauf farbig gestalten - Problem
Von Pyromane im Forum SourcecodeAntworten: 1Letzter Beitrag: 26.03.2012, 14:12
Diese Seite nutzt Cookies, um das Nutzererlebnis zu verbessern. Klicken Sie hier, um das Cookie-Tracking zu deaktivieren.
Alle Zeitangaben in WEZ +2. Es ist jetzt 05:30 Uhr.
Powered by vBulletin® - © Jelsoft Enterprises Ltd.