Blame view

sources/RoboforkApp/UserControls/ucNode.xaml.cs 4.52 KB
b338e1ff5   nguyen_nam   no message
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  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.Media;
  using System.Windows.Media.Imaging;
  using System.Windows.Navigation;
  using System.Windows.Shapes;
  
  namespace RoboforkApp
  {
      /// <summary>
      /// Interaction logic for ucNode.xaml
      /// </summary>
      public partial class ucNode : UserControl
      {
          public ucNode()
          {
              InitializeComponent();
          }
  
          private bool _isFocus = false;
a47f478f0   doan   開発 #2045 : node の...
29
          private bool _isDragDelta = false;
b338e1ff5   nguyen_nam   no message
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  
          public static readonly DependencyProperty buttTextProperty =
          DependencyProperty.Register("txtNode", typeof(String),
          typeof(ucNode), new FrameworkPropertyMetadata(string.Empty));
  
          public static readonly DependencyProperty btnWidthProperty =
          DependencyProperty.Register("btnWidth", typeof(double),
          typeof(ucNode), new FrameworkPropertyMetadata(10.0));
  
          public static readonly DependencyProperty btnHeightProperty =
          DependencyProperty.Register("btnHeight", typeof(double),
          typeof(ucNode), new FrameworkPropertyMetadata(10.0));
  
          public static readonly DependencyProperty coordStringProperty =
          DependencyProperty.Register("coordString", typeof(String),
          typeof(ucNode), new FrameworkPropertyMetadata(string.Empty));
ebf4e3eed   nguyen_nam   Update Task 2045
46
47
48
49
50
          public static readonly DependencyProperty fillColorProperty =
          DependencyProperty.Register("fillColor", typeof(String),
          typeof(ucNode), new FrameworkPropertyMetadata("Blue"));
  
        
b338e1ff5   nguyen_nam   no message
51
52
53
54
55
          public String txtNode
          {
              get { return GetValue(buttTextProperty).ToString(); }
              set { SetValue(buttTextProperty, value); }
          }
ebf4e3eed   nguyen_nam   Update Task 2045
56

b338e1ff5   nguyen_nam   no message
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
          public double btnWidth
          {
              get { return (double)GetValue(btnWidthProperty); }
              set { SetValue(btnWidthProperty, value); }
  
          }
  
          public double btnHeight
          {
              get { return (double)GetValue(btnHeightProperty); }
              set { SetValue(btnHeightProperty, value); }
  
          }
          public String coordString
          {
              get { return GetValue(coordStringProperty).ToString(); }
              set { SetValue(coordStringProperty, value); }
          }
ebf4e3eed   nguyen_nam   Update Task 2045
75
76
77
78
79
          public String fillColor
          {
              get { return GetValue(fillColorProperty).ToString(); }
              set { SetValue(fillColorProperty, value); }
          }
b338e1ff5   nguyen_nam   no message
80
81
82
83
84
85
  
          public bool IsFocus
          {
              get { return _isFocus; }
              set { _isFocus = value; }
          }
a47f478f0   doan   開発 #2045 : node の...
86
87
88
89
90
          public bool IsDragDelta
          {
              get { return _isDragDelta; }
              set { _isDragDelta = value; }
          }
b338e1ff5   nguyen_nam   no message
91
92
93
94
95
96
97
98
99
100
101
102
103
104
          private void btnHello_MouseDown(object sender, MouseButtonEventArgs e)
          {
              _isFocus = true;
          }
  
          private void btnHello_MouseUp(object sender, MouseButtonEventArgs e)
          {
  
          }
  
          private void btnHello_MouseMove(object sender, MouseEventArgs e)
          {
  
          }
a47f478f0   doan   開発 #2045 : node の...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
          private void tmbThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
          {
  
              if (_isDragDelta)
              {
                  double left = Canvas.GetLeft(this);
                  double top = Canvas.GetTop(this);
                  if (0 < (top + e.VerticalChange)
                      && (top + e.VerticalChange) < (1000 - btnHeight))
                  {
                      Canvas.SetTop(this, top + e.VerticalChange);
                  }
                  if (0 < (left + e.HorizontalChange)
                      && (left + e.HorizontalChange) < (1000 - btnWidth))
                  {
                      Canvas.SetLeft(this, left + e.HorizontalChange);
                  }
  
                  DesignerCanvas.DragDeltaFlag = true;
                  UpdateCoordString(left, top);
              }
          }
b338e1ff5   nguyen_nam   no message
127
128
129
130
131
132
133
134
135
136
  
          private void UpdateCoordString(double left, double top)
          {
              coordString = "(" + Math.Round((left + btnWidth / 2), 2) + "," + Math.Round((top + btnHeight / 2), 2) + ")";
          }
  
          private void tmbThumb_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
          {
              coordString = String.Empty;
          }
a47f478f0   doan   開発 #2045 : node の...
137
138
139
140
141
142
143
144
  
          private void tmbThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
          {
              if (_isDragDelta)
              {
                  DesignerCanvas.EditNodeFlag = true;
              }
          }
b338e1ff5   nguyen_nam   no message
145
146
      }
  }