private static void ConcatObservable() { using (Xs.Concat(Ys).Timestamp().Subscribe( z => System.Console.WriteLine($"{z.Value}: {z.Timestamp}"), () => System.Console.WriteLine("Completed. PRESS => ME"))) { System.Console.ReadKey(); } }
private void ResetBtn_Click(object sender, EventArgs e) { Xs.Clear(); Ys.Clear(); YTxtB.Clear(); XTxtB.Clear(); Resultlbl.Text = ""; }
public Ys(int xs) { int i = 0; x = new Xs[xs]; for (i = 0; i < xs; i++) { x[i] = new Xs(); } }
public void ReadTestingInfo() { TobiiCSVRead(Name, tobiiList); Dictionary <long, double> avgs = CompactifyTobiiList(tobiiList, SmoothInterval); foreach (var item in avgs) { Ys.Add(item.Value); Xs.Add(item.Key); } }
internal static void Run() { var ev = new ManualResetEvent(false); Console.WriteLine("Merge X and Y"); using (Xs.Merge(Ys).Subscribe( z => Console.Write("{0} ", z), () => ev.Set())) { ev.WaitOne(); } Console.WriteLine(); ev.Reset(); Console.WriteLine("Zip X, Y -> X + Y"); using (Xs.Zip(Ys, (x, y) => x + y) .Subscribe( z => Console.Write("{0} ", z), () => ev.Set())) { ev.WaitOne(); } Console.WriteLine(); ev.Reset(); Console.WriteLine("Combine X, Y -> X + Y"); using (Xs.CombineLatest(Ys, (x, y) => x + y) .Subscribe( z => Console.Write("{0} ", z), () => ev.Set())) { ev.WaitOne(); } Console.WriteLine(); ev.Reset(); Console.WriteLine("Concat X and Y"); using (Xs.Concat(Ys) .Subscribe( z => Console.Write("{0} ", z), () => ev.Set())) { ev.WaitOne(); } Console.WriteLine(); ev.Reset(); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); // distances var dx = Xs.Select(x => Math.Abs(x - e.X)); var dy = Ys.Select(y => Math.Abs(y - e.Y)); // smallest distance int mx = dx.Min(); int my = dy.Min(); // grid index int ix = dx.ToList().IndexOf(mx); int iy = dy.ToList().IndexOf(my); if (e.Button.HasFlag(MouseButtons.Right)) { // mouse the grid with the right mouse button Location = new Point(Left + e.X - mDown.X, Top + e.Y - mDown.Y); } else if (!e.Button.HasFlag(MouseButtons.Left)) { // if we are close enough set cursor Cursor = Cursors.Default; if (mx < HandleSize) { Cursor = Cursors.SizeWE; } if (my < HandleSize) { Cursor = Cursors.SizeNS; } if (mx < HandleSize && my < HandleSize) { Cursor = Cursors.SizeAll; } } else { // else move grid if (Cursor == Cursors.SizeWE || Cursor == Cursors.SizeAll) { Xs[ix] += e.X - mDown.X; } if (Cursor == Cursors.SizeNS || Cursor == Cursors.SizeAll) { Ys[iy] += e.Y - mDown.Y; } Invalidate(); mDown = e.Location; } // restore order in case we overshot Xs = Xs.OrderBy(x => x).ToList(); Ys = Ys.OrderBy(x => x).ToList(); }
public void Update() { int tempX = HeadX; int tempY = HeadY; HeadX = HeadX + XDir; HeadY = HeadY + YDir; Xs.Insert(0, tempX); Ys.Insert(0, tempY); Render(Xs[Xs.Count - 1], Ys[Ys.Count - 1], HeadX, HeadY); Xs.RemoveAt(Xs.Count - 1); Ys.RemoveAt(Ys.Count - 1); }
internal void Draw(Graphics g, int width, SizeF offsets) { var pen = new Pen(Color, width); var clip = g.VisibleClipBounds; var xReal = (XMax - XMin) / clip.Width; var yReal = (YMax - YMin) / clip.Height; var points = Xs.Zip(Ys, (x, y) => new PointF( // clip.X -- отступ для оси ординат (x - XMin) / xReal + clip.X, (YMax - y) / yReal )); g.DrawCurve(pen, points.ToArray <PointF>()); }
void addY(int val) { if (Ys.Count > 0) { int lastY = Ys[Ys.Count - 1]; if (val > lastY) { for (int i = lastY; i < val; i++) { Ys.Add(i); Xs.Add(curX += 1); } } else if (val < lastY) { for (int i = lastY; i > val; i--) { Ys.Add(i); Xs.Add(curX += 1); } } else { Xs.Add(curX += 1); Ys.Add(val); } } else { Ys.Add(1); Xs.Add(curX += 1); } if (Xs.Count > pictureBox1.Width) { Xs.RemoveAt(0); Ys.RemoveAt(0); difference++; } }
private void AddBtn_Click(object sender, EventArgs e) { try { if (YTxtB.Text != string.Empty && XTxtB.Text != string.Empty) { Ys.Add(Convert.ToDouble(YTxtB.Text)); Xs.Add(Convert.ToDouble(XTxtB.Text)); } else { MessageBox.Show("In order to save please add cordinate in X textbox also in Y textbox "); } } catch (Exception) { MessageBox.Show("Error adding the cordinates, please insert in correct format. Example 1.2 => 1,2"); } YTxtB.Clear(); XTxtB.Clear(); }
public override string ToString() { var cultureInfo = CultureInfo.CurrentCulture; var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo); // Initial capacity [128] is an estimate based on a sum of: // 72 = 6x double (twelve digits is generous for the range of values likely) // 4 = 4x separator characters var sb = new StringBuilder(128); sb.Append(Xs.ToString(cultureInfo)); sb.Append(listSeparator); sb.Append(Sm.ToString(cultureInfo)); sb.Append(listSeparator); sb.Append(Md.ToString(cultureInfo)); sb.Append(listSeparator); sb.Append(Lg.ToString(cultureInfo)); sb.Append(listSeparator); sb.Append(Xl.ToString(cultureInfo)); sb.Append(listSeparator); sb.Append(Xxl.ToString(cultureInfo)); return(sb.ToString()); }
public void Grow(Fruit fruit) { Ys.Insert(0, fruit.Y); Xs.Insert(0, fruit.X); Render(fruit.X, fruit.Y); }
public void Write(GeoRefData geodata) { double[] Xs = null; double[] Ys = null; ShapeLib.ShapeType type = ShapeLib.ShapeType.NullShape; if (geodata.Geometry is IXYPoint) { IXYPoint p = (IXYPoint)geodata.Geometry; type = ShapeLib.ShapeType.Point; Xs = new double[] { p.X }; Ys = new double[] { p.Y }; } else if (geodata.Geometry.GetType().Equals(typeof(XYPolyline))) { XYPolyline p = (XYPolyline)geodata.Geometry; type = ShapeLib.ShapeType.PolyLine; int npoints = p.Points.Count; Xs = new double[npoints]; Ys = new double[npoints]; for (int i = 0; i < npoints; i++) { Xs[i] = p.Points[i].X; Ys[i] = p.Points[i].Y; } } else if (geodata.Geometry.GetType().Equals(typeof(XYLine))) { XYLine p = (XYLine)geodata.Geometry; type = ShapeLib.ShapeType.PolyLine; int npoints = 2; Xs = new double[] { p.P1.X, p.P2.X }; Ys = new double[] { p.P1.Y, p.P2.Y };; } else if (geodata.Geometry.GetType().Equals(typeof(XYPolygon))) { XYPolygon p = (XYPolygon)geodata.Geometry; type = ShapeLib.ShapeType.Polygon; int npoints = p.Points.Count; Xs = new double[npoints]; Ys = new double[npoints]; p.Points.Reverse(); for (int i = 0; i < npoints; i++) { Xs[i] = p.Points[i].X; Ys[i] = p.Points[i].Y; } p.Points.Reverse(); } else if (geodata.Geometry.GetType().Equals(typeof(MultiPartPolygon))) { MultiPartPolygon p = (MultiPartPolygon)geodata.Geometry; type = ShapeLib.ShapeType.Polygon; int npoints = p.Polygons.Sum(pol => pol.Points.Count); foreach (var poly in p.Polygons) { poly.Points.Reverse(); } Xs = new double[npoints]; Ys = new double[npoints]; int i = 0; foreach (var point in p.Polygons.SelectMany(pol => pol.Points)) { Xs[i] = point.X; Ys[i] = point.Y; i++; } foreach (var poly in p.Polygons) { poly.Points.Reverse(); } } if (_shapePointer == IntPtr.Zero) { _shapePointer = ShapeLib.SHPCreate(_fileName, type); } if (_shapePointer == IntPtr.Zero) { throw new Exception("Could not create: " + Path.GetFullPath(_fileName) + "\nMake sure directory exists."); } IntPtr obj; if (geodata.Geometry.GetType().Equals(typeof(MultiPartPolygon))) { MultiPartPolygon p = (MultiPartPolygon)geodata.Geometry; int[] partstarts = new int[p.Polygons.Count]; partstarts[0] = 0; ShapeLib.PartType[] partype = new ShapeLib.PartType[p.Polygons.Count]; for (int i = 0; i < partype.Count(); i++) { partype[i] = ShapeLib.PartType.Ring; } for (int i = 1; i < partstarts.Count(); i++) { partstarts[i] = partstarts[i - 1] + p.Polygons[i - 1].Points.Count; } obj = ShapeLib.SHPCreateObject(type, -1, partstarts.Count(), partstarts, partype, Xs.Count(), Xs, Ys, null, null); } else { obj = ShapeLib.SHPCreateSimpleObject(type, Xs.Count(), Xs, Ys, null); } ShapeLib.SHPWriteObject(_shapePointer, -1, obj); ShapeLib.SHPDestroyObject(obj); _dbf.WriteData(geodata.Data); NoOfEntries++; }
void UpdateTreatmentGraphWithResidualData(bool OnlyShowFitted = false, bool ShowLinearResiduals = false, bool showQuadResiduals = false) { this.Cursor = Cursors.WaitCursor; try { GraphPane Graph = plotTreatments.GraphPane; Graph.CurveList.Clear(); Graph.Title.Text = "Growth Plots"; Graph.XAxis.Title.Text = "Hours"; Graph.YAxis.Title.Text = "Residuals"; Graph.Legend.Position = LegendPos.InsideTopLeft; Graph.Legend.FontSpec.Size = 8f; Graph.Legend.IsHStack = true; SymbolType SymboltoUse = SymbolType.Circle; Dictionary <string, GrowthCurve> curData = GetDictionaryOfGrowthRateData(); for (int i = 1; i < SelectablePlateMap.MAX_GROUP_ASSIGNMENTS; i++) { Color groupColor; var curNames = selectablePlateMap1.GetNamesOfWellsAssignedToGroup(i, out groupColor); string GroupName = ""; if (TreatmentTextBoxes[i] != null) { GroupName = TreatmentTextBoxes[i].Text; } if (GroupName == "") { GroupName = "Treatment: " + i.ToString(); } foreach (string name in curNames) { if (curData.ContainsKey(name)) { GrowthCurve GD = curData[name]; PointPairList XY; List <double> Xs; List <double> Ys; if (ShowLinearResiduals) { Xs = new List <double>(); Ys = new List <double>(); if (GD.LinFit != null) { Xs.AddRange(GD.LinFit.X); Ys.AddRange(GD.LinFit.ReturnResidualsAfterExpTransform()); } } else if (showQuadResiduals) { Xs = new List <double>(); Ys = new List <double>(); if (GD.QuadModel != null && GD.QuadModel.SuccessfulFit) { Xs.AddRange(GD.QuadModel.X); Ys.AddRange(GD.QuadModel.ReturnResidualsAfterExpTransform); } } else { GD.GetResiduals(OnlyShowFitted, out Xs, out Ys); XY = new PointPairList(Xs.ToArray(), Ys.ToArray()); //GD.LinFit.GetResiduals(out Xs, out Ys); } XY = new PointPairList(Xs.ToArray(), Ys.ToArray()); Graph.AddCurve(GroupName, XY, groupColor, SymboltoUse); } } } if (chkTreatLegend.Checked) { Graph.Legend.IsVisible = true; } else { Graph.Legend.IsVisible = false; } Graph.XAxis.Scale.MaxGrace = .05; plotTreatments.AxisChange(); plotTreatments.Invalidate(); this.Cursor = Cursors.Default; } catch (Exception thrown) { MessageBox.Show("Could not make graph, talk to nigel.\n\nError is:\n" + thrown.Message, "Graph Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }