📜  backcolor app winform C3 - C# (1)

📅  最后修改于: 2023-12-03 15:29:34.210000             🧑  作者: Mango

Backcolor App Winform C3 - C#

Introduction

Backcolor is a Winforms application developed using C# that allows users to change the background color of the form. It's a simple yet powerful application that can be used as an example for beginners who are starting to learn about Winforms and C#.

The application uses a graphic user interface (GUI) that allows the user to select a color from a color picker and apply it to the form. The user can also save the color to a file and load it later.

Features
  • Change the background color of the Winforms application with a color picker
  • Save the selected color to a file and load it later
Installation

The Backcolor application is easy to install and use. Here are the steps:

  1. Download the Backcolor.zip file from the repository.
  2. Extract the files to a location on your computer.
  3. Open the .exe file to run the application.
Code

Here is the code for the Backcolor application:

using System;
using System.Drawing;
using System.Windows.Forms;

namespace Backcolor
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ColorDialog CD = new ColorDialog();
            if (CD.ShowDialog() == DialogResult.OK)
            {
                this.BackColor = CD.Color;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SaveFileDialog SFD = new SaveFileDialog();

            if (SFD.ShowDialog() == DialogResult.OK)
            {
                using (System.IO.StreamWriter sw = new System.IO.StreamWriter(SFD.FileName))
                {
                    sw.WriteLine(this.BackColor.ToArgb());
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            OpenFileDialog OFD = new OpenFileDialog();

            if (OFD.ShowDialog() == DialogResult.OK)
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(OFD.FileName))
                {
                    int i = int.Parse(sr.ReadLine());
                    this.BackColor = Color.FromArgb(i);
                }
            }
        }
    }
}
Conclusion

The Backcolor application is a simple yet useful Winforms application that can be used to learn about Winforms and C#. It's easy to install and use, and it's free and open source.