|
using System;
using System.Windows.Forms;
using System.IO;
using System.Text;
using System.Collections;
using System.Drawing;
namespace AV.UI.Controls
{
/// <summary>
/// Summary description for CSSClassViewer.
/// </summary>
public class CSSClassViewer : Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.TextBox txtValues;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox lstCSSCollection;
private string m_FileContent;
private Hashtable m_ConfigValues;
private string m_FileName;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private string m_CSSName;
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.txtValues = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.lstCSSCollection = new System.Windows.Forms.ListBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(64)), ((System.Byte)(64)));
this.label1.Location = new System.Drawing.Point(32, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(136, 23);
this.label1.TabIndex = 1;
this.label1.Text = "List Of CSS Classes";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// panel1
//
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Controls.Add(this.txtValues);
this.panel1.Location = new System.Drawing.Point(280, 40);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(256, 212);
this.panel1.TabIndex = 2;
//
// txtValues
//
this.txtValues.Location = new System.Drawing.Point(24, 16);
this.txtValues.Multiline = true;
this.txtValues.Name = "txtValues";
this.txtValues.ReadOnly = true;
this.txtValues.Size = new System.Drawing.Size(208, 176);
this.txtValues.TabIndex = 0;
this.txtValues.Text = "";
//
// label2
//
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(64)), ((System.Byte)(64)));
this.label2.Location = new System.Drawing.Point(280, 8);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(136, 23);
this.label2.TabIndex = 3;
this.label2.Text = "Configuration";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lstCSSCollection
//
this.lstCSSCollection.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.lstCSSCollection.ForeColor = System.Drawing.SystemColors.Highlight;
this.lstCSSCollection.ItemHeight = 14;
this.lstCSSCollection.Location = new System.Drawing.Point(32, 40);
this.lstCSSCollection.Name = "lstCSSCollection";
this.lstCSSCollection.Size = new System.Drawing.Size(240, 214);
this.lstCSSCollection.TabIndex = 4;
this.lstCSSCollection.DoubleClick += new System.EventHandler(this.lstCSSCollection_DoubleClick);
this.lstCSSCollection.SelectedIndexChanged += new System.EventHandler(this.lstCSSCollection_SelectedIndexChanged);
//
// button1
//
this.button1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.button1.Location = new System.Drawing.Point(192, 272);
this.button1.Name = "button1";
this.button1.TabIndex = 5;
this.button1.Text = "SET";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold);
this.button2.Location = new System.Drawing.Point(288, 272);
this.button2.Name = "button2";
this.button2.TabIndex = 6;
this.button2.Text = "Close";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// CSSClassViewer
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(552, 309);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.lstCSSCollection);
this.Controls.Add(this.label2);
this.Controls.Add(this.panel1);
this.Controls.Add(this.label1);
this.Name = "CSSClassViewer";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Load += new System.EventHandler(this.CSSClassViewer_Load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
public CSSClassViewer(string fileName)
{
InitializeComponent();
this.FileName = fileName;
}
public string CSSName
{
get { return m_CSSName; }
set { m_CSSName = value; }
}
public string FileName
{
get { return m_FileName; }
set { m_FileName = value; }
}
[STAThread]
static void Main()
{
Application.Run(new CSSClassViewer(""));
}
private void CSSClassViewer_Load(object sender, System.EventArgs e)
{
m_ConfigValues = new Hashtable();
if(this.FileName == "")
{
this.Close();
}
ReadCSSFile();
lstCSSCollection.SelectedIndex = 0;
lstCSSCollection.Focus();
}
private void ReadCSSFile()
{
using(StreamReader reader = new StreamReader(this.FileName))
{
m_FileContent = reader.ReadToEnd();
long length = m_FileContent.Length;
int index = 0;
int nextIndex = 0;
int nextNewLineIndex = 0;
string strCSSName;
while(index < length && index > -1)
{
index = m_FileContent.IndexOf(".",index);
if(index == -1)
break;
nextIndex = m_FileContent.IndexOf("{",index);
nextNewLineIndex = m_FileContent.IndexOf("\n",index);
if(nextNewLineIndex < nextIndex)
nextIndex = nextNewLineIndex;
else
nextNewLineIndex = nextIndex;
strCSSName = m_FileContent.Substring(index+1,nextIndex-index-2);
lstCSSCollection.Items.Add(strCSSName);
index = m_FileContent.IndexOf("}",nextIndex);
try
{
m_ConfigValues.Add(strCSSName,m_FileContent.Substring(nextNewLineIndex+1,index-nextNewLineIndex));
}
catch(Exception ex)
{
}
}
}
}
private void lstCSSCollection_SelectedIndexChanged(object sender, System.EventArgs e)
{
string strCSSName = lstCSSCollection.SelectedItem.ToString();
txtValues.Text = m_ConfigValues[strCSSName].ToString();
this.CSSName = strCSSName;
}
private void lstCSSCollection_DoubleClick(object sender, System.EventArgs e)
{
this.CSSName = lstCSSCollection.SelectedItem.ToString();
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, System.EventArgs e)
{
this.CSSName = "";
this.Close();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am working as Senior Software Designer and Developer for last 3.5 years. I like reading tech articles and writing them, mainly .Net stuff.
I completed MCAD, MCSD.Net, MCSE-Win2k, MCDBA.