void Initialize () { BackgroundColor = Color.Black; strokeColor = Color.White; StrokeWidth = 2f; canvasView = new SignatureCanvasView (this.context); canvasView.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); //Set the attributes for painting the lines on the screen. paint = new Paint (); paint.Color = strokeColor; paint.StrokeWidth = StrokeWidth; paint.SetStyle (Paint.Style.Stroke); paint.StrokeJoin = Paint.Join.Round; paint.StrokeCap = Paint.Cap.Round; paint.AntiAlias = true; #region Add Subviews RelativeLayout.LayoutParams layout; BackgroundImageView = new ImageView (this.context); BackgroundImageView.Id = generateId (); AddView (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 ClearingImageView (context); imageView.SetBackgroundColor (Color.Transparent); imageView.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); AddView (imageView); lblSign = new TextView (context); lblSign.Id = generateId (); lblSign.SetIncludeFontPadding (true); lblSign.Text = "Sign Here"; layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.AlignWithParent = true; layout.BottomMargin = 6; layout.AddRule (LayoutRules.AlignBottom); layout.AddRule (LayoutRules.CenterHorizontal); lblSign.LayoutParameters = layout; lblSign.SetPadding (0, 0, 0, 6); AddView (lblSign); //Display the base line for the user to sign on. signatureLine = new View (context); signatureLine.Id = generateId (); signatureLine.SetBackgroundColor (Color.Gray); layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, 1); layout.SetMargins (10, 0, 10, 5); layout.AddRule (LayoutRules.Above, lblSign.Id); signatureLine.LayoutParameters = layout; AddView (signatureLine); //Display the X on the left hand side of the line where the user signs. xLabel = new TextView (context); xLabel.Id = generateId (); xLabel.Text = "X"; xLabel.SetTypeface (null, TypefaceStyle.Bold); layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.LeftMargin = 11; layout.AddRule (LayoutRules.Above, signatureLine.Id); xLabel.LayoutParameters = layout; AddView (xLabel); AddView (canvasView); lblClear = new TextView (context); lblClear.Id = generateId (); lblClear.Text = "Clear"; layout = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.SetMargins (0, 10, 22, 0); layout.AlignWithParent = true; layout.AddRule (LayoutRules.AlignRight); layout.AddRule (LayoutRules.AlignTop); lblClear.LayoutParameters = layout; lblClear.Visibility = ViewStates.Invisible; lblClear.Click += (object sender, EventArgs e) => { Clear (); }; AddView (lblClear); #endregion paths = new List<Path> (); points = new List<System.Drawing.PointF[]> (); currentPoints = new List<System.Drawing.PointF> (); dirtyRect = new RectF (); }
void Initialize() { BackgroundColor = Color.Black; strokeColor = Color.White; StrokeWidth = 2f; canvasView = new SignatureCanvasView(this.context); canvasView.LayoutParameters = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); //Set the attributes for painting the lines on the screen. paint = new Paint(); paint.Color = strokeColor; paint.StrokeWidth = StrokeWidth; paint.SetStyle(Paint.Style.Stroke); paint.StrokeJoin = Paint.Join.Round; paint.StrokeCap = Paint.Cap.Round; paint.AntiAlias = true; #region Add Subviews RelativeLayout.LayoutParams layout; BackgroundImageView = new ImageView(this.context); BackgroundImageView.Id = generateId(); AddView(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 ClearingImageView(context); imageView.SetBackgroundColor(Color.Transparent); imageView.LayoutParameters = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent); AddView(imageView); lblSign = new TextView(context); lblSign.Id = generateId(); lblSign.SetIncludeFontPadding(true); lblSign.Text = "Sign Here"; layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.AlignWithParent = true; layout.BottomMargin = 6; layout.AddRule(LayoutRules.AlignBottom); layout.AddRule(LayoutRules.CenterHorizontal); lblSign.LayoutParameters = layout; lblSign.SetPadding(0, 0, 0, 6); AddView(lblSign); //Display the base line for the user to sign on. signatureLine = new View(context); signatureLine.Id = generateId(); signatureLine.SetBackgroundColor(Color.Gray); layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, 1); layout.SetMargins(10, 0, 10, 5); layout.AddRule(LayoutRules.Above, lblSign.Id); signatureLine.LayoutParameters = layout; AddView(signatureLine); //Display the X on the left hand side of the line where the user signs. xLabel = new TextView(context); xLabel.Id = generateId(); xLabel.Text = "X"; xLabel.SetTypeface(null, TypefaceStyle.Bold); layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.LeftMargin = 11; layout.AddRule(LayoutRules.Above, signatureLine.Id); xLabel.LayoutParameters = layout; AddView(xLabel); AddView(canvasView); lblClear = new TextView(context); lblClear.Id = generateId(); lblClear.Text = "Clear"; layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent); layout.SetMargins(0, 10, 22, 0); layout.AlignWithParent = true; layout.AddRule(LayoutRules.AlignRight); layout.AddRule(LayoutRules.AlignTop); lblClear.LayoutParameters = layout; lblClear.Visibility = ViewStates.Invisible; lblClear.Click += (object sender, EventArgs e) => { Clear(); }; AddView(lblClear); #endregion paths = new List <Path> (); points = new List <System.Drawing.PointF[]> (); currentPoints = new List <System.Drawing.PointF> (); dirtyRect = new RectF(); }