예제 #1
0
        //Read out the hexcode over the serial port
        public void cmdReadSerial_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(cboDevices.Text) || String.IsNullOrEmpty(cboBays.Text))
            {
                MessageBox.Show("A Serial Port and a Bay must be selected!");
                return;
            }



            Regex r = new Regex(@"COM(\d+)");
            Match m = r.Match(cboDevices.Text);

            sel_port = m.Groups[0].Value;


            if (InitComInterface(sel_port) == 5)
            {
                return;
            }

            serialPort.DiscardInBuffer();
            serialPort.Write(Bay.FromName(cboBays.Text).code_read);
            serialPort.Write("\r\n");
            System.Threading.Thread.Sleep(5000);
            input_text.Text = serialPort.ReadExisting();
            serialPort.Close();
            if (String.IsNullOrEmpty(input_text.Text))
            {
                MessageBox.Show("I received nothing! Make sure the printer is connected.", "", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
예제 #2
0
        public MainWindow()
        {
            InitializeComponent();

            input_text.AcceptsReturn = true;
            input_text.IsReadOnly    = true;

            cboPrinterType.ItemsSource      = Machine.GetAllTypes();
            cboMaterialCurrent.ItemsSource  = Material.GetAllNames();
            cboMaterialChangeTo.ItemsSource = Material.GetAllNames();
            cboBays.ItemsSource             = Bay.GetAllNames();
            load_list();
        }
예제 #3
0
        //Create the new hexcode
        private void cmd_create_Click(object sender, RoutedEventArgs e)
        {
            if (c == null)
            {
                MessageBox.Show("I need to Read before I can Write.");
                return;
            }

            if (String.IsNullOrEmpty(cboBays.Text))
            {
                MessageBox.Show("A Bay must be selected!");
                return;
            }

            UpdateCartridge();
            LoadControls();
            string newflash = Bay.FromName(cboBays.Text).code_write + CreateOutput(c.Encrypted);


            if (String.IsNullOrEmpty(cboDevices.Text))
            {
                MessageBox.Show("A Serial Port must be selected!");
                return;
            }

            if (InitComInterface(sel_port) == 5)
            {
                return;
            }

            serialPort.DiscardInBuffer();
            serialPort.Write(newflash);
            serialPort.Write("\r\n");
            serialPort.Close();
            System.Threading.Thread.Sleep(2000);
            MessageBox.Show("Please check if it worked, by removing and reinserting the cartridge!", "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
            clear_all_entries();
        }