public YoutubeMusicViewModel() { youtubeDownloader = new YoutubeDownloader(); var location = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic); DirectoryLocation = ConfigCommands.LoadSavedLocation(location.Substring(0, location.LastIndexOf('\\') + 1) + "Downloads"); }
private void SetParents() { var parents = ConfigCommands.Select(command => command.Id).ToList(); parents.Insert(0, string.Empty); parentComboBox.DataSource = parents; }
public ConfigCommands Command(string name) { ConfigCommands cmd = new ConfigCommands(); Commands.Add(name, cmd); return(cmd); }
public ModCommand(ModConfig config, IModHelper helper, IMonitor monitor) { this.Config = config; this.Helper = helper; this.Monitor = monitor; this.ConfigCommands = new ConfigCommands(this.Config, this.Helper, this.Monitor); this.FarmAnimalsCommands = new FarmAnimalsCommands(this.Config, this.Helper, this.Monitor); }
/// <summary> /// Browse path for the output /// </summary> private void BrowseFile() { using (var dialog = new System.Windows.Forms.FolderBrowserDialog()) { var result = dialog.ShowDialog(); DirectoryLocation = dialog.SelectedPath; ConfigCommands.SaveLocation(DirectoryLocation); OnPropertyChanged("DirectoryLocation"); } }
private void idTextBox_Validated(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(selectedCommand.Id)) { foreach (var command in ConfigCommands.Where(cmd => cmd.Parent == selectedCommand.Id)) { command.Parent = idTextBox.Text; } } selectedCommand.Id = idTextBox.Text; SetParents(); }
private bool ValidateKey() { if (ConfigCommands .Any(cc => cc.Parent == selectedCommand.Parent && cc.Key == keyTextBox.Text && !cc.Equals(selectedCommand))) { ShowValidationError("Other command with the same parent, uses same Key."); return(false); } return(true); }
private bool ValidateId() { if (string.IsNullOrWhiteSpace(idTextBox.Text)) { ShowValidationError("Id cannot be empty."); return(false); } if (ConfigCommands.Any(configCommand => configCommand.Id == idTextBox.Text && !configCommand.Equals(selectedCommand))) { ShowValidationError("Other command, uses same Id."); return(false); } return(true); }
private bool ValidateParent() { string parent = string.Empty; if (parentComboBox.SelectedItem != null) { parent = parentComboBox.SelectedItem.ToString().Trim(); } if (parent != string.Empty) { if (ConfigCommands != null && !ConfigCommands.Any(cc => cc.Id == parent)) { ShowValidationError(String.Format("Cannot find command with id [{0}]", parent)); } } return(true); }
private void buttonDelete_Click(object sender, EventArgs e) { if (selectedCommandIndex != null && selectedCommand != null) { ConfigCommands.Remove(selectedCommand); selectedCommand = null; var oldIndex = selectedCommandIndex.Value; selectedCommandIndex = null; if (oldIndex > ConfigCommands.Count - 1) { ChangeGridRowSelection(oldIndex - 1); } else { ChangeGridRowSelection(oldIndex); } RefreshGrid(); } }
private void buttonAdd_Click(object sender, EventArgs e) { ConfigCommands.Add(new ConfigCommand()); RefreshGrid(); ChangeGridRowSelection(dataGridViewCommands.Rows.Count - 1); }
private void RefreshGrid() { dataGridViewCommands.DataSource = ConfigCommands.GetType(); dataGridViewCommands.DataSource = ConfigCommands; }