예제 #1
0
 public static int GetContentID(ChatLink link)
 {
     try
     {
         int index = link.Url.IndexOf('\x0003');
         if (index < 0)
         {
             return int.Parse(link.Url);
         }
         return int.Parse(link.Url.Substring(0, index));
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         return -1;
     }
 }
예제 #2
0
 public static string GetCharSequence(ChatLink link)
 {
     try
     {
         char ch = '\x0003';
         if (link.Url.Contains(ch.ToString()))
         {
             return link.Url.Split(new char[] { '\x0003' })[1];
         }
         return null;
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
         return null;
     }
 }
예제 #3
0
 internal ChatLink(ChatLink prototype)
 {
     this.Prototype = null;
     this.mLinkWord = null;
     this.mIsRegEx = false;
     this.mLinkColor = new Color();
     this.mLinkFont = null;
     this.mEffect = null;
     this.WhiteSpaceChar = '\0';
     this.mShowLinkUrl = true;
     this.mUrl = null;
     this.mStartIndex = -1;
     this.mEndIndex = -1;
     this.mLinkWord = prototype.LinkWord;
     this.mIsRegEx = prototype.IsRegEx;
     this.mLinkColor = prototype.mLinkColor;
     this.mLinkFont = prototype.LinkFont;
     this.mEffect = prototype.Effect;
     this.Prototype = prototype;
 }
예제 #4
0
 private static ChatLink[] FindLinksWord(string text, ChatLink link)
 {
     List<ChatLink> list = new List<ChatLink>();
     try
     {
         int index = text.IndexOf(link.LinkWord);
         while (index >= 0)
         {
             ChatLink item = new ChatLink(link);
             int startIndex = index + link.LinkWord.Length;
             int length = -1;
             if (text.Length > startIndex)
             {
                 string str;
                 if (text[startIndex] == '"')
                 {
                     item.WhiteSpaceChar = '"';
                     length = text.IndexOf('"', startIndex + 1);
                     str = text.Substring(startIndex + 1, length - (startIndex + 1));
                 }
                 else if (text[startIndex] == '\'')
                 {
                     item.WhiteSpaceChar = '\'';
                     length = text.IndexOf('\'', startIndex + 1);
                     str = text.Substring(startIndex + 1, length - (startIndex + 1));
                 }
                 else
                 {
                     length = text.IndexOf(' ', startIndex + 1);
                     if (length < 0)
                     {
                         length = text.Length;
                     }
                     str = text.Substring(startIndex, length - startIndex);
                 }
                 item.Url = str;
                 item.StartIndex = startIndex - link.LinkWord.Length;
                 item.EndIndex = length;
                 list.Add(item);
                 index = text.IndexOf(link.LinkWord, length);
             }
             else
             {
                 index = -1;
             }
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
     return list.ToArray();
 }
예제 #5
0
 private void OnClick(ChatLink link)
 {
     if (this.Click != null)
     {
         this.Click(link, link.Url);
     }
 }
예제 #6
0
 private static ChatLink[] FindLinksRegEx(string text, ChatLink link)
 {
     List<ChatLink> list = new List<ChatLink>();
     try
     {
         MatchCollection matchs = new Regex(link.LinkWord).Matches(text);
         foreach (Match match in matchs)
         {
             if (match.Success)
             {
                 ChatLink item = new ChatLink(link);
                 item.StartIndex = match.Index;
                 item.EndIndex = item.StartIndex + match.Length;
                 item.Url = match.Value;
                 list.Add(item);
             }
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
     return list.ToArray();
 }
예제 #7
0
 public static ChatLink[] FindLinks(string text, ChatLink linkType)
 {
     if (text == null)
     {
         return new ChatLink[0];
     }
     List<ChatLink> list = new List<ChatLink>();
     foreach (ChatLink link in All.Values)
     {
         if ((linkType == null) || link.Equals(linkType))
         {
             if (link.IsRegEx)
             {
                 list.AddRange(FindLinksRegEx(text, link));
             }
             else
             {
                 list.AddRange(FindLinksWord(text, link));
             }
         }
     }
     return list.ToArray();
 }
예제 #8
0
 public static Dictionary<int, ChatLink> CreateCharacterIndex(ChatLink[] links)
 {
     Dictionary<int, ChatLink> dictionary = new Dictionary<int, ChatLink>(links.Length);
     for (int i = 0; i < links.Length; i++)
     {
         dictionary.Add(links[i].StartIndex, links[i]);
     }
     return dictionary;
 }
예제 #9
0
 public ChatLink(string word, bool isRegEx, Color color, Font font, ITextEffect effect)
 {
     this.Prototype = null;
     this.mLinkWord = null;
     this.mIsRegEx = false;
     this.mLinkColor = new Color();
     this.mLinkFont = null;
     this.mEffect = null;
     this.WhiteSpaceChar = '\0';
     this.mShowLinkUrl = true;
     this.mUrl = null;
     this.mStartIndex = -1;
     this.mEndIndex = -1;
     this.mLinkWord = word;
     this.mIsRegEx = isRegEx;
     this.mLinkColor = color;
     this.mLinkFont = font;
     this.mEffect = effect;
 }
예제 #10
0
 private void wbWelcome_Navigating(object sender, WebBrowserNavigatingEventArgs e)
 {
     try
     {
         string str = e.Url.Segments[e.Url.Segments.Length - 1];
         string str2 = e.Url.ToString();
         if (!this.CanNavigate)
         {
             if ((str == "chat") || (str.IndexOf("mi") == 0))
             {
                 e.Cancel = true;
             }
         }
         else
         {
             e.Cancel = true;
             if (str == "chat")
             {
                 this.JoinChat();
             }
             else
             {
                 ChatLink link;
                 if (str2.IndexOf("player:") >= 0)
                 {
                     link = new ChatLink(ChatLink.Player);
                     link.Url = str2.Replace("player:", "");
                     link.OnClick();
                 }
                 else if (str2.IndexOf("content:") >= 0)
                 {
                     link = new ChatLink(ChatLink.Content);
                     link.Url = str2.Replace("content:", "");
                     link.OnClick();
                 }
                 else if (str2.IndexOf("replay:") >= 0)
                 {
                     link = new ChatLink(ChatLink.Replay);
                     link.Url = str2.Replace("replay:", "");
                     link.OnClick();
                 }
                 else if (this.OnWebLinkClick != null)
                 {
                     e.Cancel = this.OnWebLinkClick(e.Url.ToString(), e);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         ErrorLog.WriteLine(exception);
     }
 }