本文整理汇总了C#中Cairo.Context.ShowText方法的典型用法代码示例。如果您正苦于以下问题:C# Context.ShowText方法的具体用法?C# Context.ShowText怎么用?C# Context.ShowText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cairo.Context
的用法示例。
在下文中一共展示了Context.ShowText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Image_Loaded
private void Image_Loaded(object sender, RoutedEventArgs e)
{
Image image = (Image)sender;
using (ImageSurface surface = new ImageSurface(Format.Argb32, (int)image.Width, (int)image.Height))
{
using (Context context = new Context(surface))
{
PointD p = new PointD(10.0, 10.0);
PointD p2 = new PointD(100.0, 10.0);
PointD p3 = new PointD(100.0, 100.0);
PointD p4 = new PointD(10.0, 100.0);
context.MoveTo(p);
context.LineTo(p2);
context.LineTo(p3);
context.LineTo(p4);
context.LineTo(p);
context.ClosePath();
context.Fill();
context.MoveTo(140.0, 110.0);
context.SetFontSize(32.0);
context.SetSourceColor(new Color(0.0, 0.0, 0.8, 1.0));
context.ShowText("Hello Cairo!");
surface.Flush();
RgbaBitmapSource source = new RgbaBitmapSource(surface.Data, surface.Width);
image.Source = source;
}
}
}
示例2: DrawGraph
public void DrawGraph(Context gr)
{
int mag = Magnification;
double xoffset = (Allocation.Width/2) ;
double yoffset = (Allocation.Height/2) ;
if (ForceGraph != null) {
this.GdkWindow.Clear ();
gr.Antialias = Antialias.Subpixel;
foreach (var p in ForceGraph.Springs){
gr.LineWidth = 1.5;
if ( p.Data != null ){
var data = p.Data as NodeData;
if ( data != null )
gr.Color = data.Stroke;
} else {
gr.Color = new Color( 0,0,0,1);
}
gr.MoveTo( xoffset + ( p.NodeA.Location.X * mag ), yoffset + ( p.NodeA.Location.Y * mag ) );
gr.LineTo( xoffset + ( p.NodeB.Location.X * mag ), yoffset + ( p.NodeB.Location.Y * mag ) );
gr.Stroke();
}
foreach (var n in ForceGraph.Nodes) {
var stroke = new Color( 0.1, 0.1, 0.1, 0.8 );
var fill = new Color( 0.2, 0.7, 0.7, 0.8 );
var size = 5.5;
NodeData nd = n.Data as NodeData;
if ( nd != null ){
stroke = nd.Stroke;
fill = nd.Fill;
size = nd.Size;
}
DrawFilledCircle (gr,
xoffset + (mag * n.Location.X),
yoffset + (mag * n.Location.Y),
size,
stroke,
fill
);
if ( nd != null ) {
if ( nd.Label != null ){
gr.Color = new Color(0,0,0,0.7);
gr.SetFontSize(24);
gr.MoveTo( 25 + xoffset + (mag * n.Location.X), 25 + yoffset + (mag * n.Location.Y));
gr.ShowText( nd.Label );
}
}
}
}
}
示例3: CreatePng
public void CreatePng ()
{
const int Width = 480;
const int Height = 160;
const int CheckSize = 10;
const int Spacing = 2;
// Create an Image-based surface with data stored in ARGB32 format and a context,
// "using" is used here to ensure that they are Disposed once we are done
using (ImageSurface surface = new ImageSurface (Format.ARGB32, Width, Height))
using (Context cr = new Cairo.Context (surface))
{
// Start drawing a checkerboard
int i, j, xcount, ycount;
xcount = 0;
i = Spacing;
while (i < Width) {
j = Spacing;
ycount = xcount % 2; // start with even/odd depending on row
while (j < Height) {
if (ycount % 2 != 0)
cr.SetSourceRGB (1, 0, 0);
else
cr.SetSourceRGB (1, 1, 1);
// If we're outside the clip, this will do nothing.
cr.Rectangle (i, j, CheckSize, CheckSize);
cr.Fill ();
j += CheckSize + Spacing;
++ycount;
}
i += CheckSize + Spacing;
++xcount;
}
// Select a font to draw with
cr.SelectFontFace ("serif", FontSlant.Normal, FontWeight.Bold);
cr.SetFontSize (64.0);
// Select a color (blue)
cr.SetSourceRGB (0, 0, 1);
// Draw
cr.MoveTo (20, 100);
cr.ShowText ("Hello, World");
surface.WriteToPng ("test.png");
}
}
示例4: paintNodes
private void paintNodes(Context ctx, int w, int h, IEnumerable<Node> nodes)
{
ctx.LineWidth = 2.0d;
foreach(Node node in nodes) {
PointD abs = new PointD(node.Item2.X*w, node.Item2.Y*h);
ctx.Arc(abs.X, abs.Y, AlgorithmRadius, 0.0d, 2.0d*Math.PI);
ctx.ClosePath();
ctx.NewSubPath();
ctx.Arc(abs.X, abs.Y, AlgorithmRadius-BlueprintStyle.Thickness, 0.0d, 2.0d*Math.PI);
ctx.ClosePath();
ctx.NewSubPath();
}
ctx.Pattern = BlueprintStyle.FillPattern;
ctx.FillPreserve();
ctx.Color = BlueprintStyle.HardWhite;
ctx.Stroke();
double r_2, dx, dy;
this.nodeCenters.Clear();
foreach(Node node in nodes) {
PointD abs = new PointD(node.Item2.X*w, node.Item2.Y*h);
this.nodeCenters.Add(abs);
TextExtents te = ctx.TextExtents(node.Item1);
r_2 = (AlgorithmRadius-BlueprintStyle.Thickness)/Math.Sqrt(te.Width*te.Width+te.Height*te.Height);
ctx.Save();
ctx.MoveTo(abs.X-r_2*te.Width, abs.Y+r_2*te.Height);
ctx.Scale(2.0d*r_2, 2.0d*r_2);
ctx.ShowText(node.Item1);
ctx.Restore();
}
}
示例5: text
public void text(Context cr, int width, int height)
{
Normalize (cr, width, height);
cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Bold);
cr.SetFontSize(0.35);
cr.MoveTo(0.04, 0.53);
cr.ShowText("Hello");
cr.MoveTo(0.27, 0.65);
cr.TextPath("void");
cr.Save();
cr.Color = new Color (0.5,0.5,1);
cr.Fill();
cr.Restore();
cr.LineWidth = 0.01;
cr.Stroke();
// draw helping lines
cr.Color = new Color (1.0, 0.2, 0.2, 0.6);
cr.Arc(0.04, 0.53, 0.02, 0, 2*Math.PI);
cr.Arc(0.27, 0.65, 0.02, 0, 2*Math.PI);
cr.Fill();
}
示例6: OnExpose
public bool OnExpose (Context ctx, Gdk.Rectangle allocation)
{
if (frames == 0)
start = DateTime.UtcNow;
frames ++;
TimeSpan elapsed = DateTime.UtcNow - start;
double fraction = elapsed.Ticks / (double) duration.Ticks;
double opacity = Math.Sin (Math.Min (fraction, 1.0) * Math.PI * 0.5);
ctx.Operator = Operator.Source;
SurfacePattern p = new SurfacePattern (begin_buffer.Surface);
ctx.Matrix = begin_buffer.Fill (allocation);
p.Filter = Filter.Fast;
ctx.Source = p;
ctx.Paint ();
ctx.Operator = Operator.Over;
ctx.Matrix = end_buffer.Fill (allocation);
SurfacePattern sur = new SurfacePattern (end_buffer.Surface);
Pattern black = new SolidPattern (new Cairo.Color (0.0, 0.0, 0.0, opacity));
//ctx.Source = black;
//ctx.Fill ();
sur.Filter = Filter.Fast;
ctx.Source = sur;
ctx.Mask (black);
//ctx.Paint ();
ctx.Matrix = new Matrix ();
ctx.MoveTo (allocation.Width / 2.0, allocation.Height / 2.0);
ctx.Source = new SolidPattern (1.0, 0, 0);
#if debug
ctx.ShowText (String.Format ("{0} {1} {2} {3} {4} {5} {6} {7}",
frames,
sur.Status,
p.Status,
opacity, fraction, elapsed, start, DateTime.UtcNow));
#endif
sur.Destroy ();
p.Destroy ();
return fraction < 1.0;
}
示例7: DrawLineInfo
protected void DrawLineInfo(Context g, HChartLine line, int index)
{
g.MoveTo (NumberSpacingXLeft+15, NumberSpacingYUp+15 + index * 15);
g.LineTo (NumberSpacingXLeft+25, NumberSpacingYUp+15 + index * 15);
line.UseColor (g);
g.LineWidth = 11;
g.Stroke ();
g.MoveTo (NumberSpacingXLeft+26, NumberSpacingYUp+20 + index * 15);
g.SetSourceRGBA (0, 0, 0, 0.5f);
g.ShowText (line.GetName ());
}
示例8: DrawVerticalReferenceLines
protected void DrawVerticalReferenceLines(Context g, Gdk.Rectangle area, float xSize, float xTranslation)
{
for (int i = 0; i <= NumbersX; i++) {
float actualLoc = i * (area.Width - numberSpacingXTotal) / NumbersX + NumberSpacingXLeft;
String text = (xTranslation+i*xSize/NumbersX).ToString ("0.0");
g.MoveTo (actualLoc - g.TextExtents (text).Width / 2, area.Height - 5);
g.ShowText (text);
g.MoveTo (actualLoc, area.Height - NumberSpacingYDown);
g.LineTo (actualLoc, NumberSpacingYUp);
g.Stroke ();
}
}
示例9: GenerateStub
private ImageSurface GenerateStub()
{
ImageSurface stub = new ImageSurface (Format.ARGB32, 600, 300);
Context cairo = new Context(stub);
cairo.IdentityMatrix ();
cairo.Scale (600,300);
cairo.Rectangle (0, 0, 1, 1);
cairo.SetSourceRGB (1,1,1);
cairo.Fill ();
cairo.MoveTo (0.14, 0.5);
cairo.SetFontSize (0.08);
cairo.SetSourceRGB (0, 0, 0);
cairo.ShowText ("Загрузите подложку");
cairo.Dispose ();
return stub;
}
示例10: onDraw
//.........这里部分代码省略.........
rText.X = cb.X;
rText.Y = cb.Y;
} else {
if (horizontalStretch) {
widthRatio = (float)cb.Width / rText.Width;
if (!verticalStretch)
heightRatio = widthRatio;
}
if (verticalStretch) {
heightRatio = (float)cb.Height / rText.Height;
if (!horizontalStretch)
widthRatio = heightRatio;
}
rText.Width = (int)(widthRatio * cb.Width);
rText.Height = (int)(heightRatio * cb.Height);
switch (TextAlignment) {
case Alignment.TopLeft: //ok
rText.X = cb.X;
rText.Y = cb.Y;
break;
case Alignment.Top: //ok
rText.Y = cb.Y;
rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
break;
case Alignment.TopRight: //ok
rText.Y = cb.Y;
rText.X = cb.Right - rText.Width;
break;
case Alignment.Left://ok
rText.X = cb.X;
rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
break;
case Alignment.Right://ok
rText.X = cb.X + cb.Width - rText.Width;
rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
break;
case Alignment.Bottom://ok
rText.X = cb.Width / 2 - rText.Width / 2;
rText.Y = cb.Height - rText.Height;
break;
case Alignment.BottomLeft://ok
rText.X = cb.X;
rText.Y = cb.Bottom - rText.Height;
break;
case Alignment.BottomRight://ok
rText.Y = cb.Bottom - rText.Height;
rText.X = cb.Right - rText.Width;
break;
case Alignment.Center://ok
rText.X = cb.X + cb.Width / 2 - rText.Width / 2;
rText.Y = cb.Y + cb.Height / 2 - rText.Height / 2;
break;
}
}
gr.FontMatrix = new Matrix (widthRatio * Font.Size, 0, 0, heightRatio * Font.Size, 0, 0);
int curLineCount = 0;
for (int i = 0; i < lines.Count; i++) {
string l = lines [i].Replace ("\t", new String (' ', Interface.TabSize));
List<string> wl = new List<string> ();
int lineLength = (int)gr.TextExtents (l).XAdvance;
if (wordWrap && lineLength > cb.Width) {
string tmpLine = "";
int curChar = 0;
while (curChar < l.Length) {
tmpLine += l [curChar];
if ((int)gr.TextExtents (tmpLine).XAdvance > cb.Width) {
tmpLine = tmpLine.Remove (tmpLine.Length - 1);
wl.Add (tmpLine);
tmpLine = "";
continue;
}
curChar++;
}
wl.Add (tmpLine);
} else
wl.Add (l);
foreach (string ll in wl) {
lineLength = (int)gr.TextExtents (ll).XAdvance;
if (string.IsNullOrWhiteSpace (ll)) {
curLineCount++;
continue;
}
Foreground.SetAsSource (gr);
gr.MoveTo (rText.X, rText.Y + fe.Ascent + fe.Height * curLineCount);
gr.ShowText (ll);
gr.Fill ();
curLineCount++;
}
}
}
示例11: onDraw
//.........这里部分代码省略.........
if (SelectionInProgress)
{
if (SelBegin < 0){
SelBegin = new Point(CurrentColumn, CurrentLine);
SelStartCursorPos = textCursorPos;
SelRelease = -1;
}else{
SelRelease = new Point(CurrentColumn, CurrentLine);
if (SelRelease == SelBegin)
SelRelease = -1;
else
SelEndCursorPos = textCursorPos;
}
}
}else
computeTextCursorPosition(gr);
Foreground.SetAsSource (gr);
gr.LineWidth = 1.0;
gr.MoveTo (0.5 + textCursorPos + rText.X, rText.Y + CurrentLine * fe.Height);
gr.LineTo (0.5 + textCursorPos + rText.X, rText.Y + (CurrentLine + 1) * fe.Height);
gr.Stroke();
}
#endregion
//****** debug selection *************
// if (SelRelease >= 0) {
// gr.Color = Color.Green;
// Rectangle R = new Rectangle (
// rText.X + (int)SelEndCursorPos - 2,
// rText.Y + (int)(SelRelease.Y * fe.Height),
// 4,
// (int)fe.Height);
// gr.Rectangle (R);
// gr.Fill ();
// }
// if (SelBegin >= 0) {
// gr.Color = Color.UnmellowYellow;
// Rectangle R = new Rectangle (
// rText.X + (int)SelStartCursorPos - 2,
// rText.Y + (int)(SelBegin.Y * fe.Height),
// 4,
// (int)fe.Height);
// gr.Rectangle (R);
// gr.Fill ();
// }
//*******************
for (int i = 0; i < lines.Count; i++) {
string l = lines [i].Replace ("\t", new String (' ', Interface.TabSize));
int lineLength = (int)gr.TextExtents (l).XAdvance;
Rectangle lineRect = new Rectangle (
rText.X,
rText.Y + (int)Math.Ceiling(i * fe.Height),
lineLength,
(int)Math.Ceiling(fe.Height));
// if (TextAlignment == Alignment.Center ||
// TextAlignment == Alignment.Top ||
// TextAlignment == Alignment.Bottom)
// lineRect.X += (rText.Width - lineLength) / 2;
// else if (TextAlignment == Alignment.Right ||
// TextAlignment == Alignment.TopRight ||
// TextAlignment == Alignment.BottomRight)
// lineRect.X += (rText.Width - lineLength);
if (Selectable) {
if (SelRelease >= 0 && i >= selectionStart.Y && i <= selectionEnd.Y) {
gr.SetSourceColor (selBackground);
Rectangle selRect = lineRect;
int cpStart = (int)SelStartCursorPos,
cpEnd = (int)SelEndCursorPos;
if (SelBegin.Y > SelRelease.Y) {
cpStart = cpEnd;
cpEnd = (int)SelStartCursorPos;
}
if (i == selectionStart.Y) {
selRect.Width -= cpStart;
selRect.Left += cpStart;
}
if (i == selectionEnd.Y)
selRect.Width -= (lineLength - cpEnd);
gr.Rectangle (selRect);
gr.Fill ();
}
}
if (string.IsNullOrWhiteSpace (l))
continue;
Foreground.SetAsSource (gr);
gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i);
gr.ShowText (l);
gr.Fill ();
}
}
示例12: DrawText
private void DrawText(Context cr, string text, int x, int y)
{
cr.SetSourceRGBA(0.0, 0.0, 0.0, 0.1);
int dx = 3, dy = 4;
cr.MoveTo(x-1+dx, y-1+dy);
cr.ShowText(text);
cr.MoveTo(x+1+dx, y+1+dy);
cr.ShowText(text);
cr.MoveTo(x-1+dx, y+1+dy);
cr.ShowText(text);
cr.MoveTo(x+1+dx, y-1+dy);
cr.ShowText(text);
Gdk.Color c = textcolor;
double b = (double)c.Blue / ushort.MaxValue;
double g = (double)c.Green / ushort.MaxValue;
double r = (double)c.Red / ushort.MaxValue;
if(b>1) b = 1;
if(g>1) g = 1;
if(r>1) r = 1;
cr.SetSourceRGBA(b,g,r, 1);
cr.MoveTo(x, y);
cr.Antialias = Antialias.Default;
cr.ShowText(text);
}
示例13: OnExposed
protected override bool OnExposed(Context cr, Rectangle area)
{
cr.Save();
if(!base.OnExposed(cr, area))
{
cr.Color = new Color(1.0, 0.0, 0.0);
cr.SetFontSize(100.0);
cr.SelectFontFace("Librarian", FontSlant.Normal, FontWeight.Bold);
cr.ShowText(type.ToString());
cr.Restore();
return true;
}
cr.Restore();
if(type != CardType.Unknown)
{
ApplyConstriction(cr);
double ratio = Allocation.Height / Card.DefaultHeight;
cr.Scale(ratio, ratio);
cr.Translate(RankOffsetX, RankOffsetY);
Pango.CairoHelper.ShowLayout(cr, layout);
cr.LineWidth = 2.0;
cr.Color = new Color(1, 1, 1);
cr.LineCap = LineCap.Butt;
cr.LineJoin = LineJoin.Round;
Pango.CairoHelper.LayoutPath(cr, layout);
cr.Stroke();
}
return true;
}
示例14: DrawOnHandPieces
private void DrawOnHandPieces(Context cr, Position pos, bool BlackPlayer)
{
cr.Save();
cr.Rectangle(0, 0, ON_HAND_AREA_WIDTH, 9 * FIELD_SIZE + 2 * FIELD_NAMING_SIZE);
cr.Color = BorderColor;
cr.FillPreserve();
cr.Color = new Color(0.6, 0.5, 0.55);
cr.LineWidth = 3;
cr.Stroke();
if (BlackPlayer)
{
cr.Translate(0, 8 * FIELD_SIZE + 2 * FIELD_NAMING_SIZE);
}
for (int i = 0; i < (int)PieceType.PIECE_TYPES_COUNT; i++)
{
int player_nr = BlackPlayer ? 0 : 1;
if (pos.OnHandPieces[player_nr, i] != 0)
{
//highlight selected piece
if (gi != null && gi.localPlayerMoveState != LocalPlayerMoveState.Wait
&& gi.localPlayerMoveState != LocalPlayerMoveState.PickSource
&& gi.GetLocalPlayerMove().OnHandPiece != PieceType.NONE
&& gi.GetLocalPlayerMove().OnHandPiece == (PieceType)i
&& !((gi.CurPlayer == gi.BlackPlayer) ^ BlackPlayer))
{
cr.Rectangle(0, 0, FIELD_SIZE, FIELD_SIZE);
cr.Color = new Color(0.8, 0.835, 0.4);
cr.Fill();
}
//draw piece
cr.Save();
if (!BlackPlayer)
{
cr.Rotate(180 * Math.PI / 180);
cr.Translate(-FIELD_SIZE, -FIELD_SIZE);
}
cr.Scale(FIELD_SIZE / PieceGraphics[i].Dimensions.Width, FIELD_SIZE / PieceGraphics[i].Dimensions.Width);
PieceGraphics[i].RenderCairo(cr);
cr.Restore();
//draw amount
cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
cr.SetFontSize(FIELD_SIZE / 3 * 0.9);
cr.Color = new Color(0, 0, 0);
String amount_str = "x " + pos.OnHandPieces[player_nr, i].ToString();
TextExtents extents = cr.TextExtents(amount_str);
double x = (FIELD_SIZE);
// - (extents.Width/2 + extents.XBearing);
double y = (FIELD_SIZE / 2) - (extents.Height / 2 + extents.YBearing);
cr.MoveTo(x, y);
cr.ShowText(amount_str);
double offset = BlackPlayer ? -FIELD_SIZE - PADDING : FIELD_SIZE + PADDING;
cr.Translate(0, offset);
}
}
cr.Restore();
}
示例15: DrawBoard
private void DrawBoard(Context cr, Position pos)
{
Console.WriteLine("ShogibanSVG.DrawBoard");
#region board border
//Top
cr.Rectangle(0, 0, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
//Left
cr.Rectangle(0, 0, FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE);
//Bottom
cr.Rectangle(0, Game.BOARD_SIZE * FIELD_SIZE + FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
//Right
cr.Rectangle(9*FIELD_SIZE + FIELD_NAMING_SIZE, 0, FIELD_NAMING_SIZE, Game.BOARD_SIZE * FIELD_SIZE + 2*FIELD_NAMING_SIZE);
cr.Color = BorderColor;
cr.Fill();
#endregion
#region field namings
cr.SelectFontFace("Sans", FontSlant.Normal, FontWeight.Normal);
cr.SetFontSize(FIELD_NAMING_SIZE * 0.9);
cr.Color = new Color(0, 0, 0);
for (int i = 0; i < VerticalNamings.Length; i++)
{
TextExtents extents = cr.TextExtents(VerticalNamings[i].ToString());
double x = (FIELD_NAMING_SIZE/2) - (extents.Width/2 + extents.XBearing);
double y = (FIELD_NAMING_SIZE + i*FIELD_SIZE + FIELD_SIZE/2) - (extents.Height/2 + extents.YBearing);
cr.MoveTo(x, y);
cr.ShowText(VerticalNamings[i].ToString());
cr.MoveTo(x + 9*FIELD_SIZE + FIELD_NAMING_SIZE, y);
cr.ShowText(VerticalNamings[i].ToString());
}
for (int i = 0; i < HorizontalNamings.Length; i++)
{
TextExtents extents = cr.TextExtents(HorizontalNamings[i].ToString());
double x = (FIELD_NAMING_SIZE + i*FIELD_SIZE + FIELD_SIZE/2) - (extents.Width/2 + extents.XBearing);
double y = (FIELD_NAMING_SIZE/2) - (extents.Height/2 + extents.YBearing);
cr.MoveTo(x, y);
cr.ShowText(HorizontalNamings[Game.BOARD_SIZE-i-1].ToString());
cr.MoveTo(x, y + 9*FIELD_SIZE + FIELD_NAMING_SIZE);
cr.ShowText(HorizontalNamings[Game.BOARD_SIZE-i-1].ToString());
}
#endregion
#region board playfield
//background
cr.Translate(FIELD_NAMING_SIZE, FIELD_NAMING_SIZE);
cr.Rectangle(0, 0, Game.BOARD_SIZE * FIELD_SIZE, Game.BOARD_SIZE * FIELD_SIZE);
cr.Color = BoardColor;
cr.Fill();
if (gi != null)
{
//highlight selected piece field
if (gi.localPlayerMoveState != LocalPlayerMoveState.Wait
&& gi.localPlayerMoveState != LocalPlayerMoveState.PickSource
&& CurMoveNr < 0)
{
if (gi.GetLocalPlayerMove().OnHandPiece == PieceType.NONE)
{
cr.Rectangle((Game.BOARD_SIZE - gi.GetLocalPlayerMove().From.x - 1) * FIELD_SIZE, gi.GetLocalPlayerMove().From.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
cr.Color = SelectedFieldColor;
cr.Fill();
}
}
//highlight last move
if (gi.Moves.Count > 0 && CurMoveNr != 0)
{
Move move;
if (CurMoveNr < 0)
move = gi.Moves[gi.Moves.Count-1].move;
else
move = gi.Moves[CurMoveNr - 1].move;
if (move.OnHandPiece == PieceType.NONE)
{
cr.Rectangle((Game.BOARD_SIZE - move.From.x - 1) * FIELD_SIZE, move.From.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
}
cr.Rectangle((Game.BOARD_SIZE - move.To.x - 1) * FIELD_SIZE, move.To.y * FIELD_SIZE, FIELD_SIZE, FIELD_SIZE);
cr.Color = LastMoveFieldColor;
cr.Fill();
}
//highlight possible moves
if (gi.localPlayerMoveState == LocalPlayerMoveState.PickDestination && CurMoveNr < 0)
{
ValidMoves Moves;
Move LocalPlayerMove = gi.GetLocalPlayerMove();
if (LocalPlayerMove.OnHandPiece == PieceType.NONE)
{
Moves = pos.GetValidBoardMoves(LocalPlayerMove.From);
}
else
{
Moves = pos.GetValidOnHandMoves(LocalPlayerMove.OnHandPiece, gi.CurPlayer == gi.BlackPlayer);
}
foreach (BoardField Field in Moves)
//.........这里部分代码省略.........