private void AddToMap(IMapItem item) { // Draw the item image over the map. var pb = new PictureBox(); pb.SizeMode = PictureBoxSizeMode.AutoSize; pb.Parent = SeaChart; pb.BackColor = Color.Transparent; pb.Image = item.GetImage(); pb.BringToFront(); pb.MouseMove += IMapItem_MouseMove; pb.ParentChanged += IMapItem_ParentChanged; pb.Location = item.GetLocation(); if (item.GetType() == typeof(Stamp)) { pb.Tag = "Stamp"; pb.MouseUp += Stamp_MouseUp; pb.MouseDown += Stamp_MouseDown; } else if (item.GetType() == typeof(Waypoint)) { pb.Tag = "Waypoint"; pb.MouseUp += Waypoint_MouseUp; pb.MouseEnter += Waypoint_MouseEnter; pb.MouseLeave += Waypoint_MouseLeave; pb.MouseDown += Waypoint_MouseDown; } }
private void menuItemSelectSame_Click(object sender, System.EventArgs e) { ArrayList alsmiSelected = new ArrayList(); foreach (IMapItem mi in m_lvld.MapItems) { if (mi.GetType() != m_miContextMenu.GetType()) { continue; } if (m_miContextMenu is Tile) { if (mi is Tile) { if (((Tile)mi).Name != ((Tile)m_miContextMenu).Name) { continue; } } } alsmiSelected.Add(mi); } m_lvld.Selection = alsmiSelected; Redraw(); }
//-------------------------------------------------------------------- public static IWin32MapItem GetNewMapItem(IMapItem item) { if (item == null) { return(null); } Type tp = null; if (m_typeMapItemToMarker.TryGetValue(item.GetType(), out tp)) { try { IWin32MapItem w32Item = (IWin32MapItem)Activator.CreateInstance(tp, new object[] { item }); return(w32Item); } catch (Exception e) { } } return(null); }