终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NodeButton.xaml.cs 2.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Markup;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace BPASmartClient.CustomResource.UserControls.DeCanvas
  17. {
  18. /// <summary>
  19. /// NodeButton.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class NodeButton :UserControl
  22. {
  23. public bool IsSelected { get; set; }
  24. protected Point m_DragStartPoint;
  25. protected bool m_IsDraging = false;
  26. public NodeButton()
  27. {
  28. InitializeComponent();
  29. }
  30. public NodeButton(string text,string tag)
  31. {
  32. InitializeComponent();
  33. button.Content = text;
  34. button.Tag = tag;
  35. }
  36. private void Button_PreviewMouseDown(object sender,MouseButtonEventArgs e)
  37. {
  38. e.Handled = true;
  39. base.OnPreviewMouseDown(e);
  40. m_DragStartPoint = e.GetPosition(null);
  41. }
  42. private void Button_MouseMove(object sender,MouseEventArgs e)
  43. {
  44. try
  45. {
  46. base.OnMouseMove(e);
  47. if (e.LeftButton == MouseButtonState.Pressed && !m_IsDraging)
  48. {
  49. Point position = e.GetPosition(null);
  50. }
  51. if (e.LeftButton == MouseButtonState.Pressed && !m_IsDraging)
  52. {
  53. m_IsDraging = true;
  54. // XamlWriter.Save() has limitations in exactly what is serialized,
  55. // see SDK documentation; short term solution only;
  56. string xamlString = XamlWriter.Save(this.Content);
  57. DragObject dataObject = new DragObject();
  58. dataObject.Xaml = xamlString;
  59. dataObject.text = button.Content.ToString();
  60. dataObject.DesiredSize = new Size(200,44);
  61. DragDrop.DoDragDrop(this,dataObject,DragDropEffects.Copy);
  62. e.Handled = true;
  63. m_IsDraging = false;
  64. }
  65. }
  66. catch (Exception ex)
  67. {
  68. }
  69. }
  70. }
  71. }