完善子窗口逻辑.对单一的显示设备,主窗口的属性进行合并.

This commit is contained in:
JackLee 2026-04-20 18:06:36 +08:00
parent 759ce30427
commit f373b912bf
23 changed files with 390 additions and 265 deletions

View File

@ -3,7 +3,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit';
import { window, display, AppStorageV2, ColorMetrics } from '@kit.ArkUI';
import { IBestInit } from "@ibestservices/ibest-ui-v2"
import {ExtractDir,CheckExistDir,HilogSadboxFontDirFile} from "../pages/extractdir/ExtractDir"
import {MainWindowStageInfo,InitGlobalDisplayWindowInfo,mwInfo}from '../pages/displaywindowinfo/DispWinInfo'
import { DisplayWindowInfo, InitGlobalDisplayWindowInfo,mdwInfo}from '../pages/displaywindowinfo/DispWinInfo'
const DOMAIN = 0x0000;
@ -63,24 +63,24 @@ export default class EntryAbility extends UIAbility {
console.error(`Failed to obtain the main window. Code: ${err.code}, message: ${err.message}`);
return;
}
mwInfo.mainWin = data;
mwInfo.id =data.getWindowProperties().id;
mdwInfo.win = data;
mdwInfo.winId =data.getWindowProperties().id;
//moveWindowTo
data.moveWindowTo(50, 50)
//resize mainWindow Size
data.resize(mwInfo.width, mwInfo.height, (err) => {
data.resize(mdwInfo.winWidth, mdwInfo.winHeight, (err) => {
if (err.code) {
console.error(`Failed to resize the window. Code: ${err.code}, message: ${err.message}`);
return;
}
console.info(`Succeeded in resizing the window to ${mwInfo.width}x${mwInfo.height}.`);
console.info(`Succeeded in resizing the window to ${mdwInfo.winWidth}x${mdwInfo.winHeight}.`);
});
// windowSizeChangeListener to Change mainWindowWidth&&mainWindowHeight in AppStorage
data.on('windowSizeChange', (ChangeData) => {
// if Size Change save to AppStorage
mwInfo.width = ChangeData.width;
mwInfo.height = ChangeData.height;
mdwInfo.winWidth = ChangeData.width;
mdwInfo.winHeight = ChangeData.height;
console.info('Succeeded in enabling the listener for window size changes. Data:' + ChangeData.width,
ChangeData.height);
});
@ -95,9 +95,9 @@ export default class EntryAbility extends UIAbility {
}
onWindowStageDestroy(): void {
AppStorageV2.remove<MainWindowStageInfo>(MainWindowStageInfo);
if (mwInfo.mainWin) {
mwInfo.mainWin = undefined;
AppStorageV2.remove<DisplayWindowInfo>(DisplayWindowInfo);
if (mdwInfo.win) {
mdwInfo.win = undefined;
}
// Main window is destroyed, release UI related resources
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');

View File

@ -5,7 +5,7 @@ import { LeftSideTab } from './leftside/LeftSideTab'
import { RightSideTab } from './rightside/RightSideTab'
import { ModelViewTab } from './ModelViewTab'
import { TitleColumnSub } from './titletabs/TitleColumnSub'
import { mwInfo } from './displaywindowinfo/DispWinInfo'
import { mdwInfo } from './displaywindowinfo/DispWinInfo'
const DOMAIN = 0x0000;
@ -20,8 +20,8 @@ enum DividerType{
struct Index {
@Local startX:number=0;
@Local isDragging:boolean=false;
@Provider('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1;
@Provider('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1;
@Provider('LeftSideWidth') leftSideWidth:number=mdwInfo.winWidth * 0.1;
@Provider('RightSideWidth') rightSideWidth:number=mdwInfo.winHeight * 0.1;
@Local overlayState:boolean=true;
//利用分割线拖动改变区域容器大小.鼠标和触控整合

View File

@ -1,5 +1,5 @@
import { hilog } from '@kit.PerformanceAnalysisKit';
import { mwInfo } from './displaywindowinfo/DispWinInfo'
import { mdwInfo } from './displaywindowinfo/DispWinInfo'
import { AppStorageV2 } from '@kit.ArkUI';
import {InitXCompNode,XCompInfos,XCompInfo,CurrentXCompIndex} from './eventhub/XCompMgr'
@ -22,18 +22,18 @@ export struct ModelViewTab {
ForEach(this.xcInfos.infos, (item: XCompInfo, index: number) => {
Row({ space: 0 }) {
Image($r('app.media.startIcon'))
.width(mwInfo.width*0.012)
.height(mwInfo.width*0.012)
.width(mdwInfo.winWidth*0.012)
.height(mdwInfo.winWidth*0.012)
.objectFit(ImageFit.Contain)
Button(item.name)
.fontWeight(index === this.barFocusIndex ? FontWeight.Bold : FontWeight.Normal)
.width('auto')
.height(mwInfo.width*0.012)
.height(mdwInfo.winWidth*0.012)
.type(ButtonType.Normal)
Button('X')
.fontSize(12)
.width(mwInfo.width*0.012)
.height(mwInfo.width*0.012)
.width(mdwInfo.winWidth*0.012)
.height(mdwInfo.winWidth*0.012)
.type(ButtonType.Normal)
.align(Alignment.Center)
}.onClick(() => {

View File

@ -1,17 +1,17 @@
import { hilog } from '@kit.PerformanceAnalysisKit';
import { Execute } from '../eventhub/EventBase';
import { TitleTabData } from '../layout/TitleTabData';
import { mwInfo } from '../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
import {
TitleModel,
TitleButton
} from "../interface/Interface";
//按钮统一尺寸,该按钮为正方形,所以以主窗口宽为基准,长=高->正方形
let ebWidth=mwInfo.width*0.02;
let ebHeigth=mwInfo.width*0.02;
let ebWidth=mdwInfo.winWidth*0.02;
let ebHeigth=mdwInfo.winWidth*0.02;
//占位符的高度
let edHeigth=mwInfo.width*0.005
let edHeigth=mdwInfo.winWidth*0.005
//单一功能按钮
@ -124,7 +124,7 @@ export struct MenuBtn {
.align(Alignment.Center)
}
.constraintSize({ minWidth: ebWidth })
.height(mwInfo.width*0.01)
.height(mdwInfo.winWidth*0.01)
.backgroundColor(Color.Transparent)
.bindMenu(this.BaseMenu)
.type(ButtonType.Normal)
@ -187,7 +187,7 @@ export struct SubColumnMenu {
Button(){
Row(){
Image($r('app.media.'+(this.icon!=undefined ? this.icon:(this.menus[this.curtIndex]as TitleButton).btnIcon)))
.width(mwInfo.width*0.012)
.width(mdwInfo.winWidth*0.012)
.scale({ centerX: '50%', centerY: '50%' })
.backgroundImagePosition({ x: '10%', y: '10%' })
.backgroundImageSize({
@ -200,7 +200,7 @@ export struct SubColumnMenu {
}
}.width('auto')
}
.constraintSize({ minWidth: mwInfo.width*0.012 })
.constraintSize({ minWidth: mdwInfo.winWidth*0.012 })
.backgroundColor(Color.Transparent)
.bindMenu(this.BaseMenu)
}.borderWidth(2)

View File

@ -1,11 +1,11 @@
import { mwInfo } from '../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
import { TitleButton } from "../interface/Interface";
//按钮统一尺寸,该按钮为正方形,所以以主窗口宽为基准,长=高->正方形
let ebWidth=mwInfo.width*0.075;
let ebHeigth=mwInfo.height*0.03;
let ebWidth=mdwInfo.winWidth*0.075;
let ebHeigth=mdwInfo.winHeight*0.03;
//占位符的高度
let edHeigth=mwInfo.width*0.005
let edHeigth=mdwInfo.winWidth*0.005
@ComponentV2
export struct TextComboBox {

View File

@ -1,11 +1,11 @@
import { mwInfo } from '../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
import { Execute } from "../eventhub/EventBase";
import { TitleButton } from "../interface/Interface";
import {SwitchView} from "../layout/SwitchView"
//按钮统一尺寸,该按钮为正方形,所以以主窗口宽为基准,长=高->正方形
let ebWidth=mwInfo.width*0.02;
let ebHeigth=mwInfo.width*0.02;
let ebWidth=mdwInfo.winWidth*0.02;
let ebHeigth=mdwInfo.winWidth*0.02;
//视图切换弹窗
@CustomDialog
export struct ViewDialog {

View File

@ -1,5 +1,5 @@
import { Execute } from "../eventhub/EventBase";
import { mwInfo } from '../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
import { BaseMenuData } from "../interface/MenuInterface";
import {
TitleGroup
@ -7,8 +7,7 @@ import {
} from "../interface/Interface";
//按钮统一尺寸,该按钮为正方形,所以以主窗口宽为基准,长=高->正方形
let ebWidth=mwInfo.width*0.02;
let ebHeigth=mwInfo.width*0.02;
let ebWidth=mdwInfo.winWidth*0.02;
@Builder
export function BaseMenu(indexMenu:BaseMenuData) {
@ -66,8 +65,8 @@ export struct GroupTextEventMenu {
.fontSize(16)
Blank().width('auto')
Button()
.height(mwInfo.width*0.005)
.width(mwInfo.width*0.005)
.height(mdwInfo.winWidth*0.005)
.width(mdwInfo.winWidth*0.005)
.padding(1)
.backgroundColor(Color.Transparent)
.backgroundImage($r('app.media.base_seetings'))

View File

@ -1,60 +1,47 @@
import { AppStorageV2, display,window ,UIContext} from '@kit.ArkUI';
import { AppStorageV2, display,window} from '@kit.ArkUI';
//该文档主要储存屏幕信息,主窗口信息,窗口管理信息
//底部有全局信息变量,已导出,其他page只需要import该文件即可调用let变量
@ObservedV2
export class MainDisplayInfo {
@Trace public id: number;
@Trace public width: number;
@Trace public height: number;
constructor(_id?: number, _width?: number,_height?: number) {
this.id = _id ?? 0;
this.width = _width ?? 0;
this.height = _height ?? 0;
}
}
@ObservedV2
export class MainWindowInfo {
@Trace public id: number;
@Trace public mainWin: window.Window|undefined;
@Trace public width: number;
@Trace public height: number;
constructor(_id?:number,_mainWin?:window.Window,_width?: number, _height?: number) {
this.id = _width ?? 0;
this.mainWin=_mainWin ?? undefined;
this.width = _height ?? 0;
this.height=_id ?? 0;
}
}
@ObservedV2
export class MainWindowStageInfo {
export class DisplayWindowInfo {
@Trace public displayId: number;
@Trace public displayWidth: number;
@Trace public displayHeight: number;
@Trace public winId: number;
@Trace public win?: window.Window;
@Trace public winWidth: number;
@Trace public winHeight: number;
@Trace public winStage?: window.WindowStage;
constructor(_ws?: window.WindowStage) {
this.winStage = _ws;
constructor(
_displayId?:number,
_displayWidth?: number,
_displayHeight?:number,
_winId?: number,
_winWidth?: number,
_winHeight?: number,
)
{
this.displayId = _displayId ?? 0;
this.displayWidth=_displayWidth?? 0;
this.displayHeight = _displayHeight ?? 0;
this.winId=_winId ?? 0;
this.winWidth = _winWidth?? 0;
this.winHeight = _winHeight?? 0;
}
}
export async function InitGlobalDisplayWindowInfo(windowStage: window.WindowStage){
const mainDisplayInfo = AppStorageV2.connect<MainDisplayInfo>(MainDisplayInfo, () => new MainDisplayInfo())!;
const mainWindowInfo = AppStorageV2.connect<MainWindowInfo>(MainWindowInfo, () => new MainWindowInfo())!;
const mainWindowStage = AppStorageV2.connect<MainWindowStageInfo>(MainWindowStageInfo, () => new MainWindowStageInfo())!;
mainDisplayInfo.id = display.getDefaultDisplaySync().id;
mainDisplayInfo.width = display.getDefaultDisplaySync().width;
mainDisplayInfo.height = display.getDefaultDisplaySync().height;
const displayWindowInfo = AppStorageV2.connect<DisplayWindowInfo>(DisplayWindowInfo, () => new DisplayWindowInfo())!;
displayWindowInfo.displayId = display.getDefaultDisplaySync().id;
displayWindowInfo.displayWidth = display.getDefaultDisplaySync().width;
displayWindowInfo.displayHeight = display.getDefaultDisplaySync().height;
mainWindowInfo.width = mainDisplayInfo.width-100;
mainWindowInfo.height = mainDisplayInfo.height-200;
displayWindowInfo.winWidth = displayWindowInfo.displayWidth-100;
displayWindowInfo.winHeight = displayWindowInfo.displayHeight-200;
displayWindowInfo.winStage= windowStage;
mainWindowStage.winStage = windowStage;
console.error(`Display Size:`,mainDisplayInfo.width,mainDisplayInfo.height);
console.error(`MainWindow Size:`,mainWindowInfo.width,mainWindowInfo.height);
console.error(`Display Size:`,displayWindowInfo.displayWidth,displayWindowInfo.displayHeight);
console.error(`MainWindow Size:`,displayWindowInfo.winWidth,displayWindowInfo.winHeight);
}
//全局保存主窗口信息,屏幕信息.窗口管理器信息
export let mwInfo: MainWindowInfo = AppStorageV2.connect<MainWindowInfo>(MainWindowInfo, () => new MainWindowInfo())!;
export let mdInfo: MainDisplayInfo = AppStorageV2.connect<MainDisplayInfo>(MainDisplayInfo, () => new MainDisplayInfo())!;
export let mwsInfo: MainWindowStageInfo = AppStorageV2.connect<MainWindowStageInfo>(MainWindowStageInfo, () => new MainWindowStageInfo())!;
export let mdwInfo: DisplayWindowInfo = AppStorageV2.connect<DisplayWindowInfo>(DisplayWindowInfo, () => new DisplayWindowInfo())!;

View File

@ -1,18 +1,36 @@
import {EventExecute} from './EventExecute'
import {EventPage} from './EventPage'
import { CloseSubWindow, CreateAndShowSubWindow } from './EventSubPage';
import { CreateXCompNode } from './XCompMgr';
import { mdwInfo } from '../displaywindowinfo/DispWinInfo';
import { window } from '@kit.ArkUI';
import { common,Want } from "@kit.AbilityKit";
import NativeOpenCAX from 'libopencax.so';
import {
TitleButton,
EventType
} from '../interface/Interface';
//执行事件
export function Execute(event:TitleButton){
if(event.btnEvent.type==EventType.EVENT){
EventExecute(event);
}else{
EventPage(event);
//窗体信息
export class SubWinInfo{
name?:string;
page?:string;
subWin?:window.Window;
subOpt?:window.SubWindowOptions;
subPointX?:number=200;
subPointY?:number=200;
width?:number=0;
height?:number=0;
constructor(name?: string, page?: string,width?: number,height?: number) {
this.name = name;
this.page = page;
this.width = width;
this.height = height;
}
}
//窗体保存容器
export let subWins:Map<string,SubWinInfo>=new Map<string,SubWinInfo>;
//随机ID
export function RndId(): string {
// 获取当前时间戳(毫秒)
@ -41,3 +59,137 @@ export function CurrentTime():string {
let seconds = now.getSeconds().toString().padStart(2, '0');
return`${year}-${month}-${date} ${hours}:${minutes}:${seconds}`;
}
//执行事件
export function Execute(event:TitleButton){
if(event.btnEvent.type==EventType.EVENT){
EventExecute(event);
}else if (event.btnEvent.type==EventType.PAGE){
EventPage(event);
}else if (event.btnEvent.type==EventType.WIN){
EventWin(event);
}
}
//事件类型:纯指令
export function EventExecute(event:TitleButton){
//事件处理
if(event?.btnEvent.command=='Execute_LoadModel'){
NativeOpenCAX.loadModel("/data/storage/el2/base/haps/entry/files/example/2027.stp");
}
if(event?.btnEvent.command=='Create_New'){
CreateXCompNode("");
}
//视图切换
if(event?.btnEvent.command=='CMD_VIEW_FRONT'){
NativeOpenCAX.switchView("CMD_VIEW_FRONT");
}else if(event?.btnEvent.command=='CMD_VIEW_TOP'){
NativeOpenCAX.switchView("CMD_VIEW_TOP");
}else if(event?.btnEvent.command=='CMD_VIEW_LEFT_SIDE'){
NativeOpenCAX.switchView("CMD_VIEW_LEFT_SIDE");
}else if(event?.btnEvent.command=='CMD_VIEW_RIGHT_SIDE'){
NativeOpenCAX.switchView("CMD_VIEW_RIGHT_SIDE");
}else if(event?.btnEvent.command=='CMD_VIEW_BOTTOM'){
NativeOpenCAX.switchView("CMD_VIEW_BOTTOM");
}else if(event?.btnEvent.command=='CMD_VIEW_REAR'){
NativeOpenCAX.switchView("CMD_VIEW_REAR");
}else if(event?.btnEvent.command=='CMD_VIEW_ISO'){
NativeOpenCAX.switchView("CMD_VIEW_ISO");
}else if(event?.btnEvent.command=='CMD_VIEW_DIM'){
NativeOpenCAX.switchView("CMD_VIEW_DIM");
}
}
//事件类型:页面
export function EventPage(event:TitleButton){
if(event?.btnEvent.command=='Page_NewFile') {
const winInfo: SubWinInfo = new SubWinInfo(event.btnName, event.btnEvent.page, mdwInfo.winWidth * 0.4, mdwInfo.winHeight * 0.4);
CreateAndShowSubWindow(winInfo);
} else if(event?.btnEvent.command=='Page_OpenFile'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.4,mdwInfo.winHeight*0.4);
CreateAndShowSubWindow(winInfo);
}else if(event?.btnEvent.command=='Page_SaveAsFile'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.4,mdwInfo.winHeight*0.4);
CreateAndShowSubWindow(winInfo);
} else if(event?.btnEvent.command=='Page_ImportFile'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.4,mdwInfo.winHeight*0.4);
CreateAndShowSubWindow(winInfo);
}else if(event?.btnEvent.command=='Page_ExportFile'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.4,mdwInfo.winHeight*0.4);
CreateAndShowSubWindow(winInfo);
}else if(event?.btnEvent.command=='Page_Options'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.6,mdwInfo.winHeight*0.8);
CreateAndShowSubWindow(winInfo);
}
}
//事件类型:子窗体
export function EventWin(event:TitleButton){
let winInfo: SubWinInfo=new SubWinInfo;
if(event?.btnEvent.command=='Page_NewFile') {
winInfo = new SubWinInfo(event.btnName, event.btnEvent.page, mdwInfo.winWidth * 0.4, mdwInfo.winHeight * 0.4);
} else if(event?.btnEvent.command=='Page_OpenFile'){
winInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.4,mdwInfo.winHeight*0.4);
}else if(event?.btnEvent.command=='Page_SaveAsFile'){
winInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.4,mdwInfo.winHeight*0.4);
} else if(event?.btnEvent.command=='Page_ImportFile'){
winInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.4,mdwInfo.winHeight*0.4);
}else if(event?.btnEvent.command=='Page_ExportFile'){
winInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.4,mdwInfo.winHeight*0.4);
}else if(event?.btnEvent.command=='Page_Options'){
winInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mdwInfo.winWidth*0.6,mdwInfo.winHeight*0.8);
}
EventCreateWin().then((result) => {
//执行订阅命令,加载Sub Window参数
if(result){
let context =mdwInfo.win?.getUIContext().getHostContext()?.getApplicationContext();
context?.eventHub.emit('InitSubWindow',winInfo);
}
});
}
async function EventCreateWin(): Promise<boolean>{
let want: Want = {
deviceId: '',
bundleName: 'com.example.opencax',
abilityName: 'SubWinAbility'
};
try {
let ctx = mdwInfo.win?.getUIContext().getHostContext() as common.UIAbilityContext;
if (!ctx) {
console.error("Failed to get UIAbilityContext");
return false;
}
// 监听来自 SubWinAbility 的初始化完成事件
const initializationPromise = new Promise<boolean>((resolve) => {
let appCtx =mdwInfo.win?.getUIContext().getHostContext()?.getApplicationContext();
appCtx?.eventHub.on('SubWinInitialized', (data: Object) => {
console.info("Received SubWinInitialized event:", data);
// 可以根据 data 中的信息判断是否成功
if (data && data !== undefined) {
resolve(data as boolean);
} else {
resolve(false);
}
appCtx?.eventHub.off('SubWinInitialized');
});
});
// 发起启动 Ability 的请求
console.info("Attempting to start SubWinAbility...");
await ctx.startAbility(want);
console.info("StartAbility request sent.");
// --- 等待初始化完成事件 ---
console.info("Waiting for SubWinInitialized event...");
const initResult = await initializationPromise;
console.info("SubWin initialization result:", initResult);
return initResult;
} catch (error) {
console.error("Failed to start ability:", error);
return false;
}
}

View File

@ -1,31 +0,0 @@
import { TitleButton } from '../interface/Interface';
import { CreateXCompNode } from './XCompMgr';
import NativeOpenCAX from 'libopencax.so';
//事件类型:纯指令
export function EventExecute(event:TitleButton){
//事件处理
if(event?.btnEvent.command=='Execute_LoadModel'){
NativeOpenCAX.loadModel("/data/storage/el2/base/haps/entry/files/example/2027.stp");
}
if(event?.btnEvent.command=='Create_New'){
CreateXCompNode("");
}
//视图切换
if(event?.btnEvent.command=='CMD_VIEW_FRONT'){
NativeOpenCAX.switchView("CMD_VIEW_FRONT");
}else if(event?.btnEvent.command=='CMD_VIEW_TOP'){
NativeOpenCAX.switchView("CMD_VIEW_TOP");
}else if(event?.btnEvent.command=='CMD_VIEW_LEFT_SIDE'){
NativeOpenCAX.switchView("CMD_VIEW_LEFT_SIDE");
}else if(event?.btnEvent.command=='CMD_VIEW_RIGHT_SIDE'){
NativeOpenCAX.switchView("CMD_VIEW_RIGHT_SIDE");
}else if(event?.btnEvent.command=='CMD_VIEW_BOTTOM'){
NativeOpenCAX.switchView("CMD_VIEW_BOTTOM");
}else if(event?.btnEvent.command=='CMD_VIEW_REAR'){
NativeOpenCAX.switchView("CMD_VIEW_REAR");
}else if(event?.btnEvent.command=='CMD_VIEW_ISO'){
NativeOpenCAX.switchView("CMD_VIEW_ISO");
}else if(event?.btnEvent.command=='CMD_VIEW_DIM'){
NativeOpenCAX.switchView("CMD_VIEW_DIM");
}
}

View File

@ -1,25 +0,0 @@
import { mwInfo } from '../displaywindowinfo/DispWinInfo';
import { CloseSubWindow, CreateAndShowSubWindow, SubWinInfo } from '../subpages/SWBase';
import { TitleButton } from '../interface/Interface';
//事件类型:页面
export function EventPage(event:TitleButton){
if(event?.btnEvent.command=='Page_NewFile') {
const winInfo: SubWinInfo = new SubWinInfo(event.btnName, event.btnEvent.page, mwInfo.width * 0.4, mwInfo.height * 0.4);
CreateAndShowSubWindow(winInfo);
} else if(event?.btnEvent.command=='Page_OpenFile'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4);
CreateAndShowSubWindow(winInfo);
}else if(event?.btnEvent.command=='Page_SaveAsFile'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4);
CreateAndShowSubWindow(winInfo);
} else if(event?.btnEvent.command=='Page_ImportFile'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4);
CreateAndShowSubWindow(winInfo);
}else if(event?.btnEvent.command=='Page_ExportFile'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.4,mwInfo.height*0.4);
CreateAndShowSubWindow(winInfo);
}else if(event?.btnEvent.command=='Page_Options'){
const winInfo:SubWinInfo=new SubWinInfo(event.btnName,event.btnEvent.page,mwInfo.width*0.6,mwInfo.height*0.8);
CreateAndShowSubWindow(winInfo);
}
}

View File

@ -0,0 +1,54 @@
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
import {SubWinInfo,subWins} from './EventBase'
export async function CreateAndShowSubWindow(subWinInfo:SubWinInfo) {
try {
if(mdwInfo.winStage==null){
console.error('Failed to create the subwindow. Cause: windowStage is null');
return;
}
let options: window.SubWindowOptions = {
title: subWinInfo.name as string,
decorEnabled: true,
isModal: false,
maximizeSupported: false,
outlineEnabled:true,
};
console.info('SubWindow Size:',subWinInfo.width,subWinInfo.height)
await mdwInfo.winStage.createSubWindowWithOptions(subWinInfo.name as string, options).then((data) => {
console.info("页面路径:", subWinInfo.page);
subWinInfo.subWin = data;
//子窗口显示位置
data.moveWindowTo(subWinInfo.subPointX, subWinInfo.subPointY)
//子窗口重置大小
data.resize(subWinInfo.width,subWinInfo.height);
data.setUIContent(subWinInfo.page, (err: BusinessError) => {
if (err.code) {
console.error("加载页面失败:", err);
return;
}
})
// 显示窗口
data.showWindow((err) => {
if (err.code) {
console.error("显示窗口失败:", err);
}
});
data.setResizeByDragEnabled(false);
})
subWins[subWinInfo.name as string]=subWinInfo;
} catch (error) {
console.error('Failed to create or show sub window:', (error as BusinessError).message);
}
}
export function CloseSubWindow() {
try {
console.info('Sub window closed.');
} catch (error) {
console.error('Failed to close sub window:', (error as BusinessError).message);
}
}

View File

@ -1,6 +1,6 @@
import { BusinessError } from '@kit.BasicServicesKit';
import { window } from '@kit.ArkUI';
import { mwsInfo } from '../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
//窗体信息
export class SubWinInfo{
@ -25,7 +25,7 @@ let subWins:Map<string,SubWinInfo>=new Map<string,SubWinInfo>;
export async function CreateAndShowSubWindow(subWinInfo:SubWinInfo) {
try {
if(mwsInfo.winStage==null){
if(mdwInfo.winStage==null){
console.error('Failed to create the subwindow. Cause: windowStage is null');
return;
}
@ -38,7 +38,7 @@ export async function CreateAndShowSubWindow(subWinInfo:SubWinInfo) {
};
console.info('SubWindow Size:',subWinInfo.width,subWinInfo.height)
await mwsInfo.winStage.createSubWindowWithOptions(subWinInfo.name as string, options).then((data) => {
await mdwInfo.winStage.createSubWindowWithOptions(subWinInfo.name as string, options).then((data) => {
console.info("页面路径:", subWinInfo.page);
subWinInfo.subWin = data;
//子窗口显示位置

View File

@ -8,6 +8,7 @@ export enum ModelType{
//事件类型
export enum EventType{
WIN,
PAGE,
EVENT
}

View File

@ -25,7 +25,7 @@ export let DevModel:TitleModel= {
{btnModel:[ModelType.BASE],btnName:'新建建模实例',btnNamed:'',btnIcon:'base_new_file',btnTips:'新建建模实例',btnEvent:{uid:'',command:'Create_New',page:'',type:EventType.EVENT,args:[]}},
[
{btnModel:[ModelType.BASE],btnName:'加载模型',btnNamed:'',btnIcon:'base_new_file',btnTips:'加载模型',btnEvent:{uid:'',command:'Execute_LoadModel',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'选择加载模型',btnNamed:'',btnIcon:'base_new_file',btnTips:'选择加载模型',btnEvent:{uid:'',command:'Page_OpenFile',page:GetEventsPage('Page_OpenFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'选择加载模型',btnNamed:'',btnIcon:'base_new_file',btnTips:'选择加载模型',btnEvent:{uid:'',command:'Page_OpenFile',page:GetEventsPage('Page_OpenFile'),type:EventType.WIN,args:[]}},
],
[
{btnModel:[ModelType.BASE],btnName:'正等轴测图',btnNamed:'',btnIcon:'base_new_file',btnTips:'正等轴测图',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
@ -38,11 +38,11 @@ export let DevModel:TitleModel= {
{btnModel:[ModelType.BASE],btnName:'仰视图',btnNamed:'',btnIcon:'base_new_file',btnTips:'仰视图',btnEvent:{uid:'',command:'CMD_VIEW_BOTTOM',page:'',type:EventType.EVENT,args:[]}},
],
[
{btnModel:[ModelType.BASE],btnName:'创建文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'创建文件',btnEvent:{uid:'',command:'Page_NewFile',page:GetEventsPage('Page_NewFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_new_file',btnTips:'另存为',btnEvent:{uid:'',command:'Page_SaveAsFile',page:GetEventsPage('Page_SaveAsFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导入文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'导入文件',btnEvent:{uid:'',command:'Page_ImportFile',page:GetEventsPage('Page_ImportFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导出文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'导出文件',btnEvent:{uid:'',command:'Page_ExportFile',page:GetEventsPage('Page_ExportFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'首选项',btnNamed:'',btnIcon:'base_new_file',btnTips:'首选项',btnEvent:{uid:'',command:'Page_Options',page:GetEventsPage('Page_Options'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'创建文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'创建文件',btnEvent:{uid:'',command:'Page_NewFile',page:GetEventsPage('Page_NewFile'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_new_file',btnTips:'另存为',btnEvent:{uid:'',command:'Page_SaveAsFile',page:GetEventsPage('Page_SaveAsFile'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导入文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'导入文件',btnEvent:{uid:'',command:'Page_ImportFile',page:GetEventsPage('Page_ImportFile'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导出文件',btnNamed:'',btnIcon:'base_new_file',btnTips:'导出文件',btnEvent:{uid:'',command:'Page_ExportFile',page:GetEventsPage('Page_ExportFile'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'首选项',btnNamed:'',btnIcon:'base_new_file',btnTips:'首选项',btnEvent:{uid:'',command:'Page_Options',page:GetEventsPage('Page_Options'),type:EventType.WIN,args:[]}},
]
],grpMenu:GroupActionMenu}] as Array<TitleGroup>
]]

View File

@ -15,17 +15,17 @@ export let TitleDefaultBars:Array<TitleModel>=
{cmName:'主页',cmPage:'',cmTips:'',cmEvents:
[[[{ grpName:'文件', grpBtn:
[
{btnModel:[ModelType.BASE],btnName:'新建',btnNamed:'',btnIcon:'base_new_file',btnTips:'新建',btnEvent:{uid:'',command:'Page_NewFile',page:GetEventsPage('Page_NewFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'打开',btnNamed:'',btnIcon:'base_open_file',btnTips:'打开',btnEvent:{uid:'',command:'Page_OpenFile',page:GetEventsPage('Page_OpenFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'新建',btnNamed:'',btnIcon:'base_new_file',btnTips:'新建',btnEvent:{uid:'',command:'Page_NewFile',page:GetEventsPage('Page_NewFile'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'打开',btnNamed:'',btnIcon:'base_open_file',btnTips:'打开',btnEvent:{uid:'',command:'Page_OpenFile',page:GetEventsPage('Page_OpenFile'),type:EventType.WIN,args:[]}},
[
{btnModel:[ModelType.BASE],btnName:'保存',btnNamed:'',btnIcon:'base_save_file',btnTips:'保存',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_saveas_file',btnTips:'另存为',btnEvent:{uid:'',command:'Page_SaveAsFile',page:GetEventsPage('Page_SaveAsFile'),type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'另存为',btnNamed:'',btnIcon:'base_saveas_file',btnTips:'另存为',btnEvent:{uid:'',command:'Page_SaveAsFile',page:GetEventsPage('Page_SaveAsFile'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'保存全部',btnNamed:'',btnIcon:'base_saveall_file',btnTips:'保存全部',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
] as Array<TitleButton>,
{btnModel:[ModelType.BASE],btnName:'关闭',btnNamed:'',btnIcon:'base_close_file',btnTips:'关闭',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导入',btnNamed:'',btnIcon:'base_import_file',btnTips:'导入',btnEvent:{uid:'',command:'Page_ImportFile',page:GetEventsPage('Page_ImportFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导出',btnNamed:'',btnIcon:'base_export_file',btnTips:'导出',btnEvent:{uid:'',command:'Page_ExportFile',page:GetEventsPage('Page_ExportFile'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'选项',btnNamed:'',btnIcon:'base_properties',btnTips:'选项',btnEvent:{uid:'',command:'Page_Options',page:GetEventsPage('Page_Options'),type:EventType.PAGE,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导入',btnNamed:'',btnIcon:'base_import_file',btnTips:'导入',btnEvent:{uid:'',command:'Page_ImportFile',page:GetEventsPage('Page_ImportFile'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'导出',btnNamed:'',btnIcon:'base_export_file',btnTips:'导出',btnEvent:{uid:'',command:'Page_ExportFile',page:GetEventsPage('Page_ExportFile'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'选项',btnNamed:'',btnIcon:'base_properties',btnTips:'选项',btnEvent:{uid:'',command:'Page_Options',page:GetEventsPage('Page_Options'),type:EventType.WIN,args:[]}},
{btnModel:[ModelType.BASE],btnName:'帮助',btnNamed:'',btnIcon:'base_help_file',btnTips:'帮助',btnEvent:{uid:'',command:'CMD_VIEW_ISO',page:'',type:EventType.EVENT,args:[]}},
], grpMenu:GroupActionMenu }] as Array<TitleGroup>]]},
MatrixModel,

View File

@ -1,13 +1,13 @@
import { TitleButton } from '../interface/Interface';
import {LeftSideBars} from '../layout/LeftSideBar'
import { mwInfo } from '../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
import {LeftSideComponent} from './LeftSideComponent'
@ComponentV2
export struct LeftSideTab {
private leftSideBarTabs: TabsController = new TabsController();
@Local leftSideBarFocusIndex: number = 0;
@Local isExpanded:boolean=true;
@Consumer('LeftSideWidth') leftSideWidth:number=mwInfo.width * 0.1;
@Consumer('LeftSideWidth') leftSideWidth:number=mdwInfo.winWidth * 0.1;
build() {
Row() {
@ -21,11 +21,11 @@ export struct LeftSideTab {
})
.backgroundImage(this.isExpanded ? $r('app.media.base_expand_on'):$r('app.media.base_expand_off'))
.type(ButtonType.Normal)
.width(mwInfo.width*0.013)
.height(mwInfo.width*0.013)
.width(mdwInfo.winWidth*0.013)
.height(mdwInfo.winWidth*0.013)
.onClick(()=>{
this.isExpanded = !this.isExpanded;
this.leftSideWidth=this.isExpanded?mwInfo.width * 0.1:mwInfo.width*0.013
this.leftSideWidth=this.isExpanded?mdwInfo.winWidth * 0.1:mdwInfo.winWidth*0.013
}).margin({ top: 2,left:1,bottom:0,right:2})
Scroll() {
Flex({ direction: FlexDirection.Column}) {
@ -40,8 +40,8 @@ export struct LeftSideTab {
})
.backgroundImage($r('app.media.'+item.btnIcon))
.fontWeight(index === this.leftSideBarFocusIndex ? FontWeight.Bold : FontWeight.Normal)
.width(mwInfo.width*0.013)
.height(mwInfo.width*0.013)
.width(mdwInfo.winWidth*0.013)
.height(mdwInfo.winWidth*0.013)
.type(ButtonType.Normal)
.onClick(() => {
this.leftSideBarTabs.changeIndex(index);
@ -54,8 +54,8 @@ export struct LeftSideTab {
.align(Alignment.Start)
.scrollable(ScrollDirection.Vertical)
.scrollBar(BarState.Off)
.width(mwInfo.width*0.013)
.height(mwInfo.width*0.013)
.width(mdwInfo.winWidth*0.013)
.height(mdwInfo.winWidth*0.013)
.height('100%')
}.borderWidth(1)
.borderColor(Color.Grey)

View File

@ -1,13 +1,13 @@
import { TitleButton } from '../interface/Interface';
import {LeftSideBars} from '../layout/LeftSideBar'
import { mwInfo } from '../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
@ComponentV2
export struct RightSideTab {
private leftSideBarTabs: TabsController = new TabsController();
@Local leftSideBarFocusIndex: number = 0;
@Local isExpanded:boolean=true;
@Consumer('RightSideWidth') rightSideWidth:number=mwInfo.width * 0.1;
@Consumer('RightSideWidth') rightSideWidth:number=mdwInfo.winWidth * 0.1;
build() {
Row() {
@ -17,7 +17,7 @@ export struct RightSideTab {
}
}.barHeight(0)
}.width(this.isExpanded?this.rightSideWidth-mwInfo.width*0.013:'0%')
}.width(this.isExpanded?this.rightSideWidth-mdwInfo.winWidth*0.013:'0%')
//右边按钮列
Column({space:1}){
Button()
@ -29,15 +29,15 @@ export struct RightSideTab {
})
.backgroundImage(this.isExpanded ? $r('app.media.base_expand_on'):$r('app.media.base_expand_off'))
.type(ButtonType.Normal)
.width(mwInfo.width*0.013)
.height(mwInfo.width*0.013)
.width(mdwInfo.winWidth*0.013)
.height(mdwInfo.winWidth*0.013)
.onClick(()=>{
this.isExpanded = !this.isExpanded;
this.rightSideWidth=this.isExpanded?mwInfo.width * 0.1:mwInfo.width*0.013;
this.rightSideWidth=this.isExpanded?mdwInfo.winWidth * 0.1:mdwInfo.winWidth*0.013;
}).margin({ top: 2,left:1,bottom:0,right:2})
Blank().layoutWeight(1)
}.borderWidth(1)
.width(mwInfo.width*0.013)
.width(mdwInfo.winWidth*0.013)
}.width('auto')
}
}

View File

@ -1,6 +1,6 @@
import { picker } from '@kit.CoreFileKit';
import { TextComboBox } from "../../customcontroller/ComboBox";
import { mwInfo } from '../../displaywindowinfo/DispWinInfo';
import { mdwInfo } from '../../displaywindowinfo/DispWinInfo';
import { DocUnitsType } from './FileStr';
import { common } from '@kit.AbilityKit';
@ -105,10 +105,10 @@ export struct SWImportFile {
}.height('10%')
Row({space:5}){
Text('导入模型路径:')
.width(mwInfo.width*this.scalingText)
.width(mdwInfo.winWidth*this.scalingText)
TextInput({placeholder:this.dir}).layoutWeight(1)
Button('选择模型')
.width(mwInfo.width*this.scalingText)
.width(mdwInfo.winWidth*this.scalingText)
.backgroundColor($r('sys.color.background_secondary'))
.fontColor($r('sys.color.font_emphasize'))
.fontWeight(FontWeight.Medium)

View File

@ -3,9 +3,8 @@ import { picker } from '@kit.CoreFileKit';
import type { BusinessError } from '@kit.BasicServicesKit';
import { TextComboBox } from "../../customcontroller/ComboBox";
import { CreateModelType,DocUnitsType } from './FileStr';
import { mwInfo,mwsInfo } from '../../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../../displaywindowinfo/DispWinInfo'
import {CurrentTime,RndId} from '../../eventhub/EventBase'
import { window } from '@kit.ArkUI';
@Entry
@ComponentV2
@ -22,22 +21,22 @@ export struct SWNewFile {
this.docCreateTime=CurrentTime();
}
selectDir():string{
let selectDirStr='';
let context =this.getUIContext().getHostContext() as common.Context;
selectDir(){
let context = this.getUIContext().getHostContext() as common.Context;
try {
let documentSelectOptions = new picker.DocumentSelectOptions();
let documentPicker = new picker.DocumentViewPicker(context);
let documentSelectOptions = new picker.DocumentSelectOptions();
documentSelectOptions.selectMode=picker.DocumentSelectMode.FOLDER;
documentPicker.select(documentSelectOptions,(err: BusinessError,documentSelectResult: Array<string>) => {
selectDirStr =documentSelectResult.toString();
return selectDirStr;
this.dir =documentSelectResult.toString();
if (documentSelectResult.length === 0) {
return;
}
})
} catch (error) {
const err: BusinessError = error as BusinessError;
console.error(`DocumentViewPicker failed with err: ${err.code}, ${err.message}`);
}
return selectDirStr;
}
build() {
Column({space:5}) {
@ -53,23 +52,23 @@ export struct SWNewFile {
Row({space:5}){
Text('保存目录:')
.width(mwInfo.width*this.scalingText)
.width(mdwInfo.winWidth*this.scalingText)
TextInput({placeholder:this.dir}).layoutWeight(1)
Button('选择目录')
.width(mwInfo.width*this.scalingText)
.width(mdwInfo.winWidth*this.scalingText)
.backgroundColor($r('sys.color.background_secondary'))
.fontColor($r('sys.color.font_emphasize'))
.fontWeight(FontWeight.Medium)
.fontSize($r('sys.float.Body_L'))
.onClick(() => {
this.dir= this.selectDir();
this.selectDir();
})
}.height('10%')
Row({space:5}){
Text('文件名:').width(mwInfo.width*this.scalingText)
Text('文件名:').width(mdwInfo.winWidth*this.scalingText)
TextInput({placeholder:this.fileName}).layoutWeight(1)
Button('随机文件名')
.width(mwInfo.width*this.scalingText)
.width(mdwInfo.winWidth*this.scalingText)
.backgroundColor($r('sys.color.background_secondary'))
.fontColor($r('sys.color.font_emphasize'))
.fontWeight(FontWeight.Medium)
@ -79,14 +78,14 @@ export struct SWNewFile {
})
}.height('10%')
Row({space:5}){
Text('文档创建人:').width(mwInfo.width*this.scalingText)
Text('文档创建人:').width(mdwInfo.winWidth*this.scalingText)
TextInput({placeholder:this.fileName}).layoutWeight(1)
}.height('10%')
Row({space:5}){
Text('文档创建时间:').width(mwInfo.width*this.scalingText)
Text('文档创建时间:').width(mdwInfo.winWidth*this.scalingText)
TextInput({placeholder:this.docCreateTime}).layoutWeight(1)
Button('获取本地时间')
.width(mwInfo.width*this.scaleBtn)
.width(mdwInfo.winWidth*this.scaleBtn)
.backgroundColor($r('sys.color.background_secondary'))
.fontColor($r('sys.color.font_emphasize'))
.fontWeight(FontWeight.Medium)

View File

@ -6,10 +6,8 @@ import {SelectionFilter} from "../layout/SelectionFilter"
import {DisplayMode} from "../layout/DisplayMode"
import { LayoutSwitch } from "../layout/LayoutSwitch";
import { FileMenuData } from "../layout/FileMenuData";
import { mwInfo } from '../displaywindowinfo/DispWinInfo'
import { mdwInfo } from '../displaywindowinfo/DispWinInfo'
import { SubColumnMenu} from "../customcontroller/Button";
import { fileIo } from "@kit.CoreFileKit";
import { common,Want } from "@kit.AbilityKit";
@ComponentV2
export struct TitleColumnSub {
@ -24,8 +22,8 @@ export struct TitleColumnSub {
private ViewDialog(): CustomDialogController {
return new CustomDialogController({
builder: ViewDialog(), // 确保 ViewDialog 组件已正确定义
width: mwInfo.width*0.06,
height: mwInfo.width*0.052,
width: mdwInfo.winWidth*0.06,
height: mdwInfo.winWidth*0.052,
borderWidth: 1,
cornerRadius: 5,
isModal: true,
@ -54,8 +52,8 @@ export struct TitleColumnSub {
this.viewDialog=this.ViewDialog();
}
this.viewDialog.open();
}).width(mwInfo.width*0.012)
.height(mwInfo.width*0.012)
}).width(mdwInfo.winWidth*0.012)
.height(mdwInfo.winWidth*0.012)
.backgroundColor(Color.Transparent)
.backgroundImage($r('app.media.' + SwitchView[0].btnIcon))
.backgroundImagePosition({ x: '10%', y: '10%' })
@ -66,17 +64,7 @@ export struct TitleColumnSub {
SubColumnMenu({menus:DisplayMode})
Blank().layoutWeight(1)
Button('TabsBar显示/隐藏').onClick(()=>{
//this.$subOverlayState(!this.subOverlayState);
let want: Want = {
deviceId: '',
bundleName: 'com.example.opencax',
abilityName: 'SubWinAbility'
};
// 调用 context 启动
let context =getContext(this) as common.UIAbilityContext;
context.startAbility(want).then(() => {
console.info('yes');
})
this.$subOverlayState(!this.subOverlayState);
})
}.width('100%')
.height('100%')

View File

@ -3,18 +3,8 @@ import {TitleModel} from '../interface/ModelInterface'
import {TitleTabData} from '../layout/TitleTabData'
import { FileMenuData } from "../layout/FileMenuData";
import {TitleTabContent} from './TitleTabContent'
import { mwInfo } from '../displaywindowinfo/DispWinInfo'
import { TitleButton } from '../interface/ButtonInterface';
import { BaseMenu } from '../customcontroller/Menu';
import {
TabSegmentButtonV2,
CapsuleSegmentButtonV2,
MultiCapsuleSegmentButtonV2,
SegmentButtonV2Items,
SegmentButtonV2Item,
SegmentButtonV2ItemOptions,
} from '@kit.ArkUI';
@Entry
@ComponentV2

View File

@ -1,13 +1,51 @@
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window, display, AppStorageV2, ColorMetrics } from '@kit.ArkUI';
import {SubWinInfo} from '../pages/eventhub/EventBase'
const DOMAIN = 0x0000;
export default class SubWinAbility extends UIAbility {
private subWin?:window.Window=undefined;
private subWinStage?: window.WindowStage=undefined;
//注册订阅事件
onWinEventHub(){
let ctx =this.context.getApplicationContext()
ctx.eventHub.on('InitSubWindow', (data: Object) => {
let winInfo=data as SubWinInfo;
this.InitWindowParam(winInfo);
});
}
//执行窗口参数
InitWindowParam(winInfo:SubWinInfo){
//Load page
this.subWinStage?.loadContent(winInfo.page, (err) => {
if (err.code) {
hilog.error(DOMAIN, 'Tag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
});
//moveWindowTo
this.subWin?.moveWindowTo(winInfo.subPointX, winInfo.subPointY,(err) => {
if (err.code) {
console.error(`Failed to Move Init Point the window. Code: ${err.code}, message: ${err.message}`);
return;
}
});
//resize mainWindow Size
console.info('SubWindowSize:',winInfo.width,winInfo.height);
this.subWin?.resize(winInfo.width,winInfo.height, (err) => {
if (err.code) {
console.error(`Failed to resize the window. Code: ${err.code}, message: ${err.message}`);
return;
}
});
}
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
try {
//订阅事件
this.onWinEventHub();
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
} catch (err) {
hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err));
@ -19,43 +57,16 @@ export default class SubWinAbility extends UIAbility {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage): void {
//Load page
windowStage.loadContent('pages/subpages/file/SWNewFile', (err) => {
if (err.code) {
hilog.error(DOMAIN, 'Tag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
});
//Get Main Window
windowStage.getMainWindow((err, data) => {
if (err.code) {
console.error(`Failed to obtain the main window. Code: ${err.code}, message: ${err.message}`);
return;
}
//moveWindowTo
data.moveWindowTo(50, 50)
//resize mainWindow Size
data.resize(200,400, (err) => {
if (err.code) {
console.error(`Failed to resize the window. Code: ${err.code}, message: ${err.message}`);
return;
}
});
let color: string = '#00000000';
try {
data.setWindowBackgroundColor(color);
data.setWindowShadowEnabled(true);
} catch (exception) {
console.error(`Failed to set the background color. Cause code: ${exception.code}, message: ${exception.message}`);
};
});
async onWindowStageCreate(windowStage: window.WindowStage): Promise<void> {
this.subWinStage=windowStage;
this.subWin = await windowStage.getMainWindow();
let ctx =this.context.getApplicationContext()
ctx.eventHub.emit('SubWinInitialized',true);
}
onWindowStageDestroy(): void {
let ctx =this.context.getApplicationContext()
ctx.eventHub.off('InitSubWindow');
// Main window is destroyed, release UI related resources
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}