/// <summary> /// Resizes the TextMap to a specified size and returns it /// </summary> /// <param name="width">Width to resize to</param> /// <param name="height">Height to resize to</param> public TextMap Resize(int width, int height) { // first, if both dimensions are smaller than the current ones, return a clipped version if (width <= Width && height <= Height) { return(InternalClip(width, height)); } // if both dimensions are bigger, return an expanded version if (width > Width && height > Height) { return(ExpandWithWhiteSpace(width, height)); } // if the width is bigger but the height is smaller, expand it, then clip it if (width > Width && height <= Height) { TextMap xMap = this.ExpandWithWhiteSpace(Width, height); return(xMap.InternalClip(width, height)); } // if the width is smaller but the height it bigger, do the above if (width <= Width && height > Height) { TextMap xMap = this.ExpandWithWhiteSpace(width, Height); return(xMap.InternalClip(width, height)); } // this code should not be run: throw an exception throw new Exception("This code should not be run!"); }
public static TextLayer CompileLayer(TextLayer layer) { char[][] data = layer.Data; char[][] flippeddata; if (layer.XYView) { flippeddata = new char[data.Length][]; for (int j = 0; j < data.Length; j++) { flippeddata [0] = new char[data [0].Length]; } for (int k = 0; k < data.Length; k++) { for (int l = data [0].Length - 1; l >= 0; l--) { int x = k; int y = data [0].Length - 1; y -= l; flippeddata [x] [y] = data [k] [l]; } } } else { flippeddata = data; } TextLayer nLayer = new TextLayer(layer.Width, layer.Height, layer.xyView); TextMap nMap = new TextMap(flippeddata); nLayer.AppendMap(nMap); return(nLayer); }
protected override TextMap internalClone() { TextLayer tl = new TextLayer(Width, Height); TextMap tm = base.internalClone(); tl.AppendMap(tm); return(tl); }
protected virtual TextMap internalClone() { TextMap tm = new TextMap(Width, Height); for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { tm.data [i] [j] = data [i] [j]; } } return(tm); }
/*public TextLayer (Size size) : this(size.Width, size.Height) { * }*/ /// <summary> /// Appends a TextMap to this TextLater /// </summary> /// <returns>True if the map had to be clipped</returns> /// <param name="map">TextMap.</param> /// <param name="applyMode">Apply mode.</param> /// <param name="appendSpaces">If set to <c>true</c> append spaces.</param> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> /// <param name="width">Width.</param> /// <param name="height">Height.</param> public bool AppendMap(TextMap map, TextMapApplyMode applyMode, bool appendSpaces, int x, int y, int width, int height) { TextMap subj = map.Clip(width, height); bool forcedClip = false; char[][] data = Data; for (int i = x; i < width; i++) { int k = i - x; for (int j = y; j < height; j++) { int l = j - y; try { if (!appendSpaces && subj.Data[k][l] == ' ') { continue; } if (applyMode == TextMapApplyMode.OverwriteAll) { data[i][j] = subj.Data[k][l]; } else if (applyMode == TextMapApplyMode.OverwriteSpacesOnly && data[i][j] == ' ') { data[i][j] = subj.Data[k][l]; } else if (applyMode == TextMapApplyMode.OverwriteCharsOnly && data[i][j] != ' ') { data[i][j] = subj.Data[k][l]; } } catch (ArgumentOutOfRangeException) { forcedClip = true; continue; } } } Data = data; return(forcedClip); }
/// <summary> /// Appends a TextMap to this TextLater /// </summary> /// <returns>True if the map had to be clipped</returns> /// <param name="map">TextMap.</param> public bool AppendMap(TextMap map) { return(AppendMap(map, TextMapApplyMode.OverwriteAll)); }
/// <summary> /// Appends a TextMap to this TextLater /// </summary> /// <returns>True if the map had to be clipped</returns> /// <param name="map">TextMap.</param> /// <param name="applyMode">Apply mode.</param> public bool AppendMap(TextMap map, TextMapApplyMode applyMode) { return(AppendMap(map, applyMode, false)); }
/* * public bool AppendMap(TextMap map, TextMapApplyMode applyMode, bool appendSpaces, Rectangle rect) { * return AppendMap (map, applyMode, appendSpaces, rect.Location, rect.Size); * } */ /// <summary> /// Appends a TextMap to this TextLater /// </summary> /// <returns>True if the map had to be clipped</returns> /// <param name="map">TextMap.</param> /// <param name="applyMode">Apply mode.</param> /// <param name="appendSpaces">If set to <c>true</c> append spaces.</param> public bool AppendMap(TextMap map, TextMapApplyMode applyMode, bool appendSpaces) { return(AppendMap(map, applyMode, appendSpaces, 0, 0, map.Size.Width, map.Size.Height)); }
/*public bool AppendMap(TextMap map, TextMapApplyMode applyMode, bool appendSpaces, Point point, Size size) { * return AppendMap (map, applyMode, appendSpaces, point.X, point.Y, size.Width, size.Height); * }*/ /* * public bool AppendMap(TextMap map, TextMapApplyMode applyMode, bool appendSpaces, Point point) { * return AppendMap (map, applyMode, appendSpaces, point, map.Size); * }*/ /// <summary> /// Appends a TextMap to this TextLater /// </summary> /// <returns>True if the map had to be clipped</returns> /// <param name="map">TextMap.</param> /// <param name="applyMode">Apply mode.</param> /// <param name="appendSpaces">If set to <c>true</c> append spaces.</param> /// <param name="x">The x coordinate.</param> /// <param name="y">The y coordinate.</param> public bool AppendMap(TextMap map, TextMapApplyMode applyMode, bool appendSpaces, int x, int y) { return(AppendMap(map, applyMode, appendSpaces, x, y, map.Width, map.Height)); }