/** * Created by W.X. on 2016/11/18. */ import * as React from "react"; import {observer} from "mobx-react/index"; import {autobind} from "core-decorators"; import {Unit} from "../../../drawing/Unit"; import {DesignerHost} from '../../DesignerHost'; import Editor from "./Editor"; import {SpinnerComponent} from "./_components/SpinnerComponent"; import {ReportProperty} from "./../../../items/properties/define"; @observer export class PaperMarginEditor extends Editor { getValue(){ const paper = DesignerHost.instance().designReport.report; return { left: paper.leftMargin, right: paper.rightMargin, top: paper.topMargin, bottom: paper.bottomMargin } } renderValueEditor() { const margin = this.getValue(); return (
上
右
下
左
); } @autobind onChangeTop(value: Unit) { this.changeValue('top', value); } @autobind onChangeRight(value: Unit) { this.changeValue('right', value); } @autobind onChangeBottom(value: Unit) { this.changeValue('bottom', value); } @autobind onChangeLeft(value: Unit) { this.changeValue('left', value); } changeValue(type: string, value: Unit){ const item = this.props.items[0]; item.setPropertyValue(ReportProperty[type + 'Margin'], value); DesignerHost.instance().historyService.snap(); } }