private void OnRemoveItem(MultiSliderPoint item) { item.Polygon.KeyDown -= Polygon_KeyDown; item.PropertyChanged -= Point_PropertyChanged; try { canvas.Children.Remove(item.Polygon); } catch { } }
private void OnAddItem(MultiSliderPoint item) { item.Parent = canvas; item.Polygon.Style = SliderStyle; item.Polygon.KeyDown += Polygon_KeyDown; item.PropertyChanged += Point_PropertyChanged; try { canvas.Children.Add(item.Polygon); } catch { } }
private void canvas_MouseUp(object sender, MouseButtonEventArgs e) { if (points.Any(q => q.IsMouseOver)) { return; } var mousePoint = Mouse.GetPosition(sender as IInputElement); var point = new MultiSliderPoint(mousePoint.X, canvas); point.Polygon.MouseDown += (s, a) => SelectedIndex = points.IndexOf(point); if (point.Center >= 0 && point.Center <= canvas.Width) { points.Add(point); point.Polygon.Focus(); SelectedIndex = points.IndexOf(point); OnValueAdded(e); } }