private void SetLinksInCtrlRTF(string str)
 {
     System.Text.StringBuilder stringBuilder        = new System.Text.StringBuilder("");
     System.Collections.Generic.List <string> list1 = new System.Collections.Generic.List <string>();
     System.Collections.Generic.List <string> list2 = new System.Collections.Generic.List <string>();
     System.Collections.Generic.List <int>    list  = new System.Collections.Generic.List <int>();
     while (true)
     {
         System.GC.Collect();
         int i1 = str.IndexOf(Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkStartOpener);
         if (i1 <= 0)
         {
             stringBuilder.Append(str);
             break;
         }
         stringBuilder.Append(str.Substring(0, i1 - 1));
         string s1 = ExtractId(ParseOutRTFCode(str.Substring(i1 + Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkStartOpener.Length, str.IndexOf(Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkStartCloser) - i1 - Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkStartOpener.Length))).Trim();
         Oranikle.Studio.Controls.CtrlRichTextbox.log.Debug("Id = '" + s1 + "'");
         string s2 = ParseOutRTFCode(str.Substring(str.IndexOf(Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkStartCloser) + Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkStartCloser.Length, str.IndexOf(Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkEnd) - str.IndexOf(Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkStartCloser) - Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkStartCloser.Length)).Replace("\r", "").Replace("\n", "").Trim();
         Oranikle.Studio.Controls.CtrlRichTextbox.log.Debug("linkStr = '" + s2 + "'");
         list1.Add(s1);
         list2.Add(s2);
         using (Oranikle.Studio.Controls.RichTextBoxEx richTextBoxEx = new Oranikle.Studio.Controls.RichTextBoxEx())
         {
             richTextBoxEx.Rtf = stringBuilder.ToString();
             list.Add(richTextBoxEx.Text.Length);
         }
         str = str.Substring(str.IndexOf(Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkEnd) + Oranikle.Studio.Controls.CtrlRichTextbox.RTFLinkEnd.Length);
     }
     ctrlRtf.Rtf = "";
     ctrlRtf.Rtf = stringBuilder.ToString();
     for (int i2 = list1.Count - 1; i2 >= 0; i2--)
     {
         ctrlRtf.InsertLink(list2[i2], list1[i2], list[i2]);
     }
 }
 private void InitializeComponent()
 {
     components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager componentResourceManager = new System.ComponentModel.ComponentResourceManager(typeof(Oranikle.Studio.Controls.CtrlRichTextbox));
     toolStrip1           = new System.Windows.Forms.ToolStrip();
     bttnFont             = new System.Windows.Forms.ToolStripButton();
     bttnColour           = new System.Windows.Forms.ToolStripButton();
     bttnBackgroundColour = new System.Windows.Forms.ToolStripButton();
     toolStripSeparator2  = new System.Windows.Forms.ToolStripSeparator();
     bttnBold             = new System.Windows.Forms.ToolStripButton();
     bttnItalic           = new System.Windows.Forms.ToolStripButton();
     bttnUnderline        = new System.Windows.Forms.ToolStripButton();
     toolStripSeparator1  = new System.Windows.Forms.ToolStripSeparator();
     bttnLeftAlign        = new System.Windows.Forms.ToolStripButton();
     bttnCentreAlign      = new System.Windows.Forms.ToolStripButton();
     bttnRightAlign       = new System.Windows.Forms.ToolStripButton();
     ctrlRtf                    = new Oranikle.Studio.Controls.RichTextBoxEx();
     contextMenuStrip1          = new System.Windows.Forms.ContextMenuStrip(components);
     boldToolStripMenuItem      = new System.Windows.Forms.ToolStripMenuItem();
     italicToolStripMenuItem    = new System.Windows.Forms.ToolStripMenuItem();
     underlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     toolStripSeparator5        = new System.Windows.Forms.ToolStripSeparator();
     cutToolStripMenuItem       = new System.Windows.Forms.ToolStripMenuItem();
     copyToolStripMenuItem      = new System.Windows.Forms.ToolStripMenuItem();
     pasteToolStripMenuItem     = new System.Windows.Forms.ToolStripMenuItem();
     fontDialog1                = new System.Windows.Forms.FontDialog();
     colorDialog1               = new System.Windows.Forms.ColorDialog();
     toolStrip1.SuspendLayout();
     contextMenuStrip1.SuspendLayout();
     SuspendLayout();
     toolStrip1.BackColor = System.Drawing.Color.Transparent;
     toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
     System.Windows.Forms.ToolStripItem[] toolStripItemArr1 = new System.Windows.Forms.ToolStripItem[] {
         bttnBold,
         bttnItalic,
         bttnUnderline,
         toolStripSeparator1,
         bttnLeftAlign,
         bttnCentreAlign,
         bttnRightAlign,
         toolStripSeparator2,
         bttnFont,
         bttnColour,
         bttnBackgroundColour
     };
     toolStrip1.Items.AddRange(toolStripItemArr1);
     toolStrip1.Location            = new System.Drawing.Point(0, 0);
     toolStrip1.Name                = "toolStrip1";
     toolStrip1.RenderMode          = System.Windows.Forms.ToolStripRenderMode.System;
     toolStrip1.Size                = new System.Drawing.Size(460, 25);
     toolStrip1.TabIndex            = 0;
     toolStrip1.Text                = "toolStrip1";
     bttnFont.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     bttnFont.Image                 = Oranikle.Studio.Controls.Properties.Resources.Icon_Font_16;
     bttnFont.ImageTransparentColor = System.Drawing.Color.White;
     bttnFont.Name                              = "bttnFont";
     bttnFont.Size                              = new System.Drawing.Size(23, 22);
     bttnFont.Text                              = "toolStripButton4";
     bttnFont.ToolTipText                       = "Font";
     bttnFont.Click                            += new System.EventHandler(bttnFont_Click);
     bttnColour.DisplayStyle                    = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     bttnColour.Image                           = Oranikle.Studio.Controls.Properties.Resources.Icon_Color_16;
     bttnColour.ImageTransparentColor           = System.Drawing.Color.White;
     bttnColour.Name                            = "bttnColour";
     bttnColour.Size                            = new System.Drawing.Size(23, 22);
     bttnColour.Text                            = "toolStripButton5";
     bttnColour.ToolTipText                     = "Colour";
     bttnColour.Click                          += new System.EventHandler(bttnColour_Click);
     bttnBackgroundColour.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     bttnBackgroundColour.Image                 = Oranikle.Studio.Controls.Properties.Resources.Icon_FontColor_16;
     bttnBackgroundColour.ImageTransparentColor = System.Drawing.Color.Magenta;
     bttnBackgroundColour.Name                  = "bttnBackgroundColour";
     bttnBackgroundColour.Size                  = new System.Drawing.Size(23, 22);
     bttnBackgroundColour.Text                  = "toolStripButton1";
     bttnBackgroundColour.ToolTipText           = "Background Colour";
     bttnBackgroundColour.Click                += new System.EventHandler(bttnBackgroundColour_Click);
     toolStripSeparator2.Name                   = "toolStripSeparator2";
     toolStripSeparator2.Size                   = new System.Drawing.Size(6, 25);
     bttnBold.DisplayStyle                      = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
     bttnBold.Font                              = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
     bttnBold.Image                             = (System.Drawing.Image)componentResourceManager.GetObject("bttnBold.Image");
     bttnBold.ImageTransparentColor             = System.Drawing.Color.Magenta;
     bttnBold.Name                              = "bttnBold";
     bttnBold.Size                              = new System.Drawing.Size(23, 22);
     bttnBold.Text                              = "B";
     bttnBold.ToolTipText                       = "Bold";
     bttnBold.Click                            += new System.EventHandler(bttnBold_Click);
     bttnItalic.DisplayStyle                    = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
     bttnItalic.Font                            = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, 0);
     bttnItalic.Image                           = (System.Drawing.Image)componentResourceManager.GetObject("bttnItalic.Image");
     bttnItalic.ImageTransparentColor           = System.Drawing.Color.Magenta;
     bttnItalic.Name                            = "bttnItalic";
     bttnItalic.Size                            = new System.Drawing.Size(23, 22);
     bttnItalic.Text                            = "I";
     bttnItalic.ToolTipText                     = "Italic";
     bttnItalic.Click                          += new System.EventHandler(bttnItalic_Click);
     bttnUnderline.BackColor                    = System.Drawing.Color.Transparent;
     bttnUnderline.DisplayStyle                 = System.Windows.Forms.ToolStripItemDisplayStyle.Text;
     bttnUnderline.Font                         = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, 0);
     bttnUnderline.Image                        = (System.Drawing.Image)componentResourceManager.GetObject("bttnUnderline.Image");
     bttnUnderline.ImageTransparentColor        = System.Drawing.Color.Magenta;
     bttnUnderline.Name                         = "bttnUnderline";
     bttnUnderline.Size                         = new System.Drawing.Size(23, 22);
     bttnUnderline.Text                         = "U";
     bttnUnderline.ToolTipText                  = "Underline";
     bttnUnderline.Click                       += new System.EventHandler(bttnUnderline_Click);
     toolStripSeparator1.Name                   = "toolStripSeparator1";
     toolStripSeparator1.Size                   = new System.Drawing.Size(6, 25);
     bttnLeftAlign.DisplayStyle                 = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     bttnLeftAlign.Image                        = Oranikle.Studio.Controls.Properties.Resources.Icon_AlignMiddleLeft_16;
     bttnLeftAlign.ImageTransparentColor        = System.Drawing.Color.Black;
     bttnLeftAlign.Name                         = "bttnLeftAlign";
     bttnLeftAlign.Size                         = new System.Drawing.Size(23, 22);
     bttnLeftAlign.Text                         = "toolStripButton1";
     bttnLeftAlign.ToolTipText                  = "Align Left";
     bttnLeftAlign.Click                       += new System.EventHandler(bttnLeftAlign_Click);
     bttnCentreAlign.DisplayStyle               = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     bttnCentreAlign.Image                      = Oranikle.Studio.Controls.Properties.Resources.Icon_AlignMiddleCenter_16;
     bttnCentreAlign.ImageTransparentColor      = System.Drawing.Color.Black;
     bttnCentreAlign.Name                       = "bttnCentreAlign";
     bttnCentreAlign.Size                       = new System.Drawing.Size(23, 22);
     bttnCentreAlign.Text                       = "toolStripButton2";
     bttnCentreAlign.ToolTipText                = "Align Center";
     bttnCentreAlign.Click                     += new System.EventHandler(bttnCentreAlign_Click);
     bttnRightAlign.DisplayStyle                = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     bttnRightAlign.Image                       = Oranikle.Studio.Controls.Properties.Resources.Icon_AlignMiddleRight_16;
     bttnRightAlign.ImageTransparentColor       = System.Drawing.Color.Black;
     bttnRightAlign.Name                        = "bttnRightAlign";
     bttnRightAlign.Size                        = new System.Drawing.Size(23, 22);
     bttnRightAlign.Text                        = "toolStripButton3";
     bttnRightAlign.ToolTipText                 = "Align Right";
     bttnRightAlign.Click                      += new System.EventHandler(bttnRightAlign_Click);
     ctrlRtf.ContextMenuStrip                   = contextMenuStrip1;
     ctrlRtf.Dock     = System.Windows.Forms.DockStyle.Fill;
     ctrlRtf.Location = new System.Drawing.Point(0, 25);
     ctrlRtf.Name     = "ctrlRtf";
     ctrlRtf.Size     = new System.Drawing.Size(460, 227);
     ctrlRtf.TabIndex = 1;
     ctrlRtf.Text     = "";
     System.Windows.Forms.ToolStripItem[] toolStripItemArr2 = new System.Windows.Forms.ToolStripItem[] {
         boldToolStripMenuItem,
         italicToolStripMenuItem,
         underlineToolStripMenuItem,
         toolStripSeparator5,
         cutToolStripMenuItem,
         copyToolStripMenuItem,
         pasteToolStripMenuItem
     };
     contextMenuStrip1.Items.AddRange(toolStripItemArr2);
     contextMenuStrip1.Name                  = "contextMenuStrip1";
     contextMenuStrip1.Size                  = new System.Drawing.Size(159, 142);
     boldToolStripMenuItem.Name              = "boldToolStripMenuItem";
     boldToolStripMenuItem.ShortcutKeys      = System.Windows.Forms.Keys.RButton | System.Windows.Forms.Keys.Control;
     boldToolStripMenuItem.Size              = new System.Drawing.Size(158, 22);
     boldToolStripMenuItem.Text              = "Bold";
     boldToolStripMenuItem.Click            += new System.EventHandler(boldToolStripMenuItem_Click);
     italicToolStripMenuItem.Name            = "italicToolStripMenuItem";
     italicToolStripMenuItem.ShortcutKeys    = System.Windows.Forms.Keys.LButton | System.Windows.Forms.Keys.Back | System.Windows.Forms.Keys.Control;
     italicToolStripMenuItem.Size            = new System.Drawing.Size(158, 22);
     italicToolStripMenuItem.Text            = "Italic";
     italicToolStripMenuItem.Click          += new System.EventHandler(italicToolStripMenuItem_Click);
     underlineToolStripMenuItem.Name         = "underlineToolStripMenuItem";
     underlineToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.LButton | System.Windows.Forms.Keys.MButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Control;
     underlineToolStripMenuItem.Size         = new System.Drawing.Size(158, 22);
     underlineToolStripMenuItem.Text         = "Underline";
     underlineToolStripMenuItem.Click       += new System.EventHandler(underlineToolStripMenuItem_Click);
     toolStripSeparator5.Name                = "toolStripSeparator5";
     toolStripSeparator5.Size                = new System.Drawing.Size(155, 6);
     cutToolStripMenuItem.Name               = "cutToolStripMenuItem";
     cutToolStripMenuItem.ShortcutKeys       = System.Windows.Forms.Keys.Back | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Control;
     cutToolStripMenuItem.Size               = new System.Drawing.Size(158, 22);
     cutToolStripMenuItem.Text               = "Cut";
     cutToolStripMenuItem.Click             += new System.EventHandler(cutToolStripMenuItem_Click);
     copyToolStripMenuItem.Name              = "copyToolStripMenuItem";
     copyToolStripMenuItem.ShortcutKeys      = System.Windows.Forms.Keys.LButton | System.Windows.Forms.Keys.RButton | System.Windows.Forms.Keys.Control;
     copyToolStripMenuItem.Size              = new System.Drawing.Size(158, 22);
     copyToolStripMenuItem.Text              = "Copy";
     copyToolStripMenuItem.Click            += new System.EventHandler(copyToolStripMenuItem_Click);
     pasteToolStripMenuItem.Name             = "pasteToolStripMenuItem";
     pasteToolStripMenuItem.ShortcutKeys     = System.Windows.Forms.Keys.RButton | System.Windows.Forms.Keys.MButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Control;
     pasteToolStripMenuItem.Size             = new System.Drawing.Size(158, 22);
     pasteToolStripMenuItem.Text             = "Paste";
     pasteToolStripMenuItem.Click           += new System.EventHandler(pasteToolStripMenuItem_Click);
     AutoScaleMode  = System.Windows.Forms.AutoScaleMode.None;
     base.BackColor = System.Drawing.Color.Transparent;
     Controls.Add(ctrlRtf);
     Controls.Add(toolStrip1);
     Name = "CtrlRichTextbox";
     Size = new System.Drawing.Size(460, 252);
     toolStrip1.ResumeLayout(false);
     toolStrip1.PerformLayout();
     contextMenuStrip1.ResumeLayout(false);
     ResumeLayout(false);
     PerformLayout();
 }
 public CtrlRichTextbox()
 {
     _showToolbar = true;
     rtbTemp      = new Oranikle.Studio.Controls.RichTextBoxEx();
     InitializeComponent();
 }