Data Series Box for quickly displaying a form with a time series plot on it in the same spirit as System.Windows.Forms.MessageBox.
Наследование: System.Windows.Forms.Form
Пример #1
0
        private static DataSeriesBox show(String title, double[][] series, bool hold)
        {
            DataSeriesBox form       = null;
            Thread        formThread = null;

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

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

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

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    form.series.Add(new LineItem(i.ToString(), Matrix.Indices(0, series[i].Length).ToDouble(),
                                                 series[i], sequence.GetColor(i), SymbolType.None));
                }

                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            if (!hold)
            {
                formThread.Join();
            }

            return(form);
        }
Пример #2
0
        private static DataSeriesBox show(String title, double[] x, double[][] series,
                                          bool time = false)
        {
            DataSeriesBox form       = null;
            Thread        formThread = null;

            if (title == null)
            {
                title = "Time series";
            }

            x = (double[])x.Clone();
            var idx = Vector.Range(0, x.Length);

            Array.Sort(x, idx);

            for (int i = 0; i < series.Length; i++)
            {
                series[i] = series[i].Get(idx);
            }

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

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

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

                var pane = form.zedGraphControl.GraphPane;

                if (time)
                {
                    pane.XAxis.Type            = AxisType.Date;
                    pane.XAxis.Scale.MajorUnit = DateUnit.Hour;
                    pane.XAxis.Scale.Format    = "T";
                }

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    if (x == null)
                    {
                        x = Vector.Range(0, series[i].Length).ToDouble();
                    }

                    var lineItem = new LineItem(i.ToString(), x,
                                                series[i], sequence.GetColor(i), SymbolType.None);

                    form.series.Add(lineItem);
                }

                pane.Title.Text = title;
                pane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return(form);
        }
Пример #3
0
        private static DataSeriesBox show(String title, double[][] series, bool hold)
        {
            DataSeriesBox form = null;
            Thread formThread = null;

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

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

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

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    form.series.Add(new LineItem(i.ToString(), Matrix.Indices(0, series[i].Length).ToDouble(),
                        series[i], sequence.GetColor(i), SymbolType.None));
                }

                form.zedGraphControl.GraphPane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            if (!hold)
                formThread.Join();

            return form;
        }
Пример #4
0
        private static DataSeriesBox show(String title, double[] x, double[][] series,
            bool time = false)
        {
            DataSeriesBox form = null;
            Thread formThread = null;

            if (title == null)
                title = "Time series";

            x = (double[])x.Clone();
            var idx = Matrix.Indices(0, x.Length);
            Array.Sort(x, idx);

            for (int i = 0; i < series.Length; i++)
                series[i] = series[i].Submatrix(idx);

            AutoResetEvent stopWaitHandle = new AutoResetEvent(false);

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

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

                var pane = form.zedGraphControl.GraphPane;

                if (time)
                {
                    pane.XAxis.Type = AxisType.Date;
                    pane.XAxis.Scale.MajorUnit = DateUnit.Hour;
                    pane.XAxis.Scale.Format = "T";
                }

                var sequence = new ColorSequenceCollection(series.Length);

                for (int i = 0; i < series.Length; i++)
                {
                    if (x == null)
                        x = Matrix.Indices(0, series[i].Length).ToDouble();

                    var lineItem = new LineItem(i.ToString(), x,
                        series[i], sequence.GetColor(i), SymbolType.None);

                    form.series.Add(lineItem);
                }

                pane.Title.Text = title;
                pane.AxisChange();

                stopWaitHandle.Set();

                Application.Run(form);
            });

            formThread.SetApartmentState(ApartmentState.STA);

            formThread.Start();

            stopWaitHandle.WaitOne();

            return form;
        }