void DrawVerticalLines(IPainter painter, Rectangle canvasClipRect, Point canvasStartPoint, Rectangle imageClipRect, int filterArgb) { Action <int> paintAction = x => { var currentLineArgb = GetLineColor(x, Image.Size.Width); if (currentLineArgb == filterArgb) { var canvasX = (x - imageClipRect.Left + 1) * CellSize + canvasStartPoint.X - LineWidth; if (canvasX < canvasClipRect.RightExclusive) { var top = Math.Max(RulerWidth, canvasClipRect.Top); var bottom = Math.Min(imageClipRect.Height * CellSize + canvasStartPoint.Y, canvasClipRect.BottomExclusive); painter.DrawVerticalLine(canvasX, top, bottom - top, currentLineArgb, GetLineWidth(x, Image.Size.Width)); } } }; if (painter.SupportsMultithreading) { Parallel.For(imageClipRect.Left, imageClipRect.RightExclusive, paintAction); } else { for (int x = imageClipRect.Left; x < imageClipRect.RightExclusive; x++) { paintAction(x); } } }
/// <summary> /// Default constructor for the SyntaxBoxControl /// </summary> public EditViewControl(SyntaxBoxControl Parent) { _SyntaxBox = Parent; Painter = new NativePainter(this); _Selection = new Selection(this); _Caret = new Caret(this); _Caret.Change += CaretChanged; _Selection.Change += SelectionChanged; InitializeComponent(); CreateAutoList(); //CreateFindForm (); CreateInfoTip(); SetStyle(ControlStyles.AllPaintingInWmPaint, false); SetStyle(ControlStyles.DoubleBuffer, false); SetStyle(ControlStyles.Selectable, true); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.UserPaint, true); UpdateStyles(); // this.IMEWindow = new Keyrox.Globalization.IMEWindow (this.Handle,_SyntaxBox.FontName,_SyntaxBox.FontSize); }
protected override void Draw(IPainter <TColor> painter, Point currentCameraLocation) { var currentPercentage = _currentPercentageBinder(); if (Math.Abs(currentPercentage - 1f) < 0.01) { _innerPanel.Width = _outPanel.Width; HUDManager <TColor> .Painter.DrawRectangle(Box.Location + currentCameraLocation, _innerPanel.Size, _innerColor); } else if (currentPercentage > 0) { _innerPanel.Width = (int)(((_outPanel.Width - 1)) * currentPercentage); HUDManager <TColor> .Painter.DrawRectangle(Box.Location + currentCameraLocation, _outPanel.Size, _outColor); HUDManager <TColor> .Painter.DrawRectangle(Box.Location + currentCameraLocation, _innerPanel.Size, _innerColor); } else { HUDManager <TColor> .Painter.DrawRectangle(Box.Location + currentCameraLocation, _outPanel.Size, _outColor); _innerPanel.Width = 0; } base.Draw(painter, currentCameraLocation); }
internal void PaintSelection(IPainter painter, Rectangle canvasClipRect, Point canvasStartPoint, Point imageStartPoint) { if (painter.SupportsMultithreading && ShowSelectedRect && SelectedRect.Width > 0 && SelectedRect.Height > 0) { PaintVSelectionBorder(painter, canvasClipRect, canvasStartPoint, imageStartPoint, selectedRect.Left, selectedRect.Top, selectedRect.BottomExclusive); PaintVSelectionBorder(painter, canvasClipRect, canvasStartPoint, imageStartPoint, selectedRect.RightExclusive, selectedRect.Top, selectedRect.BottomExclusive); PaintHSelectionBorder(painter, canvasClipRect, canvasStartPoint, imageStartPoint, selectedRect.Left, selectedRect.RightExclusive, selectedRect.Top); PaintHSelectionBorder(painter, canvasClipRect, canvasStartPoint, imageStartPoint, selectedRect.Left, selectedRect.RightExclusive, selectedRect.BottomExclusive); if (ShowSelectedRectPoints) { var x1 = (SelectedRect.Left - imageStartPoint.X) * CellSize + canvasStartPoint.X - 1; var y1 = (selectedRect.Top - imageStartPoint.Y) * CellSize + canvasStartPoint.Y - 1; var x2 = (SelectedRect.RightExclusive - imageStartPoint.X) * CellSize + canvasStartPoint.X - 1; var y2 = (selectedRect.BottomExclusive - imageStartPoint.Y) * CellSize + canvasStartPoint.Y - 1; PaintShifter(painter, canvasClipRect, x1, y1); PaintShifter(painter, canvasClipRect, x2, y1); PaintShifter(painter, canvasClipRect, x1, y2); PaintShifter(painter, canvasClipRect, x2, y2); var xm = (x1 + x2) / 2; var ym = (y1 + y2) / 2; PaintShifter(painter, canvasClipRect, xm, y1); PaintShifter(painter, canvasClipRect, xm, y2); PaintShifter(painter, canvasClipRect, x1, ym); PaintShifter(painter, canvasClipRect, x2, ym); } } }
public Point(ICoor coor) { Coors = new List <ICoor> { coor }; Painter = new PointPainter(); }
public void Draw(IPainter <TVertex, TBox> painter, ISelector <TVertex, TBox> selector) { // Set reference to external painter object (only for cell Update) lastPainter = painter; // Basic cell visual data painter.FillPolygon(vertices, GetBackFillType()); if (UseEffect3D && Closed && !IsSelected) { painter.DrawBorder3D(verticesEffect3D); } //else painter.DrawPolygon(vertices); // Adding this cell to selector if needed if (selector != null) { selector.AddCell(this, vertices); } // Other common cell visual data TVertex center = Center; TBox internalBox = GetInternalBox(InternalBoxCoefficient); if (!Closed) { if (HasMine) { if (!IsLabelState) { painter.DrawMine(center, internalBox, true); } } else { switch (State) { case CellState.Label: painter.DrawMine(center, internalBox, false); break; case CellState.Normal: if (MinesNumber != 0) { painter.DrawInteger(center, internalBox, MinesNumber); } break; } } } else // closed { switch (State) { case CellState.Undefined: painter.DrawUndefined(center, internalBox); break; case CellState.Label: painter.DrawLabel(center, internalBox); break; } } }
public void PaintPrintPageImage(IPainter painter, int page, Size pageSize, Rectangle margins, string appInfo, string fileInfo) { var lineWidth = Math.Max((int)(PixelsPerMm / 4m), 1); painter.FillRectangle(margins.Left, margins.Top, margins.Width, margins.Height, WhiteColorArgb); using (painter.TranslateCoordinates(new Size(margins.Left, margins.Top))) { if (page < PagesCount - PrintPalettePagesCount) { PaintSchemePage(painter, page, new Size(margins.Width, margins.Height), new Rectangle(0, 0, margins.Width, margins.Height), lineWidth); } else { PaintPalettePage(painter, page, lineWidth, margins); } } var infoY = margins.BottomExclusive + (int)(CellSizeMm / 2); var textSize = (int)(PixelsPerMm * 3); var textPainter = new TextPainter(GridPainter.SymbolsFont, (int)(PixelsPerMm * 3)); painter.PaintText(appInfo, new Point(margins.Left, infoY), textSize, spaceBetweenCharacters: lineWidth); var fileInfoWidth = textPainter.GetTextSize(fileInfo, spaceBetweenCharacters: lineWidth).Width; painter.PaintText(fileInfo, new Point(margins.RightExclusive - fileInfoWidth, infoY), textSize, spaceBetweenCharacters: lineWidth); var pageNo = String.Format(Resources.PrintPageNo, page + 1, PagesCount); var pageNoWidth = textPainter.GetTextSize(pageNo, spaceBetweenCharacters: lineWidth).Width; painter.PaintText(pageNo, new Point(margins.Left + (margins.Width - pageNoWidth) / 2, infoY), textSize, spaceBetweenCharacters: lineWidth); }
protected override void Draw(IPainter <TColor> painter, Point currentCameraLocation) { _image.Update(HUDManager <TColor> .GameTimer.GetElapsedTime()); _image.Draw(painter, Box.Location + currentCameraLocation); base.Draw(painter, currentCameraLocation); }
protected virtual void Draw(IPainter <TColor> painter, Point currentCameraLocation) { foreach (var control in Controls) { control.MainDraw(painter, currentCameraLocation); } }
void DrawHorizontalLines(IPainter painter, Rectangle canvasClipRect, Point canvasStartPoint, Rectangle imageClipRect, int filterArgb) { Action <int> paintAction = y => { var currentLineArgb = GetLineColor(y, Image.Size.Height); if (currentLineArgb == filterArgb) { var canvasY = (y - imageClipRect.Top + 1) * CellSize + canvasStartPoint.Y - LineWidth; if (canvasY < canvasClipRect.BottomExclusive) { var left = Math.Max(RulerWidth, canvasClipRect.Left); var right = Math.Min(imageClipRect.Width * CellSize + canvasStartPoint.X, canvasClipRect.RightExclusive); painter.DrawHorizontalLine(left, canvasY, right - left, currentLineArgb, GetLineWidth(y, Image.Size.Height)); } } }; if (painter.SupportsMultithreading) { Parallel.For(imageClipRect.Top, imageClipRect.BottomExclusive, paintAction); } else { for (int y = imageClipRect.Top; y < imageClipRect.BottomExclusive; y++) { paintAction(y); } } }
public Client(IDesigner designer, IPainter painter, ICanvas canvas) { _designer = designer; _painter = painter; _canvas = canvas; _shapeDescriptions = new List <string>(); }
public SnowGameEngine (IGameContext gameContext, IPainter painter, IGameEventFactory eventFactory) : base(gameContext, painter, eventFactory) { _gameSpeed = 80; _slowFactor = 0; }
public void Paint(IPainter painter, DrawingContext dc, JointCollection joints)//change dc to draw on screen { Joint rightHand = joints.Where(joint => joint.JointType == JointType.HandRight).FirstOrDefault(); Joint leftHand = joints.Where(joint => joint.JointType == JointType.HandLeft).FirstOrDefault(); Joint head = joints.Where(joint => joint.JointType == JointType.Head).FirstOrDefault(); if (rightHand.Position.Y > head.Position.Y) { rightHandFalg = true; leftHandFalg = false; } if (leftHand.Position.Y > head.Position.Y) { leftHandFalg = true; rightHandFalg = false; } if (rightHandFalg) { DrawInBmp(painter.SkeletonPointToScreen(rightHand.Position), DrawThickness, trackedJointBrush); } if (leftHandFalg) { DrawInBmp(painter.SkeletonPointToScreen(leftHand.Position), ClearThickness, backgroundBrush); } dc.DrawImage(bmp, new System.Windows.Rect(0, 0, RenderWidth, RenderHeight)); if (leftHandFalg) { dc.DrawRectangle(CleanerBrush, null, new Rect(leftHand.Position.X - ClearThickness, leftHand.Position.Y - ClearThickness / 2, ClearThickness * 2, ClearThickness)); } }
public void DrawPicture(IPainter painter, ICanvas canvas) { if (_draft != null) { painter.DrawPicture(_draft, canvas); } }
public GameEngine(IGameContext gameContext, IPainter painter, IGameEventFactory eventFactory) { _gameContext = gameContext; Painter = painter; _eventFactory = eventFactory; CurrentEvent = _eventFactory.Create("Start", _gameContext); }
static Grid RenderFlatGrid(Dictionary <string, string> gsa2names, Dictionary <string, RectList> name2rects, int rangeX, int rangeY, int rangeZ) { int width = rangeX * 64; int height = rangeZ * 64; Grid grid = RasterLib.RasterApi.CreateGrid(width, height, 1, 4); IPainter painter = RasterLib.RasterApi.Painter; for (int z = -rangeZ; z <= rangeZ; z++) { //for (int y = 0; y <= rangeY; y++) int y = 0; { for (int x = -rangeX; x <= rangeX; x++) { GridSpaceAddress gsa = new GridSpaceAddress(x, y, z); if (gsa2names.ContainsKey(gsa.ToString())) { string name = gsa2names[gsa.ToString()]; RectList cellRects = name2rects[name]; Console.WriteLine("Rendering " + name); Grid tempGrid = new Grid(64, 64, 64, 4); RasterLib.RasterApi.Renderer.RenderRectsToGrid(cellRects, tempGrid, 0, 0, 0); BirdsEye(tempGrid, grid, (x + rangeX) * 64 / 2, (z + rangeZ) * 64 / 2); } } } } GC.Collect(); return(grid); }
private void RegisterBindings() { IKernel kernel = new StandardKernel(); kernel.Bind <IConfigurationDataProvider>().To <ConfigurationDataProvider>(); kernel.Bind <IGameEventFactory>().ToFactory(() => new UseFirstArgumentAsNameInstanceProvider()); kernel.Bind <ICellFactory>().ToFactory(() => new UseFirstArgumentAsNameInstanceProvider()); kernel.Bind <ICell>().To <GroundPiece>().Named("GroundPiece"); kernel.Bind <ICell>().To <Snowflake>().Named("Snowflake"); kernel.Bind <ICell>().To <FlyingSnowflake>().Named("FlyingSnowflake"); kernel.Bind <IGameContext>().To <SnowGameContext>(); IGameContext gameContext = kernel.Get <IGameContext>(); kernel.Bind <IGameEvent>().To <Start>().Named("Start") .WithConstructorArgument("gameContext", gameContext); kernel.Bind <IGameEvent>().To <Move>().Named("Move") .WithConstructorArgument("gameContext", gameContext); kernel.Bind <Start>().ToSelf().InSingletonScope(); kernel.Bind <Move>().ToSelf().InSingletonScope(); kernel.Bind <IPainter>().To <PainterWithLabel>() .WithConstructorArgument("gameContext", gameContext); IPainter painter = kernel.Get <IPainter>(); kernel.Bind <IGameEngine>().To <SnowGameEngine>() .WithConstructorArgument("gameContext", gameContext) .WithConstructorArgument("painter", painter); _gameEngine = kernel.Get <IGameEngine>(); }
static Grid RenderNetGrid(Dictionary <string, string> gsa2names, Dictionary <string, RectList> name2rects, int rangeX, int rangeY, int rangeZ) { int width = rangeX * 64 * 2; int height = rangeY * 64 * 2; int depth = rangeZ * 64 * 2; Grid grid = RasterLib.RasterApi.CreateGrid(width, 64, depth, 4); int ox = width / 2; int oz = depth / 2; IPainter painter = RasterLib.RasterApi.Painter; for (int z = -rangeZ; z <= rangeZ; z++) { //for (int y = 0; y <= rangeY; y++) int y = 0; { for (int x = -rangeX; x <= rangeX; x++) { GridSpaceAddress gsa = new GridSpaceAddress(x, y, z); if (gsa2names.ContainsKey(gsa.ToString())) { string name = gsa2names[gsa.ToString()]; RectList cellRects = name2rects[name]; Console.WriteLine("Rendering " + name); RasterLib.RasterApi.Renderer.RenderRectsToGrid(cellRects, grid, x * 64 + ox, y * 64, z * 64 + oz); } } } } GC.Collect(); return(grid); }
protected override void Draw(IPainter <TColor> painter, Point currentCameraLocation) { var text = _stringBinder(); var textAdjustPosition = new Point(); if (_align != TextAlign.Left) { var size = HUDManager <TColor> .Painter.GetTextSize(_iFontSize, text); switch (_align) { case TextAlign.Center: textAdjustPosition.X = size.X / 2; break; case TextAlign.Right: textAdjustPosition.X = size.X; break; } } HUDManager <TColor> .Painter.DrawString(text, _iFontSize, Box.Location + currentCameraLocation - textAdjustPosition, _color); base.Draw(painter, currentCameraLocation); }
public Game(ISpaceUpdater spaceUpdater, ISpaceStore spaceStore, IPainter painter, IGUIManager GUIManager) { this.spaceUpdater = spaceUpdater; this.spaceStore = spaceStore; this.painter = painter; this.GUIManager = GUIManager; }
/// <summary> /// 初始畫 /// </summary> /// <param name="painter">繪圖</param> /// <param name="printer">列印</param> /// <param name="x">x</param> /// <param name="y">y</param> /// <param name="radius">radius</param> public Round(IPainter painter, IPrinter printer, double x, double y, double radius) { this.painter = painter; this.printer = printer; this.x = x; this.y = y; this.radius = radius; }
public MyBrush() { Painter = new BrushIPainter(); Reaction = new NoReactionIReaction(); startPoint = new Point(-1, -1); }
public Controller(Board board, IPainter painter) { this.firstPlayer = board.FirstPlayer; this.secondPlayer = board.SecondPlayer; this.currentPlayer = board.FirstPlayer; this.board = board; this.painter = painter; }
protected override void Draw(IPainter <TColor> painter, Point currentCameraLocation) { HUDManager <TColor> .Painter.DrawRectangle(Box.Location + currentCameraLocation, Box.Size, _isHovered?_innerColorHovered : _innerColor); HUDManager <TColor> .Painter.DrawRectangleOutline(Box.Location + currentCameraLocation, Box.Size, _isHovered?_outColorHovered : _outColor); base.Draw(painter, currentCameraLocation); }
public void Draw(IPainter <Color> painter, Point location, float scale) { var currentTexture = GetCurrentTexture(); var texture = new Texture(currentTexture); painter.Draw(texture, location, scale, Color.White); }
public Colorizer(IPainter <T> painter) { this.painter = painter; SourceFilter = x => true; WordSelector = x => x as string ?? string.Empty; SearchOptions = RichTextBoxFinds.WholeWord; ResetColors = true; }
static void Main(string[] args) { IEnumerable <ProportionalPainter> painters = new ProportionalPainter[10]; IPainter fastestPainter = CompositePainterFactories.CreateFastestSelector(painters); IPainter group = CompositePainterFactories.CombineProportional(painters); }
public void MainDraw(IPainter <TColor> painter, Point currentCameraLocation) { if (!IsVisible) { return; } Draw(painter, currentCameraLocation); }
public override void Dispose(bool disposing) { if (disposing) { InnerPainter.Dispose(); InnerPainter = null; } base.Dispose(disposing); }
/// <summary> /// 初始畫 /// </summary> /// <param name="painter">畫圖庫</param> /// <param name="printer">列印庫</param> /// <param name="x1">x1</param> /// <param name="y1">y1</param> /// <param name="x2">x2</param> /// <param name="y2">y2</param> public Rectangle(IPainter painter, IPrinter printer, double x1, double y1, double x2, double y2) { this.painter = painter; this.printer = printer; this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; }
public CaptchaController( IOptions <PainterOption> painterOpt, ICodeTextGenerator codeTextGenerator, IPainter painter) { _painterOption = painterOpt.Value; _codeTextGenerator = codeTextGenerator; _painter = painter; }
public Game() { ResetToDefault(); ratioD = d2 / d1; pixel_painter = new PixelPainter(); sprite_painter = new SpritePainter(); painter = sprite_painter; rnd = new Random((int) DateTime.Now.ToBinary()); random_numbers = new double[asteriks_count_max]; for (var i = 0; i < asteriks_count_max; i++) random_numbers[i] = (rnd.NextGaussian(rnd.Next(-100, 100), 100 / 2)); render = new Thread(Render){ IsBackground = true }; }
public Drawing(IPainter painter) { _painter = painter; }
/// <summary> /// Default constructor for the SyntaxBoxControl /// </summary> public EditViewControl(CodeEditorControl Parent) : base() { _CodeEditor = Parent; Painter = new Painter_GDI(this); _Selection = new Selection(this); _Caret = new Caret(this); _Caret.Change += new EventHandler(this.CaretChanged); _Selection.Change += new EventHandler(this.SelectionChanged); // this.AttachDocument (_SyntaxBox.Document); InitializeComponent(); CreateAutoList(); //CreateFindForm (); CreateInfoTip(); this.SetStyle(ControlStyles.AllPaintingInWmPaint, false); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false); this.SetStyle(ControlStyles.Selectable, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.Opaque, true); this.SetStyle(ControlStyles.UserPaint, true); // this.SetStyle(ControlStyles.UserMouse, true); }
public virtual void Draw(IPainter painter) { painter.Draw(this); }
/// <summary> /// Default constructor for the SyntaxBoxControl /// </summary> public EditViewControl(SyntaxBoxControl Parent) { _SyntaxBox = Parent; Painter = new NativePainter(this); _Selection = new Selection(this); _Caret = new Caret(this); _Caret.Change += CaretChanged; _Selection.Change += SelectionChanged; InitializeComponent(); CreateAutoList(); //CreateFindForm (); CreateInfoTip(); SetStyle(ControlStyles.AllPaintingInWmPaint, false); SetStyle(ControlStyles.DoubleBuffer, false); SetStyle(ControlStyles.Selectable, true); SetStyle(ControlStyles.ResizeRedraw, true); SetStyle(ControlStyles.Opaque, true); SetStyle(ControlStyles.UserPaint, true); UpdateStyles(); mKeysThatInsertFromAutolist.Add(Keys.Space); mKeysThatInsertFromAutolist.Add(Keys.Enter); mKeysThatInsertFromAutolist.Add(Keys.Tab); mKeysThatInsertFromAutolist.Add(Keys.OemPeriod); mKeysThatInsertFromAutolist.Add(Keys.OemOpenBrackets); //mKeysThatInsertFromAutolist.Add( // this.IMEWindow = new Alsing.Globalization.IMEWindow (this.Handle,_SyntaxBox.FontName,_SyntaxBox.FontSize); }
/// <summary> /// Initializes a new Instance of current Class. /// </summary> /// <param name="primitivePainter">Painter used for Primitives.</param> public PrimitivePainter(IPainter primitivePainter) { if (primitivePainter == null) throw new ArgumentNullException("primitivePainter"); this.primitivePainter = primitivePainter; }
public void OverridePainter(IPainter painter) { Painter = painter; Painter.Invalidate(); }