private void CalcOffset(ref PointInt32 off, ToolAnchorMode mode, int W, int H) { off = new PointInt32(); if (mode.Has(ToolAnchorModeParts.Left)) { off.X = 0; } if (mode.Has(ToolAnchorModeParts.Center)) { off.X = W / 2; } if (mode.Has(ToolAnchorModeParts.Right)) { off.X = W; } if (mode.Has(ToolAnchorModeParts.Top)) { off.Y = 0; } if (mode.Has(ToolAnchorModeParts.Middle)) { off.Y = H / 2; } if (mode.Has(ToolAnchorModeParts.Bottom)) { off.Y = H; } }
public ToolProperties() { _MaxOutlineThickness = 10; _OutlineThickness = 1; _Height = 10; _Width = 10; _MinHeight = 1; _MinWidth = 1; _MaxHeight = 100; _MaxWidth = 100; _IsSquare = true; _brushShape = ToolBrushShape.Round; _Mode = ToolAnchorMode.Center; CalcOffset(); AnchorModes = Enum.GetValues(typeof (ToolAnchorMode)); BrushShapes = Enum.GetValues(typeof (ToolBrushShape)); }
public ToolProperties() { _MaxOutlineThickness = 10; _OutlineThickness = 1; _Height = 10; _Width = 10; _MinHeight = 1; _MinWidth = 1; _MaxHeight = 100; _MaxWidth = 100; _IsSquare = true; _brushShape = ToolBrushShape.Round; _Mode = ToolAnchorMode.Center; _PreviewMode = ToolAnchorMode.TopLeft; CalcOffset(); AnchorModes = Enum.GetValues(typeof(ToolAnchorMode)); BrushShapes = Enum.GetValues(typeof(ToolBrushShape)); }
private void CalcOffset(ref PointInt32 off, ToolAnchorMode mode, int W, int H) { off = new PointInt32(); if (mode.Has(ToolAnchorModeParts.Left)) off.X = 0; if (mode.Has(ToolAnchorModeParts.Center)) off.X = W/2; if (mode.Has(ToolAnchorModeParts.Right)) off.X = W; if (mode.Has(ToolAnchorModeParts.Top)) off.Y = 0; if (mode.Has(ToolAnchorModeParts.Middle)) off.Y = H/2; if (mode.Has(ToolAnchorModeParts.Bottom)) off.Y = H; }
public override bool MoveTool(TileMouseEventArgs e) { WriteableBitmap bmp; if (_startPoint != null) { _endPoint = e.Tile; } CheckDirectionandDraw(e); ToolAnchorMode mode = ToolAnchorMode.Center; // Line draw preview if (_isRightDown && _startPoint != null && _endPoint != null) { var sp = (PointInt32)_startPoint; var ep = (PointInt32)_endPoint; var delta = ep - sp; var rect = new RectI(new PointInt32(), new SizeInt32(Math.Abs(delta.X) + 1, Math.Abs(delta.Y) + 1)); // figure out exactly which PreviewMode mode = 0; if (delta.X < 0) { mode += (int)ToolAnchorModeParts.Left; } else if (delta.X == 0) { mode += (int)ToolAnchorModeParts.Center; } else if (delta.X > 0) { mode += (int)ToolAnchorModeParts.Right; } if (delta.Y < 0) { mode += (int)ToolAnchorModeParts.Top; } else if (delta.Y == 0) { mode += (int)ToolAnchorModeParts.Middle; } else if (delta.Y > 0) { mode += (int)ToolAnchorModeParts.Bottom; } // which direction to draw the line var linePnts = new PointInt32[2]; switch (mode) { case ToolAnchorMode.TopLeft: linePnts = new[] { rect.BottomRight, rect.TopLeft }; break; case ToolAnchorMode.TopRight: linePnts = new[] { rect.BottomLeft, rect.TopRight }; break; case ToolAnchorMode.BottomLeft: linePnts = new[] { rect.TopRight, rect.BottomLeft }; break; case ToolAnchorMode.BottomRight: linePnts = new[] { rect.TopLeft, rect.BottomRight }; break; default: // has middle or center, order doesn't matter linePnts = new[] { rect.TopLeft, rect.BottomRight }; break; } bmp = new WriteableBitmap( rect.W, rect.H, 96, 96, System.Windows.Media.PixelFormats.Bgra32, null); bmp.Clear(); foreach (PointInt32 p in WorldRenderer.DrawLine(linePnts[0], linePnts[1])) { if (_selection.IsValid(p)) { bmp.SetPixel(p.X, p.Y, previewColor); } } } // Single dot else { bmp = new WriteableBitmap( 1, 1, 96, 96, System.Windows.Media.PixelFormats.Bgra32, null); bmp.Clear(); bmp.SetPixel(0, 0, previewColor); } _properties.Image = bmp; _properties.PreviewMode = mode; return(false); }