This commit is contained in:
CortexCore
2024-03-05 15:27:29 +08:00
parent 7766082e9d
commit 2c8dfd3c86
45 changed files with 6760 additions and 138 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using BITKit;
using BITKit.CommandPattern;
@@ -17,6 +18,12 @@ namespace BITFactory.Cutting.Mod
public override string PackageName { get; set; } = "iFactory.Cutting.Mod.auto_save_images";
public override string Name { get; set; } = "自动保存导出数据";
public override string Description { get; set; } =
@"""
自动保存导出的数据到该程序所在目录下,并且在导出后弹出对话框提示
导出的格式为export_{Timestamp}.cfg
""";
[Inject] private ICuttingTool _cuttingTool;
[Inject] private IUXDialogue _dialogue;
@@ -38,40 +45,26 @@ namespace BITFactory.Cutting.Mod
var commands = obj.OfType<ICuttingCommand>().ToArray();
var stringBuilder = new System.Text.StringBuilder();
var path = Path.Combine(FolderPath, $"export_{DateTime.Now.Ticks}.cfg");
stringBuilder.AppendLine($"导出时间: {DateTime.Now},导出命令数量: {commands.Length}");
stringBuilder.AppendLine($"导出时间: {DateTime.Now},导出命令数量: {obj.Length},有效命名数量: {commands.Length}");
foreach (var command in commands)
{
if(command is CuttingPointCommand pointCommand)
switch (command)
{
stringBuilder.AppendLine(
$"切削点: {pointCommand.PlanePoint.x} {pointCommand.PlanePoint.y} {pointCommand.PlanePoint.z}");
case CuttingPointCommand pointCommand:
stringBuilder.AppendLine(
$"切削点: {pointCommand.PlanePoint.x} {pointCommand.PlanePoint.y} {pointCommand.PlanePoint.z}");
break;
case CuttingLineCommand lineCommand:
stringBuilder.AppendLine($"切削线:{lineCommand.Line.Length}");
foreach (var linePos in lineCommand.Line)
{
stringBuilder.AppendLine($"切削线点: {linePos.x} {linePos.y} {linePos.z}");
}
break;
default:
stringBuilder.AppendLine($"{command.Name}:{command.GetType().FullName}");
break;
}
else if(command is CuttingLineCommand lineCommand)
{
stringBuilder.AppendLine($"切削线:{lineCommand.Line.Length}");
foreach (var linePos in lineCommand.Line)
{
stringBuilder.AppendLine($"切削线点: {linePos.x} {linePos.y} {linePos.z}");
}
}
else
{
stringBuilder.AppendLine($"{command.Name}:{command}");
}
// switch (command)
// {
// case CuttingPointCommand pointCommand:
// stringBuilder.AppendLine(
// $"切削点: {pointCommand.PlanePoint.x} {pointCommand.PlanePoint.y} {pointCommand.PlanePoint.z}");
// break;
// case CuttingLineCommand lineCommand:
// stringBuilder.AppendLine($"切削线:{lineCommand.Line.Length}");
// foreach (var linePos in lineCommand.Line)
// {
// stringBuilder.AppendLine($"切削线点: {linePos.x} {linePos.y} {linePos.z}");
// }
// break;
// }
}
File.WriteAllText(path, stringBuilder.ToString());