| using System.Windows; |
| using Microsoft.Win32; |
| using FastPrint.Printer; |
| using FastPrint.Slicing; |
| using FastPrint.Model; |
|
|
| namespace FastPrint.UI |
| { |
| public partial class MainWindow : Window |
| { |
| private MarlinConnector printer; |
| private SliceAccelerator slicer; |
| private STLModel model; |
|
|
| public MainWindow() |
| { |
| InitializeComponent(); |
| slicer = new SliceAccelerator(); |
| model = new STLModel(); |
| } |
|
|
| private void OpenSTL_Click(object sender, RoutedEventArgs e) |
| { |
| var dlg = new OpenFileDialog { Filter = "STL Files (*.stl)|*.stl" }; |
| if (dlg.ShowDialog() == true) |
| { |
| model.LoadAscii(dlg.FileName); |
| |
| } |
| } |
|
|
| private void Slice_Click(object sender, RoutedEventArgs e) |
| { |
| |
| var vertices = new System.Collections.Generic.List<float>(); |
| foreach (var tri in model.Triangles) |
| vertices.AddRange(tri); |
|
|
| slicer.Slice(vertices.ToArray(), 0.2f, result => { |
| |
| }); |
| } |
|
|
| private async void Connect_Click(object sender, RoutedEventArgs e) |
| { |
| printer = new MarlinConnector(PortSelector.SelectedItem?.ToString() ?? "COM3"); |
| await printer.ConnectAsync(); |
| } |
| } |
| } |