Show / Hide Table of Contents

# Class Dim

Dim properties of a View to control the position.

##### Inheritance

System.Object
Dim

##### Inherited Members

System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()

###### Namespace: Terminal.Gui

###### Assembly: Terminal.Gui.dll

##### Syntax

    public class Dim

##### Remarks

Use the Dim objects on the Width or Height properties of a View to control the position.

These can be used to set the absolute position, when merely assigning an integer value (via the implicit integer to Pos conversion), and they can be combined to produce more useful layouts, like: Pos.Center - 3, which would shift the postion of the View 3 characters to the left after centering for example.

### Methods

#### Equals(Object)

Determines whether the specified object is equal to the current object.

##### Declaration

    public override bool Equals(object other)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Object | other | The object to compare with the current object.

##### Returns

Type | Description
--- | ---
System.Boolean | true if the specified object is equal to the current object; otherwise, false.

##### Overrides

System.Object.Equals(System.Object)

#### Fill(Int32)

Initializes a new instance of the Dim class that fills the dimension, but leaves the specified number of colums for a margin.

##### Declaration

    public static Dim Fill(int margin = 0)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | margin | Margin to use.

##### Returns

Type | Description
--- | ---
Dim | The Fill dimension.

#### GetHashCode()

Serves as the default hash function.

##### Declaration

    public override int GetHashCode()

##### Returns

Type | Description
--- | ---
System.Int32 | A hash code for the current object.

##### Overrides

System.Object.GetHashCode()

#### Height(View)

Returns a Dim object tracks the Height of the specified View.

##### Declaration

    public static Dim Height(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view | The view that will be tracked.

##### Returns

Type | Description
--- | ---
Dim | The Dim of the other View.

#### Percent(Single, Boolean)

Creates a percentage Dim object

##### Declaration

    public static Dim Percent(float n, bool r = false)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Single | n | A value between 0 and 100 representing the percentage.
System.Boolean | r | If `true` the Percent is computed based on the remaining space after the X/Y anchor positions. If `false` is computed based on the whole original space.

##### Returns

Type | Description
--- | ---
Dim | The percent Dim object.

##### Examples

This initializes a TextFieldthat is centered horizontally, is 50% of the way down, is 30% the height, and is 80% the width of the View it added to.

    var textView = new TextView () {
    X = Pos.Center (),
    Y = Pos.Percent (50),
    Width = Dim.Percent (80),
    	Height = Dim.Percent (30),
    };

#### Sized(Int32)

Creates an Absolute Dim from the specified integer value.

##### Declaration

    public static Dim Sized(int n)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | n | The value to convert to the Dim.

##### Returns

Type | Description
--- | ---
Dim | The Absolute Dim.

#### Width(View)

Returns a Dim object tracks the Width of the specified View.

##### Declaration

    public static Dim Width(View view)

##### Parameters

Type | Name | Description
--- | --- | ---
View | view | The view that will be tracked.

##### Returns

Type | Description
--- | ---
Dim | The Dim of the other View.

### Operators

#### Addition(Dim, Dim)

Adds a Dim to a Dim, yielding a new Dim.

##### Declaration

    public static Dim operator +(Dim left, Dim right)

##### Parameters

Type | Name | Description
--- | --- | ---
Dim | left | The first Dim to add.
Dim | right | The second Dim to add.

##### Returns

Type | Description
--- | ---
Dim | The Dim that is the sum of the values of `left` and `right`.

#### Implicit(Int32 to Dim)

Creates an Absolute Dim from the specified integer value.

##### Declaration

    public static implicit operator Dim(int n)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Int32 | n | The value to convert to the pos.

##### Returns

Type | Description
--- | ---
Dim | The Absolute Dim.

#### Subtraction(Dim, Dim)

Subtracts a Dim from a Dim, yielding a new Dim.

##### Declaration

    public static Dim operator -(Dim left, Dim right)

##### Parameters

Type | Name | Description
--- | --- | ---
Dim | left | The Dim to subtract from (the minuend).
Dim | right | The Dim to subtract (the subtrahend).

##### Returns

Type | Description
--- | ---
Dim | The Dim that is the `left` minus `right`.