private void CreateDropDownDataSource(ICollection collection) { _listItemType = ListBindingHelper.GetListItemType(collection); if (typeof(ITypedList).IsAssignableFrom(collection.GetType())) { _propertyDescriptors = ((ITypedList)collection).GetItemProperties(null); } else { if (!IsGenericCollection(collection.GetType()) && collection.Count == 0) { throw new InvalidOperationException("Unable to determine listitem type"); } else { _propertyDescriptors = TypeDescriptor.GetProperties(_listItemType); } } _dropDownDataSource = new TypedArrayList(collection, _propertyDescriptors); _dataGrid.DataSource = _dropDownDataSource; if (BindingContext != null) { _currencyManager = (CurrencyManager)BindingContext[_dataGrid.DataSource]; } }
/// <summary> /// For a system, we have to perform a recursive clone /// </summary> /// <returns></returns> public new System3 Clone() { TypedArrayList <Point3> _verts = new TypedArrayList <Point3>(); foreach (SysVertex vert in vertecies) { _verts.Add(vert.Clone()); } System3 result = (System3)MemberwiseClone(); result.SetPointMatrix(new PointMatrix(_verts)); return(result); }
protected override void ConvertGeometry(double[,] _geometry) { TypedArrayList <Point3> _vertecies = new TypedArrayList <Point3>(); SysVertex sysVert; for (int i = 0; i < _geometry.GetLength(1); i++) { sysVert = new SysVertex( (float)_geometry[0, i], (float)_geometry[1, i], (float)_geometry[2, i]); sysVert.obj = (Object3)masterObj.Clone(); sysVert.distance = i; _vertecies.Add(sysVert); } vertecies = new PointMatrix(_vertecies); }
/// <summary> /// Fills in the geometry array with points to create a smooth effect. /// Calculates distance and slope at each point. /// </summary> /// <param name="geometry"></param> /// <param name="rmaxDist">The maximum distance objects are allowed to be from each other</param> protected override void ConvertGeometry(double[,] g) { //Create the temp points array TypedArrayList <Point3> _points = new TypedArrayList <Point3>(); double dist, _dist, xdist, ydist, zdist; float[] slope = new float[] { 0f, 0f, 0f }; int noPoints; dist = 0; PenVertex _point; for (int i = 1; i < g.GetLength(1); i++) { slope = new float[] { (float)(g[0, i] / g[0, i - 1]), (float)(g[1, i] / g[1, i - 1]), (float)(g[2, i] / g[2, i - 1]) }; //Determine relevant values dist = MathUtil.Distance3(g[0, i - 1], g[0, i], g[1, i - 1], g[1, i], g[2, i - 1], g[2, i]); noPoints = (int)Math.Floor(dist / maxDist); //fill the list if (dist > maxDist) { xdist = (g[0, i] - g[0, i - 1]) / noPoints; ydist = (g[1, i] - g[1, i - 1]) / noPoints; zdist = (g[2, i] - g[2, i - 1]) / noPoints; for (double d = 0; d < noPoints; d += 1) { _point = new PenVertex( (float)(d * xdist + g[0, i - 1]), (float)(d * ydist + g[1, i - 1]), (float)(d * zdist + g[2, i - 1])); _point.obj = (Object3)masterObj.Clone(); _dist = (_points.Count() > 0) ? ((PenVertex)_points.Last()).distance : 0; _point.distance = (float)(_dist + maxDist); _point.slope = slope; _points.Add(_point); } } _point = new PenVertex((float)g[0, i], (float)g[1, i], (float)g[2, i]); _point.obj = (Object3)masterObj.Clone(); //calculate distance if (_points.Count() > 0) { _point.distance = ((PenVertex)_points.Last()).distance + ((float)maxDist); } else { _point.distance = 0; } _point.slope = slope; _points.Add(_point); } length = (_points.Count() > 0) ? ((PenVertex)_points.Last()).distance : 0; vertecies = new PointMatrix(_points); }