private void AddThumbs(SongInformation newParent) { for (int i = removeList.Count - 1; i >= 0; i--) { thumbSprite.RemoveChild(removeList[i]); removeList.RemoveAt(i); } int iter = 0; var temp = new ThumbList(device) { Position = new SharpDX.Vector2(200 * newParent.Depth, 0) }; foreach (SongInformation songInfo in newParent.Children) { var component = new LoadablePictureComponent(device, resourceManager, songInfo) { Position = new SharpDX.Vector2(100, 225 + 100 * iter) }; temp.AddChild(component); iter++; } thumbSprite.AddChild(temp); currentParent = newParent; }
public void DeleteVertex() { PointCollection points = (Figure.Segments[0] as PolyLineSegment).Points; if (points.Count > 2) { int index = GetIndex(); points.RemoveAt(index); ThumbList.RemoveAt(index); if (index == 0) { Figure.StartPoint = points[0]; } //MapCanvas parent = ((MapCanvas)Parent); if (PrevThumb == null) { NextThumb.PrevThumb = null; NextThumb.PrevInsertThumb = null; } else if (NextThumb == null) { PrevThumb.NextThumb = null; PrevThumb.NextInsertThumb = null; } else { PrevThumb.NextThumb = NextThumb; NextThumb.PrevThumb = PrevThumb; InsertThumb newInsertThumb = new InsertThumb(ParentCanvas, Figure, PrevThumb.GetIndex(), NextThumb.GetIndex(), Scale, ThumbList); newInsertThumb.PrevThumb = PrevThumb; newInsertThumb.NextThumb = NextThumb; PrevThumb.NextInsertThumb = newInsertThumb; NextThumb.PrevInsertThumb = newInsertThumb; ParentCanvas.Children.Add(newInsertThumb); } ParentCanvas.Children.Remove(this); ParentCanvas.Children.Remove(PrevInsertThumb); ParentCanvas.Children.Remove(NextInsertThumb); } }
public void InsertVertex(/*bool forceDrag = false*/) { if (PrevThumb != null && NextThumb != null) { int prevIndex = PrevThumb.GetIndex(); int nextIndex = NextThumb.GetIndex(); int newIndex = nextIndex > prevIndex ? nextIndex : prevIndex + 1; //Correct handling of closed curves (Figure.Segments[0] as PolyLineSegment).Points.Insert(newIndex, new Point(Canvas.GetLeft(this) / Scale, Canvas.GetTop(this) / Scale)); MoveThumb moveThumb = new MoveThumb(ParentCanvas, Figure, newIndex, Scale, ThumbList /*, IsDragging || forceDrag*/); ThumbList.Insert(newIndex, moveThumb); moveThumb.PrevThumb = PrevThumb; moveThumb.NextThumb = NextThumb; PrevThumb.NextThumb = moveThumb; NextThumb.PrevThumb = moveThumb; prevIndex = PrevThumb.GetIndex(); nextIndex = NextThumb.GetIndex(); //DependencyObject p = LogicalTreeHelper.GetParent(this); //MapCanvas parent = (MapCanvas)VisualTreeHelper.GetParent(this); //MapCanvas parent = ((MapCanvas)Parent); InsertThumb prevInsertThumb = new InsertThumb(ParentCanvas, Figure, prevIndex, newIndex, Scale, ThumbList); prevInsertThumb.PrevThumb = PrevThumb; prevInsertThumb.NextThumb = moveThumb; moveThumb.PrevInsertThumb = prevInsertThumb; PrevThumb.NextInsertThumb = prevInsertThumb; ParentCanvas.Children.Add(prevInsertThumb); InsertThumb nextInsertThumb = new InsertThumb(ParentCanvas, Figure, newIndex, nextIndex, Scale, ThumbList); nextInsertThumb.PrevThumb = moveThumb; nextInsertThumb.NextThumb = NextThumb; moveThumb.NextInsertThumb = nextInsertThumb; NextThumb.PrevInsertThumb = nextInsertThumb; ParentCanvas.Children.Add(nextInsertThumb); ParentCanvas.Children.Remove(this); ParentCanvas.Children.Add(moveThumb); } }
public int GetIndex() { return(ThumbList.IndexOf(this)); }