Class ProportionsAttribute
Used to specify image format proportions, for example Width=16 and Height=9 for a 16:9 wide format
Inherited Members
Namespace: AdaptiveImages.Validation
Assembly: AdaptiveImages.dll
Syntax
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true, Inherited = true)]
public class ProportionsAttribute : ImageValidationAttribute, IProportions, IEquatable<ProportionsAttribute>
Constructors
ProportionsAttribute()
Defines a new proportions constraint.
Declaration
public ProportionsAttribute()
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(FormFactor, string?)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(FormFactor formFactor, string? name)
Parameters
Type | Name | Description |
---|---|---|
FormFactor | formFactor | One or more form factors this attribute applies to (bitwise OR supported), leave empty to make it apply to all form factors. |
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(FormFactor, string?, bool)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(FormFactor formFactor, string? name, bool isDefault)
Parameters
Type | Name | Description |
---|---|---|
FormFactor | formFactor | One or more form factors this attribute applies to (bitwise OR supported), leave empty to make it apply to all form factors. |
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
bool | isDefault | Set to true to make this the default proportions if more than one attribute applies, otherwise the first proportions attribute will be used as the default. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(bool)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(bool isDefault)
Parameters
Type | Name | Description |
---|---|---|
bool | isDefault | Set to true to make this the default proportions if more than one attribute applies, otherwise the first proportions attribute will be used as the default. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int, FormFactor)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight, FormFactor formFactor)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
FormFactor | formFactor | One or more form factors this attribute applies to (bitwise OR supported), leave empty to make it apply to all form factors. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int, FormFactor, bool)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight, FormFactor formFactor, bool isDefault)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
FormFactor | formFactor | One or more form factors this attribute applies to (bitwise OR supported), leave empty to make it apply to all form factors. |
bool | isDefault | Set to true to make this the default proportions if more than one attribute applies, otherwise the first proportions attribute will be used as the default. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int, FormFactor, string?)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight, FormFactor formFactor, string? name)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
FormFactor | formFactor | One or more form factors this attribute applies to (bitwise OR supported), leave empty to make it apply to all form factors. |
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int, FormFactor, string?, bool)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight, FormFactor formFactor, string? name, bool isDefault)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
FormFactor | formFactor | One or more form factors this attribute applies to (bitwise OR supported), leave empty to make it apply to all form factors. |
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
bool | isDefault | Set to true to make this the default proportions if more than one attribute applies, otherwise the first proportions attribute will be used as the default. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int, FormFactor, string?, bool, bool, bool)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight, FormFactor formFactor, string? name, bool isDefault, bool allowCropping, bool allowFocalPoint)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
FormFactor | formFactor | One or more form factors this attribute applies to (bitwise OR supported), leave empty to make it apply to all form factors. |
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
bool | isDefault | Set to true to make this the default proportions if more than one attribute applies, otherwise the first proportions attribute will be used as the default. |
bool | allowCropping | Whether user is allowed to manually crop the image. |
bool | allowFocalPoint | Whether user is allowed to manually set the focal point. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int, bool)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight, bool isDefault)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
bool | isDefault | Set to true to make this the default proportions if more than one attribute applies, otherwise the first proportions attribute will be used as the default. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int, string?)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight, string? name)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(int, int, string?, bool)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(int relativeWidth, int relativeHeight, string? name, bool isDefault)
Parameters
Type | Name | Description |
---|---|---|
int | relativeWidth | Relative width, for example 16 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
int | relativeHeight | Relative height, for example 9 if specifying widescreen proportions like 16:9, or leave default to allow free-form cropping to any proportions. |
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
bool | isDefault | Set to true to make this the default proportions if more than one attribute applies, otherwise the first proportions attribute will be used as the default. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(string?)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(string? name)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
ProportionsAttribute(string?, bool)
Defines a new proportions constraint.
Declaration
public ProportionsAttribute(string? name, bool isDefault)
Parameters
Type | Name | Description |
---|---|---|
string | name | Name to display in the UI when multiple proportion attributes apply to the same image/form factor. Language paths can be used. |
bool | isDefault | Set to true to make this the default proportions if more than one attribute applies, otherwise the first proportions attribute will be used as the default. |
Remarks
The FormFactor property has no effect on SingleImage properties.
Exceptions
Type | Condition |
---|---|
ArgumentException |
Properties
AllowCropping
Gets or sets whether user is allowed to manually crop the image.
Declaration
public bool AllowCropping { get; set; }
Property Value
Type | Description |
---|---|
bool |
AllowFocalPoint
Gets or sets whether user is allowed to manually set the focal point.
Declaration
public bool AllowFocalPoint { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsDefault
Gets or sets whether this should be the default proportions when more than one attribute applies to an image/form factor.
Declaration
public bool IsDefault { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsFreeForm
Gets whether attribute represents free-form, i.e. no specific proportions constraint, meaning user should be able to crop image to any proportions.
Declaration
public bool IsFreeForm { get; }
Property Value
Type | Description |
---|---|
bool |
Name
Gets or sets name for the proportions, commonly displayed in UI when there are multiple proportions that apply to the same image/form factor. Language paths can be used.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Ratio
Gets the proportions ratio based on X and Y.
Declaration
public double Ratio { get; }
Property Value
Type | Description |
---|---|
double |
Remarks
A value of zero indicates free-form cropping without constraint.
X
Gets the width factor, for example 16 for 16:9 proportions.
Declaration
public int X { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
Value of zero indicates free-form proportions without constraints.
Y
Gets the height factor, for example 9 for 16:9 proportions.
Declaration
public int Y { get; }
Property Value
Type | Description |
---|---|
int |
Remarks
Value of zero indicates free-form proportions without constraints.
Methods
Equals(ProportionsAttribute?)
Used to check whether to attributes are effectively the same.
Declaration
public bool Equals(ProportionsAttribute? other)
Parameters
Type | Name | Description |
---|---|---|
ProportionsAttribute | other |
Returns
Type | Description |
---|---|
bool |
ToString()
Represents human-readable proportions string.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |