src/FingersDance.Control.Close/UserControlClose.xaml.cs
changeset 140 fc7c12f9da30
parent 131 9331c3dea175
child 141 923687896770
--- a/src/FingersDance.Control.Close/UserControlClose.xaml.cs	Sun Oct 11 20:38:22 2009 +0200
+++ b/src/FingersDance.Control.Close/UserControlClose.xaml.cs	Tue Oct 13 10:43:39 2009 +0200
@@ -10,53 +10,81 @@
 
 namespace FingersDance.Control.Close
 {
+    public class ConfirmEventArgs : EventArgs
+    {
+        public Boolean Confirmed;
+
+        public ConfirmEventArgs(Boolean b)
+        {
+            Confirmed = b;
+        }
+    }
+
 	public partial class UserControlClose
 	{
-        public event EventHandler EH_SurfaceButtonClose_ContactDown;
+        public event EventHandler<ConfirmEventArgs> ConfirmYesOrNo; 
         public bool close;
         public int Id = 0;
 
-		public UserControlClose(int closeid)
+        public static readonly DependencyProperty QuestionProperty = DependencyProperty.Register("Question", typeof(String), typeof(UserControlClose));
+
+		public UserControlClose()
 		{
-            Id = closeid;
 			this.InitializeComponent();
 
 			// Insert code required on object creation below this point.
-		}
+        }
+
+
+        public UserControlClose(int closeid, String sentence)
+        {
+            this.InitializeComponent();
+
+            Id = closeid;
+            Question = sentence;
+        }
+
+
+        public String Question
+        {
+            get { return (String)GetValue(QuestionProperty); }
+            set { SetValue(QuestionProperty, value); }
+        }
+
 
         private void SurfaceButtonOK_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
         {
-            if (EH_SurfaceButtonClose_ContactDown != null)
+            if (ConfirmYesOrNo != null)
             {
                 close = true;
-                EH_SurfaceButtonClose_ContactDown(this, new EventArgs());
+                ConfirmYesOrNo(this, new ConfirmEventArgs(true));
+            }
+        }
+
+        private void SurfaceButtonOK_Click(object sender, RoutedEventArgs e)
+        {
+            if (ConfirmYesOrNo != null)
+            {
+                close = true;
+                ConfirmYesOrNo(this, new ConfirmEventArgs(true));
             }
         }
 
         private void SurfaceButtonNO_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
         {
-            if (EH_SurfaceButtonClose_ContactDown != null)
+            if (ConfirmYesOrNo != null)
             {
                 close = false;
-                EH_SurfaceButtonClose_ContactDown(this, new EventArgs());
+                ConfirmYesOrNo(this, new ConfirmEventArgs(false));
             }
         }
 
         private void SurfaceButtonNO_Click(object sender, RoutedEventArgs e)
         {
-            if (EH_SurfaceButtonClose_ContactDown != null)
+            if (ConfirmYesOrNo != null)
             {
                 close = false;
-                EH_SurfaceButtonClose_ContactDown(this, new EventArgs());
-            }
-        }
-
-        private void SurfaceButtonOK_Click(object sender, RoutedEventArgs e)
-        {
-            if (EH_SurfaceButtonClose_ContactDown != null)
-            {
-                close = true;
-                EH_SurfaceButtonClose_ContactDown(this, new EventArgs());
+                ConfirmYesOrNo(this, new ConfirmEventArgs(false));
             }
         }
 	}