[]
        
(Showing Draft Content)

C1.C1Preview.Unit.-ctor

Unit Constructor

Unit(string)

Initializes a new instance of the Unit structure from a string. See remarks for details.

Declaration
public Unit(string str)
Parameters
Type Name Description
string str

A string representing the value.

Remarks

(In the description that follows, "object" means a RenderObject or another document object on which the current Unit represents a dimension or a coordinate, not the Unit structure itself.)

The str string should contain a valid Unit value in one of the following forms:

  • Auto, represented by the string "auto". The exact semantics depend on the type of object with which the current unit is associated.
  • An unqualified numeric value, e.g. "8" or "100.12".

    In this case DefaultUnit determines the unit of measurement.

  • A numeric value qualified with unit of measurement, e.g. "28mm" or "7in".

    The following unit type qualifiers are supported (for each type, the corresponding element of the UnitTypeEnum enumeration is listed):

    • defDefaultUnit is used (Default; this is equivalent to not specifying untis at all);
    • doc"Document" units (Document; 1/300th of an inch);
    • inInches (Inch);
    • mmMillimeters (Mm);
    • pcPicas (Pica; 1/6 of an inch);
    • pixDevice pixels (Pixel; depend on MeasurementDpi);
    • ptPoints (Point; 1/72 of a inch);
    • twTwips (Twip; 1/1440 of a inch);
    • inhs1/100 of an inch (InHs);
    • dsp"Display" units (Display; 1/75 of an inch);
    • cmCentimeters (Cm);
    • em"Em size" (Em; object font's height);
    • ex"Ex size" (Ex; object font lowercase x's height);
    • lsObject font's line spacing (LineSpacing).
  • A percentage of the object's parent size, optionally qualified with the parent's dimension ("width" or "height"; if a dimension is not specified, the dimension the current unit referes to is assumed), e.g. "50%width" or "120%".

    (Percentage can only be used to specify width or height, and is not valid for coordinates.)

  • A reference to a dimension or coordinate of another object, e.g. "prev.width", "next.bottom" or "page1column2.width".

    The referenced object may be identified by any of the following key words:

    • selfThe current object. Default, may be omitted;
    • parentThe current object's parent (container);
    • prevThe previous sibling of the current object;
    • nextThe next sibling of the current object;
    • pageThe current page;
    • columnThe current page column;
    • pageNPage by number, N is 1-based (e.g. "page8"; the page must already exist - forward references using this notation are not supported);
    • pageindexNPage by index, N is 0-based (e.g. "page0");
    • columnMColumn by number, M is 1-based, on the current page (e.g. "column2");
    • pageN.columnMColumn M on page N, M and N are 1-based (e.g. "page8.column2");
    • object nameObject with the specified name (see Name). The object is first searched among the siblings of the current object, then among its children.

    The referenced dimension or coordinate may be specified using any of the following key words:

    • leftThe X coordinate of the left edge of an object;
    • topThe Y coordinate of the top edge of an object;
    • rightThe X coordinate of the right edge of an object;
    • bottomThe Y coordinate of the bottom edge of an object;
    • widthThe width of an object;
    • heightThe height of an object.
  • A Max or Min built-in function call, e.g. "Max(prev.width,6cm)" or "Min(0.5in,next.height)".
  • An expression using operands in any of the forms described above (except "auto"), combined using operators + (add), - (subtract), * (multiply), / (divide), % (percent), functions Min and Max, and parentheses ( and ).

    Examples of unit expressions are:

    • prev.width + 50%prev.widthThis expression can be used to specify the width of an object being 1.5 times the width of its previous sibling
    • 150%prevSame as above
    • prev * 1.5Same as above but using multiplication instead of percentage

Unit(double, UnitTypeEnum)

Initializes a new instance of the Unit structure with an absolute length value.

Declaration
public Unit(double value, UnitTypeEnum unitType)
Parameters
Type Name Description
double value

The unit value.

UnitTypeEnum unitType

The unit of measurement.