コード例 #1
0
ファイル: RotaryKnobRenderer.cs プロジェクト: appsou/Helios
        protected override void OnRefresh()
        {
            RotaryKnob rotary = Visual as RotaryKnob;

            if (rotary != null)
            {
                _imageRect.Width  = rotary.Width;
                _imageRect.Height = rotary.Height;
                _image            = ConfigManager.ImageManager.LoadImage(rotary.KnobImage);
                _brush            = new ImageBrush(_image);
                _center           = new Point(rotary.Width / 2d, rotary.Height / 2d);
            }
            else
            {
                _image = null;
                _brush = null;
            }
        }
コード例 #2
0
ファイル: RotaryKnobRenderer.cs プロジェクト: appsou/Helios
        protected override void OnRender(System.Windows.Media.DrawingContext drawingContext)
        {
            RotaryKnob rotary = Visual as RotaryKnob;

            if (rotary != null)
            {
                drawingContext.PushTransform(new RotateTransform(rotary.KnobRotation, _center.X, _center.Y));
                drawingContext.DrawImage(_image, _imageRect);
                if (rotary.VisualizeDragging)
                {
                    double length = (rotary.DragPoint - _center).Length;
                    drawingContext.DrawLine(HeadingPen, _center, _center + new Vector(0d, -length));
                }
                drawingContext.Pop();

                if (rotary.VisualizeDragging)
                {
                    drawingContext.DrawLine(DragPen, _center, rotary.DragPoint);
                }
            }
        }