public static XElement ToXElement(this PresentationSpaceField Field, XName Name) { if (Field == null) { return(new XElement(Name, null)); } else { string fldText = ""; int textLx = 0; if (Field.Text != null) { textLx = Field.Text.Length; fldText = Field.Text.TrimEnd(new char[] { ' ' }); } XElement xe = new XElement(Name, Field.Location.ToXElement("Location"), new XElement("Text", fldText), new XElement("Lx", textLx), Field.FieldAttribute.ToXElement("FldAttr") ); return(xe); } }
public static bool TextContains( this PresentationSpaceField Field, string Text) { if (Field == null) { return(false); } else if (Field.Text.Contains(Text)) { return(true); } else { return(false); } }
private void LoadFields() { mFields = new LinkedList <PresentationSpaceField>(); LinkedListNode <PresentationSpacePixel> node = Pixels.First; while (node != null) { if (node.Value.IsFieldAttribute == true) { LinkedListNode <PresentationSpacePixel> endNode = null; PresentationSpaceField fld = new PresentationSpaceField(out endNode, this, node); mFields.AddLast(fld); node = endNode; // the end node of this just loaded field. } node = node.Next; } }
public static PresentationSpaceField PresentationSpaceFieldOrDefault( this XElement Elem, XNamespace ns, PresentationSpaceField Default = null) { if (Elem == null) { return(Default); } else { var loc = Elem.Element(ns + "Location").DisplayLocationOrDefault(ns, null); var fldText = Elem.Element(ns + "Text").StringOrDefault(); var lx = Elem.Element(ns + "Lx").IntOrDefault(0).Value; var fldAttr = Elem.Element(ns + "FldAttr").FieldAttributeOrDefault(null); // pad the text to its original size. fldText.PadRight(lx, ' '); return(new PresentationSpaceField(fldAttr, loc, fldText)); } }
/// <summary> /// get the DrawContext of a control from its OnRender method. /// </summary> /// <param name="DrawContext"></param> public void DrawText(DrawingContext DrawContext) { double emSize = 12; var formattedText = new FormattedText( this.Text, CultureInfo.GetCultureInfo("en-us"), System.Windows.FlowDirection.LeftToRight, new Typeface("Lucida Console"), emSize, System.Windows.Media.Brushes.Black); var charSx = PresentationSpaceField.CalcCharSize(emSize); // advance the fld location past the attribute byte. var psDim = new PresentationSpaceDim(24, 80); var loc = psDim.IncDisplayLocation(this.Location); double y = (loc.Row - 1) * charSx.Height; double x = (loc.Column - 1) * charSx.Width; // Draw the formatted text string to the DrawingContext of the control. DrawContext.DrawText(formattedText, new System.Windows.Point(x, y)); }