示例#1
0
        private static DataBarBox show(string title, string[] labels, double[][] series)
        {
            DataBarBox form       = null;
            Thread     formThread = null;

            if (title == null)
            {
                title = "Bar chart";
            }

            double[] x = Matrix.Indices(0, labels.Length).ToDouble();

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

            formThread = new Thread(() =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // Show control in a form
                form            = new DataBarBox();
                form.Text       = title;
                form.formThread = formThread;

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    form.series.Add(new BarItem(i.ToString(), x,
                                                series[i], sequence.GetColor(i)));
                }

                form.zedGraphControl.GraphPane.Title.Text             = title;
                form.zedGraphControl.GraphPane.XAxis.Type             = AxisType.Text;
                form.zedGraphControl.GraphPane.XAxis.Scale.TextLabels = labels;
                form.zedGraphControl.GraphPane.XAxis.Scale.MajorStep  = 1;
                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return(form);
        }
示例#2
0
        private static DataBarBox show(string title, string[] labels, double[][] series)
        {
            DataBarBox form = null;
            Thread formThread = null;

            if (title == null)
                title = "Bar chart";

            double[] x = Matrix.Indices(0, labels.Length).ToDouble();

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

            formThread = new Thread(() =>
            {
                Accord.Controls.Tools.ConfigureWindowsFormsApplication();

                // Show control in a form
                form = new DataBarBox();
                form.Text = title;
                form.formThread = formThread;

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    form.series.Add(new BarItem(i.ToString(), x,
                        series[i], sequence.GetColor(i)));
                }

                form.zedGraphControl.GraphPane.Title.Text = title;
                form.zedGraphControl.GraphPane.XAxis.Type = AxisType.Text;
                form.zedGraphControl.GraphPane.XAxis.Scale.TextLabels = labels;
                form.zedGraphControl.GraphPane.XAxis.Scale.MajorStep = 1;
                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return form;
        }