void FireStructureChangedUnder(RowVM row) { if (row == null) // roots changed // Reestablish dependencies from model to ViewModel { _tree.Roots.DependentSentry.OnGet(); StructureChanged(this, new TreePathEventArgs()); } else { // Reestablish dependencies from model to ViewModel row.Children.DependentSentry.OnGet(); TreePath path; if (row.Model.Parent == null) { path = new TreePath(row); } else { var list = new DList <RowVM>(); for (; row != null; row = row.Parent) { list.PushFirst(row); } path = new TreePath(list.ToArray()); } StructureChanged(this, new TreePathEventArgs(path)); } }
/* * SerializeRunResults - this is a partial implementation. I found the built in JsonConvert.SerializeObject met my needs and abandon this approach. */ public static string SerializeRunResults() { string runValuesString = "{\n"; foreach (List <decimal> DList in _runs) { runValuesString += "["; decimal[] d = DList.ToArray(); for (int i = 0; i < d.Length; i++) { runValuesString += d[i]; if (i + 1 < d.Length) { runValuesString += ","; } else { runValuesString += "]\n"; } } } runValuesString += "\n}"; Console.WriteLine("CurRun values:" + runValuesString); return(runValuesString); }
public static PointF[] ComputeConvexHull(List<PointF> points, bool sortInPlace = false) { if (!sortInPlace) points = new List<PointF>(points); points.Sort((a, b) => a.X == b.X ? a.Y.CompareTo(b.Y) : (a.X > b.X ? 1 : -1)); DList<PointF> hull = new DList<PointF>(); int L = 0, U = 0; // size of lower and upper hulls // Builds a hull such that the output polygon starts at the leftmost point. for (int i = points.Count - 1; i >= 0; i--) { PointF p = points[i], p1; // build lower hull (at end of output list) while (L >= 2 && cross((p1 = hull.Last),hull[hull.Count - 2], points[i]) >= 0) { hull.RemoveAt(hull.Count - 1); L--; } hull.PushLast(p); L++; // build upper hull (at beginning of output list) while (U >= 2 && cross((p1 = hull.First), (hull[1]), points[i]) <= 0) { hull.RemoveAt(0); U--; } if (U != 0) // when U=0, share the point added above hull.PushFirst(p); U++; } try { hull.RemoveAt(hull.Count - 1); } catch (System.Exception) { } return hull.ToArray(); }
public static PointF[] ComputeConvexHull(List <PointF> points, bool sortInPlace = false) { if (!sortInPlace) { points = new List <PointF>(points); } points.Sort((a, b) => a.X == b.X ? a.Y.CompareTo(b.Y) : (a.X > b.X ? 1 : -1)); DList <PointF> hull = new DList <PointF>(); int L = 0, U = 0; // size of lower and upper hulls // Builds a hull such that the output polygon starts at the leftmost point. for (int i = points.Count - 1; i >= 0; i--) { PointF p = points[i], p1; // build lower hull (at end of output list) while (L >= 2 && cross((p1 = hull.Last), hull[hull.Count - 2], points[i]) >= 0) { hull.RemoveAt(hull.Count - 1); L--; } hull.PushLast(p); L++; // build upper hull (at beginning of output list) while (U >= 2 && cross((p1 = hull.First), (hull[1]), points[i]) <= 0) { hull.RemoveAt(0); U--; } if (U != 0) // when U=0, share the point added above { hull.PushFirst(p); } U++; } hull.RemoveAt(hull.Count - 1); return(hull.ToArray()); }
void FireStructureChangedUnder(RowVM row) { if (row == null) { // roots changed // Reestablish dependencies from model to ViewModel _tree.Roots.DependentSentry.OnGet(); StructureChanged(this, new TreePathEventArgs()); } else { // Reestablish dependencies from model to ViewModel row.Children.DependentSentry.OnGet(); TreePath path; if (row.Model.Parent == null) path = new TreePath(row); else { var list = new DList<RowVM>(); for (; row != null; row = row.Parent) list.PushFirst(row); path = new TreePath(list.ToArray()); } StructureChanged(this, new TreePathEventArgs(path)); } }