void Initialize(bool baseProperties = true) { if (baseProperties) { BackgroundColor = UIColor.FromRGB(225, 225, 225); } strokeColor = UIColor.Black; StrokeWidth = 2f; Layer.ShadowColor = UIColor.Black.CGColor; Layer.ShadowOffset = new CGSize(2, 2); Layer.ShadowOpacity = 1f; Layer.ShadowRadius = 2f; #region Add Subviews BackgroundImageView = new UIImageView(); AddSubview(BackgroundImageView); //Add an image that covers the entire signature view, used to display already drawn //elements instead of having to redraw them every time the user touches the screen. imageView = new UIImageView(); AddSubview(imageView); Caption = new UILabel(); Caption.Text = "Sign here."; Caption.Font = UIFont.BoldSystemFontOfSize(11f); Caption.BackgroundColor = UIColor.Clear; Caption.TextColor = UIColor.Gray; Caption.TextAlignment = UITextAlignment.Center; AddSubview(Caption); //Display the base line for the user to sign on. SignatureLine = new UIView(); SignatureLine.BackgroundColor = UIColor.Gray; AddSubview(SignatureLine); //Display the X on the left hand side of the line where the user signs. SignaturePrompt = new UILabel(); SignaturePrompt.Text = "X"; SignaturePrompt.Font = UIFont.BoldSystemFontOfSize(20f); SignaturePrompt.BackgroundColor = UIColor.Clear; SignaturePrompt.TextColor = UIColor.Gray; AddSubview(SignaturePrompt); ClearLabel = UIButton.FromType(UIButtonType.Custom); ClearLabel.SetTitle("Clear", UIControlState.Normal); ClearLabel.Font = UIFont.BoldSystemFontOfSize(11f); ClearLabel.BackgroundColor = UIColor.Clear; ClearLabel.SetTitleColor(UIColor.Gray, UIControlState.Normal); //btn_clear.SetBackgroundImage (UIImage.FromFile ("Images/closebox.png"), UIControlState.Normal); //btn_clear.SetBackgroundImage (UIImage.FromFile ("Images/closebox_pressed.png"), // UIControlState.Selected); ClearLabel.TouchUpInside += (sender, e) => { Clear(); }; AddSubview(ClearLabel); ClearLabel.Hidden = true; #endregion paths = new List <UIBezierPath> (); points = new List <CGPoint[]> (); currentPoints = new List <CGPoint> (); }
private void Initialize(bool baseProperties = true) { // add the background view { BackgroundImageView = new UIImageView(); AddSubview(BackgroundImageView); } // add the main signature view { SignaturePadCanvas = new SignaturePadCanvasView(); SignaturePadCanvas.StrokeCompleted += (sender, e) => { UpdateUi(); StrokeCompleted?.Invoke(this, EventArgs.Empty); }; SignaturePadCanvas.Cleared += (sender, e) => Cleared?.Invoke(this, EventArgs.Empty); AddSubview(SignaturePadCanvas); } // add the caption { Caption = new UILabel() { Text = "Sign here.", Font = UIFont.BoldSystemFontOfSize(11f), BackgroundColor = UIColor.Clear, TextColor = UIColor.Gray, TextAlignment = UITextAlignment.Center }; AddSubview(Caption); } // add the signature line { SignatureLine = new UIView() { BackgroundColor = UIColor.Gray }; AddSubview(SignatureLine); } // add the prompt { SignaturePrompt = new UILabel() { Text = "X", Font = UIFont.BoldSystemFontOfSize(20f), BackgroundColor = UIColor.Clear, TextColor = UIColor.Gray }; AddSubview(SignaturePrompt); } // add the clear label { ClearLabel = UIButton.FromType(UIButtonType.Custom); ClearLabel.SetTitle("Clear", UIControlState.Normal); ClearLabel.Font = UIFont.BoldSystemFontOfSize(11f); ClearLabel.BackgroundColor = UIColor.Clear; ClearLabel.SetTitleColor(UIColor.Gray, UIControlState.Normal); AddSubview(ClearLabel); // attach the "clear" command ClearLabel.TouchUpInside += (sender, e) => Clear(); } // clear / initialize the view Clear(); }
private void Initialize(bool baseProperties = true) { // add the background view { BackgroundImageView = new UIImageView(); AddSubview(BackgroundImageView); } // add the main signature view { SignaturePadCanvas = new SignaturePadCanvasView(); SignaturePadCanvas.StrokeCompleted += delegate { OnSignatureStrokeCompleted(); }; SignaturePadCanvas.DblTapped += delegate { OnDoubleTapped(); }; SignaturePadCanvas.Cleared += delegate { OnSignatureCleared(); }; AddSubview(SignaturePadCanvas); } // add the caption { Caption = new UILabel() { BackgroundColor = UIColor.Clear, TextAlignment = UITextAlignment.Center, Font = UIFont.SystemFontOfSize(DefaultFontSize), Text = DefaultCaptionText, TextColor = SignaturePadDarkColor, }; AddSubview(Caption); } // add the signature line { SignatureLine = new UIView() { BackgroundColor = SignaturePadDarkColor, }; SignatureLineWidth = DefaultLineThickness; SignatureLineSpacing = DefaultNarrowSpacing; AddSubview(SignatureLine); } // add the prompt { SignaturePrompt = new UILabel() { BackgroundColor = UIColor.Clear, Font = UIFont.BoldSystemFontOfSize(DefaultFontSize), Text = DefaultPromptText, TextColor = SignaturePadDarkColor, }; AddSubview(SignaturePrompt); } // add the clear label { ClearLabel = UIButton.FromType(UIButtonType.Custom); ClearLabel.BackgroundColor = UIColor.Clear; ClearLabel.Font = UIFont.BoldSystemFontOfSize(DefaultFontSize); ClearLabel.SetTitle(DefaultClearLabelText, UIControlState.Normal); ClearLabel.SetTitleColor(SignaturePadDarkColor, UIControlState.Normal); AddSubview(ClearLabel); // attach the "clear" command ClearLabel.TouchUpInside += delegate { OnClearTapped(); }; } Padding = new UIEdgeInsets(DefaultWideSpacing, DefaultWideSpacing, DefaultNarrowSpacing, DefaultWideSpacing); // clear / initialize the view UpdateUi(); }