private void OnStrokeCompleted(object sender, EventArgs e) { StrokeCompleted?.Invoke(this, e); }
private void Initialize() { const int ThinPad = 3; const int ThickPad = 12; const int LineHeight = 2; RowSpacing = 0; ColumnSpacing = 0; // create the chrome layout var chromeStack = new StackLayout(); chromeStack.Spacing = 0; chromeStack.Padding = 0; chromeStack.Margin = 0; Children.Add(chromeStack); // add the background view { BackgroundImageView = new Image(); BackgroundImageView.SetValue(View.VerticalOptionsProperty, LayoutOptions.FillAndExpand); chromeStack.Children.Add(BackgroundImageView); } // add the prompt { SignaturePrompt = new Label { Text = "X", FontSize = 20, FontAttributes = FontAttributes.Bold, Margin = new Thickness(ThickPad, 0, 0, 0) }; chromeStack.Children.Add(SignaturePrompt); } // add the signature line { SignatureLine = new BoxView { BackgroundColor = Color.Gray, HeightRequest = LineHeight, Margin = new Thickness(ThickPad, 0, ThickPad, 0) }; chromeStack.Children.Add(SignatureLine); } // add the caption { CaptionLabel = new Label { Text = "Sign here.", FontSize = 11, TextColor = Color.Gray, HorizontalTextAlignment = TextAlignment.Center, Margin = new Thickness(ThinPad) }; chromeStack.Children.Add(CaptionLabel); } // add the main signature view { SignaturePadCanvas = new SignaturePadCanvasView(); SignaturePadCanvas.SetValue(View.HorizontalOptionsProperty, LayoutOptions.Fill); SignaturePadCanvas.SetValue(View.VerticalOptionsProperty, LayoutOptions.Fill); SignaturePadCanvas.StrokeCompleted += (sender, e) => { UpdateUi(); StrokeCompleted?.Invoke(this, EventArgs.Empty); }; SignaturePadCanvas.Cleared += (sender, e) => Cleared?.Invoke(this, EventArgs.Empty); Children.Add(SignaturePadCanvas); } // add the clear label { ClearLabel = new Label { Text = "Clear", FontSize = 11, FontAttributes = FontAttributes.Bold, IsVisible = false, TextColor = Color.Gray, Margin = new Thickness(0, ThickPad, ThickPad, 0) }; ClearLabel.SetValue(View.HorizontalOptionsProperty, LayoutOptions.End); ClearLabel.SetValue(View.VerticalOptionsProperty, LayoutOptions.Start); Children.Add(ClearLabel); // attach the "clear" command ClearLabel.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => Clear()) }); } // clear / initialize the view Clear(); }
private void Initialize() { const int ThinPad = 3; const int ThickPad = 20; const int LineHeight = 2; RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); // add the background view { BackgroundImageView = new Image(); BackgroundImageView.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Stretch); BackgroundImageView.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Stretch); BackgroundImageView.SetValue(Grid.RowProperty, 0); Children.Add(BackgroundImageView); } // add the main signature view { SignaturePadCanvas = new SignaturePadCanvasView(); SignaturePadCanvas.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Stretch); SignaturePadCanvas.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Stretch); SignaturePadCanvas.SetValue(Grid.RowProperty, 0); SignaturePadCanvas.StrokeCompleted += (sender, e) => { UpdateUi(); StrokeCompleted?.Invoke(this, EventArgs.Empty); }; SignaturePadCanvas.Cleared += (sender, e) => Cleared?.Invoke(this, EventArgs.Empty); Children.Add(SignaturePadCanvas); } // add the caption { Caption = new TextBlock() { Text = "Sign here.", FontSize = 11, Foreground = new SolidColorBrush(Colors.Gray), TextAlignment = TextAlignment.Center, Margin = new Thickness(ThinPad) }; Caption.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Stretch); Caption.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Bottom); Caption.SetValue(Grid.RowProperty, 1); Children.Add(Caption); } // add the signature line { SignatureLine = new Border() { Background = new SolidColorBrush(Colors.Gray), Height = LineHeight, Margin = new Thickness(ThickPad, 0, ThickPad, 0) }; SignatureLine.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Stretch); SignatureLine.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Bottom); Children.Add(SignatureLine); } // add the prompt { SignaturePrompt = new TextBlock() { Text = "X", FontSize = 20, FontWeight = FontWeights.Bold, Margin = new Thickness(ThickPad, 0, 0, ThinPad) }; SignaturePrompt.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left); SignaturePrompt.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Bottom); Children.Add(SignaturePrompt); } // add the clear label { ClearLabel = new TextBlock() { Text = "Clear", FontSize = 11, FontWeight = FontWeights.Bold, Visibility = Visibility.Collapsed, Foreground = new SolidColorBrush(Colors.Gray), Margin = new Thickness(0, ThickPad, ThickPad, 0) }; ClearLabel.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Right); ClearLabel.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top); Children.Add(ClearLabel); // attach the "clear" command ClearLabel.MouseLeftButtonUp += (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 += (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(); }
internal void OnStrokeCompleted() { StrokeCompleted?.Invoke(this, EventArgs.Empty); }
private void OnStrokeCompleted() { StrokeCompleted?.Invoke(this, EventArgs.Empty); }
private void OnSignatureStrokeCompleted() { UpdateUi(); StrokeCompleted?.Invoke(this, EventArgs.Empty); }
private void Initialize() { // add the background view { BackgroundImageView = new ImageView(Context) { Id = GenerateId(this), LayoutParameters = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent) }; AddView(BackgroundImageView); } // add the main signature view { SignaturePadCanvas = new SignaturePadCanvasView(Context) { Id = GenerateId(this), LayoutParameters = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent) }; SignaturePadCanvas.StrokeCompleted += (sender, e) => { UpdateUi(); StrokeCompleted?.Invoke(this, EventArgs.Empty); }; SignaturePadCanvas.Cleared += (sender, e) => Cleared?.Invoke(this, EventArgs.Empty); AddView(SignaturePadCanvas); } // add the caption { Caption = new TextView(Context) { Id = GenerateId(this), Text = "Sign Here" }; var layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent) { AlignWithParent = true, BottomMargin = 6 }; layout.AddRule(LayoutRules.AlignBottom); layout.AddRule(LayoutRules.CenterHorizontal); Caption.LayoutParameters = layout; Caption.SetIncludeFontPadding(true); Caption.SetPadding(0, 0, 0, 6); AddView(Caption); } // add the signature line { SignatureLine = new View(Context) { Id = GenerateId(this) }; SignatureLine.SetBackgroundColor(Color.Gray); var layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, 1); layout.SetMargins(10, 0, 10, 5); layout.AddRule(LayoutRules.Above, Caption.Id); SignatureLine.LayoutParameters = layout; AddView(SignatureLine); } // add the prompt { SignaturePrompt = new TextView(Context) { Id = GenerateId(this), Text = "X" }; SignaturePrompt.SetTypeface(null, TypefaceStyle.Bold); var layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent) { LeftMargin = 11 }; layout.AddRule(LayoutRules.Above, SignatureLine.Id); SignaturePrompt.LayoutParameters = layout; AddView(SignaturePrompt); } // add the clear label { ClearLabel = new TextView(Context) { Id = GenerateId(this), Text = "Clear", Visibility = ViewStates.Invisible }; var layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent) { AlignWithParent = true }; layout.SetMargins(0, 10, 22, 0); layout.AddRule(LayoutRules.AlignRight); layout.AddRule(LayoutRules.AlignTop); ClearLabel.LayoutParameters = layout; AddView(ClearLabel); // attach the "clear" command ClearLabel.Click += (sender, e) => Clear(); } // clear / initialize the view Clear(); }