Using System; using System. collections. generic; using System. componentModel; using System. data; using System. drawing; using System. linq; using System. text; using System. threading. tasks; using System. windows. forms; namespace demo10 {public partial class Form1: Form {public Form1 () {InitializeComponent ();} private void button#click (object sender, EventArgs e) {this. openFileDialog1.InitialDirectory = @ "D: "; // Set the initial directory displayed in the file dialog box this. openFileDialog1.Filter = "bmp file (*. bmp) | *. bmp | gif file (*. gif) | *. gif | Jpeg file (*. jpg) | *. jpg "; // set the currently selected filter string to determine the" Document Type "option this in the dialog box. openFileDialog1.FilterIndex = 3; // the index of the currently selected filter in the Setting Dialog Box. this. openFileDialog1.RestoreDirectory = true; // close the dialog box and restore the current directory this. openFileDialog1.Title = "select image"; // set the dialog box title if (this. openFileDialog1.ShowDialog () = DialogResult. OK) {pictureBox1.SizeMode = PictureBox SizeMode. zoom; // The image is filled with a photo frame and maintains the proportion string strpath = this. openFileDialog1.FileName; // obtain the file path this. pictureBox1.Image = Image. fromFile (strpath); // load the image int index = strpath. lastIndexOf ("\"); // The Last backslash position in the path this. richTextBox1.Text = "file name:" + this. openFileDialog1.FileName. substring (index + 1); // display file name} private void button2_Click (object sender, EventArgs e) {if (this. pictureBox1.Image! = Null) {saveFileDialog1.Filter = "Jpeg image (*. jpg) | *. jpg | Bitmap image (*. bmp) | *. bmp | Gif image (*. gif) | *. gif "; saveFileDialog1.Title =" Save image "; // set the title of the dialog box saveFileDialog1.CreatePrompt = true; // if the specified file does not exist, the system prompts that saveFileDialog1.OverwritePrompt = true; // if the specified file name already exists, a warning is displayed: saveFileDialog1.ShowDialog (); // The save dialog box is displayed. if (saveFileDialog1.FileName! = "") {System. IO. fileStream fs = (System. IO. fileStream) saveFileDialog1.OpenFile (); switch (saveFileDialog1.FilterIndex) // select the file type to save {case 1: this. pictureBox1.Image. save (fs, System. drawing. imaging. imageFormat. jpeg); // save as a jpeg file break; case 2: this. pictureBox1.Image. save (fs, System. drawing. imaging. imageFormat. bmp); break; case 3: this. pictureBox1.Image. save (fs, System. drawing. imaging. imageFormat. gif); break;} fs. close (); // Close the file stream} else {MessageBox. show ("select the image to save");} private void button3_Click (object sender, EventArgs e) {this. colorDialog1.AllowFullOpen = true; // you can use this dialog box to define the custom color this. colorDialog1.AnyColor = true; // display all available colors in the Basic Color Set this. colorDialog1.FullOpen = true; // this is visible when a custom color control is created in the dialog box. colorDialog1.SolidColorOnly = false; // select solid color only. colorDialog1.ShowDialog (); // dialog box/* set the font color in richTextBox1 to the selected color */this. richTextBox1.ForeColor = this. colorDialog1.Color;} private void button4_Click (object sender, EventArgs e) {this. fontDialog1.AllowVerticalFonts = true; // The prompt dialog box displays both the vertical font and the horizontal font. fontDialog1.FixedPitchOnly = true; // only fixed-padding font can be selected. fontDialog1.ShowApply = true; // contains the application button this. fontDialog1.ShowEffects = true; // controls that allow you to specify the strikethrough, underline, and text color options this. fontDialog1.ShowDialog (); // the pop-up dialog box this. richTextBox1.Font = this. fontDialog1.Font; // set the font in richTextBox1 to the selected font} private void button5_Click (object sender, EventArgs e) {this. printDialog1.AllowCurrentPage = true; // display the current page this. printDialog1.AllowPrintToFile = true; // You can select to print to the file this. printDialog1.AllowSelection = true; // enable the select button this. printDialog1.AllowSomePages = true; // enable the "page" radio button this. printDialog1.Document = this. printDocument1; // specifies the PrintDocument object set this. printDialog1.PrinterSettings = this. printDocument1.PrinterSettings; // this is the default setting for the print page. printDialog1.PrintToFile = false; // do not select "print to file" this. printDialog1.ShowHelp = true; // display the "help" button this. printDialog1.ShowNetwork = true; // You can select a network printer if (this. printDialog1.ShowDialog () = DialogResult. OK) {this. printDocument1.Print ();} // print }}}