Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     UpdCur();
     int ba = Int32.Parse(curcolbdisp.Text);
     int fr = Int32.Parse(curcolfdisp.Text);
     try
     {
         for (int i = 0; i != cols.Count; i++)
         {
             if (cols[i].charno == input.SelectionStart && cols[i].background == checkBox1.Checked) cols.RemoveAt(i);
         }
     }
     catch { }
     foreach (ListViewItem sel in listView1.SelectedItems)
     {
         {   BashColour b = new BashColour(sel.Index, input.SelectionStart, checkBox1.Checked);
             cols.Add(b);
         }
     }
     if (input.SelectionLength > 0)
     {
         cols.Add(new BashColour(ba, input.SelectionLength + input.SelectionStart, true));
         cols.Add(new BashColour(fr, input.SelectionLength + input.SelectionStart, false));
     }
     Console.Clear();
     foreach (var item in cols)
     {
         if (Program.debug)
         Console.Write(item.code + " ");
         if (item.background)
         {
             if (Program.debug)
             Console.Write("background");
         }
         if (Program.debug)
         Console.Write(" col ");
         if (Program.debug)
         Console.WriteLine("at " +item.charno);
     }
     SetCols();
 }
Exemplo n.º 2
0
 public void ParseXML()
 {
     if (input.Text.StartsWith("<pre") && input.Text.EndsWith("</pre>"))
     {
         XmlDocument doc = new XmlDocument();
         doc.LoadXml(input.Text);
         input.Clear();
         XmlNodeList spans = doc.GetElementsByTagName("span");
         progressBar1.Maximum = spans.Count;
         progressBar1.Value = 0;
         int no = 0;
         foreach (XmlNode span in spans)
         {
             input.Text += span.InnerText;
             foreach (XmlAttribute attr in span.Attributes)
             {
                 Color c = System.Drawing.ColorTranslator.FromHtml(attr.Value.Substring(attr.Value.IndexOf("#"), 7));
                 BashColour b = new BashColour(BashColour.ClosestBash(c),no,true);
                 //Console.WriteLine(c.ToString()+" ==> "+b.ToColor());
                 cols.Add(b);
             }
             no+=span.InnerText.Length;
             progressBar1.Increment(no);
         }
         SetCols();
     }
 }