public void EmptyPointsArrayDoesntChangeAnything()
        {
            SignaturePadView signature = new SignaturePadView();

            CGPoint [] points = new CGPoint [] { new CGPoint(0, 0), new CGPoint(10, 30), new CGPoint(50, 70) };
            signature.LoadPoints(points);
            signature.LoadPoints(new CGPoint [0]);
            Assert.That(signature.Points.Count() > 0);
        }
Esempio n. 2
0
        public void NullPointsArrayDoesntChangeAnything()
        {
            SignaturePadView signature = new SignaturePadView();

            PointF [] points = new PointF [] { new PointF(0, 0), new PointF(10, 30), new PointF(50, 70) };
            signature.LoadPoints(points);
            signature.LoadPoints(null);
            Assert.That(signature.Points.Count() > 0);
        }
Esempio n. 3
0
        public void ReturnsFalseIfPointsExist()
        {
            SignaturePadView signature = new SignaturePadView();

            signature.LoadPoints(new PointF [] { new PointF(0, 30) });
            Assert.That(!signature.IsBlank);
        }
Esempio n. 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            SignaturePadView signature = FindViewById <SignaturePadView> (Resource.Id.signatureView);

            // Get our button from the layout resource,
            // and attach an event to it
            Button btnSave = FindViewById <Button> (Resource.Id.btnSave);

            btnSave.Click += delegate {
                if (signature.IsBlank)
                {                //Display the base line for the user to sign on.
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetMessage("No signature to save.");
                    alert.SetNeutralButton("Okay", delegate { });
                    alert.Create().Show();
                }
                points = signature.Points;
            };
            btnSave.Dispose();

            Button btnLoad = FindViewById <Button> (Resource.Id.btnLoad);

            btnLoad.Click += delegate {
                if (points != null)
                {
                    signature.LoadPoints(points);
                }
            };
            btnLoad.Dispose();
        }
        public void ValidPointsArrayDoesGetLoaded()
        {
            SignaturePadView signature = new SignaturePadView();

            CGPoint [] points = new CGPoint [] { new CGPoint(0, 0), new CGPoint(10, 30), new CGPoint(50, 70) };
            signature.LoadPoints(points);
            Assert.That(signature.Points.Count() > 0);
        }
        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);
        }
Esempio n. 7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //RequestedOrientation = global::Android.Content.PM.ScreenOrientation.Landscape;

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            SignaturePadView signature = FindViewById <SignaturePadView> (Resource.Id.signatureView);

            if (true)               // Customization activated
            {
                View root = FindViewById <View> (Resource.Id.rootView);
                root.SetBackgroundColor(Color.White);

                // Activate this to internally use a bitmap to store the strokes
                // (good for frequent-redraw situations, bad for memory footprint)
                // signature.UseBitmapBuffer = true;

                signature.CaptionTextView.Text = "Authorization Signature";
                signature.CaptionTextView.SetTypeface(Typeface.Serif, TypefaceStyle.BoldItalic);
                signature.CaptionTextView.SetTextSize(global::Android.Util.ComplexUnitType.Sp, 16f);
                signature.SignaturePromptTextView.Text = ">>";
                signature.SignaturePromptTextView.SetTypeface(Typeface.SansSerif, TypefaceStyle.Normal);
                signature.SignaturePromptTextView.SetTextSize(global::Android.Util.ComplexUnitType.Sp, 32f);
                signature.BackgroundColor = Color.Rgb(255, 255, 200);                  // a light yellow.
                signature.StrokeColor     = Color.Black;

                signature.BackgroundImageView.SetImageResource(Resource.Drawable.logo_galaxy_black_64);
                signature.BackgroundImageView.SetAlpha(16);
                signature.BackgroundImageView.SetAdjustViewBounds(true);
                var layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent);
                layout.AddRule(LayoutRules.CenterInParent);
                layout.SetMargins(20, 20, 20, 20);
                signature.BackgroundImageView.LayoutParameters = layout;

                // You can change paddings for positioning...
                var caption = signature.CaptionTextView;
                caption.SetPadding(caption.PaddingLeft, 1, caption.PaddingRight, 25);
            }

            // Get our button from the layout resource,
            // and attach an event to it
            Button btnSave = FindViewById <Button> (Resource.Id.btnSave);

            btnSave.Click += delegate {
                if (signature.IsBlank)
                {                //Display the base line for the user to sign on.
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetMessage("No signature to save.");
                    alert.SetNeutralButton("Okay", delegate { });
                    alert.Create().Show();
                }
                points = signature.Points;
            };
            btnSave.Dispose();

            Button btnLoad = FindViewById <Button> (Resource.Id.btnLoad);

            btnLoad.Click += delegate {
                if (points != null)
                {
                    signature.LoadPoints(points);
                }
            };
            btnLoad.Dispose();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            signatureView = FindViewById <SignaturePadView>(Resource.Id.signatureView);

            var btnSave      = FindViewById <Button>(Resource.Id.btnSave);
            var btnLoad      = FindViewById <Button>(Resource.Id.btnLoad);
            var btnSaveImage = FindViewById <Button>(Resource.Id.btnSaveImage);

            btnSaveImage.Click += BtnCamera_Click;;
            // signatureView.SetBackgroundResource(Resource.Drawable.splash_logo);

            //btnSave.Click += delegate
            //{
            //    points = signatureView.Points;

            //    Toast.MakeText(this, "Vector signature saved to memory.", ToastLength.Short).Show();
            //};
            btnSave.Click += async delegate
            {
                points = signatureView.Points;

                Toast.MakeText(this, "Vector signature saved to memory.", ToastLength.Short).Show();

                var path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath;
                var file = System.IO.Path.Combine(path, "signature.png");

                using (var bitmap = await signatureView.GetImageStreamAsync(SignatureImageFormat.Png, Android.Graphics.Color.Black, Android.Graphics.Color.White, 1f))
                    using (var dest = File.OpenWrite(file))
                    {
                        await bitmap.CopyToAsync(dest);
                    }

                Toast.MakeText(this, "Raster signature saved to the photo gallery.", ToastLength.Short).Show();
            };

            btnLoad.Click += delegate
            {
                if (points != null)
                {
                    signatureView.LoadPoints(points);
                }
            };

            //btnSaveImage.Click += async delegate
            //{
            //    var path = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures).AbsolutePath;
            //    var file = System.IO.Path.Combine(path, "signature.png");

            //    using (var bitmap = await signatureView.GetImageStreamAsync(SignatureImageFormat.Png, Color.Black, Color.White, 1f))
            //    using (var dest = File.OpenWrite(file))
            //    {
            //        await bitmap.CopyToAsync(dest);
            //    }

            //    Toast.MakeText(this, "Raster signature saved to the photo gallery.", ToastLength.Short).Show();
            //};
        }