using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace fileDialog
{
///
/// Summary description for Dialog.
///
public class Dialog : System.Windows.Forms.Form
{
private System.Windows.Forms.Button openFileButton;
private System.Windows.Forms.Button saveFileButton;
private System.Windows.Forms.Button fontDialogButton;
private System.Windows.Forms.Button colorDialogButton;
private System.Windows.Forms.FontDialog fontDialog;
private System.Windows.Forms.ColorDialog colorDialog;
private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.SaveFileDialog saveFileDialog;
private System.Windows.Forms.StatusBar statusBar;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Dialog()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.openFileButton = new System.Windows.Forms.Button();
this.saveFileButton = new System.Windows.Forms.Button();
this.fontDialogButton = new System.Windows.Forms.Button();
this.colorDialogButton = new System.Windows.Forms.Button();
this.fontDialog = new System.Windows.Forms.FontDialog();
this.colorDialog = new System.Windows.Forms.ColorDialog();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.statusBar = new System.Windows.Forms.StatusBar();
this.SuspendLayout();
//
// openFileButton
//
this.openFileButton.Location = new System.Drawing.Point(136, 24);
this.openFileButton.Name = "openFileButton";
this.openFileButton.Size = new System.Drawing.Size(96, 23);
this.openFileButton.TabIndex = 0;
this.openFileButton.Text = "open file dialog";
this.openFileButton.Click +=
new System.EventHandler(this.openFileButton_Click);
//
// saveFileButton
//
this.saveFileButton.Location = new System.Drawing.Point(136, 72);
this.saveFileButton.Name = "saveFileButton";
this.saveFileButton.Size = new System.Drawing.Size(96, 23);
this.saveFileButton.TabIndex = 1;
this.saveFileButton.Text = "save file dialog";
this.saveFileButton.Click +=
new System.EventHandler(this.saveFileButton_Click);
//
// fontDialogButton
//
this.fontDialogButton.Location = new System.Drawing.Point(16, 24);
this.fontDialogButton.Name = "fontDialogButton";
this.fontDialogButton.Size = new System.Drawing.Size(96, 23);
this.fontDialogButton.TabIndex = 2;
this.fontDialogButton.Text = "font dialog";
this.fontDialogButton.Click +=
new System.EventHandler(this.fontDialogButton_Click);
//
// colorDialogButton
//
this.colorDialogButton.Location = new System.Drawing.Point(16, 72);
this.colorDialogButton.Name = "colorDialogButton";
this.colorDialogButton.Size = new System.Drawing.Size(96, 23);
this.colorDialogButton.TabIndex = 3;
this.colorDialogButton.Text = "color dialog";
this.colorDialogButton.Click +=
new System.EventHandler(this.colorDialogButton_Click);
//
// openFileDialog
//
this.openFileDialog.Filter = "source | *.cpp; *.cc; *.c | header | *.h";
//
// saveFileDialog
//
this.saveFileDialog.FileName = "doc1";
//
// statusBar
//
this.statusBar.Location = new System.Drawing.Point(0, 127);
this.statusBar.Name = "statusBar";
this.statusBar.Size = new System.Drawing.Size(248, 22);
this.statusBar.TabIndex = 4;
this.statusBar.Text = "show result";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(248, 149);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.statusBar,
this.colorDialogButton,
this.fontDialogButton,
this.saveFileButton,
this.openFileButton });
this.Name = "Form1";
this.Text = "Dialogs";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Dialog());
}
private void fontDialogButton_Click(object sender, System.EventArgs e) {
DialogResult dr = fontDialog.ShowDialog();
if (dr == DialogResult.OK) statusBar.Text = fontDialog.Font.ToString();
}
private void colorDialogButton_Click(object sender, System.EventArgs e) {
DialogResult dr = colorDialog.ShowDialog();
if (dr == DialogResult.OK) statusBar.Text = colorDialog.Color.ToString(); }
private void openFileButton_Click(object sender, System.EventArgs e) {
DialogResult dr = openFileDialog.ShowDialog();
if (dr == DialogResult.OK) statusBar.Text = openFileDialog.FileName;
}
private void saveFileButton_Click(object sender, System.EventArgs e) {
DialogResult dr = saveFileDialog.ShowDialog();
if (dr == DialogResult.OK) statusBar.Text = saveFileDialog.FileName;
}
}
}