public InfrastructureSettingViewModel()
        {
            pluginDirectories   = new ObservableCollection <string>();
            addDirectoryCommand = new RelayCommand(() =>
            {
                if (dialog == null)
                {
                    dialog = new FolderBrowserDialog();
                }

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (PluginDirectories.Any(d => d.Equals(dialog.SelectedPath, StringComparison.OrdinalIgnoreCase)))
                    {
                        MessageBox.Show(GisEditor.LanguageManager.GetStringResource("DirectoryExistsSelectAnotherLabel"), GisEditor.LanguageManager.GetStringResource("DirectoryExistsLabel"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        PluginDirectories.Add(dialog.SelectedPath);
                    }
                }
            });

            removeDirectoryCommand = new ObservedCommand(() =>
            {
                if (!String.IsNullOrEmpty(SelectedDirectory) && PluginDirectories.Contains(SelectedDirectory))
                {
                    int selectedIndex = PluginDirectories.IndexOf(SelectedDirectory);
                    PluginDirectories.Remove(SelectedDirectory);
                    if (PluginDirectories.Count > selectedIndex)
                    {
                        SelectedDirectory = PluginDirectories[selectedIndex];
                    }
                }
            }, () => !String.IsNullOrEmpty(SelectedDirectory));
        }
예제 #2
0
 public static void RegisterPluginDirectory(string path)
 {
     if (path == null) throw new ArgumentNullException(nameof(path));
     PluginDirectories.Add(path);
 }