C# Class SadConsole.Consoles.SurfaceEditor

显示文件 Open project: Thraka/SadConsole Class Usage Examples

Public Properties

Property Type Description
TimesShiftedDown int
TimesShiftedLeft int
TimesShiftedRight int
TimesShiftedUp int
UsePrintProcessor bool

Protected Properties

Property Type Description
textSurface ITextSurface

Private Properties

Property Type Description
PrintNoCheck void

Public Methods

Method Description
Clear ( ) : void

Clears the console data. Characters are reset to 0, the forground and background are set to default, and effect set to none.

Clear ( int x, int y ) : void

Clears a cell. Character is reset to 0, the forground and background is set to default, and effect is set to none.

ClearShiftValues ( ) : void
Fill ( Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background, int glyph, Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffect = null ) : Cell[]

Fills the console.

Fill ( Microsoft.Xna.Framework.Rectangle area, Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background, int glyph, Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffect = null ) : Cell[]

Fills the specified area.

FillWithRandomGarbage ( bool useEffect = false ) : void

Fills a console with random colors and glyphs.

GetBackground ( int x, int y ) : Microsoft.Xna.Framework.Color

Gets the background of a specified cell.

GetCellAppearance ( int x, int y ) : ICellAppearance

Gets the appearance of a cell.

GetEffect ( int x, int y ) : Effects.ICellEffect

Gets the effect of the specified cell.

GetForeground ( int x, int y ) : Microsoft.Xna.Framework.Color

Gets the foreground of a specified cell.

GetGlyph ( int x, int y ) : int

Gets the glyph of a specified cell.

GetSpriteEffect ( int x, int y ) : Microsoft.Xna.Framework.Graphics.SpriteEffects

Gets the sprite effect of a specified cell.

GetString ( int index, int length ) : string

Builds a string from the text surface.

GetString ( int x, int y, int length ) : string

Builds a string from the text surface from the specified coordinates.

GetStringColored ( int index, int length ) : ColoredString

Builds a string from the text surface.

GetStringColored ( int x, int y, int length ) : ColoredString

Builds a string from the text surface from the specified coordinates.

IsValidCell ( int index ) : bool

Tests if a cell is valid based on its index.

IsValidCell ( int x, int y ) : bool

Tests if a cell is valid based on its x,y position.

IsValidCell ( int x, int y, int &index ) : bool

Tests if a cell is valid based on its x,y position.

Print ( int x, int y, ColoredString text ) : void

Draws the string on the console at the specified location, wrapping if needed.

Print ( int x, int y, string text ) : void

Draws the string on the console at the specified location, wrapping if needed.

Print ( int x, int y, string text, ICellAppearance appearance, ICellEffect effect = null ) : void

Draws the string on the console at the specified location, wrapping if needed.

Print ( int x, int y, string text, Microsoft.Xna.Framework.Color foreground ) : void

Draws the string on the console at the specified location and color, wrapping if needed.

Print ( int x, int y, string text, Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background ) : void

Draws the string on the console at the specified location with the specified foreground and background color, wrapping if needed.

Print ( int x, int y, string text, Microsoft.Xna.Framework.Color foreground = null, Microsoft.Xna.Framework.Color background = null, Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffect = null ) : void

Draws the string on the console at the specified location with the specified settings.

SetBackground ( int x, int y, Microsoft.Xna.Framework.Color color ) : void

Changes the background of a cell to the specified color.

SetCellAppearance ( int x, int y, ICellAppearance appearance ) : void

Changes the appearance of the cell. The appearance represents the look of a cell and will first be cloned, then applied to the cell.

SetEffect ( IEnumerable cells, Effects effect ) : void

Changes the effect of a list of cells to the specified effect.

SetEffect ( int index, ICellEffect effect ) : void

Changes the effect of a cell to the specified effect.

SetEffect ( int x, int y, Effects effect ) : void

Changes the effect of a cell to the specified effect.

SetForeground ( int x, int y, Microsoft.Xna.Framework.Color color ) : void

Changes the foreground of a specified cell to a new color.

SetGlyph ( int x, int y, int glyph ) : void

Changes the glyph of a specified cell to a new value.

SetGlyph ( int x, int y, int glyph, Microsoft.Xna.Framework.Color foreground ) : void

Changes the glyph, foreground, and background of a cell.

SetGlyph ( int x, int y, int glyph, Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background ) : void

Changes the glyph, foreground, and background of a cell.

SetGlyph ( int x, int y, int glyph, Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background, ICellEffect effect ) : void

Changes the glyph, foreground, background, and effect of a cell.

SetPixels ( Microsoft.Xna.Framework.Color pixels ) : void

Sets each background of a cell to the array of colors. Must be the same length as this cell surface.

SetSpriteEffect ( int x, int y, Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffect ) : void

Sets the sprite effect of a specified cell.

ShiftDown ( ) : void

Scrolls all the console data down by one.

ShiftDown ( int amount, bool wrap = false ) : void

Scrolls all the console data down by the specified amount of rows.

ShiftLeft ( ) : void

Scrolls all the console data left by one.

ShiftLeft ( int amount, bool wrap = false ) : void

Scrolls all the console data left by the specified amount.

ShiftRight ( ) : void

Scrolls all the console data right by one.

ShiftRight ( int amount, bool wrap = false ) : void

Scrolls all the console data right by the specified amount.

ShiftUp ( ) : void

Scrolls all the console data up by one.

ShiftUp ( int amount, bool wrap = false ) : void

Scrolls all the console data up by the specified amount of rows.

SurfaceEditor ( ITextSurface surface ) : System

Creates a new cell surface that can be resized and also have its textSurface.Cells resized.

You must set the Font property before rendering this cell surface.

this ( int index ) : Cell

Gets a cell by index.

this ( int x, int y ) : Cell

Gets a cell based on it's coordinates on the surface.

Protected Methods

Method Description
OnSurfaceChanged ( ITextSurface oldSurface, ITextSurface newSurface ) : void

Called when the TextSurface property is changed. Sets Effects to a new instance of EffectsManager.

Private Methods

Method Description
PrintNoCheck ( int index, ColoredString text ) : void

Method Details

Clear() public method

Clears the console data. Characters are reset to 0, the forground and background are set to default, and effect set to none.
public Clear ( ) : void
return void

Clear() public method

Clears a cell. Character is reset to 0, the forground and background is set to default, and effect is set to none.
public Clear ( int x, int y ) : void
x int The x location of the cell.
y int The y location of the cell.
return void

ClearShiftValues() public method

public ClearShiftValues ( ) : void
return void

Fill() public method

Fills the console.
public Fill ( Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background, int glyph, Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffect = null ) : Cell[]
foreground Microsoft.Xna.Framework.Color Foregorund of every cell. If null, skips.
background Microsoft.Xna.Framework.Color Foregorund of every cell. If null, skips.
glyph int Glyph of every cell. If null, skips.
spriteEffect Microsoft.Xna.Framework.Graphics.SpriteEffects Sprite effect of every cell. If null, skips.
return Cell[]

Fill() public method

Fills the specified area.
public Fill ( Microsoft.Xna.Framework.Rectangle area, Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background, int glyph, Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffect = null ) : Cell[]
area Microsoft.Xna.Framework.Rectangle The area to fill.
foreground Microsoft.Xna.Framework.Color Foregorund of every cell. If null, skips.
background Microsoft.Xna.Framework.Color Foregorund of every cell. If null, skips.
glyph int Glyph of every cell. If null, skips.
spriteEffect Microsoft.Xna.Framework.Graphics.SpriteEffects Sprite effect of every cell. If null, skips.
return Cell[]

FillWithRandomGarbage() public method

Fills a console with random colors and glyphs.
public FillWithRandomGarbage ( bool useEffect = false ) : void
useEffect bool
return void

GetBackground() public method

Gets the background of a specified cell.
public GetBackground ( int x, int y ) : Microsoft.Xna.Framework.Color
x int The x location of the cell.
y int The y location of the cell.
return Microsoft.Xna.Framework.Color

GetCellAppearance() public method

Gets the appearance of a cell.
public GetCellAppearance ( int x, int y ) : ICellAppearance
x int The x location of the cell.
y int The y location of the cell.
return ICellAppearance

GetEffect() public method

Gets the effect of the specified cell.
public GetEffect ( int x, int y ) : Effects.ICellEffect
x int The x location of the cell.
y int The y location of the cell.
return Effects.ICellEffect

GetForeground() public method

Gets the foreground of a specified cell.
public GetForeground ( int x, int y ) : Microsoft.Xna.Framework.Color
x int The x location of the cell.
y int The y location of the cell.
return Microsoft.Xna.Framework.Color

GetGlyph() public method

Gets the glyph of a specified cell.
public GetGlyph ( int x, int y ) : int
x int The x location of the cell.
y int The y location of the cell.
return int

GetSpriteEffect() public method

Gets the sprite effect of a specified cell.
public GetSpriteEffect ( int x, int y ) : Microsoft.Xna.Framework.Graphics.SpriteEffects
x int The x location of the cell.
y int The y location of the cell.
return Microsoft.Xna.Framework.Graphics.SpriteEffects

GetString() public method

Builds a string from the text surface.
public GetString ( int index, int length ) : string
index int Where to start getting characters from.
length int How many characters to fill the string with.
return string

GetString() public method

Builds a string from the text surface from the specified coordinates.
public GetString ( int x, int y, int length ) : string
x int The x position of the surface to start at.
y int The y position of the surface to start at.
length int How many characters to fill the string with.
return string

