예제 #1
0
        internal void UpdateLegend()
        {
            if (legendButtons != null)
            {
                for (int i = 0; i < legendButtons.Length; i++)
                {
                    legendButtons[i].Dispose();
                }
            }

            legendButtons = new LegendButton[series.Count];
            for (int i = 0; i < legendButtons.Length; i++)
            {
                var s  = series[i];
                var lb = new LegendButton(legend, s);
                if (s.name == null)
                {
                    lb.Text = string.Concat("Series ", (i + 1).ToString());
                }

                lb.Width = (int)MeasureStringSimple(legend.itemStyle.font, lb.Text).Width + 20;

                if (legend.layout == LegendLayouts.horizontal)
                {
                    lb.Location = new Point(i * 120, Height - lb.Height);
                }

                Controls.Add(lb);

                legendButtons[i] = lb;
            }

            UpdateLegendLocation();
        }
예제 #2
0
        private void TryUpdateLegendButtons(Graphics g)
        {
            if (!updateLegendButtonsFlag)
            {
                return;
            }

            updateLegendButtonsFlag = false;

            if (legendButtons != null)
            {
                for (int i = 0; i < legendButtons.Length; i++)
                {
                    legendButtons[i].Dispose();
                }
            }

            if (!legend.enabled)
            {
                return;
            }

            legendButtons = new LegendButton[series.Count];

            for (int i = 0; i < legendButtons.Length; i++)
            {
                var s  = series[i];
                var lb = new LegendButton(legend, s);

                lb.Width = (int)g.MeasureString(lb.Text, legend.itemStyle.font).Width + 20;

                if (legend.layout == LegendLayouts.horizontal)
                {
                    lb.Location = new Point(i * 120, Height - lb.Height);
                }

                Controls.Add(lb);

                legendButtons[i] = lb;
            }

            Recalc();
        }