예제 #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);
                    }
                }
            }
        }