示例#1
0
        private void Delete()
        {
            if (RepositoriesCombobox.Items != null && RepositoriesCombobox.Items.Count > 0 && RepositoriesCombobox.SelectedItem != null)
            {
                Repository repositoryToRemove = (Repository)RepositoriesCombobox.SelectedItem;

                bool deletable = true;

                foreach (Source s in source)
                {
                    if (deletable == true)
                    {
                        if (s.SourceRepository == repositoryToRemove.Id)
                        {
                            deletable = false;
                        }
                    }
                    else
                    {
                    }
                }

                if (deletable == true)
                {
                    MessageBoxResult result = MessageBox.Show(Properties.Resources.ConfirmDeleteRepository, Properties.Resources.Repository, MessageBoxButton.YesNo, MessageBoxImage.Warning);

                    if (result == MessageBoxResult.Yes)
                    {
                        repository.Remove(repositoryToRemove);
                        repository.OnContentChanged();
                        Clear();
                    }
                }
                else
                {
                    MessageBox.Show(Properties.Resources.UnableDeleteRepository1 + " " + repositoryToRemove.Id + " " + Properties.Resources.UnableDeleteRepository2, Properties.Resources.Repository, MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
        }