private void OnCmdPortBut(IRectElement element) { CurrentScreen = element; }
private void OnCmdSenderBut(IRectElement senderElement) { RectElement currentScreen = new RectElement(); currentScreen.SenderIndex = senderElement.SenderIndex ; currentScreen.EleType = ElementType.sender; currentScreen.OperateEnviron = OperatEnvironment.AdjustSenderLocation; currentScreen.ConnectedIndex = senderElement.ConnectedIndex; CurrentScreen = currentScreen; }
public LineElement(int zOrder,IRectElement frontElement,IRectElement endElement) { EndElement = endElement; FrontElement = frontElement; X = FrontElement.X + FrontElement.Width / 2; Y = FrontElement.Y + FrontElement.Height / 2; EndX = EndElement.X + EndElement.Width / 2; EndY = EndElement.Y + EndElement.Height / 2; Width = Math.Sqrt(Math.Pow(EndX - X, 2) + Math.Pow(EndY - Y, 2)); Height = 3; ZOrder = zOrder; if (EndX < X) { Angle = Math.Atan((EndY - Y) / (X - EndX)); Angle = 180 - Angle * 180 / Math.PI; } else { Angle = Math.Atan((EndY - Y) / (EndX - X)); Angle = Angle * 180 / Math.PI; } Margin = new Thickness(X, Y, EndX, EndY); }
/// <summary> /// 更改某个元素的位置后,该元素处于某个组时,处理该元素组框的位置 /// </summary> /// <param name="element"></param> private void OnHandleGroupFrameLocation(IRectElement element) { #region 移动的网口属于某个组,则处理组框的位置 if (element.EleType == ElementType.receive && element.GroupName >= 0) { //找到该组下所有的元素 IRectElement groupFrame = new RectElement(); ObservableCollection<IRectElement> elementCollection = new ObservableCollection<IRectElement>(); if (element.ParentElement != null && element.ParentElement.EleType == ElementType.screen) { RectLayer screenLayer = (RectLayer)element.ParentElement; for (int i = 0; i < screenLayer.ElementCollection.Count; i++) { if (screenLayer.ElementCollection[i].EleType == ElementType.receive && screenLayer.ElementCollection[i].GroupName == element.GroupName) { elementCollection.Add((IRectElement)screenLayer.ElementCollection[i]); } else if (screenLayer.ElementCollection[i].EleType == ElementType.groupframe && screenLayer.ElementCollection[i].GroupName == element.GroupName) { groupFrame = (IRectElement)screenLayer.ElementCollection[i]; } } } //计算组框新值 if (elementCollection.Count > 0) { Rect newGroupframeRect = Function.UnionRectCollection(elementCollection); groupFrame.X = newGroupframeRect.X; groupFrame.Y = newGroupframeRect.Y; groupFrame.Width = newGroupframeRect.Width; groupFrame.Height = newGroupframeRect.Height; } } #endregion }
public static bool IsRectIntersect(IRectElement rect1, IRectElement rect2) { if (rect1 == null || rect2 == null) { return false; } Rect rc1 = new Rect(rect1.X, rect1.Y, rect1.Width, rect1.Height); Rect rc2 = new Rect(rect2.X, rect2.Y, rect2.Width, rect2.Height); return rc1.IntersectsWith(rc2); }