Click here to Skip to main content
15,881,248 members
Articles / Web Development / HTML

XML Data Files, XML Serialization, and .NET

Rate me:
Please Sign up or sign in to vote.
4.82/5 (28 votes)
27 Aug 200317 min read 337.9K   6.4K   130  
Describes a means to build XML data files using XML Schema and xsd.exe to facilitate easy XML Serialization
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace CardfileCE
{
	/// <summary>
	/// Summary description for Image.
	/// </summary>
	public class frmImage : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button cmdCancel;
		private System.Windows.Forms.Button cmdOK;
		private System.Windows.Forms.TextBox tbCardName;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.PictureBox pbImage;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.Label label2;
	
		public frmImage()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.cmdCancel = new System.Windows.Forms.Button();
			this.cmdOK = new System.Windows.Forms.Button();
			this.tbCardName = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.pbImage = new System.Windows.Forms.PictureBox();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			// 
			// cmdCancel
			// 
			this.cmdCancel.Location = new System.Drawing.Point(80, 241);
			this.cmdCancel.Text = "Cancel";
			this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
			// 
			// cmdOK
			// 
			this.cmdOK.Location = new System.Drawing.Point(160, 241);
			this.cmdOK.Text = "OK";
			this.cmdOK.Click += new System.EventHandler(this.cmdOK_Click);
			// 
			// tbCardName
			// 
			this.tbCardName.Location = new System.Drawing.Point(96, 9);
			this.tbCardName.Size = new System.Drawing.Size(136, 26);
			this.tbCardName.Text = "";
			this.tbCardName.TextChanged += new System.EventHandler(this.tbCardName_TextChanged);
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 9);
			this.label1.Size = new System.Drawing.Size(96, 20);
			this.label1.Text = "Card name:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 40);
			this.label2.Text = "Image:";
			// 
			// pbImage
			// 
			this.pbImage.Location = new System.Drawing.Point(8, 64);
			this.pbImage.Size = new System.Drawing.Size(224, 168);
			this.pbImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
			// 
			// frmImage
			// 
			this.Controls.Add(this.pbImage);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.cmdCancel);
			this.Controls.Add(this.cmdOK);
			this.Controls.Add(this.tbCardName);
			this.Controls.Add(this.label1);
			this.MaximizeBox = false;
			this.Menu = this.mainMenu1;
			this.MinimizeBox = false;
			this.Text = "Image";

		}
		#endregion

		public Bitmap Image
		{
			get { return (Bitmap)pbImage.Image; }
			set { pbImage.Image = value; }
		}

		public string CardName
		{
			get { return tbCardName.Text; }
			set
			{
				// Save the card name
				tbCardName.Text = value;

				// Retitle the form
				this.Text = value;
			}
		} 

		private void tbCardName_TextChanged(object sender, System.EventArgs e)
		{
			// The note name is changing, so update form title
			this.Text = tbCardName.Text;
		}

		private void cmdOK_Click(object sender, System.EventArgs e)
		{
			// Just quit...
			this.DialogResult = DialogResult.OK;
			this.Close();
		}

		private void cmdCancel_Click(object sender, System.EventArgs e)
		{
			// Just quit...
			this.DialogResult = DialogResult.Cancel;
			this.Close();
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions