Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
385
Rotating 3D xamChart
posted

Hi,

In the ultraWinChart component there was built in support allowing the end user to hold the ALT key + moving their mouse around to rotate a 3D chart.  Is this same behavior possible in the WPF xamChart?  If not, will it be in the future?

Thanks,

//abissette

Parents
  • 17605
    posted

    Currently such built-in functionality is not available, but you can try using the following code: 

     

    public partial class Window1 : Window

    {

    private double xTheta = 0; private double yTheta = 0;

    private Point prevPoint = new Point(0, 0);

    public Window1()

    {

    InitializeComponent();

    this.MouseLeftButtonDown += new MouseButtonEventHandler(Window1_MouseLeftButtonDown);

    this.MouseMove += new MouseEventHandler(Window1_MouseMove);

    }

    void Window1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)

    {

    this.prevPoint = e.GetPosition(null);

    }

    void Window1_MouseMove(object sender, MouseEventArgs e)

    {

    if (e.LeftButton != MouseButtonState.Pressed || System.Windows.Input.Keyboard.Modifiers != ModifierKeys.Alt)

    {

    return;

    }

    Point pt = e.GetPosition(null);

    if (prevPoint.X == 0 && prevPoint.Y == 0)

    {

    prevPoint = pt;

    return;

    }

    yTheta += (prevPoint.X - pt.X) * 360 /
    this.ActualWidth;

    xTheta += (prevPoint.Y - pt.Y) * 360 / this.ActualHeight;

    AxisAngleRotation3D angleRotationY = new AxisAngleRotation3D(new Vector3D(0.131, -0.991, 0.36), yTheta);

    RotateTransform3D rotateTransformY = new RotateTransform3D(angleRotationY);

    AxisAngleRotation3D angleRotationX = new AxisAngleRotation3D(new Vector3D(-0.991, 0.131, 0.36), xTheta);

    RotateTransform3D rotateTransformX = new RotateTransform3D(angleRotationX);

    Transform3DGroup transformGroup = new Transform3DGroup();

    transformGroup.Children.Add(rotateTransformY);

    transformGroup.Children.Add(rotateTransformX);

    this.xamChart.Transform3D = transformGroup;

    prevPoint = pt;

    }

    }

Reply Children
No Data