private void Add(int r, int c, string name, string description, Image image, bool enable, bool arrow) { ItemDescription item = new ItemDescription(); item.Col = c; item.Description = description; item.Enable = enable; item.Image = image; item.Name = name; item.Row = r; item.Arrow = arrow; if (item.Name.Length > 0) { _items.Add(name, item); } else { _items.Add(item); } if ((r + 1) > maxRow) { maxRow = r + 1; } if ((c + 1) > maxCol) { maxCol = c + 1; } if (_Matrix) { _Matrix = false; } }
public ItemEventArgs(ItemDescription item, MouseEventArgs m) { _item = item; _r = _item.Row; _c = _item.Col; _m = m; _name = _item.Name; }
void DrawPrompt(Point p) { #region 注意清理和不必要的画 string newName = GetItemDescriptionName(p); if (!String.IsNullOrEmpty(newName)) { if (newName.Equals(_current, StringComparison.OrdinalIgnoreCase)) { return; } } this.Invalidate(_lastPromptRectangle); this.Update(); #endregion _lastPromptRectangle = new Rectangle(); Graphics g = Graphics.FromHwnd(this.Handle); if (!String.IsNullOrEmpty(_current)) { ItemDescription currentitem = _items.GetItem(_current); if (currentitem != null) { if (currentitem.Enable) { ImageHandler.DrawImageDark(g, currentitem.Image, currentitem.Bounds); } } } _current = newName; if (!String.IsNullOrEmpty(newName)) { ItemDescription item = _items.GetItem(newName); GraphicsPath shape = new GraphicsPath(); if (item.Enable) { this.Invalidate(item.Bounds); this.Update(); this.Cursor = Cursors.Hand; } SizeF sf = g.MeasureString(item.Description, this.Font); Core.ImageHandler.ArcRectanglePath(shape, item.Bounds.Left + (item.Bounds.Width / 2), item.Bounds.Top + ((item.Bounds.Height - 50) / 2) - (int)(70 * 0.8), (int)(sf.Width) + 20, 50, 10, 10); RectangleF rt = shape.GetBounds(); rt.Inflate(1, 1); g.FillPath(new SolidBrush(Color.FromArgb(128, Color.Black)), shape); //g.InterpolationMode = InterpolationMode.HighQualityBicubic; //g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.DrawString(item.Name, new Font("宋体", 10, FontStyle.Bold), Brushes.AntiqueWhite, new PointF(rt.Left + 10, rt.Top + 10)); g.DrawString(item.Description, this.Font, Brushes.AntiqueWhite, new PointF(rt.Left + 10, rt.Bottom - 18)); _lastPromptRectangle = Rectangle.Ceiling(rt); } else { this.Cursor = Cursors.Default; } g.Dispose(); }
public void CopyTo(ItemDescription newItem) { if (newItem != null) { base.CopyTo(newItem as ArrowItem); newItem.Margin = this.Margin; newItem.Description = this.Description; newItem.Name = this.Name; newItem.Image = this.Image; newItem.Enable = this.Enable; } }
/// <summary> /// 动态改变Enable /// </summary> /// <param name="itemDescriptions"></param> public void RefreshEnable(ItemDescription[] itemDescriptions) { foreach (ItemDescription item in itemDescriptions) { if (_items.ContainsKey(item.Name)) { ItemDescription myItem = _items[item.Name]; if (myItem.Enable != item.Enable) { myItem.Enable = item.Enable; } } } }
protected override void OnMouseClick(MouseEventArgs e) { if (ItemMouseClick != null) { string name = GetItemDescriptionName(e.Location); if (!String.IsNullOrEmpty(name)) { ItemDescription item = _items.GetItem(name); if (item.Enable) { ItemEventArgs ea = new ItemEventArgs(item, e); ItemMouseClick(this, ea); } } } }