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); }