|
|
@ -172,15 +172,29 @@ public partial class Viewport3D |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region 页面隐式交互 |
|
|
|
#region 页面隐式交互 |
|
|
|
|
|
|
|
private System.Windows.Point _mouseDownPosition; |
|
|
|
|
|
|
|
private bool _isDragging = false; |
|
|
|
private void UIElement_OnPreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) |
|
|
|
private void UIElement_OnPreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (_isDragging) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 如果发生拖动,不显示菜单 |
|
|
|
|
|
|
|
_isDragging = false; // 重置拖动状态 |
|
|
|
|
|
|
|
MainBorder.ContextMenu.Visibility = Visibility.Hidden; |
|
|
|
|
|
|
|
MainBorder.ContextMenu.IsOpen = false; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
MainBorder.ContextMenu.Visibility = Visibility.Visible; |
|
|
|
|
|
|
|
// 未拖动时,显示右键菜单 |
|
|
|
MainBorder.ContextMenu.IsOpen = true; |
|
|
|
MainBorder.ContextMenu.IsOpen = true; |
|
|
|
|
|
|
|
// e.Handled = true; // 阻止事件继续传播 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void UIElement_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) |
|
|
|
private void UIElement_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MainBorder.ContextMenu.IsOpen = false; |
|
|
|
_mouseDownPosition = e.GetPosition(Viewport3Dx); |
|
|
|
e.Handled = true; |
|
|
|
_isDragging = false; // 重置拖动状态 |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
@ -189,4 +203,20 @@ public partial class Viewport3D |
|
|
|
//ViewportData.LoadData(); |
|
|
|
//ViewportData.LoadData(); |
|
|
|
ViewportManager.LoadModelByEntities(new List<Viewport3DTriangleEntity>()); |
|
|
|
ViewportManager.LoadModelByEntities(new List<Viewport3DTriangleEntity>()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Viewport3Dx_OnPreviewMouseMove(object sender, MouseEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (e.RightButton == MouseButtonState.Pressed) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// 计算鼠标移动距离 |
|
|
|
|
|
|
|
var currentPosition = e.GetPosition(Viewport3Dx); |
|
|
|
|
|
|
|
var distance = (currentPosition - _mouseDownPosition).Length; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否达到拖动的阈值 |
|
|
|
|
|
|
|
if (distance > 5) // 阈值可根据需要调整 |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_isDragging = true; // 标记为拖动 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |