⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comparedialog.cs

📁 Sudoku as a CSP: Using algorithms and techniques from CSP to solve an NxN Sudoku puzzle.
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ZedGraph; 
namespace MySudoku
{
    public partial class CompareDialog : Form
    {
        GraphData data;
        int puzzle_number = 0;
        public CompareDialog(int puznum,GraphData d)
        {
            InitializeComponent();
            data = d;
            puzzle_number = puznum;
            label1.Text = "Algorithms Comparison   - Puzzle number " + puzzle_number.ToString() + ".";
        }
        public void CreateChart(ZedGraphControl zgc)
        {
            // get a reference to the GraphPane
            GraphPane myPane = zgc.GraphPane;

            // Set the Titles
            myPane.Title.Text = "Run-Time Comparison";
            myPane.XAxis.Title.Text = "Algorithms";
            myPane.YAxis.Title.Text = "milliseconds";

            // Make up some random data points
            string[] labels = new string[data.datalist.Count]; 
            double[] y = new double[data.datalist.Count];
            for (int i = 0; i < data.datalist.Count; i++)
            {
                y[i] = data.datalist[i].runTime;
                labels[i] = data.datalist[i].name;
            }

            // Generate a red bar with "Curve 1" in the legend
            BarItem myBar = myPane.AddBar("Run Time.", null, y,
                                                        Color.Red);
            myBar.Bar.Fill = new Fill(Color.Red, Color.White,
                                                        Color.Red);


            // Draw the X tics between the labels instead of 
            // at the labels
            myPane.XAxis.MajorTic.IsBetweenLabels = true;

            // Set the XAxis labels
            myPane.XAxis.Scale.TextLabels = labels;
            // Set the XAxis to Text type
            myPane.XAxis.Type = AxisType.Text;

            // Fill the Axis and Pane backgrounds
            myPane.Chart.Fill = new Fill(Color.White,
                  Color.FromArgb(255, 255, 166), 90F);
            myPane.Fill = new Fill(Color.FromArgb(250, 250, 255));

            // Tell ZedGraph to refigure the
            // axes since the data have changed
            zgc.AxisChange();
        }
        
        public void CreateChart2(ZedGraphControl zgc)
        {
            // get a reference to the GraphPane
            GraphPane myPane = zgc.GraphPane;

            // Set the Titles
            myPane.Title.Text = "Backtracks Comparison";
            myPane.XAxis.Title.Text = "Algorithms";
            myPane.YAxis.Title.Text = "Num of backtracking";

            // Make up some random data points
            string[] labels = new string[data.datalist.Count];
            double[] y = new double[data.datalist.Count];
            for (int i = 0; i < data.datalist.Count; i++)
            {
                y[i] = (double)data.datalist[i].Backtracks;
                labels[i] = data.datalist[i].name;
            }
            // Generate a red bar with "Curve 1" in the legend
            BarItem myBar = myPane.AddBar("Backtracks.", null, y,
                                                        Color.Blue);
            myBar.Bar.Fill = new Fill(Color.Blue, Color.White,
                                                        Color.Blue);


            // Draw the X tics between the labels instead of 
            // at the labels
            myPane.XAxis.MajorTic.IsBetweenLabels = true;

            // Set the XAxis labels
            myPane.XAxis.Scale.TextLabels = labels;
            // Set the XAxis to Text type
            myPane.XAxis.Type = AxisType.Text;

            // Fill the Axis and Pane backgrounds
            myPane.Chart.Fill = new Fill(Color.White,
                  Color.FromArgb(255, 255, 166), 90F);
            myPane.Fill = new Fill(Color.FromArgb(250, 250, 255));

            // Tell ZedGraph to refigure the
            // axes since the data have changed
            zgc.AxisChange();
        }

      
        private void CompareDialog_Load(object sender, EventArgs e)
        {
         
           CreateChart(zg);
            CreateChart2(zg2); 
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Close(); 
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -