public MainWindow() { InitializeComponent(); SanitizeSettings(ref _settings); UpdateConnectedStatus(false); _responseProcessors = MarlinOutputItemFactory.BootstrapResponseProcessors(); //InitializeResponseSelectors(); flowDocument.IsEnabled = true; listOutput.Document = flowDocument; try { cbPort.ItemsSource = GetSerialPortList(); cbPort.SelectedItem = _settings.Port; cbBaud.ItemsSource = _baudRates; cbBaud.SelectedItem = _settings.BaudRate; CreateMacroItemsAndBindToButtons(); } catch (Exception err) { AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message)); } }
public void SendCommandToPort(string s) { if (_port == null || !_port.IsOpen) { OpenSerialPort(); } _port.WriteLine(s); AddItemToOutputCollection(MarlinOutputItemFactory.BuildPrinterCommandOutputItem(s)); }
private void cbPort_DropDownOpened(object sender, EventArgs e) { try { cbPort.ItemsSource = GetSerialPortList(); } catch (Exception err) { AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message)); } }
private void btnMacro_Click(object sender, RoutedEventArgs e) { try { ExecuteMacro(GetMacroFromButton(sender)); } catch (Exception err) { AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message)); } }
private void btnDisconnect_Click(object sender, RoutedEventArgs e) { try { CloseSerialPort(); } catch (Exception err) { AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message)); } }
public void port_DataReceived(object sender, SerialDataReceivedEventArgs e) { try { string s = _port.ReadLine(); Debug.WriteLine($"Received: {s}"); ProcessMarlinResult(MarlinOutputItemFactory.BuildMarlinResponseOutputItem(s)); } catch (Exception err) { AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message)); } }
private void SendTextboxContentsAsCommand() { try { string s = MarlinStringHelpers.CleanCommandString(txtCommandToSend.Text); SendCommandToPort(s); if (_oldCommandIndex == 0 || !DoesCommandMatchScrolledCommand(s)) // New Command, not one from the history { AddCommandToOldCommandQueue(s); } _oldCommandIndex = 0; } catch (Exception err) { AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message)); } }