Ejemplo n.º 1
0
        private void ListBoxItemContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            var selectedItems = ChildrenList.SelectedItems.OfType <DataRepositoryItem>().ToArray();

            if (selectedItems.Length > 1)
            {
                DataRepositoryHelper.AddSelectedItemsToMap(selectedItems, sender, ref tmpRelayCommand);
            }

            var folderDataRepositoryItem = sender.GetDataContext <FolderDataRepositoryItem>();

            if (folderDataRepositoryItem != null)
            {
                var listItem = sender as ListBoxItem;
                if (listItem != null)
                {
                    // listItem.DataContext
                    foreach (MenuItem menu in listItem.ContextMenu.Items)
                    {
                        if (menu.Header.Equals("Rename"))
                        {
                            menu.Visibility = Visibility.Collapsed;
                        }
                    }
                }
            }
        }
        public PostgreTableDataRepositoryItem()
        {
            Icon = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/table.png", UriKind.RelativeOrAbsolute));

            MenuItem propertyItem = new MenuItem();

            propertyItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/properties.png", 16, 16);
            propertyItem.Header  = "Properties";
            propertyItem.Command = new RelayCommand(() =>
            {
                LayerPlugin matchingLayerPlugin = GisEditor.LayerManager.GetActiveLayerPlugins <LayerPlugin>()
                                                  .FirstOrDefault(tmpPlugin => tmpPlugin.Name.Equals("PostgreSql", StringComparison.OrdinalIgnoreCase));

                PostgreSqlFeatureLayer newLayer = GetPostgreSqlFeatureLayers().FirstOrDefault();
                if (newLayer != null)
                {
                    UserControl userControl = matchingLayerPlugin.GetPropertiesUI(newLayer);

                    Window propertiesDockWindow = new Window()
                    {
                        Content       = userControl,
                        Title         = GisEditor.LanguageManager.GetStringResource("MapElementsListPluginProperties"),
                        SizeToContent = SizeToContent.WidthAndHeight,
                        ResizeMode    = System.Windows.ResizeMode.NoResize,
                        Style         = Application.Current.FindResource("WindowStyle") as System.Windows.Style
                    };

                    propertiesDockWindow.ShowDialog();
                }
            });
            ContextMenu.Items.Add(propertyItem);
        }
        private void InitRootContextMenu()
        {
            if (ContextMenu == null)
            {
                ContextMenu = new ContextMenu();
            }

            MenuItem showInWindowsExplorerItem = new MenuItem();

            showInWindowsExplorerItem.Header  = GisEditor.LanguageManager.GetStringResource("ShowInWindowsExplorerMenuItemLabel");
            showInWindowsExplorerItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/windows explorer.png", 16, 16);
            showInWindowsExplorerItem.Command = new RelayCommand(ShowInWindowsExplorer, () => folderInfo != null && Directory.Exists(folderInfo.FullName));
            ContextMenu.Items.Add(showInWindowsExplorerItem);

            MenuItem removeFolderMenuItem = new MenuItem();

            removeFolderMenuItem.Header  = GisEditor.LanguageManager.GetStringResource("DataRepositoryRemovefromRepositoryMenuItemLabel");
            removeFolderMenuItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/dr_remove_item.png", 16, 16);
            removeFolderMenuItem.Command = new RelayCommand(RemoveFolderDataRepositoryItem);
            ContextMenu.Items.Add(removeFolderMenuItem);

            if (CanRename)
            {
                MenuItem renameItem = new MenuItem();
                renameItem.Header  = GisEditor.LanguageManager.GetStringResource("DataRepositoryRenameMenuItemLabel");
                renameItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/rename.png", 16, 16);
                renameItem.Command = new RelayCommand(() => DataRepositoryContentViewModel.SelectedDataRepositoryItem.IsRenaming = true);
                ContextMenu.Items.Add(renameItem);
            }
        }
Ejemplo n.º 4
0
        private void ListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataRepositoryItem[] selectedItems = ChildrenList.SelectedItems.OfType <DataRepositoryItem>().ToArray();
            if (selectedItems.Length > 1)
            {
                DataRepositoryContentViewModel.Current.PlaceOnMapCommand = DataRepositoryHelper.GetPlaceMultipleFilesCommand(selectedItems);
            }
            else if (selectedItems.Length == 1)
            {
                DataRepositoryItem dataRepositoryItem = selectedItems[0];
                if (dataRepositoryItem != null && dataRepositoryItem.ContextMenu != null)
                {
                    DataRepositoryContentViewModel.Current.ContextMenuStackPanel = DataRepositoryContentUserControl.ConvertContextMenuToButton(dataRepositoryItem.ContextMenu);
                }

                if (dataRepositoryItem != null && dataRepositoryItem.IsLoadable)
                {
                    DataRepositoryContentViewModel.Current.PlaceOnMapCommand = ((MenuItem)selectedItems.First().ContextMenu.Items[0]).Command;
                }
                else
                {
                    DataRepositoryContentViewModel.Current.PlaceOnMapCommand = null;
                }
            }
        }
Ejemplo n.º 5
0
 private void ListBoxItemContextMenuClosing(object sender, ContextMenuEventArgs e)
 {
     if (tmpRelayCommand != null)
     {
         DataRepositoryHelper.RestoreFirstMenuItemCommand(sender, tmpRelayCommand);
     }
 }
