Пример #1
0
        private void SaveTemplate(string templateFileName)
        {
            if (File.Exists(templateFileName))
            {
                File.Delete(templateFileName);
            }
            ChartControl  chart    = this.chartControl1;
            ChartTemplate template = new ChartTemplate(typeof(ChartControl));

            if (saveChartAppearance)
            {
                template.Scan(chart);
                template.Save(templateFileName);
            }
            Stream stream = new FileStream(templateFileName, FileMode.OpenOrCreate);

            for (int i = 0; i < chart.Series.Count; i++)
            {
                template = new ChartTemplate(chart.Series[i].GetType());
                template.ScanSeries(chart.Series[i]);
                template.SaveSeries(stream);
            }
            stream.Dispose();
            stream.Close();
        }
Пример #2
0
        private void buttonAdv1_Click(object sender, EventArgs e)
        {
            //Saves file to the same template
            if (frm.radioButton1.Checked)
            {
                ChartTemplate.Save(this.chartControl1, currentTemplate);
            }
            //Saves file to a new template
            if (frm.radioButton2.Checked)
            {
                if (templateCount < 2)
                {
                    if (templateCount == 0)
                    {
                        Templatebutton.Visible   = true;
                        this.buttonAdv7.Visible  = true;
                        this.buttonAdv11.Visible = true;
                    }
                    if (templateCount == 1)
                    {
                        Templatebutton.Visible   = true;
                        this.buttonAdv10.Visible = true;
                        this.buttonAdv12.Visible = true;
                    }
                    templateCount = templateCount + 1;


                    saveTemplateFile = "Template" + templateCount.ToString() + ".xml";
                    ChartTemplate.Save(this.chartControl1, saveTemplateFile);
                }
                else
                {
                    MessageBox.Show("Programmed to add only two user defined templates");
                }
            }
            frm.Hide();
        }
Пример #3
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            Syncfusion.Windows.Forms.Chart.ChartSeries chartSeries1 = new Syncfusion.Windows.Forms.Chart.ChartSeries();
            this.chartControl1 = new Syncfusion.Windows.Forms.Chart.ChartControl();
            this.SuspendLayout();
            //
            // chartControl1
            //
            this.chartControl1.ChartArea.BackInterior   = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.Transparent);
            this.chartControl1.ChartArea.CursorLocation = new System.Drawing.Point(0, 0);
            this.chartControl1.ChartArea.CursorReDraw   = false;
            this.chartControl1.DataSourceName           = "[none]";
            this.chartControl1.IsWindowLess             = false;
            this.chartControl1.Title.Text = "Product Sales";
            this.chartControl1.Size       = new System.Drawing.Size(457, 330);
            this.chartControl1.TabIndex   = 0;
            this.chartControl1.Title.Name = "Default";
            this.chartControl1.Titles.Add(this.chartControl1.Title);
            this.chartControl1.Skins                   = Skins.Metro;
            this.chartControl1.ShowToolTips            = true;
            this.chartControl1.Tooltip.BackgroundColor = new BrushInfo(Color.White);
            this.chartControl1.Tooltip.BorderStyle     = BorderStyle.FixedSingle;
            this.chartControl1.Tooltip.Font            = new Font("Segoe UI", 10);

            //
            // Legend
            //
            this.chartControl1.Legend.Visible   = true;
            this.chartControl1.LegendAlignment  = ChartAlignment.Center;
            this.chartControl1.Legend.Position  = ChartDock.Top;
            this.chartControl1.LegendsPlacement = ChartPlacement.Outside;
            this.chartControl1.Legend.Location  = new System.Drawing.Point(321, 87);
            this.chartControl1.Localize         = null;
            this.chartControl1.Location         = new System.Drawing.Point(174, 87);
            //
            // PrimaryXAxis
            //
            this.chartControl1.PrimaryXAxis.Title      = "Year";
            this.chartControl1.PrimaryXAxis.ValueType  = ChartValueType.Category;
            this.chartControl1.PrimaryXAxis.TitleColor = System.Drawing.SystemColors.ControlText;
            //
            // PrimaryYAxis
            //
            this.chartControl1.PrimaryYAxis.Title      = "Sales(Millions)";
            this.chartControl1.PrimaryYAxis.TitleColor = System.Drawing.SystemColors.ControlText;
            //
            // Form1
            //
            BindingList <SalesData> dataSource = new BindingList <SalesData>();

            dataSource.Add(new SalesData("1999", 5));
            dataSource.Add(new SalesData("2000", 7));
            dataSource.Add(new SalesData("2001", 12));
            dataSource.Add(new SalesData("2002", 18));
            dataSource.Add(new SalesData("2003", 22));
            dataSource.Add(new SalesData("2004", 30));
            dataSource.Add(new SalesData("2005", 40));
            dataSource.Add(new SalesData("2006", 50));
            dataSource.Add(new SalesData("2007", 65));
            dataSource.Add(new SalesData("2008", 75));

            CategoryAxisDataBindModel dataSeriesModel = new CategoryAxisDataBindModel(dataSource);

            dataSeriesModel.CategoryName = "Year";
            dataSeriesModel.YNames       = new string[] { "Sales" };

            var template = new ChartTemplate(typeof(ChartControl));

            template.Scan(this.chartControl1);
            template.Save("TemplateName.xml");

            //ChartTemplate.Save(this.chartControl1, "TemplateName.xml");

            chartSeries1 = new ChartSeries("Sales");
            chartSeries1.PointsToolTipFormat   = "{2}";
            chartSeries1.PrepareStyle         += ChartSeries1_PrepareStyle;
            chartSeries1.CategoryModel         = dataSeriesModel;
            chartSeries1.Style.DisplayText     = true;
            chartSeries1.Style.TextOrientation = ChartTextOrientation.Up;
            this.chartControl1.Dock            = DockStyle.Fill;
            this.chartControl1.Series.Add(chartSeries1);

            this.chartControl1.Dock  = System.Windows.Forms.DockStyle.Fill;
            this.chartControl1.Size  = new System.Drawing.Size(600, 450);
            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
            this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize          = new System.Drawing.Size(821, 577);
            this.Controls.Add(this.chartControl1);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);
        }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     ChartTemplate.Save(this.chartControl1, "Chart.xml");
     this.button2.Enabled = true;
 }