Charts 如何在Visual Basic.NET中使用鼠标绕其轴旋转三维图表
我想通过在VisualStudio2010图表上移动鼠标(左键向下)来绕其轴旋转图表。我在WPF中找到了许多示例,但在WinForms中没有 我在用Visual Basic编写代码 是否有人能告诉我一个教程或示例代码,它将为我指明正确的方向 谢谢 试试这个:Charts 如何在Visual Basic.NET中使用鼠标绕其轴旋转三维图表,charts,rotation,Charts,Rotation,我想通过在VisualStudio2010图表上移动鼠标(左键向下)来绕其轴旋转图表。我在WPF中找到了许多示例,但在WinForms中没有 我在用Visual Basic编写代码 是否有人能告诉我一个教程或示例代码,它将为我指明正确的方向 谢谢 试试这个: private Point mousePoint; private void chart1_MouseMove(object sender, MouseEventArgs e) { if (e.Bu
private Point mousePoint;
private void chart1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
if (mousePoint.IsEmpty)
mousePoint = e.Location;
else
{
int newy = chart1.ChartAreas[0].Area3DStyle.Rotation + (e.Location.X - mousePoint.X);
if (newy < -180)
newy = -180;
if (newy > 180)
newy = 180;
chart1.ChartAreas[0].Area3DStyle.Rotation = newy;
newy = chart1.ChartAreas[0].Area3DStyle.Inclination + (e.Location.Y - mousePoint.Y);
if (newy < -90)
newy = -90;
if (newy > 90)
newy = 90;
chart1.ChartAreas[0].Area3DStyle.Inclination = newy;
mousePoint = e.Location;
}
}
}
专用点鼠标点;
私有void chart1_MouseMove(对象发送方,MouseEventArgs e)
{
if(e.Button==System.Windows.Forms.MouseButtons.Left)
{
if(mousePoint.IsEmpty)
鼠标点=e.位置;
其他的
{
int newy=chart1.ChartAreas[0].Area3DStyle.Rotation+(e.Location.X-mousePoint.X);
如果(新的<-180)
newy=-180;
如果(新的>180)
newy=180;
chart1.ChartAreas[0]。Area3DStyle.Rotation=newy;
newy=chart1.ChartAreas[0].Area3DStyle.Indeption+(e.Location.Y-mousePoint.Y);
如果(新的<-90)
newy=-90;
如果(新的>90)
newy=90;
chart1.ChartAreas[0].Area3DStyle.Indeption=newy;
鼠标点=e.位置;
}
}
}
谢谢你的代码
在VB.NET中:
Private Sub chart_drag(sender As Object, e As MouseEventArgs) Handles embChartTitrations_A_B.MouseMove
Dim intY As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
If pointStart = Nothing Then
pointStart = e.Location
Else
intY = embChartTitrations_A_B.ChartAreas(0).Area3DStyle.Rotation - Math.Round((e.Location.X - pointStart.X) / 5)
If intY < -180 Then intY = -180
If intY > 180 Then intY = 180
embChartTitrations_A_B.ChartAreas(0).Area3DStyle.Rotation = intY
intY = embChartTitrations_A_B.ChartAreas(0).Area3DStyle.Inclination + Math.Round((e.Location.Y - pointStart.Y) / 5)
If intY < -90 Then intY = -90
If intY > 90 Then intY = 90
embChartTitrations_A_B.ChartAreas(0).Area3DStyle.Inclination = intY
pointStart = e.Location
End If
End If
End Sub
Private Sub chart_drag(发送方作为对象,e作为MouseEventArgs)处理embChartTitrations_A_B.MouseMove
作为整数的Dim intY
如果e.Button=Windows.Forms.MouseButtons.Left,则
如果pointStart=Nothing,则
点开始=e.位置
其他的
intY=embchartterations\u A\u B.图表区域(0).Area3DStyle.Rotation-Math.Round((e.Location.X-pointStart.X)/5)
如果intY<-180,则intY=-180
如果intY>180,则intY=180
embChartTitrations\u A\u B.图表区域(0).Area3DStyle.Rotation=intY
intY=embChartTitrations\u A\u B.图表区域(0).Area3DStyle.interlation+Math.Round((e.Location.Y-pointStart.Y)/5)
如果intY<-90,则intY=-90
如果intY>90,则intY=90
embChartTitrations\u A\u B.图表面积(0).Area3DStyle.倾斜度=intY
点开始=e.位置
如果结束
如果结束
端接头
(我将鼠标移动除以5,因为我觉得这样可以更精确地旋转图表)
谢谢
Kristian对Ken的C#样本进行了一些小的修正和优化(在其他方面还不错,我投了+1票):
private Point _mousePos;
private void chart_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left) return;
if (!_mousePos.IsEmpty)
{
var style = chart.ChartAreas[0].Area3DStyle;
style.Rotation = Math.Min(180, Math.Max(-180,
style.Rotation - (e.Location.X - _mousePos.X)));
style.Inclination = Math.Min(90, Math.Max(-90,
style.Inclination + (e.Location.Y - _mousePos.Y)));
}
_mousePos = e.Location;
}