public void TestControlTypes() { TextControl textControl = new TextControl(); Assert.AreEqual(ControlType.Text, textControl.Type); ComboControl comboControl = new ComboControl(); Assert.AreEqual(ControlType.Combo, comboControl.Type); RadioControl radioControl = new RadioControl(); Assert.AreEqual(ControlType.Radio, radioControl.Type); CheckboxControl checkboxControl = new CheckboxControl(); Assert.AreEqual(ControlType.Checkbox, checkboxControl.Type); CheckboxGroupControl checkboxGroupControl = new CheckboxGroupControl(); Assert.AreEqual(ControlType.CheckboxGroup, checkboxGroupControl.Type); DateControl dateControl = new DateControl(); Assert.AreEqual(ControlType.Date, dateControl.Type); TimeControl timeControl = new TimeControl(); Assert.AreEqual(ControlType.Time, timeControl.Type); FileBrowserControl fileBrowserControl = new FileBrowserControl(); Assert.AreEqual(ControlType.FileBrowser, fileBrowserControl.Type); HiddenControl hiddenControl = new HiddenControl(); Assert.AreEqual(ControlType.Hidden, hiddenControl.Type); LabelControl labelControl = new LabelControl(); Assert.AreEqual(ControlType.Label, labelControl.Type); HtmlControl htmlControl = new HtmlControl(); Assert.AreEqual(ControlType.Html, htmlControl.Type); GroupControl groupControl = new GroupControl(); Assert.AreEqual(ControlType.Group, groupControl.Type); RepeaterControl repeaterControl = new RepeaterControl(); Assert.AreEqual(ControlType.Repeater, repeaterControl.Type); CalculationControl calculationControl = new CalculationControl(); Assert.AreEqual(ControlType.Calculation, calculationControl.Type); SignaturePadControl signaturePadControl = new SignaturePadControl(); Assert.AreEqual(ControlType.SignaturePad, signaturePadControl.Type); GeolocationControl geolocationControl = new GeolocationControl(); Assert.AreEqual(ControlType.Geolocation, geolocationControl.Type); HeadingControl headingControl = new HeadingControl(); Assert.AreEqual(ControlType.Heading, headingControl.Type); }
/// <summary> /// Writes the value of the signature to the table as an image. /// </summary> /// <param name="table">The <see cref="MigraDoc.DocumentObjectModel.Tables.Table"/> to write to.</param> /// <param name="control">The control.</param> /// <param name="container">The application data container.</param> /// <param name="level">The depth down the control tree being rendered (affects indenting).</param> private void WriteValueSignature(Table table, SignaturePadControl control, Dictionary<string, object> container, int level) { Row row = table.AppendRow(this.DefaultStyle.Font.Size, control.Label, string.Empty); row.Cells[0].Format.LeftIndent = new Unit(PdfConstants.IndentMultiplier * level, UnitType.Millimeter); string controlValue = container[control.Name].ToString(); if (string.IsNullOrEmpty(controlValue)) { return; } byte[] encodedBytes = Convert.FromBase64String(controlValue.Split(',')[1]); string path = this.GetTemporaryFileName("png"); using (FileStream stream = new FileStream(path, FileMode.CreateNew)) { SvgToImageConverter converter = new SvgToImageConverter(); converter.ConvertToImage(encodedBytes, stream, ImageFormat.Png); } Unit size = this.DefaultStyle.Font.Size * 2; Image addedImage = row.Cells[1].AddParagraph().AddImage(path); addedImage.LockAspectRatio = true; addedImage.Height = size; row.Height = size; }