projects/wms-framework/src/lib/models/controls/GridPanelModel.ts
Class that represents the model of a GridLength.
Properties |
Accessors |
constructor(length: number, unitType: GridUnitType)
|
|||||||||
Parameters :
|
Static Auto |
Type : any
|
Default value : new GridLength(0, GridUnitType.Auto)
|
Public length |
Type : number
|
Public unitType |
Type : GridUnitType
|
Default value : GridUnitType.Pixel
|
Value |
getValue()
|
IsAbsolute |
getIsAbsolute()
|
Gets a value indicating if the grid lenght unit is a absolute value
Returns :
boolean
|
IsAuto |
getIsAuto()
|
Gets a value indicating if the grid lenght unit is an auto value
Returns :
boolean
|
IsStar |
getIsStar()
|
Gets a value indicating if the grid lenght unit is a star value
Returns :
boolean
|
import { FrameworkElement } from '../../basecomponentmodel/FrameworkElement';
import { DependencyObject } from '../../basecomponentmodel/DependencyObject';
import { PresentationFrameworkCollectionModel } from './ItemsControlModel';
import { DependencyProperty } from '../../basecomponentmodel/DependencyProperty';
import { UIElementCollectionModel } from '../../basecomponentmodel/UIElementCollectionModel';
import { PanelModel } from './PanelModel';
import { AngularComponentId } from '../../helpers';
import { GridUnitType } from '../enums';
/**
* Class that represents the model of a RowDefinition.
*
* @export
* @class GridRowDefinition
* @wType System.Windows.Controls.RowDefinition
*/
export class GridRowDefinition extends DependencyObject {
/**
* Internal height property
*
* @private
* @type {GridLength}
* @memberof GridRowDefinition
*/
private _height: GridLength = new GridLength(1, GridUnitType.Star);
/**
* MinHeight property.
*
* @type {*}
* @memberof GridRowDefinition
*/
public MinHeight: any = null;
/**
* MaxHeight property.
*
* @type {*}
* @memberof GridRowDefinition
*/
public MaxHeight: any = null;
/**
* Gets the current value of Height
*
* @type {GridLength}
* @memberof GridRowDefinition
*/
public get Height(): GridLength {
return this._height;
}
/**
* Sets a new value for Height
*
* @memberof GridRowDefinition
*/
public set Height(value: GridLength) {
if (value != this._height) {
this._height = value;
this.change.fire(['RowDefinitionHeight']);
}
}
}
/**
* Class that represents the model of a ColumnDefinition.
*
* @export
* @class GridColumnDefinition
* @extends {DependencyObject}
* @wType System.Windows.Controls.ColumnDefinition
*/
export class GridColumnDefinition extends DependencyObject {
/**
* Width property.
*
* @private
* @type {GridLength}
* @memberof GridColumnDefinition
*/
private _width: GridLength = new GridLength(1, GridUnitType.Star);
/**
* MinWidth property.
*
* @type {*}
* @memberof GridColumnDefinition
*/
public MinWidth: any = null;
/**
* MaxWidth property.
*
* @type {*}
* @memberof GridColumnDefinition
*/
public MaxWidth: any = null;
/**
* Gets or sets the width.
*
* @type {GridLength}
* @memberof GridColumnDefinition
*/
public get Width(): GridLength {
return this._width;
}
public set Width(value: GridLength) {
if (value !== this._width) {
this._width = value;
this.change.fire(['ColumnDefinitionWidth']);
}
}
}
/**
* Class that represents the model of a ColumnDefinitionCollection.
*
* @export
* @class GridColumnDefinitions
* @extends {PresentationFrameworkCollectionModel<GridColumnDefinition>}
* @wType System.Windows.Controls.ColumnDefinitionCollection
*/
export class GridColumnDefinitions extends PresentationFrameworkCollectionModel<GridColumnDefinition> {
constructor(private grid: GridModel) {
super();
}
}
/**
* Class that represents the model of a RowDefinitionCollection.
*
* @export
* @class GridRowDefinitions
* @extends {PresentationFrameworkCollectionModel<GridRowDefinition>}
* @wType System.Windows.Controls.RowDefinitionCollection
*/
export class GridRowDefinitions extends PresentationFrameworkCollectionModel<GridRowDefinition> {
public MinWidth: number = 0;
constructor(private grid: GridModel) {
super();
}
}
/**
* Class that represents the model of a GridLength.
*
* @export
* @class GridLength
* @wType System.Windows.GridLength
*/
export class GridLength {
public static Auto: any = new GridLength(0, GridUnitType.Auto);
public get Value(): number {
return this.length;
}
constructor(
public length: number,
public unitType: GridUnitType = GridUnitType.Pixel
) {}
/**
* Gets a value indicating if the grid lenght unit is a absolute value
*
* @readonly
* @type {boolean}
* @memberof GridLength
*/
public get IsAbsolute(): boolean {
return this.unitType === GridUnitType.Pixel;
}
/**
* Gets a value indicating if the grid lenght unit is an auto value
*
* @readonly
* @type {boolean}
* @memberof GridLength
*/
public get IsAuto(): boolean {
return this.unitType === GridUnitType.Auto;
}
/**
* Gets a value indicating if the grid lenght unit is a star value
*
* @readonly
* @type {boolean}
* @memberof GridLength
*/
public get IsStar(): boolean {
return this.unitType === GridUnitType.Star;
}
}
/**
* Class that represents the model of a Grid.
*
* @export
* @class GridModel
* @extends {PanelModel}
* @wType System.Windows.Controls.Grid
*/
export class GridModel extends PanelModel {
public AngularComponentId = AngularComponentId.gridPanel;
public attachedComponentInstance;
public ColumnDefinitions: GridColumnDefinitions;
public RowDefinitions: GridRowDefinitions;
/**
* ColumnProperty dependency property
*
* @static
* @type {DependencyProperty}
* @memberof GridPanelModel
*/
static ColumnProperty: DependencyProperty = new DependencyProperty(
'Grid_Column',
null,
null
);
/**
* ColumnSpanProperty dependency property
*
* @static
* @type {DependencyProperty}
* @memberof GridPanelModel
*/
static ColumnSpanProperty: DependencyProperty = new DependencyProperty(
'Grid_ColumnSpan',
null,
null
);
/**
* RowProperty dependency property
*
* @static
* @type {DependencyProperty}
* @memberof GridPanelModel
*/
static RowProperty: DependencyProperty = new DependencyProperty(
'Grid_Row',
null,
null
);
/**
* RowSpanProperty dependency property
*
* @static
* @type {DependencyProperty}
* @memberof GridPanelModel
*/
static RowSpanProperty: DependencyProperty = new DependencyProperty(
'Grid_RowSpan',
null,
null
);
/**
* ShowGridLinesProperty dependency property
*
* @static
* @type {DependencyProperty}
* @memberof GridPanelModel
*/
static ShowGridLinesProperty: DependencyProperty = new DependencyProperty(
'Grid_ShowGridLines',
false,
null
);
constructor() {
super();
this.ColumnDefinitions = new GridColumnDefinitions(this);
this.RowDefinitions = new GridRowDefinitions(this);
this.Children = new UIElementCollectionModel(this);
}
public static getColumnInformation(cell: any): number {
return cell.getValue(GridModel.ColumnProperty);
}
public static getRowInformation(cell: any): number {
return cell.getValue(GridModel.RowProperty);
}
public static setRowInformation(cell: DependencyObject, row: number) {
cell.setValue(GridModel.RowProperty, row);
}
public static setColumnInformation(cell: DependencyObject, column: number) {
cell.setValue(GridModel.ColumnProperty, column);
}
public static SetRow(element: FrameworkElement, row: number) {
element.setValue(GridModel.RowProperty, row);
}
public static GetRow(element: FrameworkElement) {
return element.getValue(GridModel.RowProperty);
}
public static SetColumn(element: FrameworkElement, column: number) {
element.setValue(GridModel.ColumnProperty, column);
}
public static GetColumn(element: FrameworkElement) {
return element.getValue(GridModel.ColumnProperty);
}
public static SetRowSpan(element: FrameworkElement, rowSpan: number) {
element.setValue(GridModel.RowSpanProperty, rowSpan);
}
public static GetRowSpan(element: FrameworkElement): any {
return element.getValue(GridModel.RowSpanProperty);
}
public static SetColumnSpan(element: FrameworkElement, columnSpan: number) {
element.setValue(GridModel.ColumnSpanProperty, columnSpan);
}
public static GetColumnSpan(element: FrameworkElement): any {
return element.getValue(GridModel.ColumnSpanProperty);
}
}