Ejemplo n.º 6
0
        private static void AddNewLayers(IEnumerable <LayerPlugin> fileLayerPlugins, bool multiselect)
        {
            if (fileLayerPlugins.Count() > 0)
            {
                StringBuilder filterStringBuilder         = new StringBuilder();
                StringBuilder allFilesFilterStringBuilder = new StringBuilder();

                foreach (var fileLayerPlugin in fileLayerPlugins)
                {
                    string[] array = fileLayerPlugin.ExtensionFilter.Split('|');
                    if (array != null && array.Length >= 2)
                    {
                        allFilesFilterStringBuilder.Append(array[1] + ";");
                    }
                }

                filterStringBuilder.Append("All Supported Formats|" + allFilesFilterStringBuilder.ToString());

                foreach (var fileLayerPlugin in fileLayerPlugins)
                {
                    if (!string.IsNullOrEmpty(fileLayerPlugin.ExtensionFilter))
                    {
                        filterStringBuilder.Append("|" + fileLayerPlugin.ExtensionFilter);
                    }
                }

                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Multiselect = multiselect;
                openFileDialog.Filter      = filterStringBuilder.ToString();
                if (openFileDialog.ShowDialog().GetValueOrDefault())
                {
                    try
                    {
                        AddToDataRepository(openFileDialog.FileNames[0]);
                        DataRepositoryHelper.PlaceFilesOnMap(openFileDialog.FileNames);
                    }
                    catch (Exception ex)
                    {
                        //SendExceptionMessage("Warning", ex.Message);
                        GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                        MessageBox.Show(ex.Message, "Unable to Open File(s)");
                    }
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("LayerPluginManagerNotFoundText")
                                                     , GisEditor.LanguageManager.GetStringResource("LayerPluginManagerNotFoundCaption")
                                                     , System.Windows.Forms.MessageBoxButtons.OK
                                                     , System.Windows.Forms.MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 7
0
        private static void HookEventForMap()
        {
            if (!hookedMaps.Contains(GisEditor.ActiveMap))
            {
                hookedMaps.Add(GisEditor.ActiveMap);

                GisEditor.ActiveMap.Drop += (s, arg) =>
                {
                    var draggedItems = arg.Data.GetData(typeof(DataRepositoryItem[])) as DataRepositoryItem[];
                    if (draggedItems != null)
                    {
                        var selectedFileItems = draggedItems.OfType <FileDataRepositoryItem>().ToList();
                        DataRepositoryHelper.PlaceFilesOnMap(selectedFileItems);
                    }

                    arg.Handled = true;
                };
            }
        }
        private void InitSubContextMenu()
        {
            if (ContextMenu == null)
            {
                ContextMenu = new ContextMenu();
            }

            if (CanRename)
            {
                MenuItem renameItem = new MenuItem();
                renameItem.Header  = GisEditor.LanguageManager.GetStringResource("DataRepositoryRenameMenuItemLabel");
                renameItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/rename.png", 16, 16);
                renameItem.Command = new RelayCommand(() => DataRepositoryContentViewModel.SelectedDataRepositoryItem.IsRenaming = true);
                ContextMenu.Items.Add(renameItem);
            }

            MenuItem showInWindowsExplorerItem = new MenuItem();

            showInWindowsExplorerItem.Header  = GisEditor.LanguageManager.GetStringResource("ShowInWindowsExplorerMenuItemLabel");
            showInWindowsExplorerItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/windows explorer.png", 16, 16);
            showInWindowsExplorerItem.Command = new ObservedCommand(() => ProcessUtils.OpenPath(folderInfo.FullName), () => FolderInfo != null && FolderInfo.Exists);
            ContextMenu.Items.Add(showInWindowsExplorerItem);
        }
 protected override void DropOnMapCore(IEnumerable <DataRepositoryItem> dataRepositoryItems)
 {
     DataRepositoryHelper.PlaceFilesOnMap(dataRepositoryItems.OfType <FileDataRepositoryItem>());
 }
        private void AddMenuItems()
        {
            if (CanRename)
            {
                MenuItem renameFileItem = new MenuItem();
                renameFileItem.Header  = GisEditor.LanguageManager.GetStringResource("DataRepositoryRenameMenuItemLabel");
                renameFileItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/rename.png", 16, 16);
                renameFileItem.Command = new RelayCommand(() => DataRepositoryContentViewModel.SelectedDataRepositoryItem.IsRenaming = true);
                ContextMenu.Items.Add(renameFileItem);
            }

            if (fileInfo.Extension.Equals(".csv", StringComparison.InvariantCultureIgnoreCase))
            {
                MenuItem editConfigItem = new MenuItem();
                editConfigItem.Header  = GisEditor.LanguageManager.GetStringResource("DataRepositoryEditColumnMappingMenuItemLabel");
                editConfigItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/dr_edit.png", 16, 16);
                editConfigItem.Command = new RelayCommand(() =>
                {
                    try
                    {
                        var configFilePath              = fileInfo.FullName + ".config";
                        CSVInfoModel csvInfoModel       = File.Exists(configFilePath) ? CSVInfoModel.FromConfig(configFilePath) : new CSVInfoModel(fileInfo.FullName, ",");
                        CSVConfigWindow csvConfigWindow = new CSVConfigWindow(new CSVViewModel(new Collection <CSVInfoModel> {
                            csvInfoModel
                        }));
                        csvConfigWindow.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                        System.Windows.Forms.MessageBox.Show(ex.Message, GisEditor.LanguageManager.GetStringResource("DataRepositoryWarningLabel"));
                    }
                });
                ContextMenu.Items.Add(editConfigItem);
            }

            MenuItem showInWindowsExplorerItem = new MenuItem();

            showInWindowsExplorerItem.Header  = GisEditor.LanguageManager.GetStringResource("ShowInWindowsExplorerMenuItemLabel");
            showInWindowsExplorerItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/windows explorer.png", 16, 16);
            showInWindowsExplorerItem.Command = new ObservedCommand(() => ProcessUtils.OpenPath(fileInfo.FullName), () => fileInfo != null && File.Exists(fileInfo.FullName));
            ContextMenu.Items.Add(showInWindowsExplorerItem);

            MenuItem propertyItem = new MenuItem();

            propertyItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/properties.png", 16, 16);
            propertyItem.Header  = "Properties";
            propertyItem.Command = new RelayCommand(() =>
            {
                GetLayersParameters getLayersParameters = new GetLayersParameters();
                getLayersParameters.LayerUris.Add(new Uri(fileInfo.FullName));
                Layer layer             = matchingLayerPlugin.GetLayers(getLayersParameters).FirstOrDefault();
                UserControl userControl = matchingLayerPlugin.GetPropertiesUI(layer);

                Window propertiesDockWindow = new Window()
                {
                    Content       = userControl,
                    Title         = GisEditor.LanguageManager.GetStringResource("MapElementsListPluginProperties"),
                    SizeToContent = SizeToContent.WidthAndHeight,
                    ResizeMode    = System.Windows.ResizeMode.NoResize,
                    Style         = Application.Current.FindResource("WindowStyle") as System.Windows.Style
                };

                propertiesDockWindow.ShowDialog();
            });
            ContextMenu.Items.Add(propertyItem);
        }