Exemplo n.º 1
0
 private void btnApply_Click(object sender, System.EventArgs e)
 {
     if (this.cbAuto.Checked)
     {
         cc.ChartDataList.RestoreOriginalAxis();
     }
     else
     {
         AxisData ax = new AxisData(Double.Parse(tbXMin.Text), Double.Parse(tbXMax.Text), 1);
         AxisData ay = new AxisData(Double.Parse(tbYMin.Text), Double.Parse(tbYMax.Text), 1);
         cc.AxisRangeX = new AxisData(ax.Min, ax.Max, Math.Abs(ax.Max - ax.Min) / 5);
         cc.AxisRangeY = new AxisData(ay.Min, ay.Max, Math.Abs(ay.Max - ay.Min) / 5);
     }
     cc.Invalidate();
 }
        public PropertiesControl(ChartControl cc)
        {
            InitializeComponent();

            if (cc.ChartDataList.Length > 0)
            {
                cdp = new ChartDataProperties(cc.ChartDataList);

                AddStringField("Title", cdp);
                AddStringField("TitleX", cdp);
                AddStringField("AxisLabelX", cdp);
                AddStringField("AxisLabelY", cdp);

                AddBoolField("ShowZero", cdp);
                AddBoolField("ShowFullNameLegend", cdp);

                TabPage tp;
                for (int i = 0; i < cdp.TitlesY.Count; i++)
                {
                    tp           = new TabPage("Y Series " + i);
                    tp.BackColor = Color.White;
                    FlowLayoutPanel flp = new FlowLayoutPanel();
                    flp.Dock       = DockStyle.Fill;
                    flp.AutoScroll = true;
                    flp.Tag        = i;
                    tp.Controls.Add(flp);
                    this.tabControl1.TabPages.Add(tp);
                    for (int k = 0; k < cdp.TitlesY[i].Count; k++)
                    {
                        TextBox tb = new TextBox();
                        Label   l  = new Label();

                        l.Text      = "TitlesY[" + i + "][" + k + "]" + ":";
                        l.TextAlign = ContentAlignment.MiddleLeft;
                        l.Size      = new Size(labelWidth, labelHeight);
                        l.ForeColor = Color.Black;
                        //tb.DataBindings.Add("Text", datasource, name);
                        tb.Text = cdp.TitlesY[i][k];
                        tb.Tag  = k;

                        tb.LostFocus += new EventHandler(tb_LostFocus);
                        //tb.LostFocus += delegate{

                        //};


                        tb.Size = new Size(boxWidth, labelHeight);
                        flp.Controls.AddRange(new Control[] { l, tb });
                    }
                }
            }

            Button apply = new Button();

            apply.Text   = "Apply";
            apply.Click += delegate { cdp.Apply(); cc.Invalidate(); };
            apply.Dock   = DockStyle.Bottom;
            this.Controls.Add(apply);

            this.BackColor = Color.White;
        }