private void DrawLine(PTXControlSequence sequence, PrintPageEventArgs e) { // Inline (horizontal) or Baseline (vertical)? bool isInline = sequence.GetType() == typeof(DIR); // Prepare X,Y origin/destination float xOrig, yOrig, xDest, yDest; Func <float, bool, float> getInches = (float val, bool positive) => { return((float)(Converters.GetInches((int)val, unitsPerBase, measurement) * 100) * (positive ? 1 : -1)); }; // Get the length width of the line (1/1440 of an inch) float length = (short)sequence.GetType().GetProperty("RuleLength").GetValue(sequence); float width = getInches((short)sequence.GetType().GetProperty("RuleWidth").GetValue(sequence), true); float shifted = width / 2f; // Set origin/destination based on text orientation if (isInline) { if (curIOrient == 0 || curIOrient == 180) { xOrig = curInlinePos; if (curIOrient == 180) { xOrig = e.PageBounds.Right - xOrig; } xDest = xOrig + getInches(length, curIOrient == 0); yOrig = curBaselinePos + shifted; if (curBOrient == 270) { yOrig = e.PageBounds.Bottom - yOrig; } yDest = yOrig; } else { yOrig = curInlinePos; if (curIOrient == 270) { yOrig = e.PageBounds.Bottom - yOrig; } yDest = yOrig + getInches(length, curIOrient == 90); xOrig = curBaselinePos - shifted; if (curBOrient == 180) { xOrig = e.PageBounds.Right - xOrig; } xDest = xOrig; } } else { if (curBOrient == 0 || curBOrient == 180) { xOrig = curBaselinePos; if (curBOrient == 180) { xOrig = e.PageBounds.Right - xOrig; } xDest = xOrig + getInches(length, curBOrient == 0); yOrig = curInlinePos + shifted; if (curIOrient == 270) { yOrig = e.PageBounds.Bottom - yOrig; } yDest = yOrig; } else { yOrig = curBaselinePos; if (curBOrient == 270) { yOrig = e.PageBounds.Bottom - yOrig; } yDest = yOrig + getInches(length, curBOrient == 90); xOrig = curInlinePos - shifted; if (curIOrient == 180) { xOrig = e.PageBounds.Right - xOrig; } xDest = xOrig; } } e.Graphics.DrawLine(new Pen(curColor, width), (int)Math.Round(xOrig), (int)Math.Round(yOrig), (int)Math.Round(xDest), (int)Math.Round(yDest)); }
public override void ParseData() { _controlSequences = PTXControlSequence.GetCSIs(Data); }