Blame view
sources/RoboforkApp/UserControls/ucNode.xaml.cs
5.79 KB
|
e3ae88363
|
1 2 3 4 |
using RoboforkApp.Entities; using RoboforkApp.Services; using RoboforkApp.View; using System; |
|
b338e1ff5
|
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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
|
32 |
private bool _isDragDelta = false; |
|
e3ae88363
|
33 |
public Robofork15Demo _dataNode; |
|
b338e1ff5
|
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
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
|
50 51 52 |
public static readonly DependencyProperty fillColorProperty =
DependencyProperty.Register("fillColor", typeof(String),
typeof(ucNode), new FrameworkPropertyMetadata("Blue"));
|
|
01c8c8f49
|
53 54 55 56 57 58 59 60 61 |
public static readonly DependencyProperty NameNodeProperty =
DependencyProperty.Register("NameNode", typeof(String),
typeof(ucNode), new FrameworkPropertyMetadata(string.Empty));
public String NameNode
{
get { return GetValue(NameNodeProperty).ToString(); }
set { SetValue(NameNodeProperty, value); }
}
|
|
ebf4e3eed
|
62 |
|
|
b338e1ff5
|
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
public String txtNode
{
get { return GetValue(buttTextProperty).ToString(); }
set { SetValue(buttTextProperty, value); }
}
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
|
87 88 89 90 91 |
public String fillColor
{
get { return GetValue(fillColorProperty).ToString(); }
set { SetValue(fillColorProperty, value); }
}
|
|
b338e1ff5
|
92 93 94 95 96 |
public bool IsFocus
{
get { return _isFocus; }
set { _isFocus = value; }
}
|
|
a47f478f0
|
97 98 99 100 101 |
public bool IsDragDelta
{
get { return _isDragDelta; }
set { _isDragDelta = value; }
}
|
|
a47f478f0
|
102 103 104 105 106 107 108 109 110 111 112 |
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);
|
|
e3ae88363
|
113 114 115 |
if (_dataNode != null)
_dataNode.NodePos_y = Math.Round(_dataNode.NodePos_y + e.VerticalChange, 2);
|
|
a47f478f0
|
116 117 118 119 120 |
}
if (0 < (left + e.HorizontalChange)
&& (left + e.HorizontalChange) < (1000 - btnWidth))
{
Canvas.SetLeft(this, left + e.HorizontalChange);
|
|
e3ae88363
|
121 122 123 124 125 126 127 128 |
if (_dataNode != null)
_dataNode.NodePos_x = Math.Round(_dataNode.NodePos_x + e.HorizontalChange, 2);
}
if (!DesignerCanvas.LoadDBFlag)
{
DesignerCanvas.DragDeltaFlag = true;
|
|
a47f478f0
|
129 |
} |
|
a47f478f0
|
130 131 132 |
UpdateCoordString(left, top);
}
}
|
|
b338e1ff5
|
133 134 135 136 137 138 139 140 |
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)
{
|
|
01c8c8f49
|
141 |
coordString = NameNode; |
|
e3ae88363
|
142 143 144 145 146 147 148 |
// Update to DB
if (DesignerCanvas.LoadDBFlag)
{
Robofork15DemoService service = new Robofork15DemoService();
service.ModifyRobofork15Demo(_dataNode);
}
|
|
b338e1ff5
|
149 |
} |
|
a47f478f0
|
150 151 152 |
private void tmbThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
|
|
e3ae88363
|
153 154 155 156 157 158 159 160 161 162 163 164 |
if (!_isDragDelta)
return;
// Update to DB
if(DesignerCanvas.LoadDBFlag){
UpdateNodeView updateNode = new UpdateNodeView();
updateNode.txtAngle.Text = _dataNode.NodeVehAng.ToString();
updateNode.txtSpeed.Text = _dataNode.NodeVehSpd.ToString();
updateNode.txtHight.Text = _dataNode.NodeLftHeight.ToString();
updateNode._dataNode = this._dataNode;
updateNode.ShowDialog();
return;
|
|
a47f478f0
|
165 |
} |
|
a47f478f0
|
166 |
|
|
e3ae88363
|
167 168 |
DesignerCanvas.EditNodeFlag = true;
}
|
|
b338e1ff5
|
169 170 |
} } |