Exemple #1
0
        public void setPoints(CGPoint[] points)
        {
            pathSet = true;
			path.AddLines(points);
            pointsList = points;
            SetNeedsDisplay();
        }
        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);
            };

            Frame = UIScreen.MainScreen.ApplicationFrame;

            Signature = new SignaturePadView ();
            //Using different layouts for the iPhone and iPad, so setup device specific requirements here.
            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {

                //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 {

                //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);
            }
            TranslatesAutoresizingMaskIntoConstraints = false;

            //Add the subviews.
            AddSubview (Signature);
            AddSubview (btnSave);
            AddSubview (btnLoad);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View.BackgroundColor = UIColor.White;

            // the Signature Pad
            signaturepad = new SignaturePadView();
            signaturepad.Caption.Font = UIFont.FromName("Marker Felt", 16f);
            signaturepad.CaptionText = "Authorization Signature";
            signaturepad.SignaturePromptText = "☛";
            signaturepad.SignaturePrompt.Font = UIFont.FromName("Helvetica", 32f);
            signaturepad.BackgroundColor = UIColor.FromRGB(255, 255, 200); // a light yellow.
            signaturepad.BackgroundImageView.Image = UIImage.FromBundle("logo-galaxy-black-64.png");
            signaturepad.BackgroundImageView.Alpha = 0.0625f;
            signaturepad.BackgroundImageView.ContentMode = UIViewContentMode.ScaleToFill;
            signaturepad.BackgroundImageView.Frame = new System.Drawing.RectangleF(20, 20, 256, 256);
            signaturepad.Layer.ShadowOffset = new System.Drawing.SizeF(0, 0);
            signaturepad.Layer.ShadowOpacity = 1f;
            View.AddSubviews(signaturepad);

            // the buttons
            btnSave = UIButton.FromType(UIButtonType.RoundedRect);
            btnSave.SetTitle("Save", UIControlState.Normal);
            btnSave.TouchUpInside += (sender, e) =>
            {
                if (signaturepad.IsBlank)
                {
                    new UIAlertView("", "No signature to save.", null, "OK", null).Show();
                }
                else
                {
                    points = signaturepad.Points;
                    new UIAlertView("", "Vector Saved.", null, "OK", null).Show();
                }
            };
            btnLoad = UIButton.FromType(UIButtonType.RoundedRect);
            btnLoad.SetTitle("Load Last", UIControlState.Normal);
            btnLoad.TouchUpInside += (sender, e) =>
            {
                if (points != null)
                {
                    signaturepad.LoadPoints(points);
                }
            };
            View.AddSubviews(btnSave, btnLoad);
        }
 public void ResetContextAndState()
 {
     AnnotateUndoManager.RemoveAllActions(this);
     annotationDataCache = new List<IAnnotationData> ();
     annotationDataCacheArchive = new List<IAnnotationData> ();
     bzPath.RemoveAllPoints();
     arrowPoints = new CGPoint[7];
     markerPoints = new CGPoint[5];
     pathStart = CGPoint.Empty;
     counter = 0;
     IncrementImage = null;
     touchesDidMove = false;
     displayTransform = new CGAffineTransform ();
     displayRect = CGRect.Empty;
     contextRect = CGRect.Empty;
     bufferRect = CGRect.Empty;
 }
 void OnSaveTapped(object sender, EventArgs e)
 {
     if (signaturePad.IsBlank)
     {
         new UIAlertView("Signature Pad", "No signature to save.", null, "OK", null).Show();
     }
     else
     {
         points = signaturePad.Points;
         if (ShowImageView)
         {
             imageView.Image = signaturePad.GetImage();
         }
         else
         {
             new UIAlertView("Signature Pad", "Vector Saved.", null, "OK", null).Show();
         }
     }
 }