import * as React from "react"; import {ReportItemDesigner} from "./../designer/ReportItemDesigner"; import {RectF, SizeF} from "../../drawing/Unit"; import convertHexToRGB = __MaterialUI.Utils.ColorManipulator.convertHexToRGB; import {ItemSelectionType, SelectionRules} from "../behavior/Enums"; import {Cursor} from "../../drawing/Cursor"; import {Behavior} from "../behavior/Behavior"; import {DataTableItemBehavior} from "../behavior/DataTableItemBehavior"; import {DataTableGlyph} from "../behavior/DataTableGlyph"; import * as ReactDOM from "react-dom"; import Sheet from "../../../libs/gridview/src/model/sheet"; import Operation from "../../../libs/gridview/src/model/operation/index"; import {Rect} from "../../../libs/gridview/src/model/common"; import Canvas from "../../../libs/gridview/src/model/canvas/index"; import drawTable from "../../../libs/gridview/src/containers/cells/controls/table"; import drawOperation from "../../../libs/gridview/src/containers/cells/controls/operation"; import drawColumnHeader from "../../../libs/gridview/src/containers/cells/controls/column-header"; import drawRowHeader from "../../../libs/gridview/src/containers/cells/controls/row-header"; import drawCenterHeader from "../../../libs/gridview/src/containers/cells/controls/center-header"; import {ReportItemBase} from "../../items/ReportItemBase"; import {PropertyChangeEventArgs} from "../../items/PropertyChangeEventArgs"; import {CommonProperty} from "../../items/properties/define"; import {DataTableItem} from "../../items/data-table/DataTableItem"; import {ItemBodyGlyph} from "../behavior/ItemBodyGlyph"; const Konva = require('konva'); class DataTableDesigner extends ReportItemDesigner { private clipWidth:number; private clipHeight:number; private _itemBodyGlyph:DataTableGlyph; initialize(item: ReportItemBase): void { super.initialize(item); item.on(ReportItemBase.PropertyChangeEventName, this.propertyChanged.bind(this)); } protected observerChildrenChanged() { } private propertyChanged(args:PropertyChangeEventArgs) { if (args.property === CommonProperty.width || args.property === CommonProperty.height) { this.updateMinBounds(); } } render(bounds:RectF):any { const zoom = this.reportDesigner.zoom; const padding = { top: 0, left: 0, right: 0, bottom: 0 }; const clipWidth = bounds.width - padding.left - padding.right; const clipHeight = bounds.height - padding.top - padding.bottom; // const rootProps = { // x: bounds.x, // y: bounds.y, // width: bounds.width, // height: bounds.height, // clipX: padding.left, // clipY: padding.top, // clipWidth: clipWidth, // clipHeight: clipHeight, // }; this.clipWidth = clipWidth; this.clipHeight = clipHeight; let self = this; var triangle = new Konva.Shape({ sceneFunc: function(context) { const item = self.reportItem as DataTableItem; const sheet = item.sheet; const sheetConfig = item.config; const width = sheet.columnHeader.width; const height = sheet.rowHeader.height+sheetConfig.columnHeaderHeight; let opeModel = new Operation(); const ctx:CanvasRenderingContext2D = context._context; //tableElement.getContext("2d"); ctx.save(); ctx.scale(zoom, zoom); const canvas = new Canvas(ctx, width, height); drawTable(canvas, sheet, opeModel, true); ctx.restore(); } }); return triangle } set selected(value: Boolean) { const item: DataTableItem = this.reportItem as DataTableItem; if(value === true){ item.recordConfig() }else{ item.removeRecordConfig(); } this._selected = value; } createDefaultBehavior():Behavior { return new DataTableItemBehavior(this, this.host); } protected getDefaultItemBodyGlyph(): ItemBodyGlyph { this._itemBodyGlyph = new DataTableGlyph(this, Cursor.Default, this.defaultBehavior); return this._itemBodyGlyph; } canResize(resizeRule: SelectionRules): boolean{ return false; } } export default DataTableDesigner;