public PostgreServerDataRepositoryItem() { Icon = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/server.png", UriKind.RelativeOrAbsolute)); MenuItem editServerMenuItem = new MenuItem(); editServerMenuItem.Header = "Configure..."; editServerMenuItem.Command = new RelayCommand(() => { PostgreServerConfigureWindow window = new PostgreServerConfigureWindow(Server, Port, UserName, Password); window.Owner = Application.Current.MainWindow; window.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (window.ShowDialog().GetValueOrDefault()) { PostgreServerDataRepositoryPlugin.SyncToServerItem(window.Result, this); } }); editServerMenuItem.Icon = new Image { Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/server_edit.png", UriKind.RelativeOrAbsolute)), Width = 16, Height = 16 }; MenuItem deleteServerMenuItem = new MenuItem(); deleteServerMenuItem.Header = "Remove"; deleteServerMenuItem.Command = new RelayCommand(() => { if (Parent != null) { Parent.Children.Remove(this); } GisEditor.InfrastructureManager.SaveSettings(GisEditor.DataRepositoryManager.GetPlugins().OfType <PostgreServerDataRepositoryPlugin>()); }); deleteServerMenuItem.Command = new RelayCommand(() => { if (Parent != null) { Parent.Children.Remove(this); } GisEditor.InfrastructureManager.SaveSettings(GisEditor.DataRepositoryManager.GetPlugins().OfType <PostgreServerDataRepositoryPlugin>()); }); deleteServerMenuItem.Icon = new Image { Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/server_delete.png", UriKind.RelativeOrAbsolute)), Width = 16, Height = 16 }; ContextMenu = new ContextMenu(); ContextMenu.Items.Add(editServerMenuItem); ContextMenu.Items.Add(deleteServerMenuItem); }
protected override void RefreshCore() { Task.Factory.StartNew(new Action(() => { PostgreConfigureInfo postgreInfo = new PostgreConfigureInfo(); Collection <string> newDbNames = PostgreSqlFeatureSource.GetDatabaseNames(Server, Port, UserName, Password); foreach (var item in newDbNames) { postgreInfo.DbaseNames.Add(item); } postgreInfo.Server = server; postgreInfo.Port = port; postgreInfo.UserName = userName; postgreInfo.Password = password; PostgreServerDataRepositoryPlugin.SyncToServerItem(postgreInfo, this); })); }