public void updateArrow(InkCanvas ic, InkCollector _inkCollector) { List <MyArrow> maList = new List <MyArrow>(); foreach (MyArrow myArrow in _inkCollector.Sketch.MyArrows) { if (myArrow.IsDeleted == false && myArrow.NextMyButton == this && ic.Children.IndexOf(myArrow.Arrow) > -1 && myArrow.PreMyButton.isDeleted == false) { ic.Children.Remove(myArrow.Arrow); ThumbConnector tc = new ThumbConnector(myArrow.PreMyButton, this); MyArrow ma = new MyArrow(tc.arrow); ma.PreMyButton = myArrow.PreMyButton; ma.NextMyButton = this; ma.StartPoint = tc.startPoint; ma.EndPoint = tc.endPoint; maList.Add(ma); continue; } if (myArrow.IsDeleted == false && myArrow.PreMyButton == this && ic.Children.IndexOf(myArrow.Arrow) > -1 && myArrow.NextMyButton.isDeleted == false) { ic.Children.Remove(myArrow.Arrow); ThumbConnector tc = new ThumbConnector(this, myArrow.NextMyButton); MyArrow ma = new MyArrow(tc.arrow); ma.PreMyButton = this; ma.NextMyButton = myArrow.NextMyButton; ma.StartPoint = tc.startPoint; ma.EndPoint = tc.endPoint; maList.Add(ma); continue; } maList.Add(myArrow); } for (int i = 0; i < maList.Count; i++) { if (_inkCollector.Sketch.MyArrows[i] != maList[i]) { _inkCollector.Sketch.MyArrows[i] = maList[i]; ic.Children.Add(_inkCollector.Sketch.MyArrows[i].Arrow); } } }
public void updateRectangles(InkCanvas inkCanvas, InkCollector inkCollector) { if (isGlobal) { if (rBorder != null) { inkCanvas.Children.Remove(rBorder); } Rectangle rBorderRectangle = new Rectangle(); rBorderRectangle.HorizontalAlignment = HorizontalAlignment.Left; rBorderRectangle.VerticalAlignment = VerticalAlignment.Top; rBorderRectangle.Margin = new Thickness(Left, Top + Height, 0, 0); rBorderRectangle.Height = 10; rBorderRectangle.Width = Width; rBorderRectangle.Stroke = new SolidColorBrush(Colors.Black); if (this.Button.Visibility == Visibility.Visible) { inkCanvas.Children.Add(rBorderRectangle); } rBorder = rBorderRectangle; List <MySmallRectangle> msrs = new List <MySmallRectangle>(); foreach (MySmallRectangle msr in inkCollector.Sketch.mySmallRectangles) { if (msr.MyButton.VideoPath == this.VideoPath) { msrs.Add(msr); inkCanvas.Children.Remove(msr.Rectangle); } } foreach (MySmallRectangle msr in msrs) { inkCollector.Sketch.mySmallRectangles.Remove(msr); } List <MyButton> strokeCountMyButtonList = new List <MyButton>(); foreach (MyButton mb in inkCollector.Sketch.MyButtons) { if (mb.IsDeleted == false && mb.IsGlobal == false && mb.VideoPath == _videoPath && mb.Button.Visibility == Visibility.Visible) { strokeCountMyButtonList.Add(mb); } } int smallRectangleCount = strokeCountMyButtonList.Count; if (smallRectangleCount > 0) { strokeCountMyButtonList.Sort(new ComparerStrokeCount()); double totalTime = timeEnd; int mostStrokeCount = strokeCountMyButtonList[smallRectangleCount - 1].InkFrame._inkCanvas.Children.Count + strokeCountMyButtonList[smallRectangleCount - 1].InkFrame._inkCanvas.Strokes.Count; //最大的stroke count double rate; if (mostStrokeCount != 0) { for (int i = smallRectangleCount - 1; i >= 0; i--) { Rectangle r = new Rectangle(); r.Stroke = null; r.HorizontalAlignment = HorizontalAlignment.Left; r.VerticalAlignment = VerticalAlignment.Top; int strokeCount = strokeCountMyButtonList[i].InkFrame._inkCanvas.Children.Count + strokeCountMyButtonList[i].InkFrame._inkCanvas.Strokes.Count; r.Margin = new Thickness(rBorder.Margin.Left + 1 + rBorder.Width * (strokeCountMyButtonList[i].TimeStart / totalTime), rBorder.Margin.Top + 1, 0, 0); rate = (double)strokeCount / (double)mostStrokeCount; r.Fill = new SolidColorBrush(Color.FromRgb(255, Convert.ToByte(255 - 255 * rate), Convert.ToByte(255 - 255 * rate))); r.Height = rBorder.Height - 2; r.Width = rBorder.Width * (strokeCountMyButtonList[i].TimeEnd - strokeCountMyButtonList[i].TimeStart) / totalTime; r.MouseLeftButtonUp += new MouseButtonEventHandler(r_MouseLeftButtonUp); MySmallRectangle msr = new MySmallRectangle(r); inkCollector.Sketch.mySmallRectangles.Add(msr); msr.MyButton = strokeCountMyButtonList[i]; msr.ParentMyButton = this; if (this.Button.Visibility == Visibility.Visible) { inkCanvas.Children.Add(r); } } } } } else { foreach (MyButton mb in inkCollector.Sketch.MyButtons) { if (mb.isDeleted == false && mb.isGlobal && mb.VideoPath == VideoPath) { if (mb.rBorder != null) { inkCanvas.Children.Remove(mb.rBorder); } Rectangle rBorderRectangle = new Rectangle(); rBorderRectangle.HorizontalAlignment = HorizontalAlignment.Left; rBorderRectangle.VerticalAlignment = VerticalAlignment.Top; rBorderRectangle.Margin = new Thickness(mb.Left, mb.Top + mb.Height, 0, 0); rBorderRectangle.Height = 10; rBorderRectangle.Width = mb.Width; rBorderRectangle.Stroke = new SolidColorBrush(Colors.Black); if (mb.Button.Visibility == Visibility.Visible) { inkCanvas.Children.Add(rBorderRectangle); } mb.rBorder = rBorderRectangle; List <MySmallRectangle> msrs = new List <MySmallRectangle>(); foreach (MySmallRectangle msr in inkCollector.Sketch.mySmallRectangles) { if (msr.MyButton.VideoPath == this.VideoPath) { msrs.Add(msr); inkCanvas.Children.Remove(msr.Rectangle); } } foreach (MySmallRectangle msr in msrs) { inkCollector.Sketch.mySmallRectangles.Remove(msr); } List <MyButton> strokeCountMyButtonList = new List <MyButton>(); foreach (MyButton m in inkCollector.Sketch.MyButtons) { if (m.IsDeleted == false && m.IsGlobal == false && m.VideoPath == _videoPath && m.Button.Visibility == Visibility.Visible) { strokeCountMyButtonList.Add(m); } } strokeCountMyButtonList.Add(this); int smallRectangleCount = strokeCountMyButtonList.Count; if (smallRectangleCount > 0) { strokeCountMyButtonList.Sort(new ComparerStrokeCount()); double totalTime = mb.TimeEnd; int mostStrokeCount = strokeCountMyButtonList[smallRectangleCount - 1].InkFrame._inkCanvas.Children.Count + strokeCountMyButtonList[smallRectangleCount - 1].InkFrame._inkCanvas.Strokes.Count; //最大的stroke count if (mostStrokeCount != 0) { for (int i = smallRectangleCount - 1; i >= 0; i--) { Rectangle r = new Rectangle(); r.Stroke = null; r.HorizontalAlignment = HorizontalAlignment.Left; r.VerticalAlignment = VerticalAlignment.Top; int strokeCount = strokeCountMyButtonList[i].InkFrame._inkCanvas.Children.Count + strokeCountMyButtonList[i].InkFrame._inkCanvas.Strokes.Count; r.Margin = new Thickness(rBorderRectangle.Margin.Left + 1 + rBorderRectangle.Width * (strokeCountMyButtonList[i].TimeStart / totalTime), rBorderRectangle.Margin.Top + 1, 0, 0); r.Fill = new SolidColorBrush(Color.FromRgb(255, Convert.ToByte(255 - 255 * (double)strokeCount / (double)mostStrokeCount), Convert.ToByte(255 - 255 * (double)strokeCount / (double)mostStrokeCount))); r.Height = rBorderRectangle.Height - 2; r.Width = rBorderRectangle.Width * (strokeCountMyButtonList[i].TimeEnd - strokeCountMyButtonList[i].TimeStart) / totalTime; r.MouseLeftButtonUp += new MouseButtonEventHandler(r_MouseLeftButtonUp); MySmallRectangle msr = new MySmallRectangle(r); inkCollector.Sketch.mySmallRectangles.Add(msr); msr.MyButton = strokeCountMyButtonList[i]; msr.ParentMyButton = mb; if (mb.Button.Visibility == Visibility.Visible) { inkCanvas.Children.Add(r); } } } } break; } } } }