示例#1
0
		public SampleView ()
		{
			BackgroundColor = UIColor.White;

			//Create the save button
			btnSave = UIButton.FromType (UIButtonType.RoundedRect);
			btnSave.SetTitle ("Save", UIControlState.Normal);

			//Create the load button
			btnLoad = UIButton.FromType (UIButtonType.RoundedRect);
			btnLoad.SetTitle ("Load Last", UIControlState.Normal);
			btnLoad.TouchUpInside += (sender, e) => {
				if (points != null)
					signature.LoadPoints (points);
			};

			signature = new SignaturePadView ();

			//Using different layouts for the iPhone and iPad, so setup device specific requirements here.
			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
				//iPhone uses Landscape, but ApplicationFrame still returns Portrait values, so 
				//reverse them for creating the view's frame.
				Frame = new RectangleF (0, 20, UIScreen.MainScreen.ApplicationFrame.Height, 
				                        UIScreen.MainScreen.ApplicationFrame.Width);

				//iPhone version simply saves the vector of points in an instance variable.
				btnSave.TouchUpInside += (sender, e) => {
					if (signature.IsBlank)
						new UIAlertView ("", "No signature to save.", null, "Okay", null).Show ();
					else {
						points = signature.Points;
						new UIAlertView ("", "Vector Saved.", null, "Okay", null).Show ();
					}
				};
			} else {
				Frame = UIScreen.MainScreen.ApplicationFrame;

				//iPad version saves the vector of points as well as retrieving the UIImage to display
				//in a UIImageView.
				btnSave.TouchUpInside += (sender, e) => {
					//if (signature.IsBlank)
					//	new UIAlertView ("", "No signature to save.", null, "Okay", null).Show ();
					imageView.Image = signature.GetImage ();
					points = signature.Points;
				};

				//Create the UIImageView to display a saved signature.
				imageView = new UIImageView();
				AddSubview(imageView);
			}

			//Add the subviews.
			AddSubview (signature);
			AddSubview (btnSave);
			AddSubview (btnLoad);
		}
示例#2
0
		public void NullStrokeColorReturnsNullImage ()
		{
			SignaturePadView signature = new SignaturePadView (new RectangleF (0, 0, 50, 100));
			UIImage image = signature.GetImage (null);
			Assert.That (image == null);
		}
示例#3
0
		public void PositiveScaleReturnsImage ()
		{
			SignaturePadView signature = new SignaturePadView (new RectangleF (0, 0, 50, 100));
			UIImage image = signature.GetImage (2f);
			Assert.That (image != null);
		}
示例#4
0
		public void NegativeHeightReturnsNullImage ()
		{
			SignaturePadView signature = new SignaturePadView (new RectangleF (0, 0, 50, 100));
			UIImage image = signature.GetImage (new SizeF (25, -50));
			Assert.That (image == null);
		}
示例#5
0
		public void ZeroWidthReturnsNullImage ()
		{
			SignaturePadView signature = new SignaturePadView (new RectangleF (0, 0, 50, 100));
			UIImage image = signature.GetImage (new SizeF (0, 50));
			Assert.That (image == null);
		}
示例#6
0
		public void UnboundSignaturePadViewReturnsNullImage ()
		{
			SignaturePadView signature = new SignaturePadView ();
			UIImage image = signature.GetImage ();
			Assert.That (image == null);
		}
示例#7
0
		public void ValidFillColorReturnsImage ()
		{
			SignaturePadView signature = new SignaturePadView (new RectangleF (0, 0, 50, 100));
			UIImage image = signature.GetImage (UIColor.Black, UIColor.White);
			Assert.That (image != null);
		}