public override void OnInspectorGUI() { if (_target == null) _target = target as LineGraph; DrawDefaultInspector(); using (gui.Horizontal()) { if (gui.EzButton(gui.LoadValuesButton)) _target.Rot.StartRotation = _target.Pivot.rotation.eulerAngles; _target.Rot.StartRotation = gui.EzV3Field("Rot In", _target.Rot.StartRotation, 10f, GUILayout.Width(180f)); } using (gui.Horizontal()) { if (gui.EzButton(gui.LoadValuesButton)) _target.Rot.EndRotation = _target.Pivot.rotation.eulerAngles; _target.Rot.EndRotation = gui.EzV3Field("Rot Out", _target.Rot.EndRotation, 10f, GUILayout.Width(180f)); } using (gui.Horizontal()) { _target.Rot.Duration = gui.EzFloatField("Duration", _target.Rot.Duration, 10f); _target.Rot.EaseType = (Ease)gui.EzEnumPopup("Ease", _target.Rot.EaseType, 10f); } using (gui.Horizontal()) { if (gui.EzButton("Import XML Data", GUILayout.Height(24f), GUILayout.Width(180f))) { _target.ImportXML ( _idx ); } _idx = Mathf.Clamp((gui.EzIntField("Idx",_idx, 10f, GUILayout.Width(60f))),1,4); } EditorUtility.SetDirty( target ); }
public MainWindow() { InitializeComponent(); if (DesignerProperties.GetIsInDesignMode(this)) return; Loaded += delegate { _graph = new LineGraph(); host.Child = _graph.Control; ShowStaticGraph(); }; }
public Form1() { InitializeComponent(); if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) return; _graph = new LineGraph(); _graph.TextEnabled = true; _graph.Control.Dock = DockStyle.Fill; Controls.Add(_graph.Control); Load += delegate { ShowTextGraph(); }; }
public Form1() { InitializeComponent(); if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) return; _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(1.0 / 30.0); _timer.Tick += delegate { _graph.Draw(); }; _graph = new LineGraph(); _graph.TextEnabled = true; _graph.Control.Dock = DockStyle.Fill; Controls.Add(_graph.Control); Load += delegate { ShowDynamicGraph(); _timer.Start(); }; }
public MainWindow() { InitializeComponent(); double[] x; var lag = new LineGraph(); var noteTest = new List <Note> { new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 6 }, new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 6 }, new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 2 }, new Note { OctavNumber = 4, NoteNumber = 6 } }; var vm = new VM(); Interface.DataContext = vm; //NoteScroll.DataContext = noteTest; //ListNote.ItemsSource = vm.Notes; //var spectrum = TestClass.Test1(); double[] s1;// = spectrum.Select(v => v.Magnitude).ToArray(); //double[] s2 = new double[s1.Length / 2]; //x = new double[s1.Length]; //for (int i = 0; i < x.Length; i++) // x[i] = i; //lag.Plot(x, s1); //lines.Children.Add(lag); //x = new double[s1.Length/2]; //for (int i = 0; i < x.Length; i++) //{ // x[i] = i;//-x.Length/2; // s2[i] = s1[i]; //} //lag.Plot(x, s2); //lines.Children.Add(lag); //s1 = Generators.Sin(1024, 128, 6000); //lag = new LineGraph(); //lines.Children.Add(lag); //x = new double[s1.Length]; //for (int i = 0; i < x.Length; i++) // x[i] = i - x.Length / 2; //lag.Plot(x, s1); //var par = TestClass.Test6(); //var Im = Generators.InpulseSignal(1024 * 32, 256, 1000); //s1 = Correlation.AutoCorrelation(TableFunction.TableToFunction(Im, 1, 0, Im.Length), 1, 0, Im.Length);//Generators.Sin(1024, 128, 6000); par.BeatFunction; // //lag = new LineGraph(); //lines.Children.Add(lag); //x = new double[s1.Length]; //for (int i = 0; i < x.Length; i++) // x[i] = i; //lag.Plot(x, s1.Select(y => { return y; })); //s1 = new double[2048 * 32]; //for (int j = 30; j < 35; j += 1) //{ // for (int i = 0; i < 2048 * 32; i++) // { // s1[i] = BeatPerMinutDetecter.ppp[j][i]; // } // lag = new LineGraph(); // lines.Children.Add(lag); // x = new double[s1.Length]; // for (int i = 0; i < x.Length; i++) // x[i] = i; // lag.Plot(x, s1); //} //for (int a = 0; a < 2048*16; a += 64) //{ // s1 = new double[128]; // for (int j = 0; j < 128; j += 1) // { // s1[j] = par.TransformSong[a, j]; // } // lag = new LineGraph(); // lines.Children.Add(lag); // x = new double[s1.Length]; // for (int i = 0; i < x.Length; i++) // x[i] = i; // lag.Plot(x, s1); //} //int sd = 1; //s1 = par.Song.Left.Select(y => { return (double)y; }).ToArray();//Generators.Sin(1024, 128, 6000); //lag = new LineGraph(); //lines.Children.Add(lag); //x = new double[s1.Length]; //for (int i = 0; i < x.Length; i++) //{ // x[i] = i / sd; // s1[i] = s1[i] * 2; //} //lag.Plot(x, s1); //lag = new LineGraph(); //lines.Children.Add(lag); //x = new double[1000]; //double[] yc = new double[1000]; //int BPM = par.TempD; //int S = (int)par.StartBeat; //for(int i=0; i * BPM + S< par.Song.Left.Length; i++) //{ // x[i * 8] = i * BPM + S; // x[i * 8 + 1] = i * BPM + S; // x[i * 8 + 2] = i * BPM + S; // x[i * 8 + 3] = i * BPM + S; // yc[i * 8] = 0; // yc[i * 8 + 1] = 70000; // yc[i * 8 + 2] = -70000; // yc[i * 8 + 3] = 0; // x[i * 8 +4] = i * BPM + S + 10; // x[i * 8 + 4 + 1] = i * BPM + S+10; // x[i * 8 + 2 + 4] = i * BPM + S+10; // x[i * 8 + 3 + 4] = i * BPM + S+10; // yc[i * 8 + 4] = 0; // yc[i * 8 + 1 + 4] = 70000; // yc[i * 8 + 2 + 4] = -70000; // yc[i * 8 + 3 + 4] = 0; //} //lag.Stroke = new SolidColorBrush(Color.FromArgb(255, 200, 0, 0)); //lag.Plot(x, yc); //lag = new LineGraph(); //s1 = par.BeatFunction;//Correlation.Easy(TableFunction.TableToFunction(par.BeatFunction, 1, 0, par.BeatFunction.Length), 1, 0, par.BeatFunction.Length); //MaxAssistance.CompressFunc(Correlation.Easy(TableFunction.TableToFunction(par.BeatFunction, 1, 0, par.BeatFunction.Length), 1, 0, par.BeatFunction.Length/6), 1, 0);// //lag.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, (byte)(100), 0)); //lines.Children.Add(lag); //x = new double[s1.Length]; //for (int i = 0; i < x.Length; i++) // x[i] = i; //lag.Plot(x, s1.Select(y => { return y; })); //var dat = FastFourierTransform.FFTSpectr(par.Song.Left.Select(y => { return (double)y; }).ToArray(), 0,1,12); //lag = new LineGraph(); //lines.Children.Add(lag); //lag.Plot(dat.Select(v => { return v.Item1 * 8; }).ToArray(), dat.Select(v => { return v.Item2; }).ToArray()); //dat = FastFourierTransform.FFTSpectr(par.Song.Left.Select(y => { return (double)y; }).ToArray(), 0, 2, 12); //lag = new LineGraph(); //lines.Children.Add(lag); //lag.Plot(dat.Select(v => { return v.Item1 * 4; }).ToArray(), dat.Select(v => { return v.Item2; }).ToArray()); //dat = FastFourierTransform.FFTSpectr(par.Song.Left.Select(y => { return (double)y; }).ToArray(), 0, 4, 12); //lag = new LineGraph(); //lines.Children.Add(lag); //lag.Plot(dat.Select(v => { return v.Item1 * 2; }).ToArray(), dat.Select(v => { return v.Item2; }).ToArray()); //dat = FastFourierTransform.FFTSpectr(par.Song.Left.Select(y => { return (double)y; }).ToArray(), 0, 8, 10); //lag = new LineGraph(); //lines.Children.Add(lag); //lag.Plot(dat.Select(v => { return v.Item1 * 4; }).ToArray(), dat.Select(v => { return v.Item2; }).ToArray()); //s1 = TestClass.Test3WTF();//Generators.Sin(1024, 128, 6000); //lag = new LineGraph(); //lines.Children.Add(lag); //x = new double[s1.Length]; //for (int i = 0; i < x.Length; i++) // x[i] = i; //lag.Plot(x, s1); //var t4 = TestClass.Test4(); //lag = new LineGraph(); //lines.Children.Add(lag); //lag.Plot(t4.Select(v=> { return v.Item1; }).ToArray(), t4.Select(v => { return v.Item2; }).ToArray()); //var t4 = TestClass.Test5(); //lag = new LineGraph(); //lines.Children.Add(lag); //lag.Plot(t4.Select(v => { return v.Item1; }).ToArray(), t4.Select(v => { return v.Item2; }).ToArray()); //int k = 88 * 3; //int r = 1 << 3; //int N = k * r; //double[] x1 = new double[N]; //double[] y1 = new double[N]; //double[] c1 = new double[N]; //for (int i = 0; i < k; i++) //{ // for (int j = 0; j < r; j++) // { // x1[i * r + j] = i; // y1[i * r + j] = j * (44100 / (1 << 5)); // c1[i * r + j] = par.TransformSong[i * 5 * 100, j] / 1000; // } //} //circles.PlotSize(x1, y1, c1); //for (int i = 0; i < k; i++) //{ // for (int j = 1; j < r; j++) // { // x1[i * r + j] = i; // y1[i * r + j] = j * (44100 / 1<<5); // c1[i * r + j] = BeatPerMinutDetecter.ppp[j][i * 5 * 100] / 1; // } //} //circles.PlotSize(x1, y1, c1); //var t7 =TestClass.Test7(); //int k = t7.Count; //int r = 1 << 6; //int N = k * r + k; //double[] x1 = new double[N]; //double[] y1 = new double[N]; //double[] c1 = new double[N]; //double[] d1 = new double[N]; //for (int i = 0; i < k; i++) //{ // double max = 0; // int maxCh = 1; // for (int j = 0; j < 32; j++) // { // if (t7[i][j].Item2 > max) // { // max = t7[i][j].Item2; // maxCh = (int)t7[i][j].Item1; // } // } // for (int j = 0; j < t7[i].Length&&j<r; j++) // { // x1[i * r + j] = i; // y1[i * r + j] = j; // c1[i * r + j] = t7[i][j].Item2/3; // d1[i * r + j] = 0; // //if (j == maxCh - 1) // //{ // // d1[i * r + j] = 1; // // x1[k * r + i] = i; // // y1[k * r + i] = j; // // c1[k * r + i] = t7[i][j].Item2; // // d1[k * r + i] = 1; // //} // } //} //circles.PlotColorSize(x1, y1,d1, c1); }
public MainWindow(CPUinfo cP) { InitializeComponent(); cpuinfo = cP; #region Initialize members if (!cpuinfo.SST_support) { SST_TextBlock.Text = "Unavailable"; SST_Group.IsEnabled = false; EPP_Group.IsEnabled = false; } else { Toggle1.IsChecked = cpuinfo.EPP.IsEnabled; ePP = new EPP2Sliders(cpuinfo.EPP, SettingsComboBox, FrequencyRange, EPPSlider, Toggle1, ApplySettingsButton); AutoSwitchToggle.IsChecked = cpuinfo.PSM.IsEnabled; cpuinfo.PSM.EnableChanged += (status) => { if (status != AutoSwitchToggle.IsChecked) { AutoSwitchToggle.IsChecked = status; } }; AutoSwitchToggle.Click += (s, e) => { if (AutoSwitchToggle.IsChecked != cpuinfo.PSM.IsEnabled) { cpuinfo.PSM.FileSetting = AutoSwitchToggle.IsChecked.Value; } }; } frequencyRatioSensors = new List <Sensor>(cpuinfo.CoreCount); foreach (LogicalProcessor lp in cpuinfo.logicalProcessors) { frequencyRatioSensors.Add(new Sensor(lp.GetCurrentFrequency)); } #endregion UITimer = new System.Windows.Threading.DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(800) }; if (cpuinfo.Manufacturer == "GenuineIntel") { CoreVoltageSensor = new Sensor(cpuinfo.PPM.GetCurrentVoltage); PackageTemperatureSensor = new Sensor(cpuinfo.PPM.GetCurrentTemprature); PackagePowerSensor = new Sensor(cpuinfo.PPM.GetPackagePower); Sensor2LineGraph s2l1 = new Sensor2LineGraph(CoreVoltageSensor, CoreVoltagePlotter, "G4", -0.1, 1.9, new TransitionText(VoltaCurrent), VoltaMax, VoltaMin); Sensor2LineGraph s2l2 = new Sensor2LineGraph(PackagePowerSensor, PackagePowerPlotter, "G3", -1, cpuinfo.PPM.TDP + 1, new TransitionText(PowerCurrent), PowerMax, PowerMin); Sensor2LineGraph s2l3 = new Sensor2LineGraph(PackageTemperatureSensor, PackageTemperaturePlotter, "G2", -2, 101, new TransitionText(TempCurrent), TempMax, TempMin); UITimer.Tick += new EventHandler((sender, e) => { s2l1.RefreshUI(); s2l2.RefreshUI(); s2l3.RefreshUI(); }); } UV2S = new UnderVoltor2Sliders(cpuinfo.underVoltor, Slider0, Slider1, Slider2, Slider3, Slider4, Slider5, ApplyButton, SaveButton, ResetButton); int tmp = 0; List <Sensor2LineGraph> S2LGs = new List <Sensor2LineGraph>(cpuinfo.CoreCount); foreach (Sensor s in frequencyRatioSensors) { var lg = new LineGraph(); lines.Children.Add(lg); lg.Stroke = new SolidColorBrush(Color.FromArgb(255, 0, 128, (byte)(255 * Math.Pow(2, -tmp)))); lg.Description = "0 Ghz"; Sensor2LineGraph s2lg; if (tmp == 0) { s2lg = new Sensor2LineGraph(s, lg, "F2", -0.2, cpuinfo.MaxClockSpeed / 1000.0 + 2, new TransitionText(CurrentFrequencyTransition), MaxFrequencyTextBox, MinFrequencyTextBox); } else { s2lg = new Sensor2LineGraph(s, lg, "F2", -0.2, cpuinfo.MaxClockSpeed / 1000.0 + 2); } UITimer.Tick += new EventHandler((sender, e) => s2lg.RefreshUI()); S2LGs.Add(s2lg); tmp++; } #region Basic Info CPUNameTextBox.Text = cpuinfo.wmi.Name; CoresTextBox.Text = cpuinfo.CoreCount.ToString(); ThreadsTextBox.Text = cpuinfo.ThreadCount.ToString(); ManufacturerTextBox.Text = cpuinfo.SimplifiedManufacturer; SocketTextBox.Text = cpuinfo.wmi.SocketDesignation; FamilyTextBox.Text = cpuinfo.wmi.Family; ModelTextBox.Text = cpuinfo.wmi.Model; SteppingTextBox.Text = cpuinfo.wmi.Stepping; L1TextBox.Text = cpuinfo.wmi.L1Cache; L2TextBox.Text = cpuinfo.wmi.L2Cache; L3TextBox.Text = cpuinfo.wmi.L3Cache; MaxClockSpeedTextBox.Text = (cpuinfo.MaxClockSpeed / 1000F).ToString(); CPUIcon.Source = new ImageSourceConverter().ConvertFromString( "pack://application:,,,/MetroCPU;component/" + cpuinfo.wmi.CPUIcon) as ImageSource; FrequencyRangeBox.Text = $"Frequency Range (x{cpuinfo.wmi.ExtClock.ToString()} MHz)"; #endregion UITimer.Start(); }
void Page_Loaded(object sender, RoutedEventArgs e) { const int N = 200; double step = Math.PI * 2 / N; #region CompositeDataSource double[] x = new double[N]; double[] y = new double[N]; for (int i = 0; i < N; i++) { x[i] = i * step; y[i] = Math.Sin(x[i]); } var xDataSource = x.AsXDataSource(); var yDataSource = y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource); sin = new LineGraph(compositeDataSource, "sin(x)"); PlotterMain.Children.Add(sin); #endregion #region RawDataSource Point[] points = new Point[N]; for (int i = 0; i < N; i++) { points[i] = new Point(i * step, (0.7 * Math.Cos(x[i] * 3) + 3) + (1.5 * Math.Sin(x[i] / 2 + 4))); } RawDataSource rawDataSource = points.AsDataSource(); cos = new LineGraph(rawDataSource, "(0.7 * Cos(3x)+3)+(1.5*Sin(x/2+4))"); PlotterMain.Children.Add(cos); #endregion #region EnumerableDataSource and Custom Graph Settings MyClass[] myObjects = new MyClass[N]; for (int i = 0; i < N; i++) { myObjects[i] = new MyClass() { A = 0.1 + i * step } } ; EnumerableDataSource <MyClass> enumDataSource = myObjects.AsDataSource <MyClass>(); enumDataSource.SetXYMapping(o => new Point(o.A, o.B)); LineGraphSettings settings = new LineGraphSettings(); settings.LineColor = Colors.Magenta; settings.LineThickness = Math.PI; settings.Description = "Log10"; log = new LineGraph(enumDataSource, settings); PlotterMain.Children.Add(log); #endregion // PlotterMain.FitToView(); }
private void OnLineGraphsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { switch (e.Action) { case System.Collections.Specialized.NotifyCollectionChangedAction.Add: { foreach (LinePerturbationViewModel viewModel in e.NewItems) { if (viewModel.LineAndMarker) { SolidColorBrush brush = new SolidColorBrush(); brush.Color = viewModel.Color; LineAndMarker <MarkerPointsGraph> lineAndMarker = this.AddLineGraph(viewModel.PointDataSource, new Pen(brush, viewModel.Thickness), new CirclePointMarker { Size = 7, Fill = brush }, new PenDescription(viewModel.Name)); lineAndMarker.LineGraph.Name = viewModel.Name; this.lineAndMarkerGraphs.Add(lineAndMarker); } else { LineGraph lineGraph = this.AddLineGraph(viewModel.PointDataSource, viewModel.Color, viewModel.Thickness, viewModel.Name); lineGraph.Name = viewModel.Name; this.lineGraphLines.Add(lineGraph); } } break; } case System.Collections.Specialized.NotifyCollectionChangedAction.Move: { break; } case System.Collections.Specialized.NotifyCollectionChangedAction.Remove: { break; } case System.Collections.Specialized.NotifyCollectionChangedAction.Replace: { bool bTemp = false; foreach (LinePerturbationViewModel viewModel in e.NewItems) { foreach (LineGraph line in this.lineGraphLines) { if (this.Children.Contains(line) && line.Name == viewModel.Name) { this.Children.Remove(line); this.lineGraphLines.Remove(line); bTemp = true; break; } } foreach (LineAndMarker <MarkerPointsGraph> line in this.lineAndMarkerGraphs) { if (this.Children.Contains(line.LineGraph) && line.LineGraph.Name == viewModel.Name) { this.Children.Remove(line.LineGraph); this.Children.Remove(line.MarkerGraph); this.lineAndMarkerGraphs.Remove(line); bTemp = true; break; } } if (bTemp) { if (viewModel.LineAndMarker) { SolidColorBrush brush = new SolidColorBrush(); brush.Color = viewModel.Color; LineAndMarker <MarkerPointsGraph> lineAndMarker = this.AddLineGraph(viewModel.PointDataSource, new Pen(brush, viewModel.Thickness), new CirclePointMarker { Size = 7, Fill = brush }, new PenDescription(viewModel.Name)); lineAndMarker.LineGraph.Name = viewModel.Name; this.lineAndMarkerGraphs.Add(lineAndMarker); } else { LineGraph lineGraph = this.AddLineGraph(viewModel.PointDataSource, viewModel.Color, viewModel.Thickness, viewModel.Name); lineGraph.Name = viewModel.Name; this.lineGraphLines.Add(lineGraph); } bTemp = false; } } break; } case System.Collections.Specialized.NotifyCollectionChangedAction.Reset: { break; } } }
public void UpdateUi() { //plotter.Children.Clear(); for (var i = plotter.Children.Count - 1; i >= 0; i--) { if (plotter.Children[i] is LineGraph) { plotter.Children.RemoveAt(i); } } if (Min >= Max) { return; } if (SamplingCount < 2) { return; } if (TargetFunction == null) { return; } var vals = new List <double>(); var delta = (Max - Min) / (SamplingCount - 1); for (var i = 0; i < SamplingCount; i++) { vals.Add(Min + i * delta); } var pts = new List <Tuple <double, double> >(); var fnc = TargetFunction; foreach (var val in vals) { pts.Add(Tuple.Create(val, fnc(val))); } var src = new ObservableDataSource <Tuple <double, double> >(pts); src.SetXMapping(i => i.Item1); src.SetYMapping(i => i.Item2); var thickNess = 2.0; var pen = new Pen(new SolidColorBrush(GraphColor), thickNess); LineGraph gr; if (string.IsNullOrEmpty(VerticalAxisLabel)) { gr = new LineGraph(src) { LinePen = pen } } ; //plotter.AddLineGraph(src, GraphColor,thickNess); else { //plotter.AddLineGraph(src, pen, new StandardDescription( VerticalAxisLabel == null ? "" : VerticalAxisLabel)); gr = new LineGraph(src) { LinePen = pen, Name = VerticalAxisLabel == null ? "" : VerticalAxisLabel } }; plotter.Children.Add(gr); /* * var src2 = new ObservableDataSource<Tuple<double, double>>(pts); * src2.SetXMapping(i => i.Item1); * src2.SetYMapping(i => 0); * * plotter.AddLineGraph(src2); */ }
public HistoryStatic() { InitializeComponent(); wnd = (StartPage)Application.Current.MainWindow; //获取主窗口 con = wnd.con; //获取主链接 string strSelect = "select * from tb_lhf_measure where saveindex is not null"; if (con.State == ConnectionState.Open) { OleDbCommand cmd = new OleDbCommand(strSelect, con); OleDbDataAdapter adp = new OleDbDataAdapter(cmd); DataSet set = new DataSet(); adp.Fill(set); dt = set.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { list.Add(Convert.ToString(dt.Rows[i].Field <object>("name"))); } preSelectIndex.ItemsSource = list;//设置组合框数据源 preSelectIndex.SelectedIndex = nowSelectIndex; temp_datelist = new List <DateTime>(); temp_ylist = new List <double>(); x = new EnumerableDataSource <DateTime>(temp_datelist); x.SetXMapping(x => xAxis.ConvertToDouble(x)); y = new EnumerableDataSource <double>(temp_ylist); y.SetYMapping(y => y); composite = new CompositeDataSource(x, y); line = plotter.AddLineGraph(composite, Colors.Green, 2, list.ElementAt(nowSelectIndex));//添加曲线 if (dt.Rows[nowSelectIndex].Field <object>("upper") != null) { temp_datelist_upper = new List <DateTime>(); temp_ylist_upper = new List <double>(); x_upper = new EnumerableDataSource <DateTime>(temp_datelist_upper); x_upper.SetXMapping(x_upper => xAxis.ConvertToDouble(x_upper)); y_upper = new EnumerableDataSource <double>(temp_ylist_upper); y_upper.SetYMapping(y_upper => y_upper); composite_upper = new CompositeDataSource(x_upper, y_upper); Pen pen = new Pen(); pen.Brush = new SolidColorBrush(Colors.Red); pen.DashStyle = new DashStyle(new double[] { 2, 5 }, 2); pen.Thickness = 2;//新建虚线画笔 PenDescription description = new PenDescription("上限"); line_upper = plotter.AddLineGraph(composite_upper, pen, description);//添加上曲线 } if (dt.Rows[nowSelectIndex].Field <object>("lower") != null) { temp_datelist_lower = new List <DateTime>(); temp_ylist_lower = new List <double>(); x_lower = new EnumerableDataSource <DateTime>(temp_datelist_lower); x_lower.SetXMapping(x_lower => xAxis.ConvertToDouble(x_lower)); y_lower = new EnumerableDataSource <double>(temp_ylist_lower); y_lower.SetYMapping(y_lower => y_lower); composite_lower = new CompositeDataSource(x_lower, y_lower); Pen pen = new Pen(); pen.Brush = new SolidColorBrush(Colors.Red); pen.DashStyle = new DashStyle(new double[] { 2, 5 }, 2); pen.Thickness = 2;//新建虚线画笔 PenDescription description = new PenDescription("下限"); line_upper = plotter.AddLineGraph(composite_lower, pen, description);//添加下限曲线 } pie_x = new List <string>(); pie_y = new List <string>(); pie_x.Add("正常率"); pie_x.Add("过高率"); pie_x.Add("过低率"); pie_y.Add("0"); pie_y.Add("0"); pie_y.Add("0"); chart.Width = 580; chart.Height = 380; CreateChartPie("", pie_x, pie_y); // chart.Width = 20; } else { return; } }
private void drawLineGraph(Graphics g, LineGraph lineGraph, bool highlightDots, Pen pen) { SolidBrush brush = new SolidBrush(pen.Color); //Draw Rectangle around object WorldRectangle bounds = lineGraph.Bounds; if (bounds.Left < viewBounds.Left) { bounds.Left = viewBounds.Left; } if (bounds.Right > viewBounds.Right) { bounds.Right = viewBounds.Right; } if (bounds.Top < viewBounds.Top) { bounds.Top = viewBounds.Top; } if (bounds.Bottom > viewBounds.Bottom) { bounds.Bottom = viewBounds.Bottom; } Rectangle screenRect = worldToScreen(bounds); //g.DrawRectangle(Pens.LightPink, screenRect); WorldPoint previous = null; foreach (WorldPoint point in lineGraph) { double x = point.X; double y = point.Y; if (currentAction == ActionType.MoveSelection && selection.Contains(point)) { x += mouseWorldX - mouseDownWorldX; y += mouseWorldY - mouseDownWorldY; } bool selected = selection.Contains(point); //Trim off the ends! if (viewBounds.Contains(x, y)) { } if (previous != null) { WorldPoint p1 = new WorldPoint(previous.X, previous.Y); WorldPoint p2 = new WorldPoint(x, y); DrawLine(g, pen, p1, p2); } //DrawPoint if (viewBounds.Contains(x, y)) { int screenX = worldToScreenX(x); int screenY = worldToScreenY(y); if (selected) { g.FillRectangle(selectedBrush, screenX - 1, screenY - 1, 3, 3); } else if (highlightDots) { g.FillRectangle(brush, screenX - 1, screenY - 1, 3, 3); } } previous = new WorldPoint(x, y); } if (lineGraph.IsConnected && lineGraph.Count > 2) { double x = lineGraph[0].X; double y = lineGraph[0].Y; if (currentAction == ActionType.MoveSelection && selection.Contains(lineGraph[0])) { x += mouseWorldX - mouseDownWorldX; y += mouseWorldY - mouseDownWorldY; } //int screenX = worldToScreenX(x); //int screenY = worldToScreenY(y); DrawLine(g, pen, new WorldPoint(x, y), previous); //g.DrawLine(pen, previous.X, previous.Y, screenX, screenY); } }
void Awake() { HRVServer.Inst.MessageReceived += HandleHRVMessage; graph = CreateGraph("hrv"); }
public Form1() { InitializeComponent(); if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } _graph = new LineGraph(); _graph.Control.Dock = DockStyle.Fill; Controls.Add(_graph.Control); Load += delegate { ShowStaticGraph(); }; _graph.Control.MouseClick += (s, args) => { if (args.Button == MouseButtons.Right) { var origin = _graph.Window.ScreenToView(new GLPoint(args.Location.X, args.Location.Y)); var size = new GLSize(10, 1); var group1 = new MenuItem("Group 1"); group1.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color. HotPink. ToGLColor ())); _graph.Draw(); }; var group2 = new MenuItem("Group 2"); group2.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Blue. ToGLColor ())); _graph.Draw(); }; var nox = new MenuItem("No Explosive"); nox.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Aqua. ToGLColor())); _graph.Draw(); }; var ofb = new MenuItem("Out Of Bounds"); ofb.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Yellow. ToGLColor())); _graph.Draw(); }; var dnt = new MenuItem("DNT"); dnt.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Orange. ToGLColor())); _graph.Draw(); }; var explosive = new MenuItem("Explosive"); explosive.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color. Maroon . ToGLColor ())); _graph.Draw(); }; var peroxide = new MenuItem("Peroxide"); peroxide.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color. Green. ToGLColor ())); _graph.Draw(); }; var menu = new ContextMenu { MenuItems = { group1, group2, nox, ofb, dnt, explosive, peroxide } }; menu.Show(_graph.Control, args.Location); } }; }
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()); }
public void UpdateUi() { var bar = Context.TargetElement; for (var i = plotter.Children.Count - 1; i >= 0; i--) { if (plotter.Children[i] is LineGraph) { plotter.Children.RemoveAt(i); } } if (bar == null) { return; } var discPonits = Context.TargetElement.GetInternalForceDiscretationPoints().Select(i => i.Xi).ToArray(); var samples = 100; var lst = new List <double>(discPonits); //remove discrete points and add a little before and after var eps = 1e-10; foreach (var discPonit in discPonits) { lst.Add(discPonit - eps); lst.Add(discPonit + eps); } for (int i = 0; i <= samples; i++) { var c = i * 1.0 / samples; var xi = c * 2 - 1; lst.Add(xi); } var l2 = lst.Where(i => i >= -1 && i <= 1).Where(i => !discPonits.Contains(i)).Distinct().ToArray(); Array.Sort(l2); var pts = new List <Point>(); for (var i = 0; i < l2.Length; i++) { var xi = l2[i]; var x = Context.TargetElement.IsoCoordsToLocalCoords(xi)[0]; Force frc; if (Context.Type == BarInternalForceContext.ForceType.Approximate) { frc = bar.GetInternalForceAt(xi); } else { frc = bar.GetExactInternalForceAt(xi); } var y = 0.0; switch (Context.Component) { case BarInternalForceContext.ForceComponent.Fx: y = frc.Fx; break; case BarInternalForceContext.ForceComponent.Fy: y = frc.Fy; break; case BarInternalForceContext.ForceComponent.Fz: y = frc.Fz; break; case BarInternalForceContext.ForceComponent.Mx: y = frc.Mx; break; case BarInternalForceContext.ForceComponent.My: y = frc.My; break; case BarInternalForceContext.ForceComponent.Mz: y = frc.Mz; break; default: throw new ArgumentOutOfRangeException(); } pts.Add(new Point(x, y, 0)); } var src = new ObservableDataSource <Point>(pts); src.SetXMapping(i => i.X); src.SetYMapping(i => i.Y); var gr = new LineGraph(src); gr.Stroke = Brushes.Black; gr.StrokeThickness = 2; gr.Name = Context.Component.ToString(); plotter.Children.Add(gr); //plotter.AddLineGraph(src, Colors.Black, 2, Context.Component.ToString()); }
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 string getBurnDownChart(int projectID) { myCommand.CommandText = "SELECT [Completion_date], SUM(Work_estimation) FROM Task_User INNER JOIN " + "(SELECT Task_ID, Work_estimation, Completion_date FROM Task WHERE Project_ID=@projectID AND Task.Status='Done' " + "AND Completion_date IS NOT NULL) AS A ON Task_User.Task_ID = A.Task_ID " + "GROUP BY [Completion_date] ORDER BY [Completion_date]"; addParameter <int>("@projectID", SqlDbType.Int, projectID); myAdapter.Fill(myDataSet, "temp"); var table = myDataSet.Tables["temp"]; myCommand.CommandText = "SELECT SUM(Work_estimation) FROM Task WHERE Project_ID=@projectID"; int sum = (myCommand.ExecuteScalar() != DBNull.Value) ? Convert.ToInt32(myCommand.ExecuteScalar()) : 0; myCommand.Parameters.Clear(); // Manipulate data - add missing date int i = 0; while (i < table.Rows.Count - 1) { DateTime date1 = (DateTime)table.Rows[i][0]; DateTime date2 = (DateTime)table.Rows[i + 1][0]; if (date1.AddDays(1) != date2) { DataRow row = table.NewRow(); row[0] = date1.Date.AddDays(1); row[1] = 0; table.Rows.InsertAt(row, i + 1); } i++; } // Create graph LineGraph myLine = new LineGraph(); var labels = myLine.labels; var datasets = myLine.datasets; // Burn up line int colorIndex = new Random().Next(0, 6); LineGraphDataset dataset = new LineGraphDataset(colorHex[1, colorIndex], colorHex[0, colorIndex]); dataset.label = ""; // Ceiling line colorIndex = (colorIndex + 1) % 7; LineGraphDataset ceiling = new LineGraphDataset(colorHex[1, colorIndex], colorHex[0, colorIndex]); ceiling.label = ""; // Manipulate data - calculate workload int rcumulated = sum; foreach (DataRow row in table.Rows) { DateTime date = (DateTime)row[0]; labels.Add(date.ToString("dd.MM.yyyy")); rcumulated -= Convert.ToInt32(row[1]); dataset.data.Add(rcumulated); ceiling.data.Add(sum); } datasets.Add(dataset); datasets.Add(ceiling); return(JsonConvert.SerializeObject(myLine)); }
// Generic way to hook a LineGraphInterop up with a DrawingSurface private LineGraphInterop initializeLineGraph(DrawingSurface canvas, LineGraph.LineGraphReady InitializedCallback) { // Create the LineGraphInterop, the C++/CX component that will draw out to the canvas LineGraphInterop graph = new LineGraphInterop(); // Set window bounds graph.WindowBounds = new Windows.Foundation.Size( (float)canvas.ActualWidth, (float)canvas.ActualHeight ); // Set native/rendering resolution! graph.NativeResolution = new Windows.Foundation.Size( (float)Math.Floor(canvas.ActualWidth * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f), (float)Math.Floor(canvas.ActualHeight * Application.Current.Host.Content.ScaleFactor / 100.0f + 0.5f) ); graph.RenderResolution = graph.NativeResolution; // Notify the canvas who we're hooking up to them canvas.SetContentProvider(graph.CreateContentProvider()); canvas.SetManipulationHandler(graph); graph.Initialized += InitializedCallback; Dispatcher.BeginInvoke(() => InitializedCallback()); // Give back the graph object! return graph; }
public static PreparedDataPoints VerifyAndCompute(LineGraph lineGraph) { return(VerifyAndCompute(lineGraph.Lines, lineGraph.DataPointFormat)); }
public Form1() { InitializeComponent(); if (DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) return; _graph = new LineGraph(); _graph.Control.Dock = DockStyle.Fill; Controls.Add(_graph.Control); Load += delegate { ShowStaticGraph(); }; _graph.Control.MouseClick += (s, args) => { if (args.Button == MouseButtons.Right) { var origin = _graph.Window.ScreenToView(new GLPoint(args.Location.X, args.Location.Y)); var size = new GLSize(10, 1); var group1 = new MenuItem("Group 1"); group1.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.HotPink.ToGLColor())); _graph.Draw(); }; var group2 = new MenuItem("Group 2"); group2.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Blue.ToGLColor())); _graph.Draw(); }; var nox = new MenuItem("No Explosive"); nox.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Aqua.ToGLColor())); _graph.Draw(); }; var ofb = new MenuItem("Out Of Bounds"); ofb.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Yellow.ToGLColor())); _graph.Draw(); }; var dnt = new MenuItem("DNT"); dnt.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Orange.ToGLColor())); _graph.Draw(); }; var explosive = new MenuItem("Explosive"); explosive.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Maroon.ToGLColor())); _graph.Draw(); }; var peroxide = new MenuItem("Peroxide"); peroxide.Click += delegate { _graph.Markers.Add(new ThresholdMarker(_graph, origin, size, Color.Green.ToGLColor())); _graph.Draw(); }; var menu = new ContextMenu { MenuItems = { group1, group2, nox, ofb, dnt, explosive, peroxide } }; menu.Show(_graph.Control, args.Location); } }; }
private void MakePlots() { if (!PlotsMade) //Only do this once { Model mShe = new Model(SheFileName); DFS3 dfs = new DFS3(Dfs3FileName); Item dfsI = dfs.Items[ItemNumber - 1]; List <TimestampSeries> well_Concentration = new List <TimestampSeries>(); int[] TimeSteps = ParseString(TimeStepsAsString, 0, dfs.NumberOfTimeSteps - 1); int[] WellNumbers = ParseString(WellsAsString, 0, mShe.ExtractionWells.Count - 1); List <MikeSheWell> wells = new List <MikeSheWell>(); foreach (int j in WellNumbers) { wells.Add(mShe.ExtractionWells[j]); } foreach (int i in TimeSteps) { int k = 0; foreach (var w in wells) { if (i == TimeSteps[0]) { well_Concentration.Add(new TimestampSeries(w.ID, new Unit(dfsI.EumQuantity.UnitAbbreviation, 1, 0))); } well_Concentration[k].Items.Add(new TimestampValue(dfs.TimeSteps[i], (dfs.GetData(i, ItemNumber)[w.Row, w.Column, w.Layer]))); k++; } } //Sets the upper title Header.Content = dfsI.Name; //Sets the title of the y-axis var ytitle = new VerticalAxisTitle(); ytitle.Content = dfsI.EumQuantity.ItemDescription + " [" + dfsI.EumQuantity.UnitAbbreviation + "]"; TheChart.Children.Add(ytitle); int l = 0; //Loop the wells for plotting foreach (var w in wells) { if (g != null) { TheChart.Children.Remove(g); TheChart.FitToView(); } var axis = new Microsoft.Research.DynamicDataDisplay.Charts.HorizontalDateTimeAxis(); TheChart.MainHorizontalAxis = axis; TheChart.MainVerticalAxis = new Microsoft.Research.DynamicDataDisplay.Charts.VerticalAxis(); //set the data source EnumerableDataSource <TimestampValue> ds = new EnumerableDataSource <TimestampValue>(well_Concentration[l].Items); ds.SetXMapping(var => axis.ConvertToDouble(var.Time)); ds.SetYMapping(var => var.Value); //create the graph g = TheChart.AddLineGraph(ds, new Pen(Brushes.Black, 3), new PenDescription(w.ID)); //create a filename outfile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Dfs3FileName), "Well_No" + "_" + WellNumbers[l].ToString() + "_" + dfsI.EumQuantity.ItemDescription); //now save to file this.UpdateLayout(); MainWindow.SaveScreen(this, outfile + ".jpg", (int)ActualWidth, (int)ActualHeight); //Now create the dfs0-file using (DFS0 dfs0 = new DFS0(outfile + ".dfs0", 1)) { dfs0.FirstItem.Name = dfsI.Name; dfs0.FirstItem.EumItem = dfsI.EumItem; dfs0.FirstItem.EumUnit = dfsI.EumUnit; dfs0.FirstItem.ValueType = dfsI.ValueType; int t = 0; foreach (var v in well_Concentration[l].Items) { dfs0.InsertTimeStep(v.Time); dfs0.SetData(t, 1, v.Value); t++; } } //Now create the text-file using (StreamWriter sw = new StreamWriter(outfile + ".txt", false)) { foreach (var v in well_Concentration[l].Items) { sw.WriteLine(v.Time + "; " + v.Value); } } l++; } mShe.Dispose(); dfs.Dispose(); PlotsMade = true; } }