Esempio n. 1
0
        private void использоватьНастройкиВСледующиеРазыToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Customised customised = new Customised();

            if (BackColor == SystemColors.Control)
            {
                customised.Theme = "white";
            }
            if (BackColor == SystemColors.WindowFrame)
            {
                customised.Theme = "grey";
            }
            if (BackColor == SystemColors.Desktop)
            {
                customised.Theme = "black";
            }
            customised.ListViewColor = listView1.BackColor;
            customised.TextColor     = listView1.ForeColor;
            if (listView1.View == View.Tile)
            {
                customised.view = "Tile";
            }
            if (listView1.View == View.List)
            {
                customised.view = "List";
            }
            if (listView1.View == View.SmallIcon)
            {
                customised.view = "Small";
            }
            if (listView1.View == View.LargeIcon)
            {
                customised.view = "Large";
            }
            customised.Font = listView1.Font;
            XmlSerializer xml = new XmlSerializer(customised.GetType());
            FileStream    f   = new FileStream("text.xml", FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);

            xml.Serialize(f, customised);
            f.Close();
        }
Esempio n. 2
0
 public Form1()
 {
     InitializeComponent();
     try
     {
         XmlSerializer xml        = new XmlSerializer(typeof(Customised));
         FileStream    f          = new FileStream("text.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
         Customised    customised = xml.Deserialize(f) as Customised;
         if (customised.Theme == "white")
         {
             BackColor            = SystemColors.Window;
             ForeColor            = SystemColors.WindowText;
             menuStrip1.BackColor = SystemColors.Window;
             listView1.BackColor  = SystemColors.Window;
             listView1.ForeColor  = SystemColors.WindowText;
             textBox1.BackColor   = SystemColors.Window;
             textBox1.ForeColor   = SystemColors.WindowText;
             menuStrip1.ForeColor = SystemColors.WindowText;
         }
         if (customised.Theme == "grey")
         {
             BackColor            = SystemColors.WindowFrame;
             ForeColor            = SystemColors.Control;
             menuStrip1.BackColor = SystemColors.ControlDark;
             listView1.BackColor  = SystemColors.ControlDark;
             listView1.ForeColor  = SystemColors.Control;
             textBox1.BackColor   = SystemColors.ControlDark;
             textBox1.ForeColor   = SystemColors.Control;
             menuStrip1.ForeColor = SystemColors.Control;
         }
         if (customised.Theme == "black")
         {
             BackColor            = SystemColors.Desktop;
             ForeColor            = SystemColors.Control;
             menuStrip1.BackColor = SystemColors.WindowFrame;
             listView1.BackColor  = SystemColors.WindowFrame;
             listView1.ForeColor  = SystemColors.Control;
             textBox1.BackColor   = SystemColors.WindowFrame;
             textBox1.ForeColor   = SystemColors.Control;
             menuStrip1.ForeColor = SystemColors.Control;
         }
         listView1.BackColor = customised.ListViewColor;
         listView1.ForeColor = customised.TextColor;
         listView1.Font      = customised.Font;
         if (customised.view == "Tile")
         {
             listView1.View = View.Tile;
         }
         if (customised.view == "List")
         {
             listView1.View = View.List;
         }
         if (customised.view == "Small")
         {
             listView1.View = View.SmallIcon;
         }
         if (customised.view == "Large")
         {
             listView1.View = View.LargeIcon;
         }
         f.Close();
     }
     catch
     {
     }
 }