private void DoItemMouseUp(ItemMouseEventArgs e) { //get the selected item _selectedItem = e.ItemBox.Item; Point loc = new Point(e.X + ControlRectangle.X, e.Location.Y + ControlRectangle.Top); if (e.Button == MouseButtons.Left) { if (e.ItemBox.Item.LegendSymbolMode == SymbolMode.Checkbox) { if (e.ItemBox.CheckBox.Contains(loc)) { IRenderableLegendItem rendItem = e.ItemBox.Item as IRenderableLegendItem; if (rendItem != null) { // force a re-draw in the case where we are talking about layers. rendItem.IsVisible = !rendItem.IsVisible; } else { e.ItemBox.Item.Checked = !e.ItemBox.Item.Checked; } if (CheckBoxMouseUp != null) { CheckBoxMouseUp(this, e); } RefreshNodes(); } } if (e.ItemBox.Textbox.Contains(loc)) { if (e.ItemBox == _previousMouseDown) { _isDragging = false; // Edit via text box _editBox.Left = e.ItemBox.Textbox.Left; _editBox.Width = e.ItemBox.Textbox.Width + 10; _editBox.Top = e.ItemBox.Bounds.Top; _editBox.Height = e.ItemBox.Bounds.Height; _editBox.SelectedText = e.ItemBox.Item.LegendText; _editBox.Font = Font; _editBox.Visible = true; } } } if (e.Button == MouseButtons.Right) { if (e.ItemBox.Item.ContextMenuItems == null) { return; } //show nothing when right click on the symbol //var category = e.ItemBox.Item as Category; //if (category != null) return; //_contextMenu.MenuItems.Clear(); ////items for map frame || symbol //var mapFrame = e.ItemBox.Item as Layer; //if (mapFrame == null) //{ // foreach (SymbologyMenuItem mi in e.ItemBox.Item.ContextMenuItems) // { // AddMenuItem(_contextMenu.MenuItems, mi); // } //} if (_selectedItem is FeatureLayer) { _contextMenu = ContextMenuService.CreateContextMenu(this, "/FrameWork/Legend/ContextMenu/FeatureLayer"); } else if (_selectedItem is RasterLayer) { _contextMenu = ContextMenuService.CreateContextMenu(this, "/FrameWork/Legend/ContextMenu/RasterLayer"); } else if (_selectedItem is ImageLayer) { _contextMenu = ContextMenuService.CreateContextMenu(this, "/FrameWork/Legend/ContextMenu/ImageLayer"); } else if (_selectedItem is MapFrame) { _contextMenu = ContextMenuService.CreateContextMenu(this, "/FrameWork/Legend/ContextMenu/MapFrame"); } else { _contextMenu = null; return; } //if (_legendContextMenu == null) //{ // _legendContextMenu = new LegendContextMenu(); //} //_legendContextMenu.OnSelectedItem(e.ItemBox.Item); //items for layer //var contextMenuItems = _contextMenu.MenuItems; //_legendContextMenu.AddLayerMenuItem(ref contextMenuItems); _contextMenu.Show(this, e.Location); _contextMenu.MenuItems.Clear(); } }