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); }
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); }
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); }
private static WavechartBox show(String title, bool hold, params Tuple <Signal, int>[] series) { WavechartBox 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 WavechartBox(); form.Text = title; form.formThread = formThread; if (!String.IsNullOrEmpty(title)) { form.zedGraphControl.GraphPane.Title.IsVisible = true; form.zedGraphControl.GraphPane.Title.Text = title; } var sequence = new ColorSequenceCollection(series.Length); for (int i = 0; i < series.Length; i++) { var signal = series[i].Item1; int channel = series[i].Item2; ComplexSignal complex = signal as ComplexSignal; if (complex != null && complex.Status != ComplexSignalStatus.Normal) { double[] spectrum = Accord.Audio.Tools.GetPowerSpectrum(complex.GetChannel(channel)); double[] frequencies = Accord.Audio.Tools.GetFrequencyVector(signal.Length, signal.SampleRate); form.series.Add(new LineItem(i.ToString(), frequencies, spectrum, sequence.GetColor(i), SymbolType.None)); form.zedGraphControl.GraphPane.XAxis.Title.Text = "Frequency"; form.zedGraphControl.GraphPane.YAxis.Title.Text = "Power"; } else { double[] values; if (signal.Channels == 1) { values = signal.ToDouble(); } else { ExtractChannel extract = new ExtractChannel(channel); values = extract.Apply(signal).ToDouble(); } form.series.Add(new LineItem(i.ToString(), Matrix.Indices(0, signal.Length).ToDouble(), values, sequence.GetColor(i), SymbolType.None)); form.zedGraphControl.GraphPane.XAxis.Title.Text = "Time"; form.zedGraphControl.GraphPane.YAxis.Title.Text = "Amplitude"; } } form.zedGraphControl.GraphPane.AxisChange(); stopWaitHandle.Set(); Application.Run(form); }); formThread.SetApartmentState(ApartmentState.STA); formThread.Start(); stopWaitHandle.WaitOne(); if (!hold) { formThread.Join(); } return(form); }