GetStringColored() public method

Builds a string from the text surface.
public GetStringColored ( int index, int length ) : ColoredString
index int Where to start getting characters from.
length int How many characters to fill the string with.
return ColoredString

GetStringColored() public method

Builds a string from the text surface from the specified coordinates.
public GetStringColored ( int x, int y, int length ) : ColoredString
x int The x position of the surface to start at.
y int The y position of the surface to start at.
length int How many characters to fill the string with.
return ColoredString

IsValidCell() public method

Tests if a cell is valid based on its index.
public IsValidCell ( int index ) : bool
index int The index to test.
return bool

IsValidCell() public method

Tests if a cell is valid based on its x,y position.
public IsValidCell ( int x, int y ) : bool
x int The x coordinate of the cell to test.
y int The y coordinate of the cell to test.
return bool

IsValidCell() public method

Tests if a cell is valid based on its x,y position.
public IsValidCell ( int x, int y, int &index ) : bool
x int The x coordinate of the cell to test.
y int The y coordinate of the cell to test.
index int If the cell is valid, the index of the cell when found.
return bool

OnSurfaceChanged() protected method

Called when the TextSurface property is changed. Sets Effects to a new instance of EffectsManager.
protected OnSurfaceChanged ( ITextSurface oldSurface, ITextSurface newSurface ) : void
oldSurface ITextSurface The previous text surface.
newSurface ITextSurface The new text surface.
return void

Print() public method

Draws the string on the console at the specified location, wrapping if needed.
public Print ( int x, int y, ColoredString text ) : void
x int X location of the text.
y int Y location of the text.
text ColoredString The string to display.
return void

Print() public method

Draws the string on the console at the specified location, wrapping if needed.
public Print ( int x, int y, string text ) : void
x int X location of the text.
y int Y location of the text.
text string The string to display.
return void

Print() public method

Draws the string on the console at the specified location, wrapping if needed.
public Print ( int x, int y, string text, ICellAppearance appearance, ICellEffect effect = null ) : void
x int X location of the text.
y int Y location of the text.
text string The string to display.
appearance ICellAppearance The appearance of the cell
effect ICellEffect An optional effect to apply to the printed cells.
return void

Print() public method

Draws the string on the console at the specified location and color, wrapping if needed.
public Print ( int x, int y, string text, Microsoft.Xna.Framework.Color foreground ) : void
x int X location of the text.
y int Y location of the text.
text string The string to display.
foreground Microsoft.Xna.Framework.Color Sets the foreground of all characters in the text.
return void

Print() public method

Draws the string on the console at the specified location with the specified foreground and background color, wrapping if needed.
public Print ( int x, int y, string text, Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background ) : void
x int X location of the text.
y int Y location of the text.
text string The string to display.
foreground Microsoft.Xna.Framework.Color Sets the foreground of all characters in the text.
background Microsoft.Xna.Framework.Color Sets the background of all characters in the text.
return void

Print() public method

Draws the string on the console at the specified location with the specified settings.
public Print ( int x, int y, string text, Microsoft.Xna.Framework.Color foreground = null, Microsoft.Xna.Framework.Color background = null, Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffect = null ) : void
x int X location of the text.
y int Y location of the text.
text string The string to display.
foreground Microsoft.Xna.Framework.Color Sets the foreground of all characters in the text.
background Microsoft.Xna.Framework.Color Sets the background of all characters in the text.
spriteEffect Microsoft.Xna.Framework.Graphics.SpriteEffects The sprite effect to set on the cell.
return void

SetBackground() public method

Changes the background of a cell to the specified color.
public SetBackground ( int x, int y, Microsoft.Xna.Framework.Color color ) : void
x int The x location of the cell.
y int The y location of the cell.
color Microsoft.Xna.Framework.Color The desired color of the cell.
return void

SetCellAppearance() public method

Changes the appearance of the cell. The appearance represents the look of a cell and will first be cloned, then applied to the cell.
public SetCellAppearance ( int x, int y, ICellAppearance appearance ) : void
x int The x location of the cell.
y int The y location of the cell.
appearance ICellAppearance The desired appearance of the cell. A null value cannot be passed.
return void

SetEffect() public method

Changes the effect of a list of cells to the specified effect.
public SetEffect ( IEnumerable cells, Effects effect ) : void
cells IEnumerable The cells for the effect.
effect Effects The desired effect.
return void

SetEffect() public method

Changes the effect of a cell to the specified effect.
public SetEffect ( int index, ICellEffect effect ) : void
index int Index of the cell.
effect ICellEffect The desired effect.
return void

SetEffect() public method

Changes the effect of a cell to the specified effect.
public SetEffect ( int x, int y, Effects effect ) : void
x int The x location of the cell.
y int The y location of the cell.
effect Effects The desired effect.
return void

SetForeground() public method

Changes the foreground of a specified cell to a new color.
public SetForeground ( int x, int y, Microsoft.Xna.Framework.Color color ) : void
x int The x location of the cell.
y int The y location of the cell.
color Microsoft.Xna.Framework.Color The desired color of the cell.
return void

SetGlyph() public method

Changes the glyph of a specified cell to a new value.
public SetGlyph ( int x, int y, int glyph ) : void
x int The x location of the cell.
y int The y location of the cell.
glyph int The desired glyph of the cell.
return void

SetGlyph() public method

Changes the glyph, foreground, and background of a cell.
public SetGlyph ( int x, int y, int glyph, Microsoft.Xna.Framework.Color foreground ) : void
x int The x location of the cell.
y int The y location of the cell.
glyph int The desired glyph.
foreground Microsoft.Xna.Framework.Color The desired foreground.
return void

SetGlyph() public method

Changes the glyph, foreground, and background of a cell.
public SetGlyph ( int x, int y, int glyph, Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background ) : void
x int The x location of the cell.
y int The y location of the cell.
glyph int The desired glyph.
foreground Microsoft.Xna.Framework.Color The desired foreground.
background Microsoft.Xna.Framework.Color The desired background.
return void

SetGlyph() public method

Changes the glyph, foreground, background, and effect of a cell.
public SetGlyph ( int x, int y, int glyph, Microsoft.Xna.Framework.Color foreground, Microsoft.Xna.Framework.Color background, ICellEffect effect ) : void
x int The x location of the cell.
y int The y location of the cell.
glyph int The desired glyph.
foreground Microsoft.Xna.Framework.Color The desired foreground.
background Microsoft.Xna.Framework.Color The desired background.
effect ICellEffect Sets the effect of the cell
return void

SetPixels() public method

Sets each background of a cell to the array of colors. Must be the same length as this cell surface.
public SetPixels ( Microsoft.Xna.Framework.Color pixels ) : void
pixels Microsoft.Xna.Framework.Color The colors to place.
return void

SetSpriteEffect() public method

Sets the sprite effect of a specified cell.
public SetSpriteEffect ( int x, int y, Microsoft.Xna.Framework.Graphics.SpriteEffects spriteEffect ) : void
x int The x location of the cell.
y int The y location of the cell.
spriteEffect Microsoft.Xna.Framework.Graphics.SpriteEffects The sprite effect of the cell.
return void

ShiftDown() public method

Scrolls all the console data down by one.
public ShiftDown ( ) : void
return void

ShiftDown() public method

Scrolls all the console data down by the specified amount of rows.
public ShiftDown ( int amount, bool wrap = false ) : void
amount int How many rows to shift.
wrap bool
return void

ShiftLeft() public method

Scrolls all the console data left by one.
public ShiftLeft ( ) : void
return void

ShiftLeft() public method

Scrolls all the console data left by the specified amount.
public ShiftLeft ( int amount, bool wrap = false ) : void
amount int How much to scroll.
wrap bool
return void

ShiftRight() public method

Scrolls all the console data right by one.
public ShiftRight ( ) : void
return void

ShiftRight() public method

Scrolls all the console data right by the specified amount.
public ShiftRight ( int amount, bool wrap = false ) : void
amount int How much to scroll.
wrap bool
return void

ShiftUp() public method

Scrolls all the console data up by one.
public ShiftUp ( ) : void
return void

ShiftUp() public method

Scrolls all the console data up by the specified amount of rows.
public ShiftUp ( int amount, bool wrap = false ) : void
amount int How many rows to shift.
wrap bool
return void

SurfaceEditor() public method

Creates a new cell surface that can be resized and also have its textSurface.Cells resized.
You must set the Font property before rendering this cell surface.
public SurfaceEditor ( ITextSurface surface ) : System
surface ITextSurface
return System

this() public method

Gets a cell by index.
public this ( int index ) : Cell
index int The index of the cell.
return Cell

this() public method

Gets a cell based on it's coordinates on the surface.
public this ( int x, int y ) : Cell
x int The X coordinate.
y int The Y coordinate.
return Cell

Property Details

TimesShiftedDown public_oe property

public int TimesShiftedDown
return int

TimesShiftedLeft public_oe property

public int TimesShiftedLeft
return int

TimesShiftedRight public_oe property

public int TimesShiftedRight
return int

TimesShiftedUp public_oe property

public int TimesShiftedUp
return int

UsePrintProcessor public_oe property

When true, the ColoredString.Parse(string, int, ITextSurface, ParseCommandStacks) command is used to print strings.
public bool UsePrintProcessor
return bool

textSurface protected_oe property

protected ITextSurface textSurface
return ITextSurface