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); }
private void AddServer() { PostgreServerConfigureWindow configureWindow = new PostgreServerConfigureWindow(); configureWindow.Owner = Application.Current.MainWindow; configureWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (configureWindow.ShowDialog().GetValueOrDefault()) { PostgreServerDataRepositoryItem serverItem = new PostgreServerDataRepositoryItem(); serverItem.Parent = rootItem; SyncToServerItem(configureWindow.Result, serverItem); rootItem.Children.Add(serverItem); GisEditor.InfrastructureManager.SaveSettings(this); } }