|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Markup;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
-
- namespace BPASmartClient.CustomResource.UserControls.DeCanvas
- {
- /// <summary>
- /// NodeButton.xaml 的交互逻辑
- /// </summary>
- public partial class NodeButton :UserControl
- {
- public bool IsSelected { get; set; }
- protected Point m_DragStartPoint;
- protected bool m_IsDraging = false;
- public NodeButton()
- {
- InitializeComponent();
- }
-
- public NodeButton(string text,string tag)
- {
- InitializeComponent();
- button.Content = text;
- button.Tag = tag;
- }
-
-
- private void Button_PreviewMouseDown(object sender,MouseButtonEventArgs e)
- {
- e.Handled = true;
- base.OnPreviewMouseDown(e);
- m_DragStartPoint = e.GetPosition(null);
- }
-
- private void Button_MouseMove(object sender,MouseEventArgs e)
- {
- try
- {
- base.OnMouseMove(e);
-
- if (e.LeftButton == MouseButtonState.Pressed && !m_IsDraging)
- {
- Point position = e.GetPosition(null);
- }
- if (e.LeftButton == MouseButtonState.Pressed && !m_IsDraging)
- {
- m_IsDraging = true;
- // XamlWriter.Save() has limitations in exactly what is serialized,
- // see SDK documentation; short term solution only;
- string xamlString = XamlWriter.Save(this.Content);
- DragObject dataObject = new DragObject();
- dataObject.Xaml = xamlString;
- dataObject.text = button.Content.ToString();
- dataObject.DesiredSize = new Size(200,44);
- DragDrop.DoDragDrop(this,dataObject,DragDropEffects.Copy);
- e.Handled = true;
- m_IsDraging = false;
- }
- }
- catch (Exception ex)
- {
-
- }
- }
- }
- }
|