import { hilog } from '@kit.PerformanceAnalysisKit'; import { ExecuteCommand } from '../EventSubWindow/ExecuteCommand'; import { TitleButton } from "../LayoutInterface/Interface/ButtonInterface"; import { TitleModel } from "../LayoutInterface/Interface/ModelInterface"; import { TitleData } from '../LayoutInterface/Layout/TabContent'; //单一功能按钮 //图片->文本 //不能用于模块切换 @ComponentV2 export struct EventBtn { @Param eventBtn: TitleButton | undefined = undefined; build() { Column({ space: 0 }) { if (this.eventBtn != undefined) { Button() .width(35) .height(35) .backgroundImage($r('app.media.' + this.eventBtn.eIcon)) .backgroundImagePosition({ x: '5%', y: '5%' }) .backgroundColor(Color.Transparent) .backgroundImageSize({ width: '90%', // 图片宽度占满按钮 height: '90%' // 图片高度占满按钮 }) .onClick(()=>{ ExecuteCommand(this.eventBtn as TitleButton); }) Text() .width(50) .height(7) .backgroundColor(Color.Transparent) Text(this.eventBtn.eName) .fontSize(10) .width(50) .height(10) .textAlign(TextAlign.Center) .backgroundColor(Color.Transparent) } } .height(50) .width(50) .padding(1) } } //仅仅用于模块切换 @ComponentV2 export struct SwitchModelBtn { @Param eventBtn: TitleButton | undefined = undefined; @Consumer('curtModel') curtModel: Array | undefined = TitleData.mModels.get(0) build() { Column({ space: 2 }) { if (this.eventBtn != undefined) { Button() .width('35vp') .height('35vp') .backgroundImage($r('app.media.' + this.eventBtn.eIcon)) .backgroundImagePosition({ x: '10%', y: '10%' }) .backgroundColor(Color.Transparent) .backgroundImageSize({ width: '80%', // 图片宽度占满按钮 height: '80%' // 图片高度占满按钮 }).onClick(() => { if (this.eventBtn?.eEvent == 'Switch_Model_CAD') { this.curtModel = TitleData.mModels.get(1) } else if (this.eventBtn?.eEvent == 'Switch_Model_CAM') { this.curtModel = TitleData.mModels.get(2) } else if (this.eventBtn?.eEvent == 'Switch_Model_CAE') { this.curtModel = TitleData.mModels.get(3) } }) Text(this.eventBtn.eName) .fontSize('10fp') .width('45vp') .height('10vp') .textAlign(TextAlign.Center) } } .height('50vp') .width('50vp') .padding('1vp') } }