public void LoadServices() { var names = PluginServiceProvider.GetServiceNames(); foreach (var name in names) { var item = new ListItem { Text = name, Tag = PluginServiceProvider.GetServiceStore(name) }; _comboBoxServices.Items.Add(item); } }
public void LoadSetting(Setting setting) { var userAgent = setting.UserAgentSetting; _checkBoxIsRandom.Checked = userAgent.IsRandom; foreach (var i in userAgent.UserAgentList) { var item = new ListItem {Key = i.Key, Text = i.Value}; _comboBoxUserAgentList.Items.Add(item); } //从现有的items中选择 foreach (var item in _comboBoxUserAgentList.Items) { if (item.Key == userAgent.Selected.Key) { _comboBoxUserAgentList.SelectedKey = item.Key; break; } } }
public override object ReadJson(Newtonsoft.Json.JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { object instance; if (reader.TokenType == JsonToken.Null) { return null; } if (reader.TokenType == JsonToken.String) { return new ListItem { Text = Convert.ToString(reader.Value) }; } var container = JObject.Load(reader); if (container["$type"] == null) { instance = new ListItem(); serializer.Populate(container.CreateReader(), instance); } else { instance = serializer.Deserialize(container.CreateReader()); } return instance; }
public void LoadServices() { var encodeNames = PluginServiceProvider.GetServiceNamesByType("Encode"); foreach (var name in encodeNames) { var item = new ListItem { Text = name, Tag = PluginServiceProvider.GetService(name) }; _encodeItem.Add(item); } var convertName = PluginServiceProvider.GetServiceNamesByType("Decode"); foreach (var name in convertName) { var item = new ListItem { Text = name, Tag = PluginServiceProvider.GetService(name) }; _decodeItem.Add(item); } }
private void PopulateDevices() { var selectedDrive = GetCurrentlySelectedDrive(); bool hasPriorSelection = !String.IsNullOrEmpty(selectedDrive); _deviceSelectBox.Items.Clear(); foreach (var device in Common.GetRemovableDrives()) { var driveLetter = device.RootDirectory.FullName; var volumeLabel = device.VolumeLabel; var listItem = new ListItem { Key = driveLetter, Text = volumeLabel + " (" + driveLetter + ")" }; _deviceSelectBox.Items.Add(listItem); if ((hasPriorSelection && driveLetter == selectedDrive) || volumeLabel == Common.DefaultKindleVolumeLabel) _deviceSelectBox.SelectedKey = driveLetter; } }