using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

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

        private void Form1_Load(object sender, EventArgs e)
        {
            formBackColorEditor.SelectedColor = BackColor;
            formForeColorEditor.SelectedColor = ForeColor;
            labelColorEditor.SelectedColor = demoLabel.ForeColor;
            formFontEditor.SelectedFont = Font;
            labelFontEditor.SelectedFont = demoLabel.Font;
        }

        private void formBackColorEditor_SelectedColorChanged(object sender, EventArgs e)
        {
            Color c = formBackColorEditor.SelectedColor;
            if (c != Color.Empty)
            {
                BackColor = c;
            }
        }

        private void formForeColorEditor_SelectedColorChanged(object sender, EventArgs e)
        {
            Color c = formForeColorEditor.SelectedColor;
            if (c != Color.Empty)
            {
                ForeColor = c;
            }
        }

        private void labelColorEditor_SelectedColorChanged(object sender, EventArgs e)
        {
            Color c = labelColorEditor.SelectedColor;
            if (c != Color.Empty)
            {
                demoLabel.ForeColor = c;
            }
        }

        private void formFontEditor_SelectedFontChanged(object sender, EventArgs e)
        {
            Font f = formFontEditor.SelectedFont;
            if (f != null)
            {
                Font = f;
            }
        }

        private void labelFontEditor_SelectedFontChanged(object sender, EventArgs e)
        {
            Font f = labelFontEditor.SelectedFont;
            if (f != null)
            {
                demoLabel.Font = f;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("OK button pressed.", "Accept Button");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Cancel button pressed.", "Cancel Button");
        }
    }
}