private void Button_Click_2(object sender, RoutedEventArgs e) { // Start_time = DateTime.Now; //ClassTextFile.CreatFileData(PathText.Text + Start_time.Year.ToString() + "_" + Start_time.Month.ToString() + "_" + Start_time.Day.ToString() + "_" + Start_time.Hour.ToString() + "_" + Start_time.Minute.ToString()); linegraph.Children.Clear(); var x = Enumerable.Range(0, 10).Select(i => i).ToArray(); // var y = x.Select(v => Math.Abs(v) < 1e-10 ? 1 : Math.Sin(v)/v).ToArray(); var y = new double[x.Length]; for (int i = 0; i < x.Length; i++) { if (i > 5 && i < 10) { y[i] = 30; } barChart.PlotBars(y); } var lg = new LineGraph(); linegraph.Children.Add(lg); lg.Stroke = new SolidColorBrush(Color.FromArgb(255, 36, 0, 255)); lg.Description = String.Format("Sig"); lg.StrokeThickness = 2; lg.Plot(x, y); double[] y1 = new double[x.Length]; for (int i = 0; i < x.Length; i++) { double t = 100; y1[i] = ClassFilterSig.Filtr(y[i], t); } var lg1 = new LineGraph(); linegraph.Children.Add(lg1); lg1.Stroke = new SolidColorBrush(Color.FromArgb(255, 225, 0, 255)); lg1.Description = String.Format("SigIntegral"); lg1.StrokeThickness = 2; lg1.Plot(x, y1); //barChart.PlotBars(y); }
private void setChartControl() { double[] x = new double[200]; for (int i = 0; i < x.Length; i++) { x[i] = 3.1415 * i / (x.Length - 1); } for (int i = 0; i < 25; i++) { var lg = new LineGraph(); lines.Children.Add(lg); lg.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, (byte)(i * 10), 0)); lg.Description = String.Format("Data series {0}", i + 1); lg.StrokeThickness = 2; lg.Plot(x, x.Select(v => Math.Sin(v + i / 10.0)).ToArray()); } }
public void PlotGraph() { if (Application.Current.Dispatcher.CheckAccess()) { linegraph.Plot(x, y); } else { int[] tmpx = x; int[] tmpy = y; LineGraph tmp_lg = linegraph; Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { tmp_lg.Plot(tmpx, tmpy); })); } }
public MainWindow() { InitializeComponent(); double[] x = new double[200]; for (int i = 0; i < x.Length; i++) { x[i] = 3.1415 * i / (x.Length - 1); } for (int i = 0; i < 25; i++) { var lg = new LineGraph(); Lines.Children.Add(lg); lg.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); lg.Description = "F**K"; lg.StrokeThickness = 2; lg.Plot(x, x.Select(v => Math.Sin(v + i / 10.0)).ToArray()); } }
private void Orgasm_Click(object sender, RoutedEventArgs e) { // Record the time of o****m var time = DateTimeOffset.Now.ToUnixTimeMilliseconds() - startTime; var text = time + ":user:o****m"; Console.WriteLine(text); w?.WriteLine(text); var oGraph = new LineGraph(); oGraph.Description = "O****m"; Dispatcher?.Invoke(() => { Lines.Children.Add(oGraph); oGraph.Plot(new double[] { time, time }, new double[] { 0, 4000 }); OnOrgasmDataPoint?.Invoke(this, new OrgasmDataPointArgs(time)); }); }
public void DrawLinePlot(double minX, double maxX, double[] values, string name) { int pointCount = values.Length; double[] xs = Consecutive(pointCount, minX, (maxX - minX) / pointCount); colorIndex = (colorIndex + 1) % colors.Length; LineGraph line = AddLine(name, colors[colorIndex]); line.Plot(xs, values); myGrid.Children.Add(line); myChart.Title = $"Графики ({pointCount:n0} точек по Ox)"; myChart.BottomTitle = $"Угол, радианы"; myChart.LeftTitle = $"Фазовая модуляция"; myChart.IsAutoFitEnabled = true; myChart.LegendVisibility = Visibility.Visible; }
public MainWindow() { InitializeComponent(); double[] x = new double[200]; for (int i = 0; i < x.Length; i++) { x[i] = 3.1415 * i / (x.Length - 1); } for (int i = 0; i < 25; i++) { var lg = new LineGraph(); lines.Children.Add(lg); lg.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, (byte)(i * 10), 0)); lg.Description = String.Format("Data series {0}", i + 1); lg.StrokeThickness = 2; lg.Plot(x, x.Select(v => Math.Sin(v + i / 10.0)).ToArray()); lg.MouseDown += LineGraph_Clicked; } }
private void TimerTick(object sender, EventArgs e) { //if (!PerformanceCounterCategory.Exists("Processor")) //{ // Console.WriteLine("Object Processor does not exist!"); // return; //} //if (!PerformanceCounterCategory.CounterExists(@"% Processor Time", "Processor")) //{ // Console.WriteLine(@"Counter % Processor Time does not exist!"); // return; //} //while (true) //{ // Debug.WriteLine("@"); //try //{ // Debug.WriteLine(@"Current value of Processor, %Processor Time, _Total= " + mCounter.NextValue().ToString()); //} //catch //{ // Debug.WriteLine(@"_Total instance does not exist!"); // return; //} mPointsX.Add(mX++); var wY = mCounter.NextValue(); Debug.WriteLine(@"_Total= " + wY); mPointsY.Add(wY); mLineGraph.Plot(mPointsX, mPointsY); // Thread.Sleep(10000); //} }
public void RefreshUI() { if (xs != null && !IsBusy) { IsBusy = true; lineGraph.Dispatcher.Invoke(() => { lineGraph.Plot(xs, ys); lineGraph.PlotOriginY = Origin_Y; lineGraph.PlotHeight = Height_Y; lineGraph.PlotOriginX = Origin_X; lineGraph.PlotWidth = Width_X; if (IsTextBox) { TB1.Text = CurrentValue; TB2.Text = maxY.ToString(DataFormat); TB3.Text = minY.ToString(DataFormat); } lineGraph.Description = $"{CurrentValue} GHz"; }); IsBusy = false; } }
private void PlotResource(LineGraph lineGraph, IOrderedEnumerable <IGrouping <Double, Model.Planets.Planet> > orderedResouces, ref Double minAmount, ref Double maxAmount) { var oxygenValueCollection = new Dictionary <Double, Double>(); foreach (var planetGroup in orderedResouces) { var amount = planetGroup.Count(); if (amount < minAmount) { minAmount = amount; } if (amount > maxAmount) { maxAmount = amount; } oxygenValueCollection[planetGroup.Key] = amount; } lineGraph.Plot(oxygenValueCollection.Keys, oxygenValueCollection.Values); }
public MainWindow() { InitializeComponent(); var dates = new double[200]; double[] x = new double[200]; for (int i = 0; i < x.Length; i++) { x[i] = 3.1415 * i / (x.Length - 1); dates[i] = DateTime.Now.AddDays(i).Ticks; } for (int i = 0; i < 25; i++) { var lg = new LineGraph(); lines.Children.Add(lg); lg.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, (byte)(i * 10), 0)); lg.Description = String.Format("Data series {0}", i + 1); lg.StrokeThickness = 2; lg.Plot(dates, x.Select(v => Math.Sin(v + i / 10.0)).ToArray()); } plotter.XLabelProvider = new DateLabelProvider(); }
private void chartData(List <Activity> profits, List <Activity> expenses) { if (profits != null) { List <double> profitX = new List <double>(); List <double> profitY = new List <double>(); foreach (Activity activity in profits.Where(a => a.type.Equals(Constants.PROFIT))) { profitX.Add(activity.dateTime.AddMinutes(-1).ToOADate()); profitY.Add(activity.amount); } var profitLine = new LineGraph(); lines.Children.Add(profitLine); profitLine.Stroke = new SolidColorBrush(Color.FromRgb(0, 255, 0)); profitLine.StrokeThickness = 2; profitLine.Plot(profitX, profitY); } if (expenses != null) { List <double> expenseX = new List <double>(); List <double> expenseY = new List <double>(); foreach (Activity activity in expenses.Where(a => a.type.Equals(Constants.EXPENSE))) { expenseX.Add(activity.dateTime.AddMinutes(-1).ToOADate()); expenseY.Add(activity.amount); } var expenseLine = new LineGraph(); lines.Children.Add(expenseLine); expenseLine.Stroke = new SolidColorBrush(Colors.Red); expenseLine.StrokeThickness = 2; expenseLine.Plot(expenseX, expenseY); } }
public InteractiveDisplayControl() { InitializeComponent(); double[] x = new double[200]; for (int i = 0; i < x.Length; i++) { x[i] = 3.1415 * i / (x.Length - 1); } for (int i = 0; i < 25; i++) { var lg = new LineGraph(); lines.Children.Add(lg); lg.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, (byte)(i * 10), 0)); lg.Description = String.Format("Data series {0}", i + 1); lg.StrokeThickness = 2; lg.Plot(x, x.Select(v => Math.Sin(v + i / 10.0)).ToArray()); lg.SetPlotRect(new DataRect(0, -120, 100, -20)); } plotter.IsAutoFitEnabled = false; }
private void MenuFileOpen_Click(object sender, RoutedEventArgs e) { //ToDo: Dirty check var open = new Microsoft.Win32.OpenFileDialog { DefaultExt = ".log", Filter = "Logs (.log)|*.log" }; // Process save file dialog box results if (open.ShowDialog() == true) { if (port != null) { StartStop_Click(sender, e); } logFile = null; average = new List <double>(); presure = new List <double>(); vibe = new List <double>(); time = new List <double>(); output = new List <double>(); outtime = new List <double>(); var oGraphs = new List <LineGraph>(); foreach (var graph in Lines.Children) { if (graph is LineGraph g && g.Description.Contains("O****m")) { oGraphs.Add(g); } } foreach (var g in oGraphs) { Lines.Children.Remove(g); } _last_input = DateTimeOffset.Now; Dispatcher?.Invoke(() => { AverageGraph.Plot(time, average); PressureGraph.Plot(time, presure); MototGraph.Plot(time, vibe); OutputGraph.Plot(outtime, output); }); //ToDo: Background this? StreamReader stream = null; try { stream = new StreamReader(File.OpenRead(open.FileName)); } catch (ArgumentException ex) { MessageBox.Show($"Error on opening file: {ex.Message}", "Error Opening File", MessageBoxButton.OK, MessageBoxImage.Error); } try { string line; while ((line = stream?.ReadLine()) != null) { //ToDo: Abstract log event consumer var m = logRegex.Match(line.ToLower(CultureInfo.CurrentCulture)); if (m.Success) { if (!long.TryParse(m.Groups[1].Value, out var t)) { continue; } switch (m.Groups[2].Value) { case "nogasm:": var m2 = nogasmRegex.Match(m.Groups[3].Value); if (m2.Success) { average.Add(Convert.ToDouble(m2.Groups[5].Value, new NumberFormatInfo())); presure.Add(Convert.ToDouble(m2.Groups[3].Value, new NumberFormatInfo())); vibe.Add(Convert.ToDouble(m2.Groups[1].Value, new NumberFormatInfo())); time.Add(t); if (time.Count > 2 && Math.Abs(average[average.Count - 2] - average[average.Count - 1]) < 0.001 && Math.Abs(presure[presure.Count - 2] - presure[presure.Count - 1]) < 0.001 && Math.Abs(vibe[vibe.Count - 2] - vibe[vibe.Count - 1]) < 0.001) { time.RemoveAt(time.Count - 1); average.RemoveAt(time.Count - 1); presure.RemoveAt(time.Count - 1); vibe.RemoveAt(time.Count - 1); } } break; case "user:o****m": var oGraph = new LineGraph(); oGraph.Description = "O****m"; Dispatcher?.Invoke(() => { Lines.Children.Add(oGraph); oGraph.Plot(new double[] { t, t }, new double[] { 0, 4000 }); }); break; case "output:": if (double.TryParse(m.Groups[3].Value, out var val)) { output.Add(val * 1000); outtime.Add(t); } break; } } } Dispatcher?.Invoke(() => { AverageGraph.Plot(time, average); PressureGraph.Plot(time, presure); MototGraph.Plot(time, vibe); OutputGraph.Plot(outtime, output); }); } catch (IOException ex) { MessageBox.Show($"Error parsing file: {ex.Message}", "Error Opening File", MessageBoxButton.OK, MessageBoxImage.Error); } catch (OutOfMemoryException ex) { MessageBox.Show($"Error parsing file: {ex.Message}", "Error Opening File", MessageBoxButton.OK, MessageBoxImage.Error); } catch (ArgumentNullException ex) { MessageBox.Show($"Error parsing file: {ex.Message}", "Error Opening File", MessageBoxButton.OK, MessageBoxImage.Error); } catch (RegexMatchTimeoutException ex) { MessageBox.Show($"Error parsing file: {ex.Message}", "Error Opening File", MessageBoxButton.OK, MessageBoxImage.Error); } stream?.Close(); } }
public void refreshplotmassflow() //Generamos los plots de massflow en cada dt concreto { if (this.contadordt == 1) { var lg = new LineGraph(); massflowxlplot.Children.Add(lg); lg.Stroke = new SolidColorBrush(Colors.Red); lg.Description = String.Format("0 Δt"); lg.StrokeThickness = 2; lg.Plot(this.listdx.ToArray(), this.nozzle.getMassFlow()); } if (this.contadordt == 50) { var lg = new LineGraph(); massflowxlplot.Children.Add(lg); lg.Stroke = new SolidColorBrush(Colors.DarkBlue); lg.Description = String.Format("50 Δt"); lg.StrokeThickness = 2; lg.Plot(this.listdx.ToArray(), this.nozzle.getMassFlow()); } if (this.contadordt == 100) { var lg = new LineGraph(); massflowxlplot.Children.Add(lg); lg.Stroke = new SolidColorBrush(Colors.DarkGreen); lg.Description = String.Format("100 Δt"); lg.StrokeThickness = 2; lg.Plot(this.listdx.ToArray(), this.nozzle.getMassFlow()); } if (this.contadordt == 150) { var lg = new LineGraph(); massflowxlplot.Children.Add(lg); lg.Stroke = new SolidColorBrush(Colors.Purple); lg.Description = String.Format("150 Δt"); lg.StrokeThickness = 2; lg.Plot(this.listdx.ToArray(), this.nozzle.getMassFlow()); } if (this.contadordt == 200) { var lg = new LineGraph(); massflowxlplot.Children.Add(lg); lg.Stroke = new SolidColorBrush(Colors.Orange); lg.Description = String.Format("200 Δt"); lg.StrokeThickness = 2; lg.Plot(this.listdx.ToArray(), this.nozzle.getMassFlow()); } if (this.contadordt == 700) { var lg = new LineGraph(); massflowxlplot.Children.Add(lg); lg.Stroke = new SolidColorBrush(Colors.Yellow); lg.Description = String.Format("700 Δt"); lg.StrokeThickness = 2; lg.Plot(this.listdx.ToArray(), this.nozzle.getMassFlow()); } massflowxlplotdt.Children.Clear(); var lg_2 = new LineGraph(); massflowxlplotdt.Children.Add(lg_2); lg_2.Stroke = new SolidColorBrush(Colors.Blue); lg_2.Description = String.Format("Mass Flow at throat"); lg_2.StrokeThickness = 2; lg_2.Plot(this.listdt.ToArray(), this.listmassflowdt.ToArray()); }