protected override void OnMouseUp(MouseEventArgs e) { this._IsRotating = false; this.Cursor = Cursors.Default; this.EncoderDirection = EncoderDirectionType.Zero; OnDirectionChanged(new DirectionChangedEventArgs(EncoderDirection)); }
public VirtualEncoder() { InitializeComponent(); this.DoubleBuffered = true; this.SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); this._IsRotating = false; this._CurrentAngle = 270.0; this.EncoderDirection = EncoderDirectionType.Zero; GlowColor = IlluminationColor.Blue; }
protected override void OnMouseMove(MouseEventArgs e) { if (this._IsRotating) { this.Cursor = Cursors.Hand; this._CurrentAngle = Math.Atan2((double)checked (e.Y - this.KnobCenter.Y), (double)checked (e.X - this.KnobCenter.X)) * (180.0 / Math.PI) + 180.0; if (this._CurrentAngle > this._OldAngle) { this.EncoderDirection = EncoderDirectionType.Positive; } else if (this._CurrentAngle < this._OldAngle) { this.EncoderDirection = EncoderDirectionType.Negative; } OnDirectionChanged(new DirectionChangedEventArgs(EncoderDirection)); this._OldAngle = this._CurrentAngle; } this.Refresh(); }
public DirectionChangedEventArgs(EncoderDirectionType directionType) { EncoderDirection = directionType; }