///<summary>Called when any operation that moves element times (namely drag-move and hresize). ///Saves the pre-move information and begins update on all selected elements.</summary> private void elementsBeginMove(Point gridLocation) { m_elemMoveInfo = new ElementMoveInfo(gridLocation, SelectedElements, VisibleTimeStart); foreach (var elem in SelectedElements) { elem.BeginUpdate(); } }
///<summary>Called when any operation that moves element times (namely drag-move and hresize). ///Saves the pre-move information and begins update on all selected elements.</summary> private void elementsBeginMove(Point gridLocation) { m_elemMoveInfo = new ElementMoveInfo(gridLocation, SelectedElements, VisibleTimeStart); foreach (var elem in SelectedElements) elem.BeginUpdate(); }
private void OnXChanged(double value) { ObservableCollection<ElementMoveInfo> elementMoveInfoCollection = new ObservableCollection<ElementMoveInfo>(); ObservableCollection<ElementSizeInfo> elementSizeInfoCollection = new ObservableCollection<ElementSizeInfo>(); ElementMoveInfo moveInfo = new ElementMoveInfo(); moveInfo.Element = ScannerRealParams.ScannerElement; Point oldPoint = new Point(_lastX, ScannerRealParams.ScannerElement.Y); Point newPoint = new Point(value, ScannerRealParams.ScannerElement.Y); moveInfo.OldPoint = oldPoint; moveInfo.NewPoint = newPoint; elementMoveInfoCollection.Add(moveInfo); if (ScannerRealParams.Groupframe != null && ScannerRealParams.Groupframe.GroupName != -1) { ElementMoveInfo groupframeMoveInfo = new ElementMoveInfo(); groupframeMoveInfo.Element = ScannerRealParams.Groupframe; groupframeMoveInfo.OldPoint = new Point(ScannerRealParams.Groupframe.X, ScannerRealParams.Groupframe.Y); ElementSizeInfo groupframeSizeInfo = new ElementSizeInfo(); groupframeSizeInfo.Element = ScannerRealParams.Groupframe; groupframeSizeInfo.OldSize = new Size(ScannerRealParams.Groupframe.Width, ScannerRealParams.Groupframe.Height); if (ScannerRealParams.NoSelectedElementRect == null) { ScannerRealParams.Groupframe.X = ScannerRealParams.ScannerElement.X; } else { IRectElement element = ScannerRealParams.ScannerElement; Rect selectedRect = new Rect(element.X, element.Y, element.Width, element.Height); Rect unionRect = Rect.Union(selectedRect, ScannerRealParams.NoSelectedElementRect); ScannerRealParams.Groupframe.X = unionRect.X; ScannerRealParams.Groupframe.Width = unionRect.Width; } groupframeMoveInfo.NewPoint = new Point(ScannerRealParams.Groupframe.X, ScannerRealParams.Groupframe.Y); groupframeSizeInfo.NewSize = new Size(ScannerRealParams.Groupframe.Width, ScannerRealParams.Groupframe.Height); elementMoveInfoCollection.Add(groupframeMoveInfo); elementSizeInfoCollection.Add(groupframeSizeInfo); } ElementMoveAction elementMoveAction = new ElementMoveAction(elementMoveInfoCollection); ElementSizeAction elementSizeAction = new ElementSizeAction(elementSizeInfoCollection); using (Transaction.Create(SmartLCTActionManager)) { SmartLCTActionManager.RecordAction(elementMoveAction); SmartLCTActionManager.RecordAction(elementSizeAction); } _lastX = value; }
public ElementsChangedTimesEventArgs(ElementMoveInfo info, ElementMoveType type) { PreviousTimes = info.OriginalElements; Type = type; }
private void SetChangeReceiveCallBack(CustomReceiveResult info) { if (info.IsOK==true) { #region 记录相关 ObservableCollection<ElementSizeInfo> elementSizeCollection = new ObservableCollection<ElementSizeInfo>(); ObservableCollection<ElementMoveInfo> elementMoveCollection = new ObservableCollection<ElementMoveInfo>(); ElementSizeInfo elementSizeinfo = new ElementSizeInfo(); elementSizeinfo.Element = _selectedElementCollection[0]; Size oldSize = new Size(_selectedElementCollection[0].Width, _selectedElementCollection[0].Height); elementSizeinfo.OldSize = oldSize; #endregion for (int i = 0; i < _selectedElementCollection.Count; i++) { _selectedElementCollection[i].Height = info.Height; _selectedElementCollection[i].Width = info.Width; } IRectElement rectElement = _selectedElementCollection[0]; //组框大小等于选中的和没有选中的 if (rectElement.GroupName != -1) { Rect noSelectedElementRect = _currentSelectedElement[rectElement.GroupName].NoSelectedElementRect; Rect SelectedElementRect = new Rect(rectElement.X, rectElement.Y, rectElement.Width, rectElement.Height); Rect groupSize = new Rect(); if (noSelectedElementRect.Height == 0 && noSelectedElementRect.Width == 0) { groupSize = SelectedElementRect; } else { groupSize = Rect.Union(SelectedElementRect, noSelectedElementRect); } #region 记录相关 ElementMoveInfo groupMoveInfo = new ElementMoveInfo(); groupMoveInfo.Element = _groupframeList[rectElement.GroupName]; groupMoveInfo.OldPoint = new Point(_groupframeList[rectElement.GroupName].X, _groupframeList[rectElement.GroupName].Y); ElementSizeInfo groupSizeinfo = new ElementSizeInfo(); groupSizeinfo.Element = _groupframeList[rectElement.GroupName]; groupSizeinfo.OldSize = new Size(_groupframeList[rectElement.GroupName].Width, _groupframeList[rectElement.GroupName].Height); #endregion _groupframeList[rectElement.GroupName].X = groupSize.X; _groupframeList[rectElement.GroupName].Y = groupSize.Y; _groupframeList[rectElement.GroupName].Width = groupSize.Width; _groupframeList[rectElement.GroupName].Height = groupSize.Height; #region 记录相关 groupSizeinfo.NewSize = new Size(_groupframeList[rectElement.GroupName].Width, _groupframeList[rectElement.GroupName].Height); groupMoveInfo.NewPoint = new Point(_groupframeList[rectElement.GroupName].X, _groupframeList[rectElement.GroupName].Y); elementMoveCollection.Add(groupMoveInfo); elementSizeCollection.Add(groupSizeinfo); #endregion GetCurrentElementInfo(); } elementSizeinfo.NewSize = new Size(elementSizeinfo.Element.Width, elementSizeinfo.Element.Height); elementSizeCollection.Add(elementSizeinfo); ElementSizeAction elementSizeAction = new ElementSizeAction(elementSizeCollection); ElementMoveAction elementMoveAction = new ElementMoveAction(elementMoveCollection); using (Transaction.Create(SmartLCTActionManager)) { SmartLCTActionManager.RecordAction(elementSizeAction); SmartLCTActionManager.RecordAction(elementMoveAction); } } }
private Dictionary <int, List <ElementMoveInfo> > FillEmptyCells() { Dictionary <int, List <ElementMoveInfo> > oldElements = new Dictionary <int, List <ElementMoveInfo> >(); List <ElementMoveInfo> columnInfo; for (var column = 0; column < _fieldColumns; column++) { columnInfo = new List <ElementMoveInfo>(); for (var row = _fieldRows - 2; row != -1; row--) { if (!_field[column, row].isEmpty) { var isElementMoved = false; Vector2Int movedElement = Vector2Int.zero; for (var movingRow = row; movingRow < _fieldRows - 1; movingRow++) { bool isMove = _field[column, movingRow + 1].isEmpty; if (_field[column, movingRow + 1].isEmpty) { if (!isElementMoved) { isElementMoved = true; movedElement = new Vector2Int(column, movingRow); } var currentCell = _field[column, movingRow]; var targetCell = _field[column, movingRow + 1]; targetCell.isEmpty = false; targetCell.element = currentCell.element; currentCell.isEmpty = true; } bool isLastColumnElement = movingRow == _fieldRows - 2; bool isDownElementNotEmpty = !_field[column, movingRow + 1].isEmpty && !isMove; if (isDownElementNotEmpty || isLastColumnElement) { if (isElementMoved) { ElementMoveInfo elementInfo = new ElementMoveInfo(); if (isDownElementNotEmpty) { elementInfo.moveDistance = movingRow - movedElement.y; } else if (isLastColumnElement) { elementInfo.moveDistance = movingRow + 1 - movedElement.y; } elementInfo.coordinate = movedElement; columnInfo.Add(elementInfo); } break; } } } } if (columnInfo.Count > 0) { oldElements.Add(column, columnInfo); } } return(oldElements); }