//Main functions private void Okbtn_Click(object sender, EventArgs e) { if (inputCheck()) { if (concatmethodcombo.SelectedItem.ToString().Equals("Horizontal", StringComparison.OrdinalIgnoreCase)) { textfieldgroup = new LabelDef.TextFieldGroup(new CoordinateSystem(Convert.ToUInt32(mainForm.CreateGraphics().DpiX), Convert.ToUInt32(mainForm.CreateGraphics().DpiY), "Millimeter"), LabelDef.TextFieldGroup.ConcatMethod.Horizontal); } else { textfieldgroup = new LabelDef.TextFieldGroup(new CoordinateSystem(Convert.ToUInt32(mainForm.CreateGraphics().DpiX), Convert.ToUInt32(mainForm.CreateGraphics().DpiY), "Millimeter"), LabelDef.TextFieldGroup.ConcatMethod.Vertical); } textfieldgroup.ID = IDtxt.Text; textfieldgroup.PositionX = new Length(System.Convert.ToInt32(XPostxt.Text), System.Drawing.GraphicsUnit.Millimeter); textfieldgroup.PositionY = new Length(System.Convert.ToInt32(YPostxt.Text), System.Drawing.GraphicsUnit.Millimeter); textfieldgroup.Rotation = System.Convert.ToInt32(rotationcombo.SelectedItem.ToString()); if (manualwhcheck.Checked) { textfieldgroup.Height = new Length(System.Convert.ToInt32(heighttxt.Text), System.Drawing.GraphicsUnit.Millimeter); textfieldgroup.Width = new Length(System.Convert.ToInt32(widthtxt.Text), System.Drawing.GraphicsUnit.Millimeter); } LabelDef.StringFormat stringformat = new LabelDef.StringFormat(); if (alignTextcombo.SelectedItem.ToString().Equals(GetString("LEFT"), StringComparison.OrdinalIgnoreCase)) { stringformat.Align = LabelDef.FieldFormat.Alignment.Left; } else { stringformat.Align = LabelDef.FieldFormat.Alignment.Right; } textfieldgroup.printFormat = new LabelDef.PrintFormat(stringformat); IList <LabelDef.TextField> addedtextfieldlist = new List <LabelDef.TextField>(); foreach (string textfieldIDToAdd in addedtextfieldslist.Items) { LabelDef.Field fieldvalue; referencelist.TryGetValue(textfieldIDToAdd, out fieldvalue); LabelDef.TextField textfieldvalue = (LabelDef.TextField)fieldvalue; textfieldgroup.fields.Add(textfieldvalue); } DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show(GetString("INVALIDINPUTERROR"), GetString("INVALIDINPUTERRORTITLE"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void linkedtextfieldslist_SelectedIndexChanged(object sender, EventArgs e) { if (linkedtextfieldslist.SelectedItems.Count == 1) { foreach (LabelDef.TextField searchField in textfieldgroup.fields) //TODO : Make more efficient { if (searchField.ID.Equals(linkedtextfieldslist.SelectedItem.ToString())) { selectedTextfield = searchField; } } ShowTextFieldProperties(); FillData(textfieldgroup); mainForm.Invalidate(); } }
private void GetTextFields(IDictionary <string, LabelDef.Field> localReferenceList) { foreach (KeyValuePair <string, LabelDef.Field> pair in localReferenceList) { if (pair.Value is LabelDef.TextField && !(pair.Value is LabelDef.TextFieldGroup)) { LabelDef.TextField temptextfield = (LabelDef.TextField)pair.Value; textfieldlist.Add(temptextfield.ID, temptextfield); availabletextfieldslist.Items.Add(temptextfield.ID); } } if (availabletextfieldslist.Items.Count < 2) { MessageBox.Show("You need atleast two available textfields to be able to link them.", "Not enough available textfields", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.Cancel; this.Close(); } }
public override void SetData() { textfieldgroup = (Label.LabelDef.TextFieldGroup)base.Field; alignTextcombo.SelectedItem = textfieldgroup.printFormat.format.Align.ToString(); concatmethodcombo.SelectedItem = textfieldgroup.concatMethod.ToString(); LabelDef.TextField previouslySelectedTextField = null; if (selectedTextfield != null) { previouslySelectedTextField = selectedTextfield; } linkedtextfieldslist.Items.Clear(); foreach (LabelDef.TextField temptextfield in textfieldgroup.fields) { linkedtextfieldslist.Items.Add(temptextfield.ID); } if (previouslySelectedTextField != null) { selectedTextfield = previouslySelectedTextField; } else { selectedTextfield = textfieldgroup.fields.ElementAt(0); } ACA.LabelX.Label.LabelDef.FontX tempfont = null; if (selectedTextfield != null) { tempfont = selectedTextfield.Font; } Fontcombo.Items.Clear(); foreach (LabelDef.FontX fontToAdd in localfontList.Values) { addFontXtoCombobox(fontToAdd, Fontcombo); } if (tempfont != null) { Fontcombo.SelectedItem = fontToString(tempfont); } else { Fontcombo.SelectedIndex = 0; } if (selectedTextfield != null) { if (selectedTextfield.ValueRef == null) { referencecombo.SelectedIndex = 0; } else { referencecombo.SelectedItem = selectedTextfield.ValueRef; } } if (selectedTextfield != null && selectedTextfield.printFormat.format.FormatString != null) { formattxt.Text = selectedTextfield.printFormat.format.FormatString; } else { formattxt.Text = String.Empty; } }
//Main Function protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graph = e.Graphics; float TranslateX = 0.0f; float TranslateY = 0.0f; //System.Diagnostics.Debug.WriteLine(string.Format("width {0}, height {1}", this.Size.Width, this.Size.Height)); if (useWhiteBackground) { Graph.FillRectangle(Brushes.White, 0, 0, this.Size.Width, this.Size.Height); //Color label white } else { HatchBrush bb = new HatchBrush(HatchStyle.LargeCheckerBoard, Color.LightGray, Color.White); Graph.FillRectangle(bb /*Brushes.White*/, 0, 0, this.Size.Width, this.Size.Height); //Color label white bb.Dispose(); } //Graph.DrawRectangle(new Pen(Brushes.CadetBlue), 0, 0, this.Size.Width, this.Size.Height); //showit, edge filling... //mve,1.3.2 Matrix mat = new Matrix(); mat.Scale(zoomFactor, zoomFactor, MatrixOrder.Append); Graph.Transform = mat; if (rotation != 0) { Graph.RotateTransform(rotation, MatrixOrder.Append); if (rotation > 0) { TranslateX = 0.0f;// -Size.Width / 2; TranslateY = -Size.Width / zoomFactor; } else { TranslateX = -Size.Height / zoomFactor; TranslateY = 0.0f; } Graph.TranslateTransform(TranslateX, TranslateY); } mat.Dispose(); mat = Graph.Transform; Boolean isSelectedField = false; foreach (LabelDef.Field field in drawingreferenceList.Values) //Draw each element in drawingreferenceList { field.BaseTransformation = mat; //mve,1.3.2 Graph.ResetTransform(); //Al drawing routines can perform transforms. Reset here to start fresh. //if (zoomFactor != 1.0f) //{ Graph.Transform = mat; // if (rotation != 0) // { // Graph.RotateTransform(rotation, MatrixOrder.Append); // Graph.TranslateTransform(TranslateX, TranslateY); // } //} //* if (field.ID.Equals(selectedFieldId)) { isSelectedField = true; } else { isSelectedField = false; } if (field is LabelDef.TextFieldGroup) { LabelDef.TextFieldGroup textfieldgroup = (LabelDef.TextFieldGroup)field; returnRectangle = textfieldgroup.Draw(Graph, new System.Drawing.Point(0, 0), labelset, 1043, isSelectedField); } else if (field is LabelDef.TextField) { LabelDef.TextField textfield = (LabelDef.TextField)field; System.Drawing.StringFormat stringFormat = new System.Drawing.StringFormat(StringFormatFlags.NoWrap); if (textfield.printFormat == null) { stringFormat.Alignment = StringAlignment.Near; } else { stringFormat.Alignment = textfield.printFormat.format.GetAsStringAlignment(); } returnRectangle = textfield.Draw(Graph, new System.Drawing.Point(0, 0), labelset, 1043, isSelectedField); } else if (field is LabelDef.ImageField) { LabelDef.ImageField imagefield = (LabelDef.ImageField)field; returnRectangle = imagefield.Draw(Graph, new System.Drawing.Point(0, 0), labelset, 1043, isSelectedField); } else if (field is LabelDef.BarcodeField) { LabelDef.BarcodeField barcodefield = (LabelDef.BarcodeField)field; returnRectangle = barcodefield.Draw(Graph, new System.Drawing.Point(0, 0), labelset, 1043, isSelectedField); } /* System.Diagnostics.Debug.WriteLine( * string.Format("{6}: Returnrectangle: {0},{1} -> {2},{3} Contains? {4},{5} ?", * returnRectangle.X, * returnRectangle.Y, * returnRectangle.Right, * returnRectangle.Bottom, * selectX, selectY, * field.ID.ToString() * ) * );*/ if (detectedClickToSelect) { if (returnRectangle.Contains(new System.Drawing.Point(selectX, selectY))) { fieldIDToSelect = field.ID; detectedClickToSelect = false; } } } detectedClickToSelect = false; mat.Dispose(); }
//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); } }