public static void ConectTo(CommonObject st, bool start = false) { if (!IsCatch()) { if (start) { ToTempObj(st); } } else { if (!IsEquelWithTemp(st)) { Connect(st); ToTempObj(null); } } }
protected virtual void Move(CommonObject obj, double x, double y) { if (_catc) { var circle = obj; var parent = LogicalTreeHelper.GetParent(circle) as Panel; circle.Margin = new Thickness(x - _stX, y - _stY, 0, 0); Left = x - _stX; Top = y - _stY; if (Left > parent.ActualWidth - Width) { Left = parent.ActualWidth - Width; circle.Margin = new Thickness(Left, Top, 0, 0); _catc = false; } if (Top > parent.ActualHeight - Height) { Top = parent.ActualHeight - Height; circle.Margin = new Thickness(Left, Top, 0, 0); _catc = false; } if (Left < 0) { Left = 0; circle.Margin = new Thickness(Left, Top, 0, 0); _catc = false; } if (Top < 0) { Top = 0; circle.Margin = new Thickness(Left, Top, 0, 0); _catc = false; } if (Connection != null) { for (int i = 0; i < Connection.Count; i++) { Connection[i].UpdateLine(this); } } } }
public double GetDistanse(CommonObject st) { var x = GetCenter().X - st.GetCenter().X; var y = GetCenter().Y - st.GetCenter().Y; return Math.Sqrt(x*x + y*y); }
private void CheckValidationOfObject(CommonObject obj) { if ((obj as GpdData) != null) { foreach (var data in grd.Children.OfType<GpdData>().ToList().Where(data => data.Number > obj.Number)) { data.Number--; data.Update(); } _dataCount--; } if ((obj as GpdModule) != null) { foreach (var data in grd.Children.OfType<GpdModule>().ToList().Where(data => data.Number > obj.Number)) { data.Number--; data.Update(); } _moduleCount--; } Update(); }
private void CheckValidationOfObject(CommonObject obj) { if ((obj as NetStation) != null) { foreach (var data in grd.Children.OfType<NetStation>().ToList().Where(data => data.Number > obj.Number)) { data.Number--; data.Update(); } _stationCount--; } if ((obj as NetBus) != null) { foreach (var data in grd.Children.OfType<NetBus>().ToList().Where(data => data.Number > obj.Number)) { data.Number--; data.Update(); } _busCount--; } Update(); }
public static void Connect(CommonObject st1, CommonObject st2, bool direction = false) { if (Equals(st1, st2)) { MessageBox.Show("Нельзя соединить станцию с собой", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); ToTempObj(null); return; } if ((st1.Connection != null) && (st2.Connection != null)) { if (st1.Connection.Any(t1 => st2.Connection.Any(t => t1 == t))) { MessageBox.Show("Такое соединение уже существует", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); return; } } var parent = LogicalTreeHelper.GetParent(st1) as Panel; st1.Connection.Add(new StanConnection(stArrow)); var index1 = st1.Connection.Count - 1; st2.Connection.Add(st1.Connection[index1]); //var index2 = st2.Connection.Count - 1; st1.Connection[index1].obj1 = st1; st1.Connection[index1].obj2 = st2; st1.Connection[index1].line.X1 = st1.GetCenter().X; st1.Connection[index1].line.Y1 = st1.GetCenter().Y; st1.Connection[index1].line.X2 = st2.GetCenter().X; st1.Connection[index1].line.Y2 = st2.GetCenter().Y; st1.Connection[index1].line.StrokeThickness = 2; st1.Connection[index1].line.Stroke = new SolidColorBrush(Colors.Black); if (stArrow) { st1.Connection[index1].arrow1.X1 = st1.Connection[index1].arrow2.X1 = st1.Connection[index1].line.X2; st1.Connection[index1].arrow1.Y1 = st1.Connection[index1].arrow2.Y1 = st1.Connection[index1].line.Y2; var stP = new Point(st1.Connection[index1].line.X1, st1.Connection[index1].line.Y1); var endP = new Point(st1.Connection[index1].line.X2, st1.Connection[index1].line.Y2); Point arP1, arP2; SetArrowCoords(stP, endP, out arP1, out arP2); st1.Connection[index1].arrow1.X2 = arP1.X; st1.Connection[index1].arrow1.Y2 = arP1.Y; st1.Connection[index1].arrow2.X2 = arP2.X; st1.Connection[index1].arrow2.Y2 = arP2.Y; st1.Connection[index1].arrow1.StrokeThickness = 2; st1.Connection[index1].arrow2.StrokeThickness = 2; st1.Connection[index1].arrow1.Stroke = st1.Connection[index1].arrow2.Stroke = new SolidColorBrush(Colors.Black); } if (parent != null) { parent.Children.Add(st1.Connection[index1].line); if (stArrow) { parent.Children.Add(st1.Connection[index1].arrow1); parent.Children.Add(st1.Connection[index1].arrow2); } } stArrow = false; }
public static void Connect(CommonObject st) { Connect(tmpObject, st); }
public void UpdateLine(CommonObject st) { Point arP1, arP2; if (Equals(obj1, st)) { line.X1 = st.GetCenter().X; line.Y1 = st.GetCenter().Y; if (_arrow) { var stP = new Point(line.X1, line.Y1); var endP = new Point(line.X2, line.Y2); SetArrowCoords(stP, endP, out arP1, out arP2); arrow1.X2 = arP1.X; arrow1.Y2 = arP1.Y; arrow2.X2 = arP2.X; arrow2.Y2 = arP2.Y; } } else if (Equals(obj2, st)) { line.X2 = st.GetCenter().X; line.Y2 = st.GetCenter().Y; if (_arrow) { arrow1.X1 = arrow2.X1 = line.X2; arrow1.Y1 = arrow2.Y1 = line.Y2; var stP = new Point(line.X1, line.Y1); var endP = new Point(line.X2, line.Y2); SetArrowCoords(stP, endP, out arP1, out arP2); arrow1.X2 = arP1.X; arrow1.Y2 = arP1.Y; arrow2.X2 = arP2.X; arrow2.Y2 = arP2.Y; } } }
public static void ToTempObj(CommonObject obj) { tmpObject = obj; }
public static bool IsEquelWithTemp(CommonObject obj) { return (Equals(tmpObject, obj)); }
protected override void Move(CommonObject obj, double x, double y) { base.Move(obj, x, y); var data = obj as GpdData; data._subscribe.Margin = new Thickness(Left + Width, Top, 0, 0); }