コード例 #1
0
        public YoutubeMusicViewModel()
        {
            youtubeDownloader = new YoutubeDownloader();
            var location = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);

            DirectoryLocation = ConfigCommands.LoadSavedLocation(location.Substring(0, location.LastIndexOf('\\') + 1) + "Downloads");
        }
コード例 #2
0
        private void SetParents()
        {
            var parents = ConfigCommands.Select(command => command.Id).ToList();

            parents.Insert(0, string.Empty);
            parentComboBox.DataSource = parents;
        }
コード例 #3
0
        public ConfigCommands Command(string name)
        {
            ConfigCommands cmd = new ConfigCommands();

            Commands.Add(name, cmd);

            return(cmd);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 /// <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");
     }
 }
コード例 #6
0
 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();
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        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();
            }
        }
コード例 #11
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     ConfigCommands.Add(new ConfigCommand());
     RefreshGrid();
     ChangeGridRowSelection(dataGridViewCommands.Rows.Count - 1);
 }
コード例 #12
0
 private void RefreshGrid()
 {
     dataGridViewCommands.DataSource = ConfigCommands.GetType();
     dataGridViewCommands.DataSource = ConfigCommands;
 }