/// <summary> /// Changes the active mode to stencil mode when the Stencil Mode radio is /// checked. /// </summary> /// <param name="sender">Not used</param> /// <param name="e">Not used</param> public void StencilMode_Checked(object sender, RoutedEventArgs e) { Mode = EtchMode.Stencil; Button exportButton = this.FindControl <Button>("ExportButton"); exportButton.IsEnabled = false; }
/// <summary> /// Creates a new MainWindow instance. /// </summary> public MainWindow() { AvaloniaXamlLoader.Load(this); #if DEBUG this.AttachDevTools(); #endif // Cache the UI components PassesBox = this.FindControl <TextBox>("PassesBox"); PixelSizeBox = this.FindControl <TextBox>("PixelSizeBox"); OriginXBox = this.FindControl <TextBox>("OriginXBox"); OriginYBox = this.FindControl <TextBox>("OriginYBox"); ZHeightBox = this.FindControl <TextBox>("ZHeightBox"); TravelSpeedBox = this.FindControl <TextBox>("TravelSpeedBox"); EtchSpeedBox = this.FindControl <TextBox>("EtchSpeedBox"); LaserOffCommandBox = this.FindControl <TextBox>("LaserOffCommandBox"); LaserLowCommandBox = this.FindControl <TextBox>("LaserLowCommandBox"); LaserHighCommandBox = this.FindControl <TextBox>("LaserHighCommandBox"); MoveCommandBox = this.FindControl <ComboBox>("MoveCommandBox"); CommentStyleBox = this.FindControl <ComboBox>("CommentStyleBox"); HomeToggle = this.FindControl <CheckBox>("HomeToggle"); BoundaryPreviewToggle = this.FindControl <CheckBox>("BoundaryPreviewToggle"); BoundaryPreviewDelayBox = this.FindControl <TextBox>("BoundaryPreviewDelayBox"); // File drag and drop support AddHandler(DragDrop.DropEvent, Drop); // Load the saved configuration, or fallback to the defaults Config = new Configuration("Configuration.toml"); try { Config.Load(); PassesBox.Text = Config.Passes.ToString(); PixelSizeBox.Text = Config.PixelSize.ToString(); OriginXBox.Text = Config.OriginX.ToString(); OriginYBox.Text = Config.OriginY.ToString(); ZHeightBox.Text = Config.ZHeight.ToString(); TravelSpeedBox.Text = Config.TravelSpeed.ToString(); EtchSpeedBox.Text = Config.EtchSpeed.ToString(); LaserOffCommandBox.Text = Config.LaserOffCommand; LaserLowCommandBox.Text = Config.LaserLowCommand; LaserHighCommandBox.Text = Config.LaserHighCommand; if (Config.MoveCommand == "G1") { MoveCommandBox.SelectedIndex = 1; } else { MoveCommandBox.SelectedIndex = 0; } if (Config.CommentMode == CommentMode.Parentheses) { CommentStyleBox.SelectedIndex = 1; } else { CommentStyleBox.SelectedIndex = 0; } HomeToggle.IsChecked = Config.HomeXY; BoundaryPreviewToggle.IsChecked = Config.IsBoundaryPreviewEnabled; BoundaryPreviewDelayBox.Text = Config.PreviewDelay.ToString(); } catch (Exception ex) { _ = MessageBox.Show(this, $"Error loading configuration: {ex.Message}. " + $"Configuration will be set to the default values.", "Error loading configuration"); } // Load the processors Mode = EtchMode.Raster; RasterRouter = new RasterRouter(Config); StencilRouter = new StencilRouter(Config); Exporter = new GcodeExporter(Config); }