protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); _ActiveLabel = null; }
void LegendPanel_MouseEnter(object sender, EventArgs e) { _ActiveLabel = sender as LegendLabel; if (!_AllowHighlightingGraphs) return; LegendLabel lbl = sender as LegendLabel; lbl.BackColor = _HighlightedColor; if (OnLabelHilighted != null) OnLabelHilighted((ILegendItem)lbl.Tag); }
public void UpdateLegend() { foreach (LegendLabel lbl in _Labels) lbl.Dispose(); _Labels.Clear(); int i = 0; if (Items != null) { _AutoWidth = 0; foreach (ILegendItem gr in Items) { LegendLabel lbl = new LegendLabel(); lbl.Parent = this; lbl.SquareColor = gr.Color; lbl.Text = gr.Hint; lbl.Grayed = gr.Hidden; lbl.Left = 0; lbl.Top = i * lbl.Height + label1.Top; lbl.Width = Width; lbl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; lbl.Tag = gr; lbl.Cursor = Cursors.Arrow; lbl.MouseClick += new MouseEventHandler(LegendPanel_MouseClick); lbl.MouseEnter += new EventHandler(LegendPanel_MouseEnter); lbl.MouseLeave += new EventHandler(LegendPanel_MouseLeave); lbl.MouseMove += new MouseEventHandler(lbl_MouseMove); lbl.MouseDown += new MouseEventHandler(lbl_MouseDown); _AutoWidth = Math.Max(_AutoWidth, lbl.Left + lbl.MeasureWidth() + 10); _AutoHeight = lbl.Bottom + 10; lbl.Visible = true; _Labels.Add(lbl); i++; } label1.Visible = false; } if (i == 0) { label1.Visible = true; _AutoWidth = label1.Right + 10; _AutoHeight = label1.Bottom + 10; } if (_Autosize) { Width = _AutoWidth; Height = _AutoHeight; } }