Пример #1
0
        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));
            }
        }
Пример #2
0
 public void SendCommandToPort(string s)
 {
     if (_port == null || !_port.IsOpen)
     {
         OpenSerialPort();
     }
     _port.WriteLine(s);
     AddItemToOutputCollection(MarlinOutputItemFactory.BuildPrinterCommandOutputItem(s));
 }
Пример #3
0
 private void cbPort_DropDownOpened(object sender, EventArgs e)
 {
     try
     {
         cbPort.ItemsSource = GetSerialPortList();
     }
     catch (Exception err)
     {
         AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message));
     }
 }
Пример #4
0
 private void btnMacro_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ExecuteMacro(GetMacroFromButton(sender));
     }
     catch (Exception err)
     {
         AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message));
     }
 }
Пример #5
0
 private void btnDisconnect_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         CloseSerialPort();
     }
     catch (Exception err)
     {
         AddItemToOutputCollection(MarlinOutputItemFactory.BuildApplicationMessageOutputItem(err.Message));
     }
 }
Пример #6
0
 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));
     }
 }
Пример #7
0
 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));
     }
 }