private void AddContextMenuItems(ILayer addedLayer) { IMapGroup grp = addedLayer as IMapGroup; if (grp != null) { // map.layerAdded event doesn't fire for groups. Therefore, it's necessary // to handle this event separately for groups. grp.LayerAdded += Map_LayerAdded; } if (addedLayer.ContextMenuItems.Exists(item => item.Name == contextMenuItemName)) { // assume menu item already exists. Do nothing. return; } // add context menu item. var menuItem = new SymbologyMenuItem(contextMenuItemName, delegate { ShowAttributes(addedLayer as IFeatureLayer); }); menuItem.Image = Resources.table_16x16; var cmi = addedLayer.ContextMenuItems; if (cmi.Count > 2) { addedLayer.ContextMenuItems.Insert(2, menuItem); } else { addedLayer.ContextMenuItems.Add(menuItem); } }
/// <summary> /// Forces the creation of an entirely new context menu list. That way, we are not /// pointing to an event handler in the previous parent. /// </summary> public void CreateContextMenuItems() { base.ContextMenuItems = new List <SymbologyMenuItem>(); _mnuRemoveMe = new SymbologyMenuItem("Remove Category", RemoveCategoryClicked); _mnuSelectFeatures = new SymbologyMenuItem("Select Features", SelectFeaturesClicked); _mnuDeselectFeatures = new SymbologyMenuItem("Deselect Features", DeselectFeaturesClicked); base.ContextMenuItems.Add(_mnuRemoveMe); base.ContextMenuItems.Add(_mnuSelectFeatures); base.ContextMenuItems.Add(_mnuDeselectFeatures); }
/// <summary> /// Forces the creation of an entirely new context menu list. That way, we are not /// pointing to an event handler in the previous parent. /// </summary> public void CreateContextMenuItems() { ContextMenuItems = new List <SymbologyMenuItem>(); _mnuRemoveMe = new SymbologyMenuItem("Categ_Remove", RemoveCategoryClicked); _mnuSelectFeatures = new SymbologyMenuItem("Categ_Select", SelectFeaturesClicked); _mnuDeselectFeatures = new SymbologyMenuItem("Categ_Deselect", DeselectFeaturesClicked); ContextMenuItems.Add(_mnuRemoveMe); ContextMenuItems.Add(_mnuSelectFeatures); ContextMenuItems.Add(_mnuDeselectFeatures); }
private void Configure() { SelectionEnabled = true; ContextMenuItems = new List <SymbologyMenuItem> { new SymbologyMenuItem(SymbologyMessageStrings.RemoveLayer, SymbologyImages.mnuLayerClear, RemoveLayerClick), new SymbologyMenuItem(SymbologyMessageStrings.ZoomToLayer, SymbologyImages.ZoomInMap, ZoomToLayerClick), new SymbologyMenuItem(SymbologyMessageStrings.SetDynamicVisibilityScale, SymbologyImages.ZoomScale, SetDynamicVisibility) }; SymbologyMenuItem mnuData = new SymbologyMenuItem(SymbologyMessageStrings.Data); mnuData.MenuItems.Add(new SymbologyMenuItem(SymbologyMessageStrings.ExportData, SymbologyImages.save, ExportDataClick)); ContextMenuItems.Add(mnuData); ContextMenuItems.Add(new SymbologyMenuItem(SymbologyMessageStrings.Properties, SymbologyImages.color_scheme, ShowPropertiesClick)); LegendSymbolMode = SymbolMode.Checkbox; LegendType = LegendType.Layer; IsExpanded = true; }
private void SerializationManager_Deserializing(object sender, SerializingEventArgs e) { // context menu items are added to layers when opening a project // this call is necessary because the LayerAdded event doesn't fire when a project is opened. foreach (ILayer layer in App.Map.MapFrame.GetAllLayers()) { IFeatureLayer fl = layer as IFeatureLayer; if (fl != null) { if (!fl.ContextMenuItems.Exists(item => item.Name == contextMenuItemName)) { // add context menu item. var menuItem = new SymbologyMenuItem(contextMenuItemName, delegate { ShowAttributes(fl); }); menuItem.Image = Resources.table_16x16; fl.ContextMenuItems.Insert(2, menuItem); } } } //attach layer added events to existing groups foreach (IGroup grp in App.Map.MapFrame.GetAllGroups()) { grp.LayerAdded += Map_LayerAdded; } }
private void Configure() { _selectionEnabled = true; base.ContextMenuItems = new List<SymbologyMenuItem> { new SymbologyMenuItem(SymbologyMessageStrings.RemoveLayer, SymbologyImages.mnuLayerClear, RemoveLayerClick), new SymbologyMenuItem(SymbologyMessageStrings.ZoomToLayer, SymbologyImages.ZoomInMap, ZoomToLayerClick), new SymbologyMenuItem(SymbologyMessageStrings.SetDynamicVisibilityScale, SymbologyImages.ZoomScale, SetDynamicVisibility) }; SymbologyMenuItem mnuData = new SymbologyMenuItem("Data"); mnuData.MenuItems.Add(new SymbologyMenuItem(SymbologyMessageStrings.ExportData, SymbologyImages.save, ExportDataClick)); base.ContextMenuItems.Add(mnuData); base.ContextMenuItems.Add(new SymbologyMenuItem(SymbologyMessageStrings.Properties, SymbologyImages.color_scheme, ShowPropertiesClick)); base.LegendSymbolMode = SymbolMode.Checkbox; LegendType = LegendType.Layer; base.IsExpanded = true; }
/// <summary> /// The configure. /// </summary> /// <param name="featureSet"> /// The feature set. /// </param> private void Configure(IFeatureSet featureSet) { _categoryExtents = new Dictionary<IFeatureCategory, Extent>(); _drawingBounds = new Rectangle(-32000, -32000, 64000, 64000); DataSet = featureSet; LegendText = featureSet.Name; _name = featureSet.Name; var label = new SymbologyMenuItem(Msg.FeatureLayer_Labeling); label.MenuItems.Add(new SymbologyMenuItem(Msg.FeatureLayer_Label_Setup, SymbologyImages.Label, LabelSetupClick)); label.MenuItems.Add(new SymbologyMenuItem(Msg.SetDynamicVisibilityScale, SymbologyImages.ZoomScale, LabelExtentsClick)); ContextMenuItems.Insert(4, label); var selection = new SymbologyMenuItem(Msg.FeatureLayer_Selection, SymbologyImages.select, null); ContextMenuItems.Insert(5, selection); selection.MenuItems.Add(new SymbologyMenuItem(Msg.FeatureLayer_Zoom_To_Selected, SymbologyImages.ZoomInMap, SelectionZoomClick)); selection.MenuItems.Add(new SymbologyMenuItem(Msg.FeatureLayer_Create_Layer_From_Selected_Features, SymbologyImages.Copy, SelectionToLayerClick)); selection.MenuItems.Add(new SymbologyMenuItem(Msg.FeatureLayer_SelectAll, SymbologyImages.select_all, SelectAllClick)); selection.MenuItems.Add(new SymbologyMenuItem(Msg.FeatureLayer_UnselectAll, SymbologyImages.deselect_16x16, UnselectAllClick)); ContextMenuItems.Add(new SymbologyMenuItem(Msg.FeatureLayer_Join_Excel_File, SymbologyImages.redbluearrows, JoinExcel)); if (!featureSet.IndexMode) { _editMode = true; } // Categories and selections // these are like a stored procedure that only care about the selection and no other drawing characteristics. if (_editMode) { _drawingFilter = new DrawingFilter(DataSet.Features, _scheme, 5000); _selection = new Selection(featureSet, _drawingFilter); } else { _selection = new IndexSelection(this); } _selection.Changed += SelectedFeaturesChanged; _drawnStatesNeeded = false; }
/// <summary> /// Recursive add method to handle nesting of menu items. /// </summary> /// <param name="parent"></param> /// <param name="mi"></param> private static void AddMenuItem(Menu.MenuItemCollection parent, SymbologyMenuItem mi) { MenuItem m; if (mi.Icon != null) { m = new IconMenuItem(mi.Name, mi.Icon, mi.ClickHandler); } else if (mi.Image != null) { m = new IconMenuItem(mi.Name, mi.Image, mi.ClickHandler); } else { m = new IconMenuItem(mi.Name, mi.ClickHandler); } parent.Add(m); foreach (SymbologyMenuItem child in mi.MenuItems) { AddMenuItem(m.MenuItems, child); } }
/// <summary> /// Forces the creation of an entirely new context menu list. That way, we are not /// pointing to an event handler in the previous parent. /// </summary> public void CreateContextMenuItems() { base.ContextMenuItems = new List<SymbologyMenuItem>(); _mnuRemoveMe = new SymbologyMenuItem("Remove Category", RemoveCategoryClicked); _mnuSelectFeatures = new SymbologyMenuItem("Select Features", SelectFeaturesClicked); _mnuDeselectFeatures = new SymbologyMenuItem("Deselect Features", DeselectFeaturesClicked); base.ContextMenuItems.Add(_mnuRemoveMe); base.ContextMenuItems.Add(_mnuSelectFeatures); base.ContextMenuItems.Add(_mnuDeselectFeatures); }