public SettingWindow() { InitializeComponent(); pscomm = App.Current.Resources["PSCommDataSource"] as PSCommModel; ComPortBox.IsEnabled = true; DataContext = new SettingWindowModel(); string[] ports = SerialPort.GetPortNames(); // Display each port name to the console. foreach (string port in ports) { if (port.Substring(0, 3) == "COM") { ComPortBox.Items.Add(port); } } ComPortBox.SelectedIndex = 0; }
public CheckoutDialog() { pscomm = App.Current.Resources["PSCommDataSource"] as PSCommModel; shoppingCart = App.Current.Resources["CartListDataSource"] as CartList; shippingCart = App.Current.Resources["ShipListDataSource"] as CartList; //ShoppingCart = _shoppingCart; InitializeComponent(); showListBox(); if (pscomm.isCommInit) { if (isPsTradable = CheckPSTradable()) { PSStatusTextBlock.Text = "請投幣... "; //pstrad.reqTransactionAmount(); //詢問PS3收到的鈔票與硬幣 backgroundWorker = new BackgroundWorker { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; backgroundWorker.DoWork += backgroundWorker_DoWork; //For the display of operation progress to UI. backgroundWorker.ProgressChanged += backgroundWorker_ProgressChanged; //After the completation of operation. backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; backgroundWorker.RunWorkerAsync("Press Enter in the next 5 seconds to Cancel operation:"); } else { PSStatusTextBlock.Text = "投幣機狀態錯誤!"; } } else { PSStatusTextBlock.Text = "PS3 init Failed!"; checkoutimage.Source = new BitmapImage(new Uri(@"/images/stop.png", UriKind.Relative)); } }