Exemplo n.º 1
0
        private async void DataGridProgProcess_MouseDoubleClickAsync(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (e.ChangedButton != System.Windows.Input.MouseButton.Left)
            {
                return;
            }
            DataGridCellInfo cell = (sender as DataGrid).CurrentCell;

            if (cell.Column == null)
            {
                return;
            }
            if (cell.Column.DisplayIndex == ProgViewModel.N_JLinkSN || cell.Column.DisplayIndex == ProgViewModel.N_TimeEscape)
            {
                string jlink = (cell.Item as ProgViewModel.ProgProcess).Steps[ProgViewModel.N_JLinkSN].Text;
                if (!this.progTaskStatusList.Contains(jlink))
                {
                    this.view.Running = true;
                    this.progTaskStatusList.Add(jlink);
                    this.progProcessList[jlink].Reset();
                    await this.progTaskList[jlink].Run();
                }
            }
            else
            {
                MsgWindow msgWindow = new MsgWindow();
                ProgViewModel.ProgProcess.ProgStep step = (cell.Item as ProgViewModel.ProgProcess).Steps[cell.Column.DisplayIndex];
                msgWindow.SetResult(step.Text);
                msgWindow.SetMsg(step.DetailMsg);
                msgWindow.SetTitle("J-Link SN: " + (cell.Item as ProgViewModel.ProgProcess).Steps[ProgViewModel.N_JLinkSN].Text);
                msgWindow.SetStep(this.view.ProgView.StepTitles[cell.Column.DisplayIndex]);
                msgWindow.Show();
            }
        }
Exemplo n.º 2
0
        public async Task <(List <string> jlinkList, string commanderVersion)> GetJlinkList()
        {
            List <string> list    = new List <string>();
            string        version = string.Empty;

            if (!File.Exists(CommanderPath))
            {
                MessageBox.Show("Commander.exe does not exist. Please check first.",
                                "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(list, version);
            }
            List <(string option, string argument)> args = new List <(string option, string argument)>()
            {
                ("--version", null)
            };
            bool result = await RunCommander(null, null, args);

            if (!result)
            {
                MsgWindow msg = new MsgWindow();
                msg.SetTitle("Error");
                msg.SetStep("Get Connected J-Link List");
                msg.SetResult("Failure");
                msg.SetMsg(this.ConsoleLog);
                msg.Show();
                return(list, version);
            }
            string pattern = @"Emulator\s+found\s+with\s+SN=([0-9]{8})\s+USBAddr=([0-9]+)";

            foreach (Match m in Regex.Matches(this.ConsoleLog, pattern))
            {
                list.Add(m.Groups[1].Value);
            }
            string pattern2 = @"Simplicity\s+Commander\s+([0-9a-zA-Z]+)";

            foreach (Match m in Regex.Matches(this.ConsoleLog, pattern2))
            {
                version = m.Groups[1].Value;
            }
            return(list, version);
        }