protected override Collection <MenuItem> GetLayerListItemContextMenuItemsCore(GetLayerListItemContextMenuParameters parameters)
        {
            var menuItems = base.GetLayerListItemContextMenuItemsCore(parameters);
            ShapeFileFeatureLayer shpLayer = (ShapeFileFeatureLayer)parameters.LayerListItem.ConcreteObject;
            MenuItem rebuildShpItem        = new MenuItem();

            rebuildShpItem.Header = GisEditor.LanguageManager.GetStringResource("ShapefileRebuildHeader");
            rebuildShpItem.Name   = "Rebuild";
            rebuildShpItem.Icon   = new Image {
                Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/rebuildShp.png", UriKind.RelativeOrAbsolute))
            };
            rebuildShpItem.Click += (s, e) =>
            {
                string directory = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, "Output");
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                shpLayer.CloseInOverlay();

                //bool isCanceld = false;

                ProgressWindow window = new ProgressWindow();
                window.Title = GisEditor.LanguageManager.GetStringResource("RebuildShapefileWindowTitle");
                window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                window.Owner       = Application.Current.MainWindow;
                window.MainContent = "Rebuilding...";

                window.ProgressAction = () =>
                {
                    shpLayer.SafeProcess(() =>
                    {
                        ShapeFileFeatureSource.Rebuilding += (sender, e1) =>
                        {
                            if (e1.ShapePathFilename.Equals(shpLayer.ShapePathFilename, StringComparison.InvariantCultureIgnoreCase))
                            {
                                e1.Cancel = window.IsCanceled;
                                Application.Current.Dispatcher.BeginInvoke(() =>
                                {
                                    window.Maximum       = e1.RecordCount;
                                    window.ProgressValue = e1.CurrentRecordIndex;
                                });
                            }
                        };
                        ShapeFileFeatureSource.Rebuild(shpLayer.ShapePathFilename);
                    });

                    Application.Current.Dispatcher.BeginInvoke(() =>
                    {
                        if (window.DialogResult == null)
                        {
                            window.DialogResult = !window.IsCanceled;
                        }
                    });
                };

                if (window.ShowDialog().GetValueOrDefault())
                {
                    GisEditor.ActiveMap.GetOverlaysContaining(shpLayer).ForEach(o => o.Invalidate());
                    MessageBox.Show(GisEditor.LanguageManager.GetStringResource("RebuildCompletedLabel"));
                }
            };
            var index = menuItems.Count - 3;

            if (index >= 0 && index <= menuItems.Count)
            {
                menuItems.Insert(index, LayerListMenuItemHelper.GetRebuildIndexMenuItem());
                menuItems.Insert(index++, rebuildShpItem);
            }
            return(menuItems);
        }
Пример #2
0
        protected override Collection <MenuItem> GetLayerListItemContextMenuItemsCore(GetLayerListItemContextMenuParameters parameters)
        {
            Collection <MenuItem> menuItems = base.GetLayerListItemContextMenuItemsCore(parameters);

            if (parameters.LayerListItem.ConcreteObject is FilterStyle)
            {
                MenuItem menuItem = new MenuItem();
                menuItem.Header = "--";
                menuItems.Add(menuItem);

                MenuItem viewDataMenuItem = new MenuItem();
                viewDataMenuItem.Header = "View filtered data";
                viewDataMenuItem.Click += new System.Windows.RoutedEventHandler(ViewDataMenuItem_Click);
                viewDataMenuItem.Tag    = parameters.LayerListItem;
                viewDataMenuItem.Icon   = new Image {
                    Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/styles_filterarealinepoint.png", UriKind.RelativeOrAbsolute))
                };
                menuItems.Add(viewDataMenuItem);

                MenuItem zoomToFilterMenuItem = new MenuItem();
                zoomToFilterMenuItem.Header = GisEditor.LanguageManager.GetStringResource("FilterStylePluginZoomtofilter");
                zoomToFilterMenuItem.Tag    = parameters.LayerListItem;
                zoomToFilterMenuItem.Click += ZoomToFilterMenuItem_Click;
                zoomToFilterMenuItem.Icon   = new Image {
                    Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/zoomto.png", UriKind.RelativeOrAbsolute))
                };
                menuItems.Add(zoomToFilterMenuItem);
            }

            return(menuItems);
        }
        protected override Collection <MenuItem> GetLayerListItemContextMenuItemsCore(GetLayerListItemContextMenuParameters parameters)
        {
            Collection <MenuItem> menuItems = base.GetLayerListItemContextMenuItemsCore(parameters);
            object concreteObject           = parameters.LayerListItem.ConcreteObject;

            //if (concreteObject is FeatureLayer)
            //{
            //    if (EditorUIPlugin.IsRelateAndAliasEnabled)
            //    {
            //        MenuItem relateMenuItem = GetRelateMenuItem((FeatureLayer)concreteObject);
            //        menuItems.Add(relateMenuItem);
            //    }
            //}

            if (concreteObject is RasterLayer)
            {
                MenuItem keyColorsMenuItem = GetKeyColorsMenuItem((RasterLayer)concreteObject);
                menuItems.Add(keyColorsMenuItem);
            }

            return(menuItems);
        }
Пример #4
0
        protected override Collection <MenuItem> GetLayerListItemContextMenuItemsCore(GetLayerListItemContextMenuParameters parameters)
        {
            Collection <MenuItem> menuItems = base.GetLayerListItemContextMenuItemsCore(parameters);

            if (parameters.LayerListItem.ConcreteObject is FeatureLayer || parameters.LayerListItem.ConcreteObject is LayerOverlay)
            {
                MenuItem selectLayerItem = new MenuItem();
                selectLayerItem.Header = "Select Layer";
                selectLayerItem.Icon   = new Image {
                    Width = 16, Height = 16, Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/SelectTool.png", UriKind.RelativeOrAbsolute))
                };
                selectLayerItem.Command = new ObservedCommand(SelectLayer, () => true);

                menuItems.Add(selectLayerItem);
            }

            return(menuItems);
        }
        protected override Collection <MenuItem> GetLayerListItemContextMenuItemsCore(GetLayerListItemContextMenuParameters parameters)
        {
            Collection <MenuItem> menuItems = base.GetLayerListItemContextMenuItemsCore(parameters);

            if (parameters.LayerListItem == null)
            {
                return(menuItems);
            }
            FeatureLayer featureLayer = parameters.LayerListItem.ConcreteObject as FeatureLayer;

            if (featureLayer != null && featureLayer.FeatureSource.IsEditable)
            {
                bool     isInEditing       = featureLayer == GisEditor.ActiveMap.FeatureLayerEditOverlay.EditTargetLayer;
                MenuItem editLayerMenuItem = new MenuItem()
                {
                    Header = GisEditor.LanguageManager.GetStringResource("LayerListUIPluginEditLayerText"), Name = "EditLayer"
                };
                editLayerMenuItem.Icon = new Image {
                    Source = new BitmapImage(new Uri("pack://application:,,,/GisEditorPluginCore;component/Images/sketchTools.png", UriKind.RelativeOrAbsolute)), Width = 16, Height = 16
                };

                MenuItem startMenuItem = new MenuItem()
                {
                    Header = GisEditor.LanguageManager.GetStringResource("LayerListMenuItemHelperStartEditingText"), IsEnabled = !isInEditing
                };
                startMenuItem.Click += StartEditMenuItem_Click;
                MenuItem cancelMenuItem = new MenuItem()
                {
                    Header = GisEditor.LanguageManager.GetStringResource("LayerListMenuItemHelperCancelEditingText")
                };
                cancelMenuItem.Command = EditingToolsViewModel.Instance.CancelCommand;
                MenuItem saveMenuItem = new MenuItem()
                {
                    Header = GisEditor.LanguageManager.GetStringResource("LayerListMenuItemHelperSaveEditingText")
                };
                saveMenuItem.Command = EditingToolsViewModel.Instance.SaveEditingCommand;
                MenuItem endMenuItem = new MenuItem()
                {
                    Header    = GisEditor.LanguageManager.GetStringResource("EndEditSelectionWindowTitle"),
                    IsEnabled = isInEditing || cancelMenuItem.Command.CanExecute(null) || saveMenuItem.Command.CanExecute(null)
                };
                endMenuItem.Click += EndMenuItem_Click;

                editLayerMenuItem.Items.Add(startMenuItem);
                editLayerMenuItem.Items.Add(cancelMenuItem);
                editLayerMenuItem.Items.Add(saveMenuItem);
                editLayerMenuItem.Items.Add(endMenuItem);

                menuItems.Add(editLayerMenuItem);
            }
            return(menuItems);
        }