コード例 #1
0
        void LoadConfig()
        {
            try
            {
                string fileName = Path.Combine(Program.MainForm.UserDir, "sru\\sru.xml");
                _config = SruConfig.From(fileName);

                var servers = _config.ListTargets("*");
                this.Invoke((Action)(() =>
                {
                    this.comboBox_server.Items.Clear();
                    foreach (var server in servers)
                    {
                        this.comboBox_server.Items.Add(server.Name);
                    }
                }));
            }
            catch (Exception ex)
            {
                this.Invoke((Action)(() =>
                {
                    MessageBox.Show(this, $"装载 sru.xml 出现异常: {ex.Message}");
                }));
            }
        }
コード例 #2
0
        async Task UpdateUseList()
        {
            this.comboBox_use.Items.Clear();

            if (string.IsNullOrEmpty(this.comboBox_server.Text))
            {
                return;
            }

            var targets = _config.ListTargets(this.comboBox_server.Text);

            if (targets.Count == 0)
            {
                return;
            }
            var lines = await _config.ListUses(targets[0]);

            foreach (var line in lines)
            {
                this.comboBox_use.Items.Add(line.Name == null ? line.Value : line.Name);
            }
        }