Пример #1
0
        private void OnAddItem(SliderPoint sliderPoint)
        {
            sliderPoint.Parent            = Canvas;
            sliderPoint.SliderShape.Style = SliderStyle;
            sliderPoint.PropertyChanged  += LevelPoint_PropertyChanged;
            sliderPoint.DragCompleted    += SliderPoint_DragCompleted;

            try
            {
                Canvas.Children.Add(sliderPoint.SliderShape);
            }
            catch { }
        }
Пример #2
0
        private void OnRemoveItem(SliderPoint sliderPoint)
        {
            sliderPoint.SliderShape.KeyDown -= GradientPoint_KeyDown;
            sliderPoint.PropertyChanged     -= GradientPoint_PropertyChanged;
            sliderPoint.DragCompleted       -= SliderPoint_DragCompleted;
            sliderPoint.AltClick            -= SliderPoint_AltClick;
            try
            {
                _canvas.Children.Remove(sliderPoint.SliderShape);
            }
            catch { }

            sliderPoint.Dispose();
        }
Пример #3
0
 private void OnAddItem(SliderPoint sliderPoint)
 {
     sliderPoint.Parent               = _canvas;
     sliderPoint.SliderShape.Style    = SliderStyle;
     sliderPoint.SliderShape.KeyDown += GradientPoint_KeyDown;;
     sliderPoint.PropertyChanged     += GradientPoint_PropertyChanged;
     sliderPoint.DragCompleted       += SliderPoint_DragCompleted;
     sliderPoint.AltClick            += SliderPoint_AltClick;
     try
     {
         _canvas.Children.Add(sliderPoint.SliderShape);
     }
     catch { }
 }
Пример #4
0
        private SliderPoint AddPoint(double position, bool isSelected = false)
        {
            //Logging.Debug("Enter Add Point");
            var point = new SliderPoint(position, _canvas);

            if (point.Center >= 0 && point.Center <= _canvas.Width)
            {
                _points.Add(point);
                _points.Sort(new SliderPointPositionComparer());
                OnAddItem(point);
                if (isSelected)
                {
                    point.SliderShape.Focus();
                }
            }
            //Logging.Debug("Exit Add Point");
            return(point);
        }
Пример #5
0
        private void AddLevelSlider()
        {
            var points = GetCurveValue().Points;

            if (points.Count == 2 && points[0].Y == points[1].Y)
            {
                _levelPoint = new SliderPoint(GetCurveValue().Points[0].Y / 100.0, Canvas, true);
            }
            else
            {
                _levelPoint = new SliderPoint(0.0, Canvas, true);
            }


            if (_levelPoint.Center >= 0 && _levelPoint.Center <= Canvas.Width)
            {
                OnAddItem(_levelPoint);
            }
        }
Пример #6
0
        private void LevelPoint_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("center", StringComparison.OrdinalIgnoreCase))
            {
                if (_holdValue == null)
                {
                    _holdValue = new Curve(GetCurveValue());
                }
                SliderPoint point = sender as SliderPoint;
                if (point != null)
                {
                    if (point.IsDragging)
                    {
                        var level = Math.Round(point.NormalizedPosition * 100, MidpointRounding.AwayFromZero);

                        _holdValue = new Curve(new PointPairList(new[] { 0.0, 100.0 }, new[] { level, level }));

                        UpdateImage(_holdValue);
                    }
                }
            }
        }
Пример #7
0
        private void GradientPoint_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("center", StringComparison.OrdinalIgnoreCase))
            {
                if (_holdValue == null)
                {
                    _holdValue = new ColorGradient(GetColorGradientValue());
                    //Logging.Debug("Position changed, initialized holdvalue");
                }
                SliderPoint point = sender as SliderPoint;
                if (point != null)
                {
                    if (point.IsDragging)
                    {
                        var pointIndexes = point.Tag as List <int>;
                        var colorPoints  = _holdValue.Colors;
                        if (pointIndexes != null)
                        {
                            foreach (var index in pointIndexes)
                            {
                                if (index < colorPoints.Count)
                                {
                                    colorPoints[index].Position = point.NormalizedPosition;
                                }
                                else
                                {
                                    Logging.Error("Index out of bounds for colorpoint. Index:{0}, colorpoint size:{1}, position:{3}", index,
                                                  colorPoints.Count, point.NormalizedPosition);
                                }
                            }
                        }

                        UpdateImage(_holdValue);
                    }
                }
            }
        }