Index: trunk/MacFaceFloat/MainForm.cs
===================================================================
--- trunk/MacFaceFloat/MainForm.cs	(revision 10)
+++ trunk/MacFaceFloat/MainForm.cs	(revision 13)
@@ -17,5 +17,5 @@
 using System.Threading;
 
-namespace MacFace
+namespace MacFace.FloatApp
 {
 	public class MainForm : Misuzilla.Windows.Forms.AlphaForm
@@ -23,9 +23,11 @@
 		private System.Windows.Forms.ContextMenu contextMenu;
 		private System.Windows.Forms.MenuItem menuItemPatternSelect;
+		private System.Windows.Forms.MenuItem menuItemConfigure;
 		private System.Windows.Forms.MenuItem menuItemExit;
-		private Hashtable _property;
-		private ArrayList _parts;
 		private String _facePath;
 		private System.Windows.Forms.Timer _updateTimer;
+
+		private FaceDef _currentFaceDef;
+		private Configuration _config;
 		
 		Int32 prevUsage;
@@ -62,8 +64,7 @@
 		}
 
-		// THIS METHOD IS MAINTAINED BY THE FORM DESIGNER
-		// DO NOT EDIT IT MANUALLY! YOUR CHANGES ARE LIKELY TO BE LOST
 		void InitializeComponent() {
 			this.menuItemPatternSelect = new System.Windows.Forms.MenuItem();
+			this.menuItemConfigure = new System.Windows.Forms.MenuItem();
 			this.menuItemExit = new System.Windows.Forms.MenuItem();
 			this.contextMenu = new System.Windows.Forms.ContextMenu();
@@ -71,8 +72,12 @@
 			// menuItemPatternSelect
 			// 
-			this.menuItemPatternSelect.Index = 0;
 			this.menuItemPatternSelect.Text = "çp^[ÌIð(&S)";
-			this.menuItemPatternSelect.Click += new System.EventHandler(this.PatternSelect_Click);
-
+			this.menuItemPatternSelect.Click += new System.EventHandler(this.menuItemPatternSelect_Click);
+
+			// 
+			// menuItemConfigure
+			// 
+			this.menuItemConfigure.Text = "MacFace ÌÝè(&C)...";
+			this.menuItemConfigure.Click +=new EventHandler(menuItemConfigure_Click);
 			// 
 			// menuItemExit
@@ -81,10 +86,10 @@
 			this.menuItemExit.Shortcut = System.Windows.Forms.Shortcut.CtrlQ;
 			this.menuItemExit.Text = "I¹(&X)";
-			this.menuItemExit.Click += new System.EventHandler(this.doQuit);
+			this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
 			// 
 			// contextMenu
 			// 
 			this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
-						this.menuItemPatternSelect, new MenuItem("-"), this.menuItemExit});
+						this.menuItemPatternSelect, this.menuItemConfigure, new MenuItem("-"), this.menuItemExit});
 			// 
 			// MainForm
@@ -102,4 +107,6 @@
 			this.TopMost = true;
 			this.Load += new EventHandler(MainForm_Load);
+			this.Closing += new CancelEventHandler(MainForm_Closing);
+			this.Move += new EventHandler(MainForm_Move);
 		}
 			
@@ -143,6 +150,7 @@
 
 
-		bool LoadFaceDefine(string path)
-		{
+		public bool LoadFaceDefine(string path)
+		{
+			FaceDef newFaceDef = null;
 			string plistPath = Path.Combine(path, "faceDef.plist");
 
@@ -155,8 +163,7 @@
 			}
 			
-			Hashtable property;
 			try 
 			{
-				property = PropertyList.Load(plistPath);
+				newFaceDef = MacFace.FaceDef.CreateFaceDefFromFile(path);
 			} 
 			catch (System.IO.IOException ie) 
@@ -180,7 +187,6 @@
 			if (_updateTimer != null) _updateTimer.Stop();
 
-			_property = property;
-			_facePath = path;
-			_parts = (ArrayList)_property["parts"];
+			_currentFaceDef = newFaceDef;
+			_facePath = _currentFaceDef.Path;
 			prevUsage = -10;
 
@@ -205,18 +211,10 @@
 				
 			if (prevUsage/10 != usage/10) {
-				ArrayList patterns = (ArrayList)_property["pattern"];
-				ArrayList patternCpu = (ArrayList)patterns[0];
-				ArrayList facePattern = (ArrayList)patternCpu[usage/10];
-				
 				this.Graphics.Clear(Color.FromArgb(0, 0, 0, 0));
-				foreach (Int32 i in facePattern) {
-					Hashtable part = _parts[i] as Hashtable;
-					string filename = (string)part["filename"];
-					string imgPath = Path.Combine(_facePath, filename);
-					using (Bitmap bitmap = new Bitmap(imgPath)) {
-						int x = (int)part["pos x"];
-						int y = 128 - (int)part["pos y"] - bitmap.Size.Height;
-						this.Graphics.DrawImage(bitmap,x,y,bitmap.Size.Width,bitmap.Size.Height);
-					}
+				foreach (Part part in _currentFaceDef.FacePattern.GetPartList(usage, PageOutFlag.Normal))
+				{
+					this.Graphics.DrawImage(part.Image,
+						part.Point.X, part.Point.Y,
+						part.Image.Size.Width, part.Image.Size.Height);
 				}
 				this.Update();
@@ -227,12 +225,20 @@
 		
 
+		//
+		// N®
+		//
 		public void MainForm_Load(object sender, System.EventArgs e)
 		{
-			string faceDefPath = Path.Combine(Application.StartupPath, "default.mcface");
+			// Ýè
+			_config = Configuration.GetInstance();
+			_config.Load();
+
+			ApplyConfiguration();
+
+			// çp^[ÇÝÝ
 			bool result = false;
-
-			if (Directory.Exists(faceDefPath))
-			{
-				result = LoadFaceDefine(faceDefPath);
+			if (Directory.Exists(_config.FaceDefPath))
+			{
+				result = LoadFaceDefine(_config.FaceDefPath);
 			}
 
@@ -241,5 +247,5 @@
 				if (!SelectFaceDefine(Application.StartupPath))
 				{
-					Application.Exit();
+					this.Close();
 					return;
 				}
@@ -247,4 +253,19 @@
 			}
 		}
+
+		// 
+		// I¹
+		//
+		private void MainForm_Closing(object sender, CancelEventArgs e)
+		{
+			// Û¶
+			_config.Opacity = (int) (this.Opacity * 100);
+			_config.FaceDefPath = (_currentFaceDef != null ? _currentFaceDef.Path : Path.Combine(Application.StartupPath, "default.mcface"));
+			_config.Location = this.Location;
+			_config.TransparentMouseMessage = this.TransparentMouseMessage;
+
+			_config.Save();
+		}
+
 
 		/*
@@ -252,15 +273,35 @@
 [NbNCxg
 		 */
-		public void PatternSelect_Click(object sender, System.EventArgs e)
+		public void menuItemPatternSelect_Click(object sender, System.EventArgs e)
 		{
 			SelectFaceDefine(_facePath);	
 		}
 
-		public void doQuit(object sender, System.EventArgs e)
+		public void menuItemExit_Click(object sender, System.EventArgs e)
 		{
 			_updateTimer.Stop();
-			Application.Exit();
-		}
-		
+			this.Close();
+		}
+
+		private void menuItemConfigure_Click(object sender, EventArgs e)
+		{
+			ConfigurationForm configForm = new ConfigurationForm(this);
+			if (configForm.ShowDialog() == DialogResult.OK) 
+			{
+				ApplyConfiguration();
+			}
+		}
+
+		private void ApplyConfiguration()
+		{
+			this.Opacity = (float)_config.Opacity / 100;
+			this.Location = _config.Location;
+			this.TransparentMouseMessage = _config.TransparentMouseMessage;
+		}
+
+		private void MainForm_Move(object sender, EventArgs e)
+		{
+			_config.Location = this.Location;
+		}
 	}
 }
