private void MouseUp_DragMoving(Point gridLocation) { m_lastSingleSelectedElementLocation = gridLocation; elementsFinishedMoving(ElementMoveType.Move); endAllDrag(); CurrentDragSnapPoints.Clear(); }
private void MouseUp_HResizing(Point gridLocation) { elementsFinishedMoving(ElementMoveType.Resize); CurrentDragSnapPoints.Clear(); }
private void calculateSnapPoints() { if (!EnableSnapTo) { return; } // build up a full set of snap points/details, from (a) the static snap points for the grid, and // (b) calculated snap points for this move (ie. other elements in the row[s]). // iterate through the rows, calculating snap points for every single element in each row that has any selected elements foreach (Row row in Rows.Where(x => x.Visible)) { // This would skip generating snap points for elements on any rows that have nothing selected. // However, we still need to do that; as we might be dragging elements vertically into rows that // (currently) have nothing selected. So we'll generate for everything, but that's going to be // quite overkill. So, the big TODO: here is to regenerate element snap points for only rows with // selected elements, but also regenerate them whenever we move vertically. foreach (Element element in row) { // skip it if it's a selected element; we don't want to snap to them, as they'll be moving as well if (element.Selected) { continue; } // if it's a non-selected element, generate snap points for it; for the start and end times. Also record the // row its from in the generated point, so when snapping we can check against only elements from this row. SnapDetails details = CalculateSnapDetailsForPoint(element.StartTime, SnapPriorityForElements, Color.Empty); details.SnapRow = row; if (!CurrentDragSnapPoints.ContainsKey(details.SnapTime)) { CurrentDragSnapPoints[details.SnapTime] = new List <SnapDetails>(); } CurrentDragSnapPoints[details.SnapTime].Add(details); details = CalculateSnapDetailsForPoint(element.EndTime, SnapPriorityForElements, Color.Empty); details.SnapRow = row; if (!CurrentDragSnapPoints.ContainsKey(details.SnapTime)) { CurrentDragSnapPoints[details.SnapTime] = new List <SnapDetails>(); } CurrentDragSnapPoints[details.SnapTime].Add(details); } } //Add in our static snap points as a copy so they are not modified foreach (var staticSnapPoint in StaticSnapPoints) { if (CurrentDragSnapPoints.ContainsKey(staticSnapPoint.Key)) { CurrentDragSnapPoints[staticSnapPoint.Key].AddRange(staticSnapPoint.Value); } else { CurrentDragSnapPoints.Add(staticSnapPoint.Key, staticSnapPoint.Value); } } }