public ViewEditor(MainWindow w) { current = w; //menu = new Menu(current); GUI_Animations.Initialize(current); GUI_Changer.initialize(current); start = DateTime.Now; actions = new List<Action>(); //actions.Add(() => menu.init_SelectLoadOrCreateState()); actionEnumerator = actions.GetEnumerator(); }
public IEnumerator GetEnumerator() { this.EnsureCollectionInSync(); this.VerifyRefreshNotDeferred(); if (this.IsGrouping) { CollectionViewGroupRoot rootGroup = this.RootGroup; if (rootGroup == null) { return null; } return rootGroup.GetLeafEnumerator(); } if (this.PageSize <= 0) { return new NewItemAwareEnumerator(this, this.InternalList.GetEnumerator(), this.CurrentAddItem); } List<object> list = new List<object>(); if (this.PageIndex < 0) { return list.GetEnumerator(); } for (int i = this._pageSize * this.PageIndex; i < Math.Min(this._pageSize * (this.PageIndex + 1), this.InternalList.Count); i++) { list.Add(this.InternalList[i]); } return new NewItemAwareEnumerator(this, list.GetEnumerator(), this.CurrentAddItem); }
/// <summary> /// This method is called when rendering is required. /// </summary> /// <param name="drawingContext"></param> protected override void OnRender(DrawingContext drawingContext) { if (!Initializing) { // Update the CAmera position persptCamera.LookDirection = cameraLookDirection; persptCamera.Position = cameraPosition; // If the user's mouse is on one of the 3D bar. then enhance the bar and display its values. if (null != SelectedHit && (PrevSelectedHit == null || 0 != PrevSelectedHit.StringToDisplay.CompareTo(SelectedHit.StringToDisplay))) { if (geometryForHitText != null) { geometryForHitText = null; modelForHitText.Content = null; mainViewPort.Children.Remove(modelForHitText); } if (modelsForHitTest != null) { List<ModelVisual3D>.Enumerator enumModelsI = modelsForHitTest.GetEnumerator(); while (enumModelsI.MoveNext()) { mainViewPort.Children.Remove(enumModelsI.Current); } } LetterLengthForHitText = SelectedHit.StringToDisplay.Length * OneLetterWidthForHitText; Point3D ptToWRite = SelectedHit.P2; ptToWRite.Y += LITTLE_ABOVE; geometryForHitText = WriteText(SelectedHit.PointToWrite, LetterLengthForHitText, OneLetterHeightForHitText, SelectedHit.StringToDisplay, Colors.Black); modelsForHitTest = Draw3DBar(SelectedHit.XItem, SelectedHit.YItem, SelectedHit.ZItem, SelectedHit.PointToStart, SelectedHit.Height, SelectedHit.Width , SelectedHit.BarColor); List<ModelVisual3D>.Enumerator enumModels = modelsForHitTest.GetEnumerator(); while (enumModels.MoveNext()) { mainViewPort.Children.Add(enumModels.Current); } PrevSelectedHit = SelectedHit; modelForHitText.Content = geometryForHitText; mainViewPort.Children.Add(modelForHitText); } // Else if there is no bar selected remove the enhancement and Hit text. else if (null == SelectedHit) { geometryForHitText = null; modelForHitText.Content = null; mainViewPort.Children.Remove(modelForHitText); if (modelsForHitTest != null) { List<ModelVisual3D>.Enumerator enumModels = modelsForHitTest.GetEnumerator(); while (enumModels.MoveNext()) { mainViewPort.Children.Remove(enumModels.Current); } } } } base.OnRender(drawingContext); }
/// <summary> /// Finds the ConvexHull of a series of points. See /// http://www.cs.princeton.edu/courses/archive/spr10/cos226/demo/ah/GrahamScan.html /// for further information. /// </summary> /// <param name="points">The points to compute the ConvexHull for</param> /// <returns>a collection of points that represents the polygon /// of the ConvexHull</returns> private static ICollection<Point> GrahamScan(List<ConvexHullPoint> chPoints) { Stack<ConvexHullPoint> chPointStack = new Stack<ConvexHullPoint>(); IEnumerator<ConvexHullPoint> enumerator = chPoints.GetEnumerator(); chPointStack.Push(anchor); chPointStack.Push(chPoints[0]); // Advance the enumerator to account for the two points // that we already got enumerator.MoveNext(); enumerator.MoveNext(); int i = 1; // Loop over all the points that were provided while (i < chPoints.Count) { // Ensure that stack contains points if (chPointStack.Count > 1) { ConvexHullPoint firstCHPoint = chPointStack.Pop(); ConvexHullPoint secondCHPoint = chPointStack.Pop(); chPointStack.Push(secondCHPoint); chPointStack.Push(firstCHPoint); if (Orientation(secondCHPoint, firstCHPoint, enumerator.Current) == COUNTER_CLOCKWISE) { chPointStack.Push(enumerator.Current); enumerator.MoveNext(); i++; } else chPointStack.Pop(); } else // No points in stack { chPointStack.Push(enumerator.Current); enumerator.MoveNext(); i++; } } return GetSortedPoints(chPointStack); }