This commit is contained in:
iambossTC 2025-04-08 14:34:22 +08:00
parent 884fb61a77
commit c3001697ac
3 changed files with 70 additions and 54 deletions

View File

@ -4,7 +4,6 @@
<OutputType>Exe</OutputType>
<TargetFramework>net9.0-windows</TargetFramework>
<Platforms>x64</Platforms>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<Configurations>Demo;Maintenance</Configurations>
</PropertyGroup>
@ -21,8 +20,5 @@
<PackageReference Include="HiNc" Version="1.4.*" />
<PackageReference Include="Hi.Wpf" Version="1.4.*" />
</ItemGroup>
<ItemGroup>
<Folder Include="MachiningProcs\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,70 @@
using Hi.Wpf.Disp;
using System;
using Hi.MongoUtils;
using Hi.Licenses;
using Hi.MachiningProcs;
using Hi.Common.FileLines;
using Hi.MillingSteps;
using System.Windows;
using Hi.Disp;
namespace Hi.Sample.Wpf.Machining
{
class DemoRenderingMachiningProcessAndStripPosSelection
{
[STAThread]
public static void Main(string[] args)
{
#region Initialize Environment
License.LogInAll();
DispEngine.Init();
MongoServer.Default = MongoServer.Run(new MongoRunnerOptions()
{
MongoPort = 28100
});
#endregion
#region Load Machining Project
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
Console.WriteLine($"Load Project: {projectPath}");
MachiningProject machiningProject = MachiningProject.LoadFile(projectPath);
machiningProject.ShellApi.MillingStepSelected += (MillingStep step) =>
{
var sourceCommand = step.SourceCommand;
Console.WriteLine($"Step Selected: MRR = {step.Mrr_mm3ds} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
};
machiningProject.PacePlayer.Start();
#endregion
#region Configure Rendering Options
var projectDisplayee = new MachiningProjectDisplayee(machiningProject);
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Mech] = true;
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Fixture] = true;
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom] = true;
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.ClStrip] = true;
projectDisplayee.RenderingFlagBitArray[(int)RenderingFlag.DimensionBar] = true;
#endregion
#region Create and Run WPF Application
Application app = new Application
{
ShutdownMode = ShutdownMode.OnMainWindowClose
};
app.Exit += (o, e) =>
{
machiningProject.Dispose();
MongoServer.Default.Dispose();
DispEngine.FinishDisp();
License.LogOutAll();
Console.WriteLine($"App exit.");
};
app.Run(new RenderingWindow()
{
Title = "Demo",
Displayee = projectDisplayee
});
#endregion
}
}
}

View File

@ -1,50 +0,0 @@
using Hi.Disp.Flag;
using Hi.Disp;
using Hi.Geom;
using Hi.Wpf.Disp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hi.MongoUtils;
using Hi.Licenses;
using Hi.MachiningProcs;
using System.Windows.Forms;
namespace Hi.Sample.Wpf
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
License.LogInAll();
MongoServer.Default = MongoServer.Run(new MongoRunnerOptions()
{
MongoPort = 28100
});
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
Console.WriteLine($"Load Project: {projectPath}");
MachiningCourse course = MachiningCourse.LoadFile(projectPath);
course.PacePlayer.Start();
Application.ApplicationExit += (object? sender, EventArgs e)=> {
course.Dispose();
MongoServer.Default.Dispose();
License.LogOutAll();
};
var courseDisplayee = new MachiningCourseDisplayee(() => course);
//courseDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Mech] = true;
courseDisplayee.RenderingFlagBitArray[(int)RenderingFlag.Fixture] = true;
courseDisplayee.RenderingFlagBitArray[(int)RenderingFlag.WorkpieceGeom] = true;
courseDisplayee.RenderingFlagBitArray[(int)RenderingFlag.ClStrip] = true;
courseDisplayee.RenderingFlagBitArray[(int)RenderingFlag.DimensionBar] = true;
RenderingWindow.RunApplication("Demo ", courseDisplayee);
}
}
}