List <GridTrack> ParseTracks(List <string> inputLayoutList, List <string> inputColorList, List <string> inputDirectionList) { List <GridTrack> returnTracks = new List <GridTrack>(); bool useColorList = true; bool useDirectionList = true; if (inputColorList.Count == 0 || inputColorList[0] == "N/A" || inputColorList.Count < inputLayoutList.Count) { useColorList = false; } if (inputDirectionList.Count == 0 || inputDirectionList[0] == "N/A" || inputDirectionList.Count < inputLayoutList.Count) { useDirectionList = false; } int rowIndex = 0; foreach (string row in inputLayoutList) { int columnIndex = 0; foreach (char track in row) { if (track != '\n' && track != '\r') { GridTrack newTrack = new GridTrack(); newTrack.type = track; newTrack.position = new Vector2(columnIndex, rowIndex); char colorMask = ' '; if (useColorList) { colorMask = inputColorList[rowIndex][columnIndex]; } newTrack.SetBitmask(colorMask + ""); if (useDirectionList) { if (inputDirectionList.Count > rowIndex && inputDirectionList[rowIndex].Length > columnIndex) { newTrack.direction = inputDirectionList[rowIndex][columnIndex] + ""; } else { newTrack.direction = null; } } columnIndex++; returnTracks.Add(newTrack); } } rowIndex++; } return(returnTracks); }
/// <summary> /// Gets the measured length of layout grid track. /// </summary> /// <param name="gridTrack">The layout grid track.</param> /// <returns>the measured length.</returns> public double?GetMeasuredLength(GridTrack gridTrack) { gridTrack.VerifyNotNull(nameof(gridTrack)); if (!gridTrack.IsContainer) { throw new ArgumentException(DiagnosticMessages.RowPresenter_Resize_InvalidGridTrack, nameof(gridTrack)); } if (IsDisposed) { throw new ObjectDisposedException(GetType().FullName); } var scrollableManager = ScrollableManager; if (scrollableManager == null || Template.FlowRepeatCount != 1) { throw new InvalidOperationException(DiagnosticMessages.RowPresenter_Resize_NotAllowed); } var rowView = View; if (rowView == null) { return(null); } var containerView = scrollableManager[rowView.ContainerOrdinal]; return(scrollableManager.GetMeasuredLength(containerView, gridTrack)); }
public bool BeginDrag(ColumnHeader columnHeader, UIElement resizeGripper, MouseEventArgs e) { Debug.Assert(columnHeader != null); Debug.Assert(resizeGripper != null); _gridTrack = columnHeader.GridTrackToResize; if (_gridTrack == null) { return(false); } _oldValues = new GridLength[_gridTrack.Ordinal + 1]; var gridTrackOwner = _gridTrack.Owner; for (int i = 0; i < _oldValues.Length - 1; i++) { var current = gridTrackOwner[i]; _oldValues[i] = current.Length; if (current.Length.IsStar) { current.Resize(new GridLength(current.MeasuredLength, GridUnitType.Pixel)); } } _oldValues[_oldValues.Length - 1] = _gridTrack.Length; DragDetect(resizeGripper, e); return(true); }
/// <summary> /// Resizes the layout grid track. /// </summary> /// <param name="gridTrack">The layout grid track.</param> /// <param name="length">The resized length.</param> public void Resize(GridTrack gridTrack, GridLength length) { gridTrack.VerifyNotNull(nameof(gridTrack)); if (!gridTrack.IsContainer) { throw new ArgumentException(DiagnosticMessages.RowPresenter_Resize_InvalidGridTrack, nameof(gridTrack)); } if (length.IsStar) { throw new ArgumentException(DiagnosticMessages.RowPresenter_Resize_InvalidStarLength, nameof(length)); } if (IsDisposed) { throw new ObjectDisposedException(GetType().FullName); } var scrollableManager = ScrollableManager; if (scrollableManager == null || Template.FlowRepeatCount != 1) { throw new InvalidOperationException(DiagnosticMessages.RowPresenter_Resize_NotAllowed); } scrollableManager.Resize(this, gridTrack, length); }
public bool BeginDrag(RowHeader rowHeader, UIElement resizeGripper, MouseEventArgs e) { Debug.Assert(rowHeader != null); Debug.Assert(resizeGripper != null); _gridTrack = rowHeader.GridTrackToResize; if (_gridTrack == null) { return(false); } _oldValue = _gridTrack.Length; _rowPresenter = rowHeader.RowPresenter; DragDetect(resizeGripper, e); return(true); }