WPF version C#
using FT_Tools; using MSFramework. Common; using System; using System.Collections.Generic; using System. ComponentModel; using System. Linq; using System. Text; using System. Threading. Tasks; using System. Windows; using System. Windows. Controls; using System. Windows. Data; using System. Windows. Documents; using System. Windows. Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System. Windows. Shapes; using WpfM20UpdateFW; namespace WpfDownloadTool { /// <summary> /// Interaction logic of SettingsWindow.xaml /// </summary> public partial class SettingsWindow : Window { List<BindingSettingsClass> bindingSettingsList = new List<BindingSettingsClass>(); public SettingsWindow() { InitializeComponent(); Dictionary<string, string> config = IniFile. ReadAll(); foreach (KeyValuePair<string, string> k in config) { bindingSettingsList.Add(new BindingSettingsClass() { Name = k.Key, Value = k.Value, Describe = "TEST" }); } myListBox.ItemsSource = bindingSettingsList; } private void Window_Loaded(object sender, RoutedEventArgs e) { try { for (int i = 0; i < myListBox.Items.Count; i + + )// special treatment { BindingSettingsClass o = (BindingSettingsClass)(myListBox.Items.GetItemAt(i)); if (o.Name.Equals("SP")) { ComboBox sp = (ComboBox)MyAPI. getControl(myListBox, i, "ComboBoxSelect"); sp.Items.Add("0_Close"); sp.Items.Add("1_1902"); sp.Items.Add("2_1902T"); sp.Items.Add("3_Max332555"); sp.SelectionChanged += Sp_SelectionChanged; sp.SelectedIndex = int.Parse(o.Value); sp.Visibility = Visibility.Visible; } else if (o.Name.Equals("AP")) { ComboBox ap = (ComboBox)MyAPI. getControl(myListBox, i, "ComboBoxSelect"); ap.Items.Add("0_Close"); ap.Items.Add("1_F200"); ap.Items.Add("2_F600"); ap.Items.Add("3_F100"); ap.Items.Add("4_F210 F200-A"); ap.SelectionChanged += Ap_SelectionChanged; ap.SelectedIndex = int.Parse(o.Value); ap.Visibility = Visibility.Visible; } else if (o.Name.Equals("AP_File")) { Button buttonSP = (Button)MyAPI. getControl(myListBox, i, "ButtonSelect"); buttonSP.Visibility = Visibility.Visible; buttonSP.Click += Button_Click_ap; } else if (o.Name.Equals("SP_SigFile")) { Button buttonSP = (Button)MyAPI. getControl(myListBox, i, "ButtonSelect"); buttonSP.Visibility = Visibility.Visible; buttonSP.Click += Button_Click_sp_sig; } else if (o.Name.Equals("SP_RSAKeyFile")) { Button buttonSP = (Button)MyAPI. getControl(myListBox, i, "ButtonSelect"); buttonSP.Visibility = Visibility.Visible; buttonSP.Click += Button_Click_sp_rsa; } else { TextBlock tb = (TextBlock)MyAPI.getControl(myListBox, i, "textBlockDescribe"); tb.Visibility = Visibility.Visible; } } } catch (Exception e2) { MessageBox. Show(e2. StackTrace); } } private void Sp_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox c = (ComboBox)sender; int index=c.SelectedIndex; string cText=c.Items.GetItemAt(c.SelectedIndex).ToString(); for (int i = 0; i < myListBox.Items.Count; i + + )// special treatment { BindingSettingsClass o = (BindingSettingsClass)(myListBox.Items.GetItemAt(i)); if (o.Name.Equals("SP")) { o.Value = cText.Substring(0,1); return; } } } private void Ap_SelectionChanged(object sender, SelectionChangedEventArgs e) { ComboBox c = (ComboBox)sender; int index = c. SelectedIndex; string cText = c.Items.GetItemAt(c.SelectedIndex).ToString(); for (int i = 0; i < myListBox.Items.Count; i + + )// special treatment { BindingSettingsClass o = (BindingSettingsClass)(myListBox.Items.GetItemAt(i)); if (o.Name.Equals("AP")) { if (cText. Equals("")) { return; } o.Value = cText.Substring(0, 1); return; } } } private void Button_Click_ap(object sender, RoutedEventArgs e) { var openFileDialog = new Microsoft.Win32.OpenFileDialog() { Filter = "F200 F600 AP|*.mbn|F100 AP|*.txt|F200-A F210 AP|*.pac", Multiselect = false }; if (openFileDialog. ShowDialog() == true) { Log("AP_File=" + openFileDialog. FileName); IniFile.WritePrivateProfileString(DownloadSP1902QualComm.configAppName, DownloadSP1902QualComm.APPath, DownloadSP1902QualComm.AP_File = openFileDialog.FileName, IniFile.m_FileName); } } private void Button_Click_sp_sig(object sender, RoutedEventArgs e) { if (DownloadSP1902QualComm.SP == 3) { //folder var dialog = new System.Windows.Forms.FolderBrowserDialog() { Description = "Please select SP File path" }; if (dialog. ShowDialog() == System. Windows. Forms. DialogResult. OK) { Log("SP_SigFile=" + dialog. SelectedPath); IniFile.WritePrivateProfileString(DownloadSP1902QualComm.configAppName, DownloadSP1902QualComm.SigFilePath, DownloadSP1902QualComm.SP_SigFile = dialog.SelectedPath, IniFile.m_FileName); } } else { var openFileDialog = new Microsoft.Win32.OpenFileDialog() { Filter = "SP File|*.SIG|F100 SP|*.hex", Multiselect = false }; if (openFileDialog. ShowDialog() == true) { Log("SP_SigFile=" + openFileDialog. FileName); IniFile.WritePrivateProfileString(DownloadSP1902QualComm.configAppName, DownloadSP1902QualComm.SigFilePath, DownloadSP1902QualComm.SP_SigFile = openFileDialog.FileName, IniFile.m_FileName); } } } private void Button_Click_sp_rsa(object sender, RoutedEventArgs e) { var openFileDialog = new Microsoft.Win32.OpenFileDialog() { Filter = "SP File|*.RSA", Multiselect = false }; if (openFileDialog. ShowDialog() == true) { Log("SP_RSAKeyFile=" + openFileDialog. FileName); IniFile.WritePrivateProfileString(DownloadSP1902QualComm.configAppName, DownloadSP1902QualComm.RSAKeyPath, DownloadSP1902QualComm.SP_RSAKeyFile = openFileDialog.FileName, IniFile.m_FileName); } } private void Log(string s) { } } }
MFC
void CScanLicenceInfoUploadDlg::OnSelchangeComboDevices() { int index = ((CComboBox*)GetDlgItem(IDC_COMBO_DEVICES))->GetCurSel(); ((CComboBox*)GetDlgItem(IDC_COMBO_DEVICES))->SetCurSel(index); FilterList(); }