增加新建文件,导入文件页面
This commit is contained in:
parent
3c6329c251
commit
45226308c2
@ -24,20 +24,18 @@ export struct TextComboBox {
|
||||
})
|
||||
}.fontSize(20)
|
||||
}
|
||||
@Builder
|
||||
build() {
|
||||
Row() {
|
||||
Row({space:5}) {
|
||||
Text(this.name!=undefined?this.name:'')
|
||||
.fontSize(16)
|
||||
.width('auto')
|
||||
Text(this.menu[this.selectIndex].eName)
|
||||
.bindMenu(this.EventMenu)
|
||||
.width('50%')
|
||||
.fontSize(16)
|
||||
.backgroundColor('#ffe6e6e3')
|
||||
.height(mwInfo.height*0.02)
|
||||
.margin({ top:0, left: 5, bottom: 0, right: 0 })
|
||||
}.width(ebWidth)
|
||||
.height(mwInfo.width*0.01)
|
||||
}.height(mwInfo.width*0.01)
|
||||
.justifyContent(FlexAlign.Start)
|
||||
}
|
||||
}
|
||||
@ComponentV2
|
||||
|
||||
@ -32,7 +32,7 @@ export class XCompInfos{
|
||||
export let xcInfos:XCompInfos = AppStorageV2.connect<XCompInfos>(XCompInfos, () => new XCompInfos)!;
|
||||
export let ctInfo: XCompInfo = AppStorageV2.connect<XCompInfo>(XCompInfo, () => new XCompInfo)!;
|
||||
|
||||
function XNRandomId(): string {
|
||||
export function XNRandomId(): string {
|
||||
// 获取当前时间戳(毫秒)
|
||||
const now = Date.now();
|
||||
// 取时间戳的最后几位(例如4位)作为基础部分
|
||||
@ -97,16 +97,16 @@ export function ExecuteCommand(event:TitleButton){
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.6,mwInfo.height*0.9);
|
||||
CreateAndShowSubWindow(winInfo);
|
||||
} else if(event?.eEvent=='Execute_NewFileWindow'){
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.6,mwInfo.height*0.9);
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.4,mwInfo.height*0.4);
|
||||
CreateAndShowSubWindow(winInfo);
|
||||
}else if(event?.eEvent=='Execute_SaveAsFileWindow'){
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.6,mwInfo.height*0.9);
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.4,mwInfo.height*0.4);
|
||||
CreateAndShowSubWindow(winInfo);
|
||||
}else if(event?.eEvent=='Execute_ImportFileWindow'){
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.6,mwInfo.height*0.9);
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.4,mwInfo.height*0.4);
|
||||
CreateAndShowSubWindow(winInfo);
|
||||
}else if(event?.eEvent=='Execute_ExportFileWindow'){
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.6,mwInfo.height*0.9);
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.4,mwInfo.height*0.4);
|
||||
CreateAndShowSubWindow(winInfo);
|
||||
} else if(event?.eEvent=='Open_NewModel'){
|
||||
const winInfo:WinInfo=new WinInfo(event.eName,event.ePage,mwInfo.width*0.6,mwInfo.height*0.9);
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
import { FileInter } from "./FileInter";
|
||||
import { ModelType } from "../../LayoutInterface/Layout/ModelType";
|
||||
import { TitleButton } from "../../LayoutInterface/Interface/ButtonInterface";
|
||||
|
||||
//创建模块类型
|
||||
export let CreateModelType:Array<TitleButton>=[
|
||||
{eModel:[ModelType.BASE],eName:"BASE(基础模式)",eNamed:"",ePage:'',eIcon:"",eTips:"基础建模",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"CAD(制图模式)",eNamed:"",ePage:'',eIcon:"",eTips:"制图模块",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"CAM(加工模式)",eNamed:"",ePage:'',eIcon:"",eTips:"加工模块",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"CAE(仿真模式)",eNamed:"",ePage:'',eIcon:"",eTips:"仿真模块",eEvent:""},
|
||||
]
|
||||
export let DocUnitsType:Array<TitleButton>=[
|
||||
{eModel:[ModelType.BASE],eName:"mm(米制:毫米)",eNamed:"",ePage:'',eIcon:"",eTips:"毫米",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"m(米制:米)",eNamed:"",ePage:'',eIcon:"",eTips:"米",eEvent:""},
|
||||
{eModel:[ModelType.BASE],eName:"inch(英制:英寸)",eNamed:"",ePage:'',eIcon:"",eTips:"英制",eEvent:""},
|
||||
]
|
||||
|
||||
export let FileStr:Array<FileInter>=[
|
||||
{
|
||||
|
||||
@ -1,23 +1,144 @@
|
||||
import { picker } from '@kit.CoreFileKit';
|
||||
import { TextComboBox } from "../../CustomController/ComboBox";
|
||||
import { mwInfo } from '../../DispWinInfo/DispWinInfo';
|
||||
import { DocUnitsType } from './FileStr';
|
||||
import { common } from '@kit.AbilityKit';
|
||||
|
||||
@Entry
|
||||
@ComponentV2
|
||||
export struct SWImportFile {
|
||||
|
||||
@Local dir: string = '选择导入模型文件';
|
||||
//按钮宽度统一缩放系数
|
||||
@Local scaleBtn:number=0.05;
|
||||
//文本宽度统一缩放系数
|
||||
@Local scalingText:number=0.04;
|
||||
build() {
|
||||
Column({ space: 5 }) {
|
||||
Column({space:5}) {
|
||||
Column({space:5}){
|
||||
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
|
||||
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
|
||||
.selectedColor(0x39a2db)
|
||||
.shape(CheckBoxShape.ROUNDED_SQUARE)
|
||||
.onChange((value: boolean) => {
|
||||
console.info('Checkbox1 change is'+ value);
|
||||
})
|
||||
.mark({
|
||||
strokeColor:Color.Black,
|
||||
size: 50,
|
||||
strokeWidth: 5
|
||||
})
|
||||
.unselectedColor(Color.Red)
|
||||
.width(30)
|
||||
.height(30)
|
||||
Text('强制单位:').fontSize(20)
|
||||
TextComboBox({menu:DocUnitsType})
|
||||
|
||||
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
|
||||
.selectedColor(0x39a2db)
|
||||
.shape(CheckBoxShape.ROUNDED_SQUARE)
|
||||
.onChange((value: boolean) => {
|
||||
console.info('Checkbox1 change is'+ value);
|
||||
})
|
||||
.mark({
|
||||
strokeColor:Color.Black,
|
||||
size: 50,
|
||||
strokeWidth: 5
|
||||
})
|
||||
.unselectedColor(Color.Red)
|
||||
.width(30)
|
||||
.height(30)
|
||||
Text('默认单位').fontSize(20)
|
||||
|
||||
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
|
||||
.selectedColor(0x39a2db)
|
||||
.shape(CheckBoxShape.ROUNDED_SQUARE)
|
||||
.onChange((value: boolean) => {
|
||||
console.info('Checkbox1 change is'+ value);
|
||||
})
|
||||
.mark({
|
||||
strokeColor:Color.Black,
|
||||
size: 50,
|
||||
strokeWidth: 5
|
||||
})
|
||||
.unselectedColor(Color.Red)
|
||||
.width(30)
|
||||
.height(30)
|
||||
Text('文档单位').fontSize(20)
|
||||
|
||||
}
|
||||
}
|
||||
Row({space:5}){
|
||||
Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) {
|
||||
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
|
||||
.selectedColor(0x39a2db)
|
||||
.shape(CheckBoxShape.ROUNDED_SQUARE)
|
||||
.onChange((value: boolean) => {
|
||||
console.info('Checkbox1 change is'+ value);
|
||||
})
|
||||
.mark({
|
||||
strokeColor:Color.Black,
|
||||
size: 50,
|
||||
strokeWidth: 5
|
||||
})
|
||||
.unselectedColor(Color.Red)
|
||||
.width(30)
|
||||
.height(30)
|
||||
Text('导入到当前图层').fontSize(20)
|
||||
|
||||
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
|
||||
.selectedColor(0x39a2db)
|
||||
.shape(CheckBoxShape.ROUNDED_SQUARE)
|
||||
.onChange((value: boolean) => {
|
||||
console.info('Checkbox1 change is'+ value);
|
||||
})
|
||||
.mark({
|
||||
strokeColor:Color.Black,
|
||||
size: 50,
|
||||
strokeWidth: 5
|
||||
})
|
||||
.unselectedColor(Color.Red)
|
||||
.width(30)
|
||||
.height(30)
|
||||
Text('导入到全新图层').fontSize(20)
|
||||
}
|
||||
Blank().layoutWeight(1)
|
||||
}
|
||||
Row({space:5}){
|
||||
Text('导入模型路径:')
|
||||
.width(mwInfo.width*this.scalingText)
|
||||
TextInput({placeholder:this.dir}).layoutWeight(1)
|
||||
Button('选择模型')
|
||||
.width(mwInfo.width*this.scalingText)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.fontColor($r('sys.color.font_emphasize'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontSize($r('sys.float.Body_L'))
|
||||
.onClick(() => {
|
||||
let context = getContext(this) as common.Context;
|
||||
try {
|
||||
let documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
documentSelectOptions.selectMode = picker.DocumentSelectMode.FILE;
|
||||
let documentPicker = new picker.DocumentViewPicker(context);
|
||||
documentPicker.select(documentSelectOptions,(err: BusinessError,documentSelectResult: Array<string>) => {
|
||||
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}`);
|
||||
}
|
||||
})
|
||||
}
|
||||
Blank().layoutWeight(1)
|
||||
Row(){
|
||||
Text('保存目录:').width('10%')
|
||||
TextInput().width('80%')
|
||||
Button('选择目录').width('10%')
|
||||
}.height('5%')
|
||||
Row(){
|
||||
Text('文件名:')
|
||||
TextInput()
|
||||
}.height('5%')
|
||||
Blank().height('85%')
|
||||
Row(){
|
||||
Button('新建')
|
||||
Button('确定')
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.fontColor($r('sys.color.font_emphasize'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontSize($r('sys.float.Body_L'))
|
||||
}.alignItems(VerticalAlign.Center)
|
||||
}.margin({ top:0, left: 5, bottom: 0, right: 5 })
|
||||
}.margin({ top:5, left: 5, bottom: 5, right: 5 })
|
||||
}
|
||||
}
|
||||
@ -1,85 +1,112 @@
|
||||
import { common } from '@kit.AbilityKit';
|
||||
import { picker } from '@kit.CoreFileKit';
|
||||
import type { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { TextComboBox } from "../../CustomController/ComboBox";
|
||||
import {XNRandomId} from '../ExCom'
|
||||
import { CreateModelType,DocUnitsType } from './FileStr';
|
||||
import { mwInfo } from '../../DispWinInfo/DispWinInfo'
|
||||
|
||||
function CurrentTime():string {
|
||||
let now = new Date();
|
||||
// 格式化时间字符串
|
||||
let year = now.getFullYear().toString();
|
||||
let month = (now.getMonth() + 1).toString().padStart(2, '0'); // padStart 确保月份是两位数
|
||||
let date = now.getDate().toString().padStart(2, '0');
|
||||
let hours = now.getHours().toString().padStart(2, '0');
|
||||
let minutes = now.getMinutes().toString().padStart(2, '0');
|
||||
let seconds = now.getSeconds().toString().padStart(2, '0');
|
||||
|
||||
|
||||
return`${year}-${month}-${date} ${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
@Entry
|
||||
@ComponentV2
|
||||
export struct SWNewFile {
|
||||
@Local message: string = '';
|
||||
@Local dir: string = '选择文档保存路径';
|
||||
@Local fileName:string='模型文档名';
|
||||
@Local docCreateTime:string='';
|
||||
//按钮宽度统一缩放系数
|
||||
@Local scaleBtn:number=0.05;
|
||||
//文本宽度统一缩放系数
|
||||
@Local scalingText:number=0.04;
|
||||
aboutToAppear(): void {
|
||||
this.docCreateTime=CurrentTime();
|
||||
}
|
||||
build() {
|
||||
Column({ space: 5 }) {
|
||||
Row(){
|
||||
Text('保存目录:').width('10%')
|
||||
TextInput({placeholder:this.message}).width('80%')
|
||||
Column({space:5}) {
|
||||
Row({space:5}){
|
||||
TextComboBox({name:'创建文档模块:',menu:CreateModelType})
|
||||
Blank().layoutWeight(1)
|
||||
}
|
||||
Row({space:5}){
|
||||
TextComboBox({name:'建模单位:',menu:DocUnitsType})
|
||||
Blank().layoutWeight(1)
|
||||
}
|
||||
Row({space:5}){
|
||||
Text('保存目录:')
|
||||
.width(mwInfo.width*this.scalingText)
|
||||
TextInput({placeholder:this.dir}).layoutWeight(1)
|
||||
Button('选择目录')
|
||||
.width('10%')
|
||||
.width(mwInfo.width*this.scalingText)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.height(40)
|
||||
.fontColor($r('sys.color.font_emphasize'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontSize($r('sys.float.Body_L'))
|
||||
.onClick(() => {
|
||||
let context = getContext(this) as common.Context;
|
||||
try {
|
||||
const documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
let documentSelectOptions = new picker.DocumentSelectOptions();
|
||||
documentSelectOptions.selectMode = picker.DocumentSelectMode.FOLDER;
|
||||
const documentPicker = new picker.DocumentViewPicker(context);
|
||||
documentPicker.select(documentSelectOptions).then((documentSelectResult: Array<string>) => {
|
||||
this.message =documentSelectResult.toString();
|
||||
let documentPicker = new picker.DocumentViewPicker(context);
|
||||
documentPicker.select(documentSelectOptions,(err: BusinessError,documentSelectResult: Array<string>) => {
|
||||
this.dir =documentSelectResult.toString();
|
||||
if (documentSelectResult.length === 0) {
|
||||
return;
|
||||
}
|
||||
// this.getUIContext().showAlertDialog(
|
||||
// {
|
||||
// title: '文件路径',
|
||||
// message: this.message,
|
||||
// autoCancel: true,
|
||||
// alignment: DialogAlignment.Center,
|
||||
// offset: { dx: 0, dy: -20 },
|
||||
// gridCount: 3,
|
||||
// width: 300,
|
||||
// height: 300,
|
||||
// cornerRadius: $r('sys.float.corner_radius_level7'),
|
||||
// borderWidth: 1,
|
||||
// borderStyle: BorderStyle.Dashed,
|
||||
// borderColor: Color.Blue,
|
||||
// backgroundColor: Color.White,
|
||||
// textStyle: { wordBreak: WordBreak.BREAK_ALL },
|
||||
// confirm: {
|
||||
// value: '确定',
|
||||
// action: () => {
|
||||
// console.log('Confirm button is clicked.');
|
||||
// },
|
||||
// },
|
||||
// onWillDismiss: (dismissDialogAction: DismissDialogAction) => {
|
||||
// if (dismissDialogAction.reason === DismissReason.PRESS_BACK) {
|
||||
// dismissDialogAction.dismiss();
|
||||
// }
|
||||
// if (dismissDialogAction.reason === DismissReason.TOUCH_OUTSIDE) {
|
||||
// dismissDialogAction.dismiss();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// )
|
||||
}).catch((err: BusinessError) => {
|
||||
console.error(`DocumentViewPicker.select failed with err: ${err.code}, ${err.message}`);
|
||||
});
|
||||
})
|
||||
} catch (error) {
|
||||
const err: BusinessError = error as BusinessError;
|
||||
console.error(`DocumentViewPicker failed with err: ${err.code}, ${err.message}`);
|
||||
}
|
||||
})
|
||||
}.height('5%')
|
||||
}
|
||||
Row({space:5}){
|
||||
Text('文件名:').width(mwInfo.width*this.scalingText)
|
||||
TextInput({placeholder:this.fileName}).layoutWeight(1)
|
||||
Button('随机文件名')
|
||||
.width(mwInfo.width*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.fileName='OpenCAX_'+XNRandomId();
|
||||
})
|
||||
}
|
||||
Row({space:5}){
|
||||
Text('文档创建人:').width(mwInfo.width*this.scalingText)
|
||||
TextInput({placeholder:this.fileName}).layoutWeight(1)
|
||||
}
|
||||
Row({space:5}){
|
||||
Text('文档创建时间:').width(mwInfo.width*this.scalingText)
|
||||
TextInput({placeholder:this.docCreateTime}).layoutWeight(1)
|
||||
Button('获取本地时间')
|
||||
.width(mwInfo.width*this.scaleBtn)
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.fontColor($r('sys.color.font_emphasize'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontSize($r('sys.float.Body_L'))
|
||||
.onClick(()=>{
|
||||
this.docCreateTime=CurrentTime();
|
||||
})
|
||||
}
|
||||
Blank().layoutWeight(1)
|
||||
Row(){
|
||||
Text('文件名:')
|
||||
TextInput({placeholder:'model.prt'})
|
||||
}.height('5%')
|
||||
Blank().height('85%')
|
||||
Row(){
|
||||
Button('新建')
|
||||
Button('确定')
|
||||
.backgroundColor($r('sys.color.background_secondary'))
|
||||
.fontColor($r('sys.color.font_emphasize'))
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.fontSize($r('sys.float.Body_L'))
|
||||
}.alignItems(VerticalAlign.Center)
|
||||
}.margin({ top:0, left: 5, bottom: 0, right: 5 })
|
||||
}.margin({ top:5, left: 5, bottom: 5, right: 5 })
|
||||
}
|
||||
}
|
||||
@ -30,6 +30,7 @@ export async function CreateAndShowSubWindow(winInfo:WinInfo) {
|
||||
outlineEnabled:true,
|
||||
};
|
||||
|
||||
console.info('SubWindow Size:',winInfo.width,winInfo.height)
|
||||
await mwsInfo.winStage.createSubWindowWithOptions('subWindow', options).then((data) => {
|
||||
subWindow = data;
|
||||
//子窗口创建成功后,设置子窗口的位置、大小及相关属性等。
|
||||
@ -49,13 +50,7 @@ export async function CreateAndShowSubWindow(winInfo:WinInfo) {
|
||||
console.error("显示窗口失败:", err);
|
||||
}
|
||||
});
|
||||
//不允许窗口小于默认尺寸
|
||||
subWindow.on('windowSizeChange', (subWinData) => {
|
||||
// if Size Change save to AppStorage
|
||||
if(subWinData.width<winInfo.width||subWinData.height<winInfo.height){
|
||||
subWindow?.resize(winInfo.width,winInfo.height);
|
||||
}
|
||||
});
|
||||
subWindow.setResizeByDragEnabled(false);
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Failed to create or show sub window:', (error as BusinessError).message);
|
||||
|
||||
@ -64,11 +64,11 @@ struct Index {
|
||||
Divider().vertical(false).strokeWidth(1).lineCap(LineCapStyle.Round).width('100%').backgroundColor(Color.Grey)
|
||||
///状态栏
|
||||
Column() {
|
||||
Text('状态栏')
|
||||
Text('状态栏').fontSize(16)
|
||||
}.width('100%')
|
||||
.align(Alignment.End)
|
||||
.alignItems(HorizontalAlign.Start)
|
||||
.height(mwInfo.height * 0.01)
|
||||
.height(20)
|
||||
}.backgroundColor('#f3f3f0')
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user