private void typecombo_SelectionChangeCommitted(object sender, System.EventArgs e) { if (typecombo.SelectedItem.ToString().Equals("Text", StringComparison.OrdinalIgnoreCase)) { LabelDef.StringFormat newformat = new LabelDef.StringFormat(); newformat.FormatString = string.Empty; textField.printFormat.format = newformat; } else if (typecombo.SelectedItem.ToString().Equals("Date", StringComparison.OrdinalIgnoreCase)) { LabelDef.DateTimeFormat newformat = new LabelDef.DateTimeFormat(); newformat.FormatString = textField.printFormat.format.FormatString; textField.printFormat.format = newformat; } else if (typecombo.SelectedItem.ToString().Equals("Decimal:Whole", StringComparison.OrdinalIgnoreCase)) { LabelDef.DecimalFormat newformat = new LabelDef.DecimalFormat(); newformat.Portion = LabelDef.DecimalFormat.DecimalPortion.Entire; newformat.FormatString = textField.printFormat.format.FormatString; textField.printFormat.format = newformat; } else if (typecombo.SelectedItem.ToString().Equals("Decimal:Integer", StringComparison.OrdinalIgnoreCase)) { LabelDef.DecimalFormat newformat = new LabelDef.DecimalFormat(); newformat.Portion = LabelDef.DecimalFormat.DecimalPortion.Integer; newformat.FormatString = textField.printFormat.format.FormatString; textField.printFormat.format = newformat; } else if (typecombo.SelectedItem.ToString().Equals("Decimal:Fraction", StringComparison.OrdinalIgnoreCase)) { LabelDef.DecimalFormat newformat = new LabelDef.DecimalFormat(); newformat.Portion = LabelDef.DecimalFormat.DecimalPortion.Fraction; newformat.FormatString = textField.printFormat.format.FormatString; textField.printFormat.format = newformat; } FillData(textField); mainForm.Invalidate(); }
//Main functions private void button1_Click(object sender, EventArgs e) { try { textfield = new LabelDef.TextField(new ACA.LabelX.Tools.CoordinateSystem(200, 200, GetString("MILLIMETER"))); textfield.ID = IDtxt.Text; textfield.PositionX = new Length(System.Convert.ToInt32(XPostxt.Text), System.Drawing.GraphicsUnit.Millimeter); textfield.PositionY = new Length(System.Convert.ToInt32(YPostxt.Text), System.Drawing.GraphicsUnit.Millimeter); textfield.Rotation = System.Convert.ToInt32(rotationcombo.SelectedItem.ToString()); string selectedfont = Fontcombo.SelectedItem.ToString().Split(' ')[0].Trim(); fontList.TryGetValue(selectedfont, out textfield.Font); if (manualwhcheck.Checked) { textfield.Height = new Length(System.Convert.ToInt32(heighttxt.Text), System.Drawing.GraphicsUnit.Millimeter); textfield.Width = new Length(System.Convert.ToInt32(widthtxt.Text), System.Drawing.GraphicsUnit.Millimeter); } LabelDef.FieldFormat.Alignment alignment = LabelDef.FieldFormat.Alignment.Left; if (alignTextcombo.SelectedItem.ToString().Equals(GetString("LEFT"), StringComparison.OrdinalIgnoreCase)) { alignment = LabelDef.FieldFormat.Alignment.Left; } else if (alignTextcombo.SelectedItem.ToString().Equals(GetString("RIGHT"), StringComparison.OrdinalIgnoreCase)) { alignment = LabelDef.FieldFormat.Alignment.Right; } string formatString = null; if (formatstringlist.SelectedItem == null || formatstringlist.SelectedItem.ToString().Length < 1) { formatString = String.Empty; } else { formatString = formatstringlist.SelectedItem.ToString(); } if (typecombo.SelectedItem.ToString().Equals(GetString("TEXT"), StringComparison.OrdinalIgnoreCase)) { LabelDef.StringFormat stringformat = new LabelDef.StringFormat(); stringformat.Align = alignment; stringformat.FormatString = formatString; stringformat.IsBarcode = false; textfield.printFormat = new LabelDef.PrintFormat(stringformat); } else if (typecombo.SelectedItem.ToString().Equals(GetString("DATE"), StringComparison.OrdinalIgnoreCase)) { LabelDef.DateTimeFormat datetimeformat = new LabelDef.DateTimeFormat(); datetimeformat.Align = alignment; datetimeformat.FormatString = formatString; textfield.printFormat = new LabelDef.PrintFormat(datetimeformat); } else if (typecombo.SelectedItem.ToString().Equals(GetString("DECIMALWHOLE"), StringComparison.OrdinalIgnoreCase)) { LabelDef.DecimalFormat decimalformat = new LabelDef.DecimalFormat(); decimalformat.Align = alignment; decimalformat.FormatString = formatString; decimalformat.Portion = LabelDef.DecimalFormat.DecimalPortion.Entire; textfield.printFormat = new LabelDef.PrintFormat(decimalformat); } else if (typecombo.SelectedItem.ToString().Equals(GetString("DECIMALINTEGER"), StringComparison.OrdinalIgnoreCase)) { LabelDef.DecimalFormat decimalformat = new LabelDef.DecimalFormat(); decimalformat.Align = alignment; decimalformat.FormatString = formatString; decimalformat.Portion = LabelDef.DecimalFormat.DecimalPortion.Integer; textfield.printFormat = new LabelDef.PrintFormat(decimalformat); } else if (typecombo.SelectedItem.ToString().Equals(GetString("DECIMALFRACTION"), StringComparison.OrdinalIgnoreCase)) { LabelDef.DecimalFormat decimalformat = new LabelDef.DecimalFormat(); decimalformat.Align = alignment; decimalformat.FormatString = formatString; decimalformat.Portion = LabelDef.DecimalFormat.DecimalPortion.Fraction; textfield.printFormat = new LabelDef.PrintFormat(decimalformat); } if (referencecombo.SelectedItem.ToString().Equals(GetString("NOTHING"))) { textfield.ValueRef = null; } else { textfield.ValueRef = referencecombo.SelectedItem.ToString(); } DialogResult = DialogResult.OK; this.Close(); } catch { MessageBox.Show(GetString("INVALIDINPUTERROR"), GetString("INVALIDINPUTERRORTITLE"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }