public override void Draw(IGraphics graphics) { int drawX = (int)Math.Round(X); int drawY = (int)Math.Round(Y); graphics.SetColor(255, r, g, b); graphics.DrawObject(Image.BigExplosion, drawX, drawY, 64, 64, animation / 4, animation % 4, angle); }
public override void Draw(int size, int x, int y, IGraphics g, Pen pen, Brush brush) { int s2 = size/2; Point[] points = new[]{new Point(x - s2, y), new Point(x, y - s2), new Point(x + s2, y), new Point(x, y + s2)}; g.FillPolygon(brush, points); g.DrawPolygon(pen, points); }
/// <summary> /// Function to render the actual map decoration /// </summary> /// <param name="g"></param> /// <param name="map"></param> protected override void OnRender(IGraphics g, Map map) { // Render the rosetta base.OnRender(g, map); var clip = g.ClipBounds; var oldTransform = g.Transform; var newTransform = new Matrix(1f, 0f, 0f, 1f, clip.Left + Size.Width*0.5f, clip.Top + Size.Height*0.5f); g.Transform = newTransform; var width = Size.Width; var height = Size.Height; var pts = new[] { new PointF(0f, -0.35f*height), new PointF(0.125f*width, 0.35f*height), new PointF(0f, 0.275f*height), new PointF(-0.125f*width, 0.35f*height), new PointF(0f, -0.35f*height), }; // need to outline the needle if (NeedleOutlineWidth>0) { g.DrawPolygon(new Pen(OpacityColor(NeedleOutlineColor), NeedleOutlineWidth), pts); } // need to outline the needle g.FillPolygon(new SolidBrush(OpacityColor(NeedleFillColor)), pts ); g.Transform = oldTransform; }
/// <summary> /// Do all rendering associated with this <see cref="CurveItem"/> to the specified /// <see cref="Graphics"/> device. This method is normally only /// called by the Draw method of the parent <see cref="ZedGraph.CurveList"/> /// collection object. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="pos">The ordinal position of the current <see cref="Bar"/> /// curve.</param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public override void Draw(IGraphics g, GraphPane pane, int pos, float scaleFactor) { if (IsXAxisMarker) DrawXMarker(pane, g); else DrawYMarker(pane, g); }
public override void Draw(int size, float x, float y, IGraphics g, Pen2 pen, Brush2 brush) { int s2 = size/2; Point2[] points = {new Point2(x - s2, y), new Point2(x, y - s2), new Point2(x + s2, y), new Point2(x, y + s2)}; g.FillPolygon(brush, points); g.DrawPolygon(pen, points); }
public override void Draw(IGraphics graphics) { int drawX = (int)Math.Round(X); int drawY = (int)Math.Round(Y); graphics.SetColor(255, 255, 255, 255); graphics.DrawObject(Image.Mushi, drawX, drawY, 32, 64, type, animation % 3 == 1 ? 1 : 0, angle); }
public void DrawString(IGraphics g, string text, Font font, Brush brush, PointF location) { int oldCount = _glyphCoords.Count; AddString(text, font, brush, g.TextRenderingHint); if (g is GLGraphics) UpdateTextureIfNeeded(); List<RectangleF> glyphDst = new List<RectangleF>(); List<Rectangle> glyphSrc = new List<Rectangle>(); location.X += 2.0f; // magic ... really don't know how to get this offset from MeasureString foreach (var c in text) { var glyphCoord = _glyphCoords[c]; var glyphSize = glyphCoord.RealSize; glyphSize.Width = (float)Math.Ceiling(glyphSize.Width); glyphSize.Height = (float)Math.Ceiling(glyphSize.Height); glyphDst.Add(new RectangleF(location, glyphSize)); glyphSrc.Add(glyphCoord.GlyphRect); if (g is GDIGraphics) g.DrawImage(_bitmap, location.X, location.Y, glyphCoord.GlyphRect.ToRectangleF(), GraphicsUnit.Pixel); location.X += (float)Math.Round(glyphCoord.RealSize.Width + 0.2f); // another magic } if (g is GLGraphics) _texture.DrawGlyphs(glyphDst, glyphSrc); }
/// <summary> /// Advances the time position and draws the current frame of the animation. /// </summary> /// <param name="gameTime">A game time</param> /// <param name="spriteBatch">A graphics</param> /// <param name="position">A position</param> /// <param name="spriteEffects">To flip an image</param> NOT USED public void Draw(GameTime gameTime, IGraphics spriteBatch, PointF position, bool spriteEffects) { if (AnimTexture == null) { throw new NotSupportedException("No animation is currently playing."); } // Process passing time. this.time += (float)gameTime.ElapsedTime.TotalSeconds; while (this.time > AnimTexture.FrameTime) { this.time -= AnimTexture.FrameTime; // Advance the frame index; looping or clamping as appropriate. if (AnimTexture.IsLooping) { this.FrameIndex = (this.FrameIndex + 1) % AnimTexture.FrameCount; } else { this.FrameIndex = Math.Min(this.FrameIndex + 1, AnimTexture.FrameCount - 1); } } // Draw the current frame. this.DrawFrame(spriteBatch, position, this.FrameIndex); }
public override void Draw(IGraphics graphics) { int drawX = (int)Math.Round(X); int drawY = (int)Math.Round(Y); graphics.SetColor(255, 255, 255, 255); graphics.DrawObject(Image.RedEnemy, drawX, drawY, 32, 32, 0, 0, angle); }
public override void Draw(IGraphics graphics) { int drawX = (int)Math.Round(X); int drawY = (int)Math.Round(Y); graphics.SetColor(255, 255, 255, 255); graphics.DrawBullet(Image.Bullet, drawX, drawY, 16, 16, 0, 0, Angle); }
public void Draw(IGraphics g) { if (Font != null) { g.SetFont (Font); } g.SetColor (Colors.Gray); var border = Frame; border.Y += PaddingTop; border.Height -= PaddingTop + PaddingBottom; border.Inflate (-1, -1); g.DrawRoundedRect (border, 5, 1); var inner = border; inner.Inflate (-2, -2); if (Checked) { g.FillRoundedRect (inner, 3); g.SetColor (Colors.Black); } if (!string.IsNullOrEmpty (Title)) { var fm = g.GetFontMetrics (); var sw = fm.StringWidth (Title); g.DrawString (Title, inner.X + (inner.Width - sw)/2, inner.Y + (inner.Height - fm.Height)/2); } }
public static void BotForecast(IGraphics graphics, double X, double Y, double Heading, double Velocity, int Turns) { BotPosition bot = new BotPosition(X, Y, Heading, Velocity); BotPosition[][] moves = BotPosition.AllMoves(bot, Turns); foreach (BotPosition[] path in moves) { int i = 0; //float LastX = (float)X; //float LastY = (float)Y; foreach (BotPosition b in path) { if (i++ % 4 == Turns % 4) //if (i++ % 5 == Turns % 5 && Turns/i < 2) { BotDot(graphics, b.Location.X, b.Location.Y); //BotBox(graphics, new Pen(Color.FromArgb(100, 255, 255, 0)), b.Location.X, b.Location.Y, b.Heading); //graphics.DrawRectangle(new Pen(Color.FromArgb(100, 255, 255, 0)), b.Location.X - 18, b.Location.Y - 18, 36, 36); //graphics.DrawLine(new Pen(Color.FromArgb(100, 255, 255, 0)), LastX, LastY, (float)b.Location.X, (float)b.Location.Y); //LastX = (float)b.Location.X; //LastY = (float)b.Location.Y; } } } }
public override void draw(IGraphics graphics) { // DEBUG: should use shapes instead of drawString and handle cut time, etc. FinalPoint hotspot = getScreenHotspot(); graphics.DrawString("" + _topNumber, hotspot.x, hotspot.y + 10); graphics.DrawString("" + _bottomNumber, hotspot.x, hotspot.y + 20); }
internal SandboxedHost(IHost host, IObjectAccessor accessor, MicroScheduler scheduler) { m_host = host; m_accessor = accessor; m_graphics = new SandboxedGraphics(host.Graphics); m_scheduler = scheduler; }
/** Draw this object */ public override void draw(IGraphics graphics) { int multiNodeCount = getMultiNodeCount(); if (multiNodeCount == 0) // Only the defining Beam draws the beams for all in the multi-node group return; if (multiNodeCount != 2) // DEBUG: should handle this case return; Tie leftNode = getMultiNode(0); Tie rightNode = getMultiNode(1); FinalPoint leftHotspot = leftNode.getAnchor().getScreenHotspot(); FinalPoint rightHotspot = rightNode.getAnchor().getScreenHotspot(); Staff leftNodeParentStaff = leftNode.getParentTimeSlice().getParentMeasureStart().getParentStaff(); if (leftNodeParentStaff != rightNode.getParentTimeSlice().getParentMeasureStart().getParentStaff()) { // The two ends of the tie are on different staves. Assume that // the left end should extend to the end of the staff and that // the right end should have a little continuation from the beginning int endX = leftNodeParentStaff.getParentSystem().getScreenHotspot().x + leftNodeParentStaff.getParentSystem().getWidth() + 10; drawTie(graphics, leftHotspot.x + 3, leftHotspot.y, endX); drawTie(graphics, rightHotspot.x - 12, rightHotspot.y, rightHotspot.x - 3); } else drawTie(graphics, leftHotspot.x + 3, leftHotspot.y, rightHotspot.x - 3); }
protected virtual void Draw (IGraphics g, int startIndex, int length, float thickness) { g.BeginEntity (this); if (length == 0) { } else if (length == 1) { var p = _points [startIndex]; var r = thickness / 2; g.FillOval (p.X - r, p.Y - r, thickness, thickness); } else { g.BeginLines (true); var end = startIndex + length; for (var i = startIndex; i < end - 1; i++) { g.DrawLine ( _points [i].X, _points [i].Y, _points [i + 1].X, _points [i + 1].Y, thickness); } g.EndLines (); } }
/** Draw this object */ public override void draw(IGraphics graphics) { // Look at the clef we are in and shift the staff step given // by SHARP_STEPS, etc. accordingly. Use G_CLEF as default. int clefStepOffset = 0; if (getClefShape() == Clef.Shape.F_CLEF) clefStepOffset = -2; // DEBUG: add support for clefs other than G clef and F clef. FinalPoint hotspot = getScreenHotspot(); // DEBUG: does not handle negative standard code. if (_standardCode >= 1 && _standardCode <= 7) { // sharps for (int i = 0; i < _standardCode; ++i) { Accidental._sharp.draw (graphics, hotspot.x + i * 5, hotspot.y + Notehead.staffStepOffsetY(SHARP_STEPS[i] + clefStepOffset)); } } else if (_standardCode >= 8 && _standardCode <= 14) { // flats for (int i = 0; i < _standardCode - 7; ++i) { Accidental._flat.draw (graphics, hotspot.x + i * 5, hotspot.y + Notehead.staffStepOffsetY(FLAT_STEPS[i] + clefStepOffset)); } } }
/// <summary> /// Paints the fragment /// </summary> /// <param name="g">the device to draw to</param> protected override void PaintImp(IGraphics g) { var offset = HtmlContainer != null ? HtmlContainer.ScrollOffset : PointF.Empty; var rect = new RectangleF(Bounds.X + offset.X, Bounds.Y + offset.Y, Bounds.Width, Bounds.Height); if (rect.Height > 2 && RenderUtils.IsColorVisible(ActualBackgroundColor)) { g.FillRectangle(RenderUtils.GetSolidBrush(ActualBackgroundColor), rect.X, rect.Y, rect.Width, rect.Height); } var b1 = RenderUtils.GetSolidBrush(ActualBorderTopColor); BordersDrawHandler.DrawBorder(Border.Top, g, this, b1, rect); if (rect.Height > 1) { var b2 = RenderUtils.GetSolidBrush(ActualBorderLeftColor); BordersDrawHandler.DrawBorder(Border.Left, g, this, b2, rect); var b3 = RenderUtils.GetSolidBrush(ActualBorderRightColor); BordersDrawHandler.DrawBorder(Border.Right, g, this, b3, rect); var b4 = RenderUtils.GetSolidBrush(ActualBorderBottomColor); BordersDrawHandler.DrawBorder(Border.Bottom, g, this, b4, rect); } }
public override void Draw(IGraphics graphics) { int drawX = (int)Math.Round(X); int drawY = (int)Math.Round(Y); graphics.SetColor(255, 255, 255, 255); graphics.DrawObject(Image.Smoke, drawX, drawY, 32, 32, animation / 4, animation % 4, angle); }
/// <summary> /// Clip the region the graphics will draw on by the overflow style of the containing block.<br/> /// Recursively travel up the tree to find containing block that has overflow style set to hidden. if not /// block found there will be no clipping and null will be returned. /// </summary> /// <param name="g">the graphics to clip</param> /// <param name="box">the box that is rendered to get containing blocks</param> /// <returns>the prev region if clipped, otherwise null</returns> public static RectangleF ClipGraphicsByOverflow(IGraphics g, CssBox box) { var containingBlock = box.ContainingBlock; while (true) { if (containingBlock.Overflow == CssConstants.Hidden) { var prevClip = g.GetClip(); var rect = box.ContainingBlock.ClientRectangle; rect.X -= 2; // atodo: find better way to fix it rect.Width += 2; rect.Offset(box.HtmlContainer.ScrollOffset); rect.Intersect(prevClip); g.SetClip(rect); return prevClip; } else { var cBlock = containingBlock.ContainingBlock; if (cBlock == containingBlock) return RectangleF.Empty; containingBlock = cBlock; } } }
public override void Draw(IGraphics graphics) { int drawX = (int)Math.Round(X); int drawY = (int)Math.Round(Y); graphics.SetColor(255, 255, 255, 255); graphics.DrawObject(Image.Clipper, drawX, drawY, 32, 32, 1, 0, 0); }
public IndexBuffer(IGraphics graphics) { _graphics = graphics as Graphics; _graphics.MakeCurrent(); GL.GenBuffers(1, out id); }
/// <summary> /// Run game logic here such as updating the world, /// checking for collisions, handling input and drawing the game. /// This method will be called as frequently as possible, /// when the Windows message queue is empty. /// Check GameTime to get the elapsed time since the last update. /// </summary> /// <param name="gameTime">Game time</param> /// <param name="renderer">A Renderer</param> /// <param name="keyboardState">A keyboard state</param> public void Run(GameTime gameTime, IGraphics renderer, IControllerState keyboardState) { if (this.levelStat == LevelChangeStatus.NoChange) { if (Collisions.GetPlayerTile(this.level.Player) == TileType.Next) { this.level.LevelIndex++; this.levelStat = LevelChangeStatus.Change; } else if (Collisions.GetPlayerTile(this.level.Player) == TileType.Back) { this.level.LevelIndex--; this.levelStat = LevelChangeStatus.Change; } else { this.level.Update(gameTime, keyboardState); this.level.Draw(gameTime, renderer); } } else { this.level.UpdateLevel(); this.levelStat = LevelChangeStatus.NoChange; } }
public override void DrawSmoothFilledCurve(IGraphics g, GraphPane pane, CurveItem curve, float scaleFactor) { base.DrawSmoothFilledCurve(g, pane, curve, scaleFactor); // Draw the curve at the bottom of the graph. DrawCurve(g, pane, curve, scaleFactor, GetPointsForLowPointsArray(curve)); }
public override void Draw(IGraphics graphics) { int drawX = (int)Math.Round(X); int drawY = (int)Math.Round(Y); graphics.SetColor(255, type == 0 ? 255 : 0, type == 1 ? 255 : 0, type == 2 ? 255 : 0); graphics.DrawObject(Image.Teki, drawX, drawY, 32, 32, 0, 0, angle); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(Window.FEATURE_NO_TITLE); GetWindow().SetFlags(IWindowManager_LayoutParams.FLAG_FULLSCREEN, IWindowManager_LayoutParams.FLAG_FULLSCREEN); bool isPortrait = GetResources().GetConfiguration().Orientation == Configuration.ORIENTATION_PORTRAIT; int frameBufferWidth = isPortrait ? 480 : 800; int frameBufferHeight = isPortrait ? 800 : 480; Bitmap frameBuffer = Bitmap.CreateBitmap(frameBufferWidth, frameBufferHeight, Bitmap.Config.RGB_565); float scaleX = (float)frameBufferWidth / GetWindowManager().GetDefaultDisplay().GetWidth(); float scaleY = (float)frameBufferHeight / GetWindowManager().GetDefaultDisplay().GetHeight(); renderView = new AndroidFastRenderView(this, frameBuffer); graphics = new AndroidGraphics(GetAssets(), GetAssetsPrefix(), frameBuffer); fileIO = new AndroidFileIO(this); audio = new AndroidAudio(this); input = new AndroidInput(this, renderView, scaleX, scaleY); screen = getInitScreen(); SetContentView(renderView); PowerManager powerManager = (PowerManager)GetSystemService(Context.POWER_SERVICE); wakeLock = powerManager.NewWakeLock(PowerManager.FULL_WAKE_LOCK, "MyGame"); }
protected override void OnRenderInternal(Map map, IPolygon polygon, IGraphics g) { IPoint pt = polygon.Centroid; Point renderingOrigin = Point.Truncate(Transform.WorldtoMap(pt.Coordinate, map)); g.RenderingOrigin = new PointStruct(renderingOrigin.X, renderingOrigin.Y); base.OnRenderInternal(map, polygon, g); }
/** Draw this object */ public override void draw(IGraphics graphics) { int multiNodeCount = getMultiNodeCount(); if (multiNodeCount == 0) // Only the defining Beam draws the beams for all in the multi-node group return; if (multiNodeCount == 1) // DEBUG: should handle this case return; FinalPoint left = getScreenHotspot(); double slope = getSlope(); int maxParts = getMaxParts(); int stemDirection = getStemDirection(); for (int i = 0; i < multiNodeCount; ++i) { Beam beam = getMultiNode(i); Beam previousBeam = null, nextBeam = null; if (i > 0) previousBeam = getMultiNode(i - 1); if (i < (multiNodeCount - 1)) nextBeam = getMultiNode(i + 1); FinalPoint stemTip = beam.getAnchor().getScreenHotspot(); // Get X and Y for this beam int beamX = stemTip.x; int beamY = (int)(left.y + slope * (beamX - left.x)); // First, extend the stem. graphics.DrawLine(beamX, beamY, stemTip.x, stemTip.y); // For each of the possible parts, draw as needed to the left or right for (int part = 1; part <= maxParts; part++) { if (i > 0) { // Only do parts to left if we are not the leftmost stem if (part <= beam._partsToLeft && part > previousBeam._partsToRight) // Draw a stub to the left // DEBUG: should make sure this doesn't run into the other stem drawBeam(graphics, beamX, beamY, beamX - 6); // The case where the beam would extend all the way was handled // by the previousBeam drawing to here. } if (i < (multiNodeCount - 1)) { // Only do parts to right if we are not the rightmost stem if (part <= beam._partsToRight && part > nextBeam._partsToLeft) // Draw a stub to the right // DEBUG: should make sure this doesn't run into the other stem drawBeam(graphics, beamX, beamY, beamX + 6); if (part <= beam._partsToRight && part <= nextBeam._partsToLeft) // Draw beam extended over to the other drawBeam(graphics, beamX, beamY, nextBeam.getAnchor().getScreenHotspot().x); } beamY += -stemDirection * SPACING; } } }
public override void RenderControl(Control c, IGraphics g) { for (int i = 0; i < styleNames.Count; i++) { List<Location> locs = styleLocations[i]; List<Path> paths = stylePaths[i]; if (styleNames[i] != (string)c.Style) continue; if (styleTypes[i] != c.GetType()) { if ((c.GetType().Assembly == Assembly.GetExecutingAssembly()) || !c.GetType().IsSubclassOf(styleTypes[i])) continue; } if ((styleStates[i] & c.State) != styleStates[i]) continue; PatternList plist = styleOperations[i]; for (int j = 0; j < plist.Count; j++) { g.Save(); Path path = (paths[j] != null) ? paths[j].Clone() : c.Path.Clone(); path.Control = c; if (locs[j] != null) { // This is a little hackish, but I can't think of a better way // Without reworking major chunks of the geometry classes Control tmp = new Control(); tmp.Path = path; tmp.Parent = c; path.Control = tmp; Location loc = locs[j].Clone(); loc.Control = tmp; g.Translate(loc.RealL, loc.RealT); loc.HandleRel(); path = tmp.Path.ClonePixels(); tmp.Parent = null; } path.Apply(g); plist[j].Apply(g, path.W, path.H); if (plist[j].Type == PatternType.Fill) g.Fill(); else g.Stroke(); g.Restore(); } } }
protected override void DrawEndCap(IGraphics g, bool onScreen, Style style) { linePen.Color = style.RelationshipColor; linePen.Width = style.RelationshipWidth; g.FillPath(Brushes.White, Arrowhead.ClosedArrowPath); g.DrawPath(linePen, Arrowhead.ClosedArrowPath); }
/// <summary> /// Redraw the canvas. /// </summary> public void RefreshDrawCanvas(IGraphics graphics) { _canvasManager.RefreshDrawCanvas(graphics); }
protected virtual void PaintBorder(IGraphics g, RectangleF signBorder) { g.DrawRectangle(signBorder, this.SignBorderColor, PenAlignment.Inset, this.SignBorderWidth); }
public override IBrush CreateBrush(IGraphics graphics, Color backColor, Rectangle rectangle) { return(graphics.SolidBrush(backColor)); }
public override void FillIn(IGraphics g, Color fillingColor) { base.FillIn(g, fillingColor); g.FillPolygon(fillingColor, points); }
public override void OnPaint(IGraphics graphics) { _brain.Render(graphics); }
protected abstract void DrawContent(IGraphics g, Style style);
//static int i = 0; public void PaintFormatText( IGraphics graphics, RectangleF paintingRectangle, bool useCompatibleTextRendering, TextFormatFlags flags, PointF currentLineBeginLocation, float lineHeight, float lineBaseLine, bool clipText) { if (this.image != null) { graphics.DrawBitmap(this.image, (int)currentLineBeginLocation.X, (int)currentLineBeginLocation.Y); currentLineBeginLocation.X += this.image.Size.Width;//return; } if (string.IsNullOrEmpty(this.Text) || currentLineBeginLocation.X >= paintingRectangle.Right) { return; } using (Font font = new Font(this.FontName, this.FontSize, this.FontStyle)) { if (!useCompatibleTextRendering) { TextRenderer.DrawText((Graphics)graphics.UnderlayGraphics, this.ProduceTextBullets() + this.Text, font, new Rectangle((int)Math.Round(currentLineBeginLocation.X), (int)Math.Round(currentLineBeginLocation.Y), (int)Math.Round(this.BlockSize.Width), (int)Math.Round(lineHeight)), this.FontColor, flags); return; } SizeF textSize = new SizeF(Math.Min(this.BlockSize.Width, paintingRectangle.Right - currentLineBeginLocation.X), Math.Min(this.BlockSize.Height, paintingRectangle.Height)); using (StringFormat sf = new StringFormat(StringFormat.GenericTypographic)) { if (!clipText) { sf.FormatFlags |= StringFormatFlags.NoClip; } else { sf.FormatFlags &= ~StringFormatFlags.NoClip; } sf.FormatFlags |= StringFormatFlags.NoWrap | StringFormatFlags.MeasureTrailingSpaces; sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Near; sf.Trimming = StringTrimming.None; sf.HotkeyPrefix = HotkeyPrefix.None; sf.FormatFlags &= ~StringFormatFlags.LineLimit & ~StringFormatFlags.FitBlackBox; if (this.bgColor != null) { this.DrawBgColor(currentLineBeginLocation, textSize, graphics); } RectangleF textRectangle = new RectangleF(currentLineBeginLocation, textSize); SolidBrush brush = new SolidBrush(this.FontColor); Graphics g = ((Graphics)graphics.UnderlayGraphics); this.DrawBullets(g, textRectangle, sf, brush); float drawingBeginPointX = textRectangle.X + this.bulletSize.Width; float drawingBeginPointY = textRectangle.Y + (lineBaseLine - this.baseLine); this.drawingRectangle = new RectangleF(drawingBeginPointX, drawingBeginPointY, textRectangle.Width, textRectangle.Height); //TODO: This fixes a 1-pixel error in GDI+ if (clipText) { this.drawingRectangle.Width++; } g.DrawString(this.Text, font, brush, this.drawingRectangle, sf); brush.Dispose(); } //this draw debug rectangles around textblocks //++i; //graphics.DrawRectangle(Rectangle.Ceiling(drawingRectangle), i % 2 == 1 ? Color.Red : Color.Green); } }
/// <summary> /// /// </summary> /// <param name="node"></param> /// <param name="vertexIdx"></param> /// <param name="startingPt"></param> private void BeginVertexMove(INode node, int vertexIdx, System.Drawing.Point startingPt) { this.node = node; this.vertexIdx = vertexIdx; if (this.View.Grid.SnapToGrid) { this.startingPoint = this.View.SnapPointToGrid(startingPt); } else { this.startingPoint = startingPt; } this.trackingNode = null; this.trackingPath = null; if (this.Controller == null || this.View == null) { return; } if (this.node != null) { this.node = node; this.trackingNode = (INode)this.node.Clone(); IPoints objPoints = this.trackingNode as IPoints; if (objPoints != null) { ITransform objXform = this.trackingNode as ITransform; PointF[] ptWorld = new PointF[1] { this.View.ViewToWorld(this.View.DeviceToView(startingPt)) }; if (objXform != null) { Matrix worldTransform = objXform.WorldTransform; worldTransform.Invert(); worldTransform.TransformPoints(ptWorld); } objPoints.SetPoint(this.vertexIdx, ptWorld[0]); } int prevStack = Global.SelectMatrixStack(Global.TemporaryStack); Global.MatrixStack.Clear(); ITransform nodeTrans = this.trackingNode as ITransform; if (nodeTrans != null) { Global.MatrixStack.Push(nodeTrans.ParentTransform); } IGraphics nodeGrfx = this.trackingNode as IGraphics; if (nodeGrfx != null) { this.trackingPath = nodeGrfx.GraphicsPath; } Global.SelectMatrixStack(prevStack); this.trackingRect = this.View.DrawTrackingPath(this.trackingPath); this.editMode = EditMode.Moving; } }
public void PaintFill(IGraphics graphics, float angle, SizeF scale) { RectangleF prefferedRectangle = this.primitiveElement.GetPaintRectangle(this.primitiveElement.BorderThickness, angle, scale); PaintFill(graphics, angle, scale, prefferedRectangle); }
protected override void RenderGadget(IGraphics gfx) { theme.RenderGadget(gfx, this); }
public override void PerformLayout(IGraphics gfx) { base.PerformLayout(gfx); CalcKnobSize(); }
/// <summary> /// Handles text input event. /// </summary> /// <exception cref="InvalidOperationException"> /// This object is already disposed. /// </exception> /// <exception cref="ArgumentNullException">Parameter 'text' is null.</exception> internal void HandleTextInput(string text) { if (_IsDisposed) { throw new InvalidOperationException("This object is already disposed."); } if (text == null) { throw new ArgumentNullException("text"); } var doc = Document; var input = new StringBuilder(Math.Max(64, text.Length)); IGraphics g = null; // if in read only mode, just notify and return if (doc.IsReadOnly) { Plat.Inst.MessageBeep(); return; } // ignore if input is an empty text if (text.Length == 0) { return; } try { int newCaretIndex; int selBegin, selEnd; g = _UI.GetIGraphics(); // begin grouping UNDO action doc.BeginUndo(); // clear rectangle selection if (doc.RectSelectRanges != null) { doc.DeleteRectSelectText(); } // handle input characters foreach (char ch in text) { // try to use hook delegate if (AutoIndentHook != null && AutoIndentHook(_UI, ch) == true) { // Do nothing if this was handled by the hook continue; } // execute built-in hook logic if (TextUtil.IsEolChar(ch)) { // if an EOL code was found, stop consuming and discard // following inputs if (IsSingleLineMode) { break; } // change all EOL code in the text input.Append(doc.EolCode); } else if (ch == '\t' && _UsesTabForIndent == false) { string spaces = GetTabEquivalentSpaces(_UI, doc.CaretIndex); if (spaces == "") { // When the caret position is close to next tab // stop, an empty string will be the equivalent to // a tab. In this case we should think as if the // caret is just on the next tab stop. for (int i = 0; i < View.TabWidth; i++) { spaces += ' '; } } input.Append(spaces); } else if (ch == '\x3000' && ConvertsFullWidthSpaceToSpace) { input.Append('\x0020'); } else { // remember this character input.Append(ch); } } // calculate new caret position doc.GetSelection(out selBegin, out selEnd); newCaretIndex = selBegin + input.Length; // calc replacement target range if (IsOverwriteMode && selBegin == selEnd && selEnd + 1 < doc.Length && TextUtil.IsEolChar(doc[selBegin]) != true) { selEnd++; } // replace selection to input char doc.Replace(input.ToString(), selBegin, selEnd); doc.SetSelection(newCaretIndex, newCaretIndex); // set desired column if (UsesStickyCaret == false) { _View.SetDesiredColumn(g); } // update graphic _View.ScrollToCaret(g); //NO_NEED//_View.Invalidate( xxx ); // Doc_ContentChanged will do invalidation well. } finally { doc.EndUndo(); input.Length = 0; if (g != null) { g.Dispose(); } } }
public override void Draw(IGraphics g, bool onScreen, Style style) { DrawSurface(g, onScreen, style); DrawText(g, onScreen, style); }
protected void DrawSeparatorLine(IGraphics g, int height) { g.DrawLine(borderPen, Left, height, Right, height); }
public void PaintFill(IGraphics graphics, float angle, SizeF scale, RectangleF paintRect) { if (this.IsTransparent()) { return; } Size size = Size.Round(paintRect.Size); if ((size.Width <= 0) || (size.Height <= 0)) { return; } this.lastScale = scale; ElementShape currentShape = this.primitiveElement.GetCurrentShape(); //Check if we have already painded in PaintBuffer with this shape FillElementPaintBuffer paintBuffer = this.FillElementPaintBuffer; if (currentShape != null && paintBuffer != null) { string shapeProps = currentShape.SerializeProperties(); int shapeHash; if (!string.IsNullOrEmpty(shapeProps)) { shapeHash = shapeProps.GetHashCode(); } else { shapeHash = currentShape.GetHashCode(); } paintBuffer.SetShapeHash(shapeHash); } //Graphics graphics = null; bool usePaintBuffer = paintBuffer != null && paintBuffer.ShouldUsePaintBuffer() && this.primitiveElement.ShouldUsePaintBuffer(); try { if (usePaintBuffer) { if (!this.primitiveElement.IsDesignMode && paintBuffer.PaintFromBuffer(graphics, scale, size)) { return; } graphics.ChangeOpacity(1d); if (!this.primitiveElement.IsDesignMode) { paintBuffer.SetGraphics(graphics, scale); } } } catch { usePaintBuffer = false; } GraphicsPath clippingPath = null; if (currentShape != null) { clippingPath = currentShape.CreatePath(paintRect); graphics.PushCurrentClippingPath(clippingPath); } this.FillRectangle(graphics, paintRect); if (clippingPath != null) { graphics.PopCurrentClippingPath(); clippingPath.Dispose(); } if (usePaintBuffer) { graphics.RestoreOpacity(); if (!this.primitiveElement.IsDesignMode) { paintBuffer.ResetGraphics(graphics, scale); } } }
private float GetTextHeight(IGraphics g) { return(Math.Max(g.MeasureString("abfgijlpqyAIJQ170,`'\"", UserboxFont).Height + TextYOffset * 2, MinTextHeight)); }
/// <summary> /// Paints the outline of the collider in purple. /// </summary> /// <param name="g">The graphics component.</param> public void PaintOutline(IGraphics g) { g.DrawRect(Boundary.Left, Boundary.Top, Boundary.Right - Boundary.Left, Boundary.Bottom - Boundary.Top, Color.Purple); }
protected virtual void PaintFill(IGraphics g, Rectangle rect) { if (this.SignBackColor.A == (byte)0 && (this.SignNumberOfColors <= 1 || this.SignBackColor2.A == (byte)0 && (this.SignNumberOfColors <= 2 || this.SignBackColor3.A == (byte)0 && (this.SignNumberOfColors <= 3 || this.SignBackColor4.A == (byte)0))) || (this.Size.Width <= 0 || this.Size.Height <= 0)) { return; } int val2 = 4; Color[] colorStops = new Color[Math.Min(Math.Max(this.SignNumberOfColors, 1), val2)]; float[] colorOffsets = new float[Math.Min(Math.Max(this.SignNumberOfColors, 1), val2)]; if (this.SignNumberOfColors > 0) { colorStops[0] = this.SignBackColor; colorOffsets[0] = 0.0f; } if (this.SignNumberOfColors > 1) { colorStops[1] = this.SignBackColor2; colorOffsets[colorStops.Length - 1] = 1f; } if (this.SignNumberOfColors > 2) { colorStops[2] = this.SignBackColor3; colorOffsets[1] = this.SignGradientPercentage; } if (this.SignNumberOfColors > 3) { colorStops[3] = this.SignBackColor4; colorOffsets[2] = this.SignGradientPercentage2; } switch (this.SignGradientStyle) { case GradientStyles.Solid: g.FillRectangle(rect, this.SignBackColor); break; case GradientStyles.Linear: case GradientStyles.Radial: if (this.SignNumberOfColors < 2) { g.FillRectangle(rect, this.SignBackColor); break; } g.FillGradientRectangle(rect, colorStops, colorOffsets, this.SignGradientStyle, this.SignGradientAngle, this.SignGradientPercentage, this.SignGradientPercentage2); break; case GradientStyles.Glass: g.FillGlassRectangle(rect, this.SignBackColor, this.SignBackColor2, this.SignBackColor3, this.SignBackColor4, this.SignGradientPercentage, this.SignGradientPercentage2); break; case GradientStyles.OfficeGlass: g.FillOfficeGlassRectangle(rect, this.SignBackColor, this.SignBackColor2, this.SignBackColor3, this.SignBackColor4, this.SignGradientPercentage, this.SignGradientPercentage2, true); break; case GradientStyles.OfficeGlassRect: g.FillOfficeGlassRectangle(rect, this.SignBackColor, this.SignBackColor2, this.SignBackColor3, this.SignBackColor4, this.SignGradientPercentage, this.SignGradientPercentage2, false); break; case GradientStyles.Gel: g.FillGellRectangle(rect, colorStops, this.SignGradientPercentage, this.SignGradientPercentage2); break; case GradientStyles.Vista: g.FillVistaRectangle(rect, this.SignBackColor, this.SignBackColor2, this.SignBackColor3, this.SignBackColor4, this.SignGradientPercentage, this.SignGradientPercentage2); break; } }
/// <summary> /// Dispatch this event for a robot, it's statistics, and graphics context. /// </summary> /// <param name="robot">the robot to dispatch to.</param> /// <param name="statics">the robot to statistics to.</param> /// <param name="graphics">the robot to graphics to.</param> // This method must be invisible on Robot API internal virtual void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) { }
public DrawingAppHelper(Model model, Canvas canvas) { _model = model; _graphics = new AppGraphicsAdapter(canvas); }
public override void OnRender(IGraphics g) { var temp = g.Transform; g.TranslateTransform(LocalPosition.X, LocalPosition.Y); g.RotateTransform(-Overlay.Control.Bearing); int length = 500; // anti NaN try { g.DrawLine(new Pen(Color.Red, 2), 0.0f, 0.0f, (float)Math.Cos((heading - 90) * MathHelper.deg2rad) * length, (float)Math.Sin((heading - 90) * MathHelper.deg2rad) * length); } catch { } g.DrawLine(new Pen(Color.Green, 2), 0.0f, 0.0f, (float)Math.Cos((nav_bearing - 90) * MathHelper.deg2rad) * length, (float)Math.Sin((nav_bearing - 90) * MathHelper.deg2rad) * length); g.DrawLine(new Pen(Color.Black, 2), 0.0f, 0.0f, (float)Math.Cos((cog - 90) * MathHelper.deg2rad) * length, (float)Math.Sin((cog - 90) * MathHelper.deg2rad) * length); g.DrawLine(new Pen(Color.Orange, 2), 0.0f, 0.0f, (float)Math.Cos((target - 90) * MathHelper.deg2rad) * length, (float)Math.Sin((target - 90) * MathHelper.deg2rad) * length); // anti NaN try { float desired_lead_dist = 100; double width = (Overlay.Control.MapProvider.Projection.GetDistance(Overlay.Control.FromLocalToLatLng(0, 0), Overlay.Control.FromLocalToLatLng(Overlay.Control.Width, 0)) * 1000.0); double m2pixelwidth = Overlay.Control.Width / width; float alpha = (float)(((desired_lead_dist * (float)m2pixelwidth) / radius) * MathHelper.rad2deg); var scaledradius = radius * (float)m2pixelwidth; if (radius < -1 && alpha < -1) { // fixme float p1 = (float)Math.Cos((cog) * MathHelper.deg2rad) * scaledradius + scaledradius; float p2 = (float)Math.Sin((cog) * MathHelper.deg2rad) * scaledradius + scaledradius; g.DrawArc(new Pen(Color.HotPink, 2), p1, p2, Math.Abs(scaledradius) * 2, Math.Abs(scaledradius) * 2, cog, alpha); } else if (radius > 1 && alpha > 1) { // correct float p1 = (float)Math.Cos((cog - 180) * MathHelper.deg2rad) * scaledradius + scaledradius; float p2 = (float)Math.Sin((cog - 180) * MathHelper.deg2rad) * scaledradius + scaledradius; g.DrawArc(new Pen(Color.HotPink, 2), -p1, -p2, scaledradius * 2, scaledradius * 2, cog - 180, alpha); } } catch { } try { g.RotateTransform(heading); } catch { } // 'which' variable simply selects different coloured plane icon/s from the resource library if (which == 0) { g.DrawImageUnscaled(icon, icon.Width / -2, icon.Height / -2); } if (which == 1) { g.DrawImageUnscaled(icon1, icon1.Width / -2, icon1.Height / -2); } if (which == 2) { g.DrawImageUnscaled(icon2, icon2.Width / -2, icon2.Height / -2); } if (which == 3) { g.DrawImageUnscaled(icon3, icon3.Width / -2, icon3.Height / -2); } if (which == 4) { g.DrawImageUnscaled(icon4, icon4.Width / -2, icon4.Height / -2); } if (which == 5) { g.DrawImageUnscaled(icon5, icon5.Width / -2, icon5.Height / -2); } if (which == 6) { g.DrawImageUnscaled(icon6, icon6.Width / -2, icon6.Height / -2); } g.Transform = temp; }
protected override void PaintElement(IGraphics graphics, float angle, SizeF scale) { base.PaintElement(graphics, angle, scale); this.Paint(((RadGdiGraphics)graphics).Graphics, this.BoundingRectangle); }
/// <summary> /// Setup the Transform Matrix to handle drawing of this <see cref="XAxis"/> /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> override public void SetTransformMatrix(IGraphics g, GraphPane pane, float scaleFactor) { // Move the origin to the BottomLeft of the ChartRect, which is the left // side of the X axis (facing from the label side) g.TranslateTransform(pane.Chart._rect.Left, pane.Chart._rect.Bottom); }
internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) { if (robot != null) { IBasicEvents3 listener = robot.GetBasicEventListener() as IBasicEvents3; if (listener != null) { listener.OnRoundEnded(this); } } }
public override void Paint(IGraphics g, Color clr, int penWidth) { SetCharacteristics(); g.DrawPolygon(clr, penWidth, points); SetShapeProperties(clr, penWidth); }
protected override void DrawEndCap(IGraphics g, bool onScreen, Style style) { linePen.Color = style.RelationshipColor; linePen.Width = style.RelationshipWidth; g.DrawLines(linePen, Arrowhead.OpenArrowPoints); }
/// <summary> /// Draw a legend key entry for this <see cref="CurveItem"/> at the specified location. /// This abstract base method passes through to <see cref="BarItem.DrawLegendKey"/> or /// <see cref="LineItem.DrawLegendKey"/> to do the rendering. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="rect">The <see cref="RectangleF"/> struct that specifies the /// location for the legend key</param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public override void DrawLegendKey(IGraphics g, GraphPane pane, RectangleF rect, float scaleFactor) { throw new System.NotImplementedException(); }
public static void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) { eventHelper.Dispatch(evnt, robot, statics, graphics); }
public Match3(IGameLoop gameLoop, IGraphics graphics, IAudio audio, IKeyboard keyboard, IMouse mouse = null, IFileSystem fileSystem = null) : base(nameof(Match3), gameLoop, graphics, audio, keyboard, mouse, fileSystem) { Keyboard = new StatefulKeyboard(keyboard); Instance = this; }
protected override void PaintElement(IGraphics graphics, float angle, SizeF scale) { base.PaintElement(graphics, angle, scale); this.PaintDots(graphics, angle, scale); }