public override void Draw(System.Drawing.RectangleF dirtyRect) { var g = new Graphics(); // NSView does not have a background color so we just use Clear to white here g.Clear(Color.White); //RectangleF ClientRectangle = this.Bounds; RectangleF ClientRectangle = dirtyRect; // Calculate the location and size of the drawing area // within which we want to draw the graphics: Rectangle rect = new Rectangle((int)ClientRectangle.X, (int)ClientRectangle.Y, (int)ClientRectangle.Width, (int)ClientRectangle.Height); drawingRectangle = new Rectangle(rect.Location, rect.Size); drawingRectangle.Inflate(-offset, -offset); //Draw ClientRectangle and drawingRectangle using Pen: g.DrawRectangle(Pens.Red, rect); g.DrawRectangle(Pens.Black, drawingRectangle); // Draw a line from point (3,2) to Point (6, 7) // using the Pen with a width of 3 pixels: Pen aPen = new Pen(Color.Green, 3); g.DrawLine(aPen, Point2D(new PointF(3, 2)), Point2D(new PointF(6, 7))); g.PageUnit = GraphicsUnit.Inch; ClientRectangle = new RectangleF(0.5f,0.5f, 1.5f, 1.5f); aPen.Width = 1 / g.DpiX; g.DrawRectangle(aPen, ClientRectangle); aPen.Dispose(); g.Dispose(); }
public static void FillRoundedRectangle(this Graphics g, Brush brush, RectangleF rect, float topLeftCorner, float topRightCorner, float bottomLeftCorner, float bottomRightCorner) { using(var gp = GraphicsUtility.GetRoundedRectangle(rect, topLeftCorner, topRightCorner, bottomLeftCorner, bottomRightCorner)) { g.FillPath(brush, gp); } }
private LoadingIndicator() : base() { int ScreenWidth = Platform.ScreenWidth; int ScreenHeight = Platform.ScreenHeight - 80; const int Padding = 10; const int TextWidth = 65; const int SpinnerSize = 20; const int SeparateWidth = 5; const int Width = Padding + SpinnerSize + SeparateWidth + TextWidth + Padding; const int Height = Padding + SpinnerSize + Padding; Frame = new RectangleF((ScreenWidth - Width) / 2, ScreenHeight / 2, Width, Height); BackgroundColor = UIColor.FromWhiteAlpha(0.5f, 0.5f); spinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge) { Frame = new RectangleF(Padding, Padding, SpinnerSize, SpinnerSize) }; label = new UILabel { Frame = new RectangleF(Padding + SpinnerSize + SeparateWidth, Padding, TextWidth, SpinnerSize), Text = "Loading...", TextColor = StyleExtensions.lightGrayText, BackgroundColor = StyleExtensions.transparent, AdjustsFontSizeToFitWidth = true }; AddSubview(label); AddSubview(spinner); Hidden = true; }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { Caja = new RectangleF((int)((e.X - MedCambiante.X) / (trackBar1.Value / 100.0f)), (int)((e.Y - MedCambiante.Y) / (trackBar1.Value / 100.0f)), 0, 0); label1.Text = "X= " + Caja.X; label2.Text = "Y= " + Caja.Y; }
public static void FillPill(Brush b, RectangleF rect, Graphics g) { if (rect.Width > rect.Height) { g.SmoothingMode = SmoothingMode.HighQuality; g.FillEllipse(b, new RectangleF(rect.Left, rect.Top, rect.Height, rect.Height)); g.FillEllipse(b, new RectangleF(rect.Left + rect.Width - rect.Height, rect.Top, rect.Height, rect.Height)); var w = rect.Width - rect.Height; var l = rect.Left + ((rect.Height) / 2); g.FillRectangle(b, new RectangleF(l, rect.Top, w, rect.Height)); g.SmoothingMode = SmoothingMode.Default; } else if (rect.Width < rect.Height) { g.SmoothingMode = SmoothingMode.HighQuality; g.FillEllipse(b, new RectangleF(rect.Left, rect.Top, rect.Width, rect.Width)); g.FillEllipse(b, new RectangleF(rect.Left, rect.Top + rect.Height - rect.Width, rect.Width, rect.Width)); var t = rect.Top + (rect.Width / 2); var h = rect.Height - rect.Width; g.FillRectangle(b, new RectangleF(rect.Left, t, rect.Width, h)); g.SmoothingMode = SmoothingMode.Default; } else if (rect.Width == rect.Height) { g.SmoothingMode = SmoothingMode.HighQuality; g.FillEllipse(b, rect); g.SmoothingMode = SmoothingMode.Default; } }
/// <summary> /// Draw a preview of the <see cref="ColorPair"/> /// </summary> /// <param name="e">The paint event args providing the <see cref="Graphics"/> and bounding /// rectangle</param> public override void PaintValue(PaintValueEventArgs e) { ColorPair colorPair = (ColorPair)e.Value ; using ( SolidBrush b = new SolidBrush(colorPair.Background)) { e.Graphics.FillRectangle(b, e.Bounds); } // Draw the text "ab" using the Foreground/Background values from the ColorPair using(SolidBrush b = new SolidBrush(colorPair.Foreground)) { using(Font f = new Font("Arial",6)) { RectangleF temp = new RectangleF(e.Bounds.Left,e.Bounds.Top,e.Bounds.Height,e.Bounds.Width) ; temp.Inflate(-2,-2) ; // Set up how we want the text drawn StringFormat format = new StringFormat(StringFormatFlags.FitBlackBox | StringFormatFlags.NoWrap) ; format.Trimming = StringTrimming.EllipsisCharacter ; format.Alignment = StringAlignment.Center ; format.LineAlignment = StringAlignment.Center ; // save the Smoothing mode of the Graphics object so we can restore it SmoothingMode saveMode = e.Graphics.SmoothingMode ; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias ; e.Graphics.DrawString("ab",f,b,temp,format) ; e.Graphics.SmoothingMode = saveMode ; } } }
public CanvasView AutoStart(RectangleF RectangleF, double Width, double Height) { return new CanvasView( this.X - (RectangleF.Left + RectangleF.Right) / 2 + Width / 2, this.Y - (RectangleF.Bottom + RectangleF.Top) / 2 + Height / 2, this.Phi, this.Zoom, this.Mirrow); }
public static float CalculateIntersectPercentage(RectangleF rect, RectangleF referenceRect) { if (rect.IsEmpty || referenceRect.IsEmpty) return 0; referenceRect.Intersect(rect); // replace referenceRect with intersect return referenceRect.IsEmpty ? 0 : (referenceRect.Width * referenceRect.Height) / (rect.Width * rect.Height); }
public GameWindow(Game game, RectangleF frame) : base (frame) { if (game == null) throw new ArgumentNullException("game"); _game = game; _platform = (MacGamePlatform)_game.Services.GetService(typeof(MacGamePlatform)); //LayerRetainsBacking = false; //LayerColorFormat = EAGLColorFormat.RGBA8; this.AutoresizingMask = MonoMac.AppKit.NSViewResizingMask.HeightSizable | MonoMac.AppKit.NSViewResizingMask.MaxXMargin | MonoMac.AppKit.NSViewResizingMask.MinYMargin | MonoMac.AppKit.NSViewResizingMask.WidthSizable; RectangleF rect = NSScreen.MainScreen.Frame; clientBounds = new Rectangle (0,0,(int)rect.Width,(int)rect.Height); // Enable multi-touch //MultipleTouchEnabled = true; // Initialize GameTime _updateGameTime = new GameTime (); _drawGameTime = new GameTime (); // Initialize _lastUpdate _lastUpdate = DateTime.Now; }
public override void DrawRect(RectangleF dirtyRect) { base.DrawRect(dirtyRect); var context = NSGraphicsContext.CurrentContext.GraphicsPort; var wrapper = new GraphicsContextWrapper(context, Bounds.Width, Bounds.Height, GenericControlHelper.ToBasicRect(dirtyRect)); _control.Render(wrapper); }
public override void ViewDidLoad() { base.ViewDidLoad (); // Create the chart float margin = UserInterfaceIdiomIsPhone ? 10 : 50; RectangleF frame = new RectangleF (margin, margin, View.Bounds.Width - 2 * margin, View.Bounds.Height - 2 * margin); chart = new ShinobiChart (frame) { Title = "Project Commit Punchcard", AutoresizingMask = ~UIViewAutoresizing.None, LicenseKey = "", // TODO: add your trail licence key here! DataSource = new BubbleSeriesDataSource(), YAxis = new SChartCategoryAxis { Title = "Day", RangePaddingHigh = new NSNumber(0.5), RangePaddingLow = new NSNumber(0.5) }, XAxis = new SChartNumberAxis { Title = "Hour", RangePaddingHigh = new NSNumber(0.5), RangePaddingLow = new NSNumber(0.5) } }; View.AddSubview (chart); }
public byte[] GetImageAsJpeg(RectangleF roi) { var buf = _contents[_index]; _index = (_index + 1) % _contents.Count; return buf; }
/// <summary> /// Draws grid lines corresponding to a vertical scale</summary> /// <param name="g">The Direct2D graphics object</param> /// <param name="transform">Graph (world) to window's client (screen) transform</param> /// <param name="graphRect">Graph rectangle</param> /// <param name="majorSpacing">Scale's major spacing</param> /// <param name="lineBrush">Grid line brush</param> public static void DrawVerticalScaleGrid( this D2dGraphics g, Matrix transform, RectangleF graphRect, int majorSpacing, D2dBrush lineBrush) { double xScale = transform.Elements[0]; RectangleF clientRect = Transform(transform, graphRect); double min = Math.Min(graphRect.Left, graphRect.Right); double max = Math.Max(graphRect.Left, graphRect.Right); double tickAnchor = CalculateTickAnchor(min, max); double step = CalculateStep(min, max, Math.Abs(clientRect.Right - clientRect.Left), majorSpacing, 0.0); if (step > 0) { double offset = tickAnchor - min; offset = offset - MathUtil.Remainder(offset, step) + step; for (double x = tickAnchor - offset; x <= max; x += step) { double cx = (x - graphRect.Left) * xScale + clientRect.Left; g.DrawLine((float)cx, clientRect.Top, (float)cx, clientRect.Bottom, lineBrush); } } }
public DrawingView (RectangleF p, double lag, double max, double min) : base(p) { BackgroundColor = UIColor.White; this.lag = lag; this.max = max; this.min = min; }
public PacketMove(int id, RectangleF newPosition, System.Net.IPEndPoint destination) : base("PACKET:MOVE", destination) { this.ID = id; this.NewPosition = newPosition; this.SetData(new PacketData(this, newPosition.X + ":" + newPosition.Y + ":" + newPosition.Width + ":" + newPosition.Height, id)); }
// Draw a carpet in the rectangle. private void DrawRectangle(Graphics gr, int level, RectangleF rect) { // See if we should stop. if (level == 0) { // Fill the rectangle. gr.FillRectangle(Brushes.Blue, rect); } else { // Divide the rectangle into 9 pieces. float wid = rect.Width / 3f; float x0 = rect.Left; float x1 = x0 + wid; float x2 = x0 + wid * 2f; float hgt = rect.Height / 3f; float y0 = rect.Top; float y1 = y0 + hgt; float y2 = y0 + hgt * 2f; // Recursively draw smaller carpets. DrawRectangle(gr, level - 1, new RectangleF(x0, y0, wid, hgt)); DrawRectangle(gr, level - 1, new RectangleF(x1, y0, wid, hgt)); DrawRectangle(gr, level - 1, new RectangleF(x2, y0, wid, hgt)); DrawRectangle(gr, level - 1, new RectangleF(x0, y1, wid, hgt)); DrawRectangle(gr, level - 1, new RectangleF(x2, y1, wid, hgt)); DrawRectangle(gr, level - 1, new RectangleF(x0, y2, wid, hgt)); DrawRectangle(gr, level - 1, new RectangleF(x1, y2, wid, hgt)); DrawRectangle(gr, level - 1, new RectangleF(x2, y2, wid, hgt)); } }
public Physics(Point p, RectangleF boundingBox) { startPosition = p; position = startPosition; this.boundingBox = boundingBox; visible = true; }
public MonoMacGameView (RectangleF frame, NSOpenGLContext context) : base(frame) { var attribs = new object [] { NSOpenGLPixelFormatAttribute.Accelerated, NSOpenGLPixelFormatAttribute.NoRecovery, NSOpenGLPixelFormatAttribute.DoubleBuffer, NSOpenGLPixelFormatAttribute.ColorSize, 24, NSOpenGLPixelFormatAttribute.DepthSize, 16 }; pixelFormat = new NSOpenGLPixelFormat (attribs); if (pixelFormat == null) Console.WriteLine ("No OpenGL pixel format"); // NSOpenGLView does not handle context sharing, so we draw to a custom NSView instead openGLContext = new NSOpenGLContext (pixelFormat, context); openGLContext.MakeCurrentContext (); // default the swap interval and displaylink SwapInterval = true; DisplaylinkSupported = true; // Look for changes in view size // Note, -reshape will not be called automatically on size changes because NSView does not export it to override notificationProxy = NSNotificationCenter.DefaultCenter.AddObserver (NSView.GlobalFrameChangedNotification, HandleReshape); }
public ImageScrollView (RectangleF frame) : base (frame) { ShowsVerticalScrollIndicator = false; ShowsHorizontalScrollIndicator = false; BouncesZoom = true; DecelerationRate = UIScrollView.DecelerationRateFast; }
public static void DrawRoundedRectangle(this Graphics g, Pen pen, RectangleF rect, float cornerRadius) { using(var gp = GraphicsUtility.GetRoundedRectangle(rect, cornerRadius)) { g.DrawPath(pen, gp); } }
public static void FillRoundedRectangle(this Graphics g, Brush brush, RectangleF rect, float cornerRadius) { using(var gp = GraphicsUtility.GetRoundedRectangle(rect, cornerRadius)) { g.FillPath(brush, gp); } }
public override void ViewWillAppear (bool animated) { base.ViewWillAppear (animated); if(BL.Managers.UpdateManager.IsUpdating) { if (loadingOverlay == null) { var bounds = new RectangleF(0,0,768,1004); if (InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || InterfaceOrientation == UIInterfaceOrientation.LandscapeRight) { bounds = new RectangleF(0,0,1024,748); } loadingOverlay = new MWC.iOS.UI.Controls.LoadingOverlay (bounds); // because DialogViewController is a UITableViewController, // we need to step OVER the UITableView, otherwise the loadingOverlay // sits *in* the scrolling area of the table View.Superview.Add (loadingOverlay); View.Superview.BringSubviewToFront (loadingOverlay); } ConsoleD.WriteLine("Waiting for updates to finish before displaying table."); } else { loadingOverlay = null; if (AlwaysRefresh || Root == null || Root.Count == 0) { ConsoleD.WriteLine("Not updating, populating table."); PopulateTable(); } else ConsoleD.WriteLine("Data already populated."); } }
public override void Draw(RectangleF rect) { var element = Element as CircleView; if (element == null) { throw new InvalidOperationException ("Element must be a Circle View type"); } //get graphics context using(CGContext context = UIGraphics.GetCurrentContext ()){ context.SetFillColor(element.FillColor.ToCGColor()); context.SetStrokeColor(element.StrokeColor.ToCGColor()); context.SetLineWidth(element.StrokeThickness); if (element.StrokeDash > 1.0f) { context.SetLineDash ( 0, new float[] { element.StrokeDash, element.StrokeDash }); } //create geometry var path = new CGPath (); path.AddEllipseInRect (rect); path.CloseSubpath(); //add geometry to graphics context and draw it context.AddPath(path); context.DrawPath(CGPathDrawingMode.FillStroke); } }
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e) { // base.OnRenderSeparator(e); if (!e.Item.IsOnDropDown) { int top = 9; int left = e.Item.Width / 2; left--; int height = e.Item.Height - top * 2; RectangleF separator = new RectangleF(left, top, 0.5f, height); using (LinearGradientBrush b = new LinearGradientBrush( separator.Location, new Point(Convert.ToInt32(separator.Left), Convert.ToInt32(separator.Bottom)), Color.Red, Color.Black)) { ColorBlend blend = new ColorBlend(); blend.Colors = new Color[] { ToolStripColorTable.ToolStripSplitButtonTop, ToolStripColorTable.ToolStripSplitButtonMiddle, ToolStripColorTable.ToolStripSplitButtonMiddle, ToolStripColorTable.ToolStripSplitButtonBottom }; blend.Positions = new float[] { 0.0f, 0.22f, 0.78f, 1.0f }; b.InterpolationColors = blend; e.Graphics.FillRectangle(b, separator); } } }
// Draw the carpet. private void DrawGasket() { Level = int.Parse(txtLevel.Text); Bitmap bm = new Bitmap( picGasket.ClientSize.Width, picGasket.ClientSize.Height); using (Graphics gr = Graphics.FromImage(bm)) { gr.Clear(Color.White); gr.SmoothingMode = SmoothingMode.AntiAlias; // Draw the top-level carpet. const float margin = 10; RectangleF rect = new RectangleF( margin, margin, picGasket.ClientSize.Width - 2 * margin, picGasket.ClientSize.Height - 2 * margin); DrawRectangle(gr, Level, rect); } // Display the result. picGasket.Image = bm; // Save the bitmap into a file. bm.Save("Carpet " + Level + ".bmp"); }
public void AddSiteUrl(RectangleF frame) { url = UIButton.FromType(UIButtonType.Custom); url.LineBreakMode = UILineBreakMode.TailTruncation; url.HorizontalAlignment = UIControlContentHorizontalAlignment.Left; url.TitleShadowOffset = new SizeF(0, 1); url.SetTitleColor(UIColor.FromRGB (0x32, 0x4f, 0x85), UIControlState.Normal); url.SetTitleColor(UIColor.Red, UIControlState.Highlighted); url.SetTitleShadowColor(UIColor.White, UIControlState.Normal); url.AddTarget(delegate { if (UrlTapped != null) UrlTapped (); }, UIControlEvent.TouchUpInside); // Autosize the bio URL to fit available space var size = _urlSize; var urlFont = UIFont.BoldSystemFontOfSize(size); var urlSize = new NSString(_bio.Url).StringSize(urlFont); var available = Util.IsPad() ? 400 : 185; // Util.IsRetina() ? 185 : 250; while(urlSize.Width > available) { urlFont = UIFont.BoldSystemFontOfSize(size--); urlSize = new NSString(_bio.Url).StringSize(urlFont); } url.Font = urlFont; url.Frame = new RectangleF ((float)_left, (float)70, (float)(frame.Width - _left), (float)size); url.SetTitle(_bio.Url, UIControlState.Normal); url.SetTitle(_bio.Url, UIControlState.Highlighted); AddSubview(url); }
public override void ViewDidLoad () { base.ViewDidLoad (); // set the background color of the view to white View.BackgroundColor = UIColor.White; // instantiate a new image view that takes up the whole screen and add it to // the view hierarchy RectangleF imageViewFrame = new RectangleF (0, -NavigationController.NavigationBar.Frame.Height, View.Frame.Width, View.Frame.Height); imageView = new UIImageView (imageViewFrame); View.AddSubview (imageView); // create our offscreen bitmap context // size SizeF bitmapSize = new SizeF (imageView.Frame.Size); using (CGBitmapContext context = new CGBitmapContext (IntPtr.Zero, (int)bitmapSize.Width, (int)bitmapSize.Height, 8, (int)(4 * bitmapSize.Width), CGColorSpace.CreateDeviceRGB (), CGImageAlphaInfo.PremultipliedFirst)) { // draw our coordinates for reference DrawCoordinateSpace (context); // draw our flag DrawFlag (context); // add a label DrawCenteredTextAtPoint (context, 384, 700, "Stars and Stripes", 60); // output the drawing to the view imageView.Image = UIImage.FromImage (context.ToImage ()); } }
public override void Draw() { float powerScaleBy = 100; var maxPower = Math.Max(pm.PowerProvided, pm.PowerDrained); while (maxPower >= powerScaleBy) powerScaleBy *= 2; // Current power supply var providedFrac = pm.PowerProvided / powerScaleBy; lastProvidedFrac = providedFrac = float2.Lerp(lastProvidedFrac.GetValueOrDefault(providedFrac), providedFrac, .3f); var color = Color.LimeGreen; if (pm.PowerState == PowerState.Low) color = Color.Orange; if (pm.PowerState == PowerState.Critical) color = Color.Red; var b = RenderBounds; var rect = new RectangleF(b.X, b.Y + (1-providedFrac)*b.Height, (float)b.Width, providedFrac*b.Height); Game.Renderer.LineRenderer.FillRect(rect, color); var indicator = ChromeProvider.GetImage("sidebar-bits", "left-indicator"); var drainedFrac = pm.PowerDrained / powerScaleBy; lastDrainedFrac = drainedFrac = float2.Lerp(lastDrainedFrac.GetValueOrDefault(drainedFrac), drainedFrac, .3f); float2 pos = new float2(b.X + b.Width - indicator.size.X, b.Y + (1-drainedFrac)*b.Height - indicator.size.Y / 2); Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, pos); }
public override bool Update(Vector2 mouseS, IMapManager currentMap) { if (currentMap == null) return false; spriteToDraw = GetDirectionalSprite(pManager.CurrentBaseSprite); mouseScreen = mouseS; mouseWorld = MapUtil.worldToTileSize(mouseScreen); var spriteSize = MapUtil.worldToTileSize(spriteToDraw.Size); var spriteRectWorld = new RectangleF(mouseWorld.X - (spriteSize.X / 2f), mouseWorld.Y - (spriteSize.Y / 2f), spriteSize.X, spriteSize.Y); if (pManager.CurrentPermission.IsTile) return false; if (pManager.CollisionManager.IsColliding(spriteRectWorld)) return false; //if (currentMap.IsSolidTile(mouseWorld)) return false; if (pManager.CurrentPermission.Range > 0) if ( (pManager.PlayerManager.ControlledEntity.GetComponent<TransformComponent>(ComponentFamily.Transform) .Position - mouseWorld).Length > pManager.CurrentPermission.Range) return false; currentTile = currentMap.GetTileRef(mouseWorld); return true; }
public MyOpenGLView (RectangleF frame,NSOpenGLContext context) : base(frame) { var attribs = new object[] { NSOpenGLPixelFormatAttribute.Accelerated, NSOpenGLPixelFormatAttribute.NoRecovery, NSOpenGLPixelFormatAttribute.DoubleBuffer, NSOpenGLPixelFormatAttribute.ColorSize, 24, NSOpenGLPixelFormatAttribute.DepthSize, 16 }; pixelFormat = new NSOpenGLPixelFormat (attribs); if (pixelFormat == null) Console.WriteLine ("No OpenGL pixel format"); // NSOpenGLView does not handle context sharing, so we draw to a custom NSView instead openGLContext = new NSOpenGLContext (pixelFormat, context); openGLContext.MakeCurrentContext (); // Synchronize buffer swaps with vertical refresh rate openGLContext.SwapInterval = true; // Initialize our newly created view. InitGL (); SetupDisplayLink (); // Look for changes in view size // Note, -reshape will not be called automatically on size changes because NSView does not export it to override notificationProxy = NSNotificationCenter.DefaultCenter.AddObserver (NSView.NSViewGlobalFrameDidChangeNotification, HandleReshape); }
protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) { e.PageSettings.Landscape = false; e.Graphics.PageUnit = GraphicsUnit.Display; m_Pagina++; int PrintAreaHeight = base.DefaultPageSettings.PaperSize.Height - base.DefaultPageSettings.Margins.Top - base.DefaultPageSettings.Margins.Bottom, PrintAreaWidth = base.DefaultPageSettings.PaperSize.Width - base.DefaultPageSettings.Margins.Left - base.DefaultPageSettings.Margins.Right, MarginLeft = base.DefaultPageSettings.Margins.Left, MarginTop = base.DefaultPageSettings.Margins.Top; // intMarginBottom = MyBase.DefaultPageSettings.Margins.Bottom if (base.DefaultPageSettings.Landscape) { int intTemp = 0; intTemp = PrintAreaHeight; PrintAreaHeight = PrintAreaWidth; PrintAreaWidth = intTemp; } //RectangleF PrintingArea = new RectangleF(MarginLeft, MarginTop, PrintAreaWidth, PrintAreaHeight); StringFormat FormatoCC = new StringFormat(); FormatoCC.Alignment = StringAlignment.Center; FormatoCC.LineAlignment = StringAlignment.Center; StringFormat FormatoLC = new StringFormat(); FormatoLC.Alignment = StringAlignment.Near; FormatoLC.LineAlignment = StringAlignment.Center; FormatoLC.FormatFlags = StringFormatFlags.NoWrap; FormatoLC.Trimming = StringTrimming.EllipsisCharacter; StringFormat FormatoRC = new StringFormat(); FormatoRC.Alignment = StringAlignment.Far; FormatoRC.LineAlignment = StringAlignment.Center; StringFormat FormatoLT = new StringFormat(); FormatoLT.Alignment = StringAlignment.Near; FormatoLT.LineAlignment = StringAlignment.Near; FormatoLT.FormatFlags = StringFormatFlags.LineLimit; FormatoLT.Trimming = StringTrimming.EllipsisWord; Font Fuente = null; Font FuentePequena = new Font("Arial", 7); RectangleF Rect = new System.Drawing.RectangleF(); int iTop = MarginTop; // Título: PRESUPUESTO Fuente = new Font("Arial Black", 20); Rect = new RectangleF(MarginLeft, iTop, PrintAreaWidth, 32); e.Graphics.DrawString("PRESUPUESTO", Fuente, Brushes.SteelBlue, Rect, FormatoCC); // ev.Graphics.DrawRectangle(Pens.Silver, Rect.X, Rect.Y, Rect.Width, Rect.Height) iTop += System.Convert.ToInt32(Rect.Height); // Fecha Fuente = new Font("Arial", 9); Rect = new RectangleF(MarginLeft, iTop, PrintAreaWidth, 18); e.Graphics.DrawString(System.DateTime.Now.ToString(Lfx.Types.Formatting.DateTime.LongDatePattern), Fuente, Brushes.Black, Rect, FormatoCC); // ev.Graphics.DrawRectangle(Pens.Red, Rect.X, Rect.Y, Rect.Width, Rect.Height) iTop += System.Convert.ToInt32(Rect.Height + 4); // Cliente Rect = new RectangleF(MarginLeft, iTop, PrintAreaWidth - 100, 20); e.Graphics.DrawString("Para: " + this.Tarea.Cliente.Nombre, Fuente, Brushes.Black, Rect, FormatoLC); // ev.Graphics.DrawRectangle(Pens.Blue, Rect.X, Rect.Y, Rect.Width, Rect.Height) // Nº PS Rect = new RectangleF(MarginLeft + PrintAreaWidth - 100, iTop, 100, 20); e.Graphics.DrawString("PS" + this.Tarea.Numero.ToString("000000"), Fuente, Brushes.Black, Rect, FormatoRC); // ev.Graphics.DrawRectangle(Pens.Green, Rect.X, Rect.Y, Rect.Width, Rect.Height) iTop += System.Convert.ToInt32(Rect.Height + 4); // Encab Fuente = new Font("Arial", 10, FontStyle.Bold); Rect = new RectangleF(MarginLeft, iTop, PrintAreaWidth, 20); e.Graphics.FillRectangle(Brushes.Wheat, Rect.X, Rect.Y, Rect.Width, Rect.Height); Rect = new RectangleF(MarginLeft, iTop, 20, 20); e.Graphics.DrawString("#", Fuente, Brushes.DimGray, Rect, FormatoRC); Rect = new RectangleF(MarginLeft + 26, iTop, 40, 20); e.Graphics.DrawString("Cant", Fuente, Brushes.Black, Rect, FormatoRC); Rect = new RectangleF(MarginLeft + 70, iTop, PrintAreaWidth - MarginLeft - 160, 20); e.Graphics.DrawString("Detalle", Fuente, Brushes.Black, Rect, FormatoLC); // ev.Graphics.DrawRectangle(Pens.Violet, Rect.X, Rect.Y, Rect.Width, Rect.Height) Rect = new RectangleF(MarginLeft + PrintAreaWidth - 200, iTop, 100, 20); e.Graphics.DrawString("Precio", Fuente, Brushes.Black, Rect, FormatoRC); Rect = new RectangleF(MarginLeft + PrintAreaWidth - 100, iTop, 100, 20); e.Graphics.DrawString("Importe", Fuente, Brushes.Black, Rect, FormatoRC); // ev.Graphics.DrawRectangle(Pens.Violet, Rect.X, Rect.Y, Rect.Width, Rect.Height) iTop += System.Convert.ToInt32(Rect.Height + 4); // Obs int AlturaPie = 0; if (this.Tarea.Obs != null && this.Tarea.Obs.Length > 0) { Rect = new RectangleF(MarginLeft, 0, PrintAreaWidth, 500); SizeF Tamano = e.Graphics.MeasureString("Obs: " + this.Tarea.Obs, FuentePequena, Rect.Size, FormatoLT); Rect.Height = Tamano.Height; Rect.Y = MarginTop + PrintAreaHeight - 20 - Rect.Height; e.Graphics.DrawString("Obs: " + this.Tarea.Obs, FuentePequena, Brushes.Black, Rect, FormatoLT); AlturaPie += System.Convert.ToInt32(Rect.Height); } AlturaPie += 24; // Detalle Fuente = new Font(Lazaro.Pres.DisplayStyles.Template.Current.DefaultPrintFontName, 10); int RowNumber = 0; foreach (Lbl.Comprobantes.DetalleArticulo Detalle in this.Tarea.Articulos) { RowNumber++; Rect = new RectangleF(MarginLeft, iTop, 20, 20); e.Graphics.DrawString(RowNumber.ToString(), Fuente, Brushes.DarkGray, Rect, FormatoRC); Rect = new RectangleF(MarginLeft + 26, iTop, 40, 20); e.Graphics.DrawString( Lfx.Types.Formatting.FormatNumber(Detalle.Cantidad, Lbl.Sys.Config.Articulos.Decimales), Fuente, Brushes.Black, Rect, FormatoRC); Rect = new RectangleF(MarginLeft + 70, iTop, PrintAreaWidth - MarginLeft - 160, 20); e.Graphics.DrawString(Detalle.Nombre, Fuente, Brushes.Black, Rect, FormatoLC); Rect = new RectangleF(MarginLeft + PrintAreaWidth - 200, iTop, 100, 20); e.Graphics.DrawString(Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatNumber(Detalle.ImporteUnitario, Lfx.Workspace.Master.CurrentConfig.Moneda.DecimalesCosto), Fuente, Brushes.Black, Rect, FormatoRC); Rect = new RectangleF(MarginLeft + PrintAreaWidth - 100, iTop, 100, 20); e.Graphics.DrawString(Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatNumber(Detalle.ImporteAImprimir, Lfx.Workspace.Master.CurrentConfig.Moneda.DecimalesCosto), Fuente, Brushes.Black, Rect, FormatoRC); iTop += 20; if (Detalle.Articulo != null) { Rect = new RectangleF(MarginLeft + 70, iTop, PrintAreaWidth - MarginLeft - 140, 100); if (Detalle.Articulo.Descripcion != null && Detalle.Articulo.Descripcion.Length > 0) { SizeF Tamano = e.Graphics.MeasureString(Detalle.Articulo.Descripcion, FuentePequena, Rect.Size, FormatoLT); if (Tamano.Height > 50) { Tamano.Height = 50; } Rect.Height = Tamano.Height; e.Graphics.DrawString(Detalle.Articulo.Descripcion, FuentePequena, Brushes.Black, Rect, FormatoLT); iTop += System.Convert.ToInt32(Rect.Height); } } Rect = new RectangleF(MarginLeft, iTop, PrintAreaWidth, 4); e.Graphics.DrawLine(Pens.Gray, Rect.X, Rect.Y, Rect.X + Rect.Width, Rect.Y); iTop += System.Convert.ToInt32(Rect.Height); if (iTop > PrintAreaHeight - AlturaPie - 52) { // Los 52 son para Subtotal y total break; } } if (RowNumber < this.Tarea.Articulos.Count) { //No es última página // Pie Der Fuente = new Font("Arial", 8, FontStyle.Italic); iTop = MarginTop + PrintAreaHeight - 24; Rect = new RectangleF(MarginLeft + PrintAreaWidth - 160, iTop, 160, 12); e.Graphics.DrawString("Página " + m_Pagina.ToString(), Fuente, Brushes.Black, Rect, FormatoRC); iTop += System.Convert.ToInt32(Rect.Height); Rect = new RectangleF(MarginLeft + PrintAreaWidth - 160, iTop, 160, 12); e.Graphics.DrawString("Continúa en pág. " + (m_Pagina + 1).ToString(), Fuente, Brushes.Black, Rect, FormatoRC); e.HasMorePages = true; } else { iTop += 10; int iTopOld = iTop; // Guardo el iTop. Imprimo a la iquierda, vuelvo arriba e imprimo a la derecha if (this.Tarea.DescuentoArticulos > 0) { Rect = new RectangleF(MarginLeft, iTop, 240, 14); e.Graphics.DrawString("Descuento: " + Lfx.Types.Formatting.FormatNumber(this.Tarea.DescuentoArticulos, 2) + "%", Fuente, Brushes.Black, Rect, FormatoLC); iTop += System.Convert.ToInt32(Rect.Height); } iTop = iTopOld; Fuente = new Font("Arial", 12); Rect = new RectangleF(MarginLeft + PrintAreaWidth - 200, iTop, 200, 20); e.Graphics.DrawString("Subtotal: " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(this.Tarea.ImporteAsociado, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales), Fuente, Brushes.Black, Rect, FormatoRC); iTop += System.Convert.ToInt32(Rect.Height + 4); Fuente.Dispose(); Fuente = new Font("Arial Black", 14); Rect = new RectangleF(MarginLeft + PrintAreaWidth - 220, iTop, 220, 28); string Total = "Total: " + Lbl.Sys.Config.Moneda.Simbolo + " " + Lfx.Types.Formatting.FormatCurrency(this.Tarea.ImporteAsociado, Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales); SizeF Tamano = e.Graphics.MeasureString(Total, Fuente, Rect.Location, FormatoLT); Rect.Width = Tamano.Width + 20; Rect.Height = Tamano.Height + 10; Rect.X = MarginLeft + PrintAreaWidth - Rect.Width; e.Graphics.DrawRectangle(new Pen(Color.Gray, 2), Rect.X, Rect.Y, Rect.Width, Rect.Height); e.Graphics.DrawString(Total, Fuente, Brushes.Black, Rect, FormatoCC); Fuente.Dispose(); Fuente = new Font("Arial", 8, FontStyle.Italic); iTop = MarginTop + PrintAreaHeight - 24; Rect = new RectangleF(MarginLeft + PrintAreaWidth - 160, iTop, 160, 12); e.Graphics.DrawString("Página " + m_Pagina.ToString(), Fuente, Brushes.Black, Rect, FormatoRC); iTop += System.Convert.ToInt32(Rect.Height); if (m_Pagina == 1) { Rect = new RectangleF(MarginLeft + PrintAreaWidth - 160, iTop, 160, 12); e.Graphics.DrawString("de 1.", Fuente, Brushes.Black, Rect, FormatoRC); } else { Rect = new RectangleF(MarginLeft + PrintAreaWidth - 160, iTop, 160, 12); e.Graphics.DrawString("Esta es la última página.", Fuente, Brushes.Black, Rect, FormatoRC); } e.HasMorePages = false; } // Pie Izq Fuente.Dispose(); Fuente = new Font("Arial", 9); iTop = MarginTop + PrintAreaHeight - 12; Rect = new RectangleF(MarginLeft, iTop, PrintAreaWidth - 160, 12); e.Graphics.DrawString("Lo atendió: " + this.Tarea.Encargado.Nombre, Fuente, Brushes.Black, Rect, FormatoLC); Fuente.Dispose(); base.OnPrintPage(e); }
private void DrawImageSized(PageImage pi, System.Drawing.Image im, System.Drawing.Graphics g, System.Drawing.RectangleF r) { float height, width; // some work variables StyleInfo si = pi.SI; // adjust drawing rectangle based on padding System.Drawing.RectangleF r2 = new System.Drawing.RectangleF(r.Left + PixelsX(si.PaddingLeft), r.Top + PixelsY(si.PaddingTop), r.Width - PixelsX(si.PaddingLeft + si.PaddingRight), r.Height - PixelsY(si.PaddingTop + si.PaddingBottom)); System.Drawing.Rectangle ir; // int work rectangle switch (pi.Sizing) { case ImageSizingEnum.AutoSize: // Note: GDI+ will stretch an image when you only provide // the left/top coordinates. This seems pretty stupid since // it results in the image being out of focus even though // you don't want the image resized. if (g.DpiX == im.HorizontalResolution && g.DpiY == im.VerticalResolution) { ir = new System.Drawing.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top), im.Width, im.Height); } else { ir = new System.Drawing.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top), Convert.ToInt32(r2.Width), Convert.ToInt32(r2.Height)); } g.DrawImage(im, ir); break; case ImageSizingEnum.Clip: Region saveRegion = g.Clip; Region clipRegion = new Region(g.Clip.GetRegionData()); clipRegion.Intersect(r2); g.Clip = clipRegion; if (g.DpiX == im.HorizontalResolution && g.DpiY == im.VerticalResolution) { ir = new System.Drawing.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top), im.Width, im.Height); } else { ir = new System.Drawing.Rectangle(Convert.ToInt32(r2.Left), Convert.ToInt32(r2.Top), Convert.ToInt32(r2.Width), Convert.ToInt32(r2.Height)); } g.DrawImage(im, ir); g.Clip = saveRegion; break; case ImageSizingEnum.FitProportional: float ratioIm = (float)im.Height / (float)im.Width; float ratioR = r2.Height / r2.Width; height = r2.Height; width = r2.Width; if (ratioIm > ratioR) { // this means the rectangle width must be corrected width = height * (1 / ratioIm); } else if (ratioIm < ratioR) { // this means the ractangle height must be corrected height = width * ratioIm; } r2 = new RectangleF(r2.X, r2.Y, width, height); g.DrawImage(im, r2); break; case ImageSizingEnum.Fit: default: g.DrawImage(im, r2); break; } return; }
public Rect(System.Drawing.RectangleF rectF) : this(rectF.Left, rectF.Right, rectF.Top, rectF.Bottom) { }
public void FillRectangle(Color Color, RectangleF Rectangle) { _editorSession.RenderTarget.FillRectangle(Convert(Rectangle), Convert(Color)); }
internal static void ShowFilterPanel(unvell.ReoGrid.Data.AutoColumnFilter.AutoColumnFilterBody headerBody, Point point) { if (headerBody.ColumnHeader == null || headerBody.ColumnHeader.Worksheet == null) { return; } var worksheet = headerBody.ColumnHeader.Worksheet; if (worksheet == null) { return; } RGRectF headerRect = unvell.ReoGrid.Views.ColumnHeaderView.GetColHeaderBounds(worksheet, headerBody.ColumnHeader.Index, point); if (headerRect.Width == 0 || headerRect.Height == 0) { return; } RGRectF buttonRect = headerBody.GetColumnFilterButtonRect(headerRect.Size); if (headerBody.ContextMenuStrip == null) { var filterPanel = new ColumnFilterContextMenu(); filterPanel.SortAZItem.Click += (s, e) => { try { worksheet.SortColumn(headerBody.ColumnHeader.Index, headerBody.autoFilter.ApplyRange, SortOrder.Ascending); } catch (Exception ex) { worksheet.NotifyExceptionHappen(ex); } }; filterPanel.SortZAItem.Click += (s, e) => { try { worksheet.SortColumn(headerBody.ColumnHeader.Index, headerBody.autoFilter.ApplyRange, SortOrder.Descending); } catch (Exception ex) { worksheet.NotifyExceptionHappen(ex); } }; filterPanel.OkButton.Click += (s, e) => { if (filterPanel.CheckedListBox.GetItemCheckState(0) == CheckState.Checked) { headerBody.IsSelectAll = true; } else { headerBody.IsSelectAll = false; headerBody.selectedTextItems.Clear(); for (int i = 1; i < filterPanel.CheckedListBox.Items.Count; i++) { if (filterPanel.CheckedListBox.GetItemChecked(i)) { headerBody.selectedTextItems.Add(Convert.ToString(filterPanel.CheckedListBox.Items[i])); } } } headerBody.autoFilter.Apply(); filterPanel.Hide(); }; filterPanel.CancelButton.Click += (s, e) => filterPanel.Hide(); headerBody.ContextMenuStrip = filterPanel; } if (headerBody.ContextMenuStrip != null) { if (headerBody.ContextMenuStrip is ColumnFilterContextMenu) { var filterPanel = (ColumnFilterContextMenu)headerBody.ContextMenuStrip; if (headerBody.DataDirty) { // todo: keep select status for every items before clear filterPanel.CheckedListBox.Items.Clear(); filterPanel.CheckedListBox.Items.Add(LanguageResource.Filter_SelectAll); filterPanel.CheckedListBox.SetItemChecked(0, true); try { headerBody.ColumnHeader.Worksheet.ControlAdapter.ChangeCursor(CursorStyle.Busy); var items = headerBody.GetDistinctItems(); foreach (string item in items) { filterPanel.CheckedListBox.Items.Add(item); if (headerBody.IsSelectAll) { filterPanel.CheckedListBox.SetItemChecked(filterPanel.CheckedListBox.Items.Count - 1, true); } else { filterPanel.CheckedListBox.SetItemChecked(filterPanel.CheckedListBox.Items.Count - 1, headerBody.selectedTextItems.Contains(item)); } } } finally { headerBody.ColumnHeader.Worksheet.ControlAdapter.ChangeCursor(CursorStyle.PlatformDefault); } filterPanel.SelectedCount = filterPanel.CheckedListBox.Items.Count - 1; headerBody.DataDirty = false; headerBody.IsSelectAll = true; } } var pp = new Graphics.Point(headerRect.Right - 240, buttonRect.Bottom + 1); pp = worksheet.ControlAdapter.PointToScreen(pp); headerBody.ContextMenuStrip.Show(Point.Round(pp)); } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.IntersectClip(new RectangleF(new PointF(), ClientSize - new SizeF(_scrollSizeTotal, _scrollSizeTotal))); // Only proceed if texture is actually available if (VisibleTexture?.IsAvailable ?? false) { PointF drawStart = ToVisualCoord(new Vector2(0.0f, 0.0f)); PointF drawEnd = ToVisualCoord(new Vector2(VisibleTexture.Image.Width, VisibleTexture.Image.Height)); RectangleF drawArea = RectangleF.FromLTRB(drawStart.X, drawStart.Y, drawEnd.X, drawEnd.Y); // Draw background using (var textureBrush = new TextureBrush(Properties.Resources.misc_TransparentBackground)) e.Graphics.FillRectangle(textureBrush, drawArea); // Switch interpolation based on current view scale if (ViewScale >= 1.0) { e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor; } else { e.Graphics.InterpolationMode = InterpolationMode.Bicubic; } // Draw image VisibleTexture.Image.GetTempSystemDrawingBitmap(tempBitmap => { // System.Drawing being silly, it draws the first row of pixels only half, so everything would be shifted // To work around it, we have to do some silly coodinate changes :/ e.Graphics.DrawImage(tempBitmap, new RectangleF(drawArea.X, drawArea.Y, drawArea.Width + 0.5f * ViewScale, drawArea.Height + 0.5f * ViewScale), new RectangleF(-0.5f, -0.5f, tempBitmap.Width + 0.5f, tempBitmap.Height + 0.5f), GraphicsUnit.Pixel); }); OnPaintSelection(e); } else { string notifyMessage; if (string.IsNullOrEmpty(VisibleTexture?.Path)) { notifyMessage = "Click here to load new texture file."; } else { string fileName = PathC.GetFileNameWithoutExtensionTry(VisibleTexture?.Path) ?? ""; if (PathC.IsFileNotFoundException(VisibleTexture?.LoadException)) { notifyMessage = "Texture file '" + fileName + "' was not found!\n"; } else { notifyMessage = "Unable to load texture from file '" + fileName + "'.\n"; } notifyMessage += "Click here to choose a replacement.\n\n"; notifyMessage += "Path: " + (_editor.Level.Settings.MakeAbsolute(VisibleTexture?.Path) ?? ""); } RectangleF textArea = ClientRectangle; textArea.Size -= new SizeF(_scrollSizeTotal, _scrollSizeTotal); using (var b = new SolidBrush(Colors.DisabledText)) e.Graphics.DrawString(notifyMessage, Font, b, textArea, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }); } // Draw borders using (Pen pen = new Pen(Colors.GreySelection, 1.0f)) e.Graphics.DrawRectangle(pen, new RectangleF(0, 0, ClientSize.Width - _scrollSizeTotal - 1, ClientSize.Height - _scrollSizeTotal - 1)); }
private void DrawBackground(Graphics g, System.Drawing.RectangleF rect, StyleInfo si) { LinearGradientBrush linGrBrush = null; SolidBrush sb = null; HatchBrush hb = null; try { if (si.BackgroundGradientType != BackgroundGradientTypeEnum.None && !si.BackgroundGradientEndColor.IsEmpty && !si.BackgroundColor.IsEmpty) { Color c = si.BackgroundColor; Color ec = si.BackgroundGradientEndColor; switch (si.BackgroundGradientType) { case BackgroundGradientTypeEnum.LeftRight: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); break; case BackgroundGradientTypeEnum.TopBottom: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical); break; case BackgroundGradientTypeEnum.Center: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); break; case BackgroundGradientTypeEnum.DiagonalLeft: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.ForwardDiagonal); break; case BackgroundGradientTypeEnum.DiagonalRight: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.BackwardDiagonal); break; case BackgroundGradientTypeEnum.HorizontalCenter: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); break; case BackgroundGradientTypeEnum.VerticalCenter: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical); break; default: break; } } if (si.PatternType != patternTypeEnum.None) { switch (si.PatternType) { case patternTypeEnum.BackwardDiagonal: hb = new HatchBrush(HatchStyle.BackwardDiagonal, si.Color, si.BackgroundColor); break; case patternTypeEnum.CheckerBoard: hb = new HatchBrush(HatchStyle.LargeCheckerBoard, si.Color, si.BackgroundColor); break; case patternTypeEnum.Cross: hb = new HatchBrush(HatchStyle.Cross, si.Color, si.BackgroundColor); break; case patternTypeEnum.DarkDownwardDiagonal: hb = new HatchBrush(HatchStyle.DarkDownwardDiagonal, si.Color, si.BackgroundColor); break; case patternTypeEnum.DarkHorizontal: hb = new HatchBrush(HatchStyle.DarkHorizontal, si.Color, si.BackgroundColor); break; case patternTypeEnum.DiagonalBrick: hb = new HatchBrush(HatchStyle.DiagonalBrick, si.Color, si.BackgroundColor); break; case patternTypeEnum.HorizontalBrick: hb = new HatchBrush(HatchStyle.HorizontalBrick, si.Color, si.BackgroundColor); break; case patternTypeEnum.LargeConfetti: hb = new HatchBrush(HatchStyle.LargeConfetti, si.Color, si.BackgroundColor); break; case patternTypeEnum.OutlinedDiamond: hb = new HatchBrush(HatchStyle.OutlinedDiamond, si.Color, si.BackgroundColor); break; case patternTypeEnum.SmallConfetti: hb = new HatchBrush(HatchStyle.SmallConfetti, si.Color, si.BackgroundColor); break; case patternTypeEnum.SolidDiamond: hb = new HatchBrush(HatchStyle.SolidDiamond, si.Color, si.BackgroundColor); break; case patternTypeEnum.Vertical: hb = new HatchBrush(HatchStyle.Vertical, si.Color, si.BackgroundColor); break; } } if (linGrBrush != null) { g.FillRectangle(linGrBrush, rect); linGrBrush.Dispose(); } else if (hb != null) { g.FillRectangle(hb, rect); hb.Dispose(); } else if (!si.BackgroundColor.IsEmpty) { sb = new SolidBrush(si.BackgroundColor); g.FillRectangle(sb, rect); sb.Dispose(); } } finally { if (linGrBrush != null) { linGrBrush.Dispose(); } if (sb != null) { sb.Dispose(); } } return; }
public MacGameNSWindow(RectF rect, NSWindowStyle style, NSBackingStore backing, bool defer) : base(rect, style, backing, defer) { }
public static List <CharBox> GetCharBoxsSurroundedByRectangle(List <CharBox> cbs, System.Drawing.RectangleF r) { return(cbs.Where(a => /*selectedR.IntersectsWith(a.R) || */ r.Contains(a.R)).ToList()); }
public static List <string> GetTextLinesSurroundedByRectangle(List <CharBox> cbs, System.Drawing.RectangleF r, TextAutoInsertSpace textAutoInsertSpace) { cbs = GetCharBoxsSurroundedByRectangle(cbs, r); List <string> ls = new List <string>(); foreach (Line l in GetLines(cbs, textAutoInsertSpace)) { StringBuilder sb = new StringBuilder(); foreach (CharBox cb in l.CharBoxs) { sb.Append(cb.Char); } ls.Add(sb.ToString()); } return(ls); }
/// <summary> /// Saves the cropped image area to a temp file, and shows a confirmation /// popup from where the user may accept or reject the cropped image. /// If they accept the new cropped image will be used as the new image source /// for the current canvas, if they reject the crop, the existing image will /// be used for the current canvas /// </summary> private void SaveCroppedImage() { if (popUpImage.Source != null) { popUpImage.Source = null; } try { _rubberBandLeft = Canvas.GetLeft(_rubberBand); _rubberBandTop = Canvas.GetTop(_rubberBand); //create a new .NET 2.0 bitmap (which allowing saving) based on the bound bitmap url using (System.Drawing.Bitmap source = new System.Drawing.Bitmap(ImgUrl)) { //create a new .NET 2.0 bitmap (which allowing saving) to store cropped image in, should be //same size as rubberBand element which is the size of the area of the original image we want to keep using (System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap((int)_rubberBand.Width, (int)_rubberBand.Height)) { //create a new destination rectange System.Drawing.RectangleF recDest = new System.Drawing.RectangleF(0.0f, 0.0f, (float)bitmap.Width, (float)bitmap.Height); //different resolution fix prior to cropping image float hd = 1.0f / (bitmap.HorizontalResolution / source.HorizontalResolution); float vd = 1.0f / (bitmap.VerticalResolution / source.VerticalResolution); float hScale = 1.0f / (float)_zoomFactor; float vScale = 1.0f / (float)_zoomFactor; System.Drawing.RectangleF recSrc = new System.Drawing.RectangleF((hd * (float)_rubberBandLeft) * hScale, (vd * (float)_rubberBandTop) * vScale, (hd * (float)_rubberBand.Width) * hScale, (vd * (float)_rubberBand.Height) * vScale); using (System.Drawing.Graphics gfx = System.Drawing.Graphics.FromImage(bitmap)) { gfx.DrawImage(source, recDest, recSrc, System.Drawing.GraphicsUnit.Pixel); } //create a new temporary file, and delete all old ones prior to this new temp file //This is is a hack that I had to put in, due to GDI+ holding on to previous //file handles used by the Bitmap.Save() method the last time this method was run. //This is a well known issue see http://support.microsoft.com/?id=814675 for example _tempFileName = System.IO.Path.GetTempPath(); if (_fixedTempIdx > 2) { _fixedTempIdx = 0; } else { ++_fixedTempIdx; } //do the clean CleanUp(_tempFileName, _fixedTempName, _fixedTempIdx); //Due to the so problem above, which believe you me I have tried and tried to resolve //I have tried the following to fix this, incase anyone wants to try it //1. Tried reading the image as a strea of bytes into a new bitmap image //2. I have tried to use teh WPF BitmapImage.Create() //3. I have used the trick where you use a 2nd Bitmap (GDI+) to be the newly saved // image // //None of these worked so I was forced into using a few temp files, and pointing the //cropped image to the last one, and makeing sure all others were deleted. //Not ideal, so if anyone can fix it please this I would love to know. So let me know _tempFileName = _tempFileName + _fixedTempName + _fixedTempIdx.ToString() + ".jpg"; bitmap.Save(_tempFileName, System.Drawing.Imaging.ImageFormat.Jpeg); //rewire up context menu _cmDragCanvas.RemoveHandler(MenuItem.ClickEvent, _cmDragCanvasRoutedEventHandler); _dragCanvasForImg.ContextMenu = null; _cmDragCanvas = null; //create popup BitmapImage BitmapImage bmpPopup = new BitmapImage(new Uri(_tempFileName)); popUpImage.Source = bmpPopup; grdCroppedImage.Visibility = Visibility.Visible; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public override void DrawRect(System.Drawing.RectangleF dirtyRect) { var context = NSGraphicsContext.CurrentContext.GraphicsPort; // Engine.Instance.Stats.Charts.Hit (RandomGenerator.GetInt (1024, 1024 * 1024), RandomGenerator.GetInt (1024, 1024 * 1024)); // Debugging context.SetFillColor(m_colorBackground.CGColor); context.FillRect(dirtyRect); NSColor.Gray.Set(); NSBezierPath.StrokeRect(Bounds); float DX = this.Bounds.Size.Width; float DY = this.Bounds.Size.Height; m_chartDX = DX; m_chartDY = DY - m_legendDY; m_chartStartX = 0; m_chartStartY = m_chartDY; float maxY = m_chart.GetMax(); if (maxY <= 0) { maxY = 4096; } else if (maxY > 1000000000000) { maxY = 1000000000000; } Point lastPointDown = new Point(-1, -1); Point lastPointUp = new Point(-1, -1); float stepX = (m_chartDX - 0) / m_chart.Resolution; // Grid lines for (int g = 0; g < m_chart.Grid; g++) { float x = ((m_chartDX - 0) / m_chart.Grid) * g; DrawLine(m_colorGrid, m_chartStartX + x, 0, m_chartStartX + x, m_chartStartY); } // Axis line DrawLine(m_colorAxis, 0, m_chartStartY, m_chartDX, m_chartStartY); // Legend /* * { * string legend = ""; * legend += Messages.ChartRange + ": " + Utils.FormatSeconds(m_chart.Resolution * m_chart.TimeStep); * legend += " "; * legend += Messages.ChartGrid + ": " + Utils.FormatSeconds(m_chart.Resolution / m_chart.Grid * m_chart.TimeStep); * legend += " "; * legend += Messages.ChartStep + ": " + Utils.FormatSeconds(m_chart.TimeStep); * * Point mp = Cursor.Position; * mp = PointToClient(mp); * if ((mp.X > 0) && (mp.Y < chartDX) && (mp.Y > chartDY) && (mp.Y < DY)) * legend += " - " + Messages.ChartClickToChangeResolution; * * e.Graphics.DrawString(legend, FontLabel, BrushLegendText, ChartRectangle(0, chartStartY, chartDX, m_legendDY), formatTopCenter); * } */ // Graph for (int i = 0; i < m_chart.Resolution; i++) { int p = i + m_chart.Pos + 1; if (p >= m_chart.Resolution) { p -= m_chart.Resolution; } float downY = ((m_chart.Download[p]) * (m_chartDY - m_marginTopY)) / maxY; float upY = ((m_chart.Upload[p]) * (m_chartDY - m_marginTopY)) / maxY; Point pointDown = ChartPoint(m_chartStartX + stepX * i, m_chartStartY - downY); Point pointUp = ChartPoint(m_chartStartX + stepX * i, m_chartStartY - upY); //e.Graphics.DrawLine(Pens.Green, new Point(0,0), point); if (lastPointDown.X != -1) { DrawLine(m_colorDownloadGraph, lastPointDown, pointDown); DrawLine(m_colorUploadGraph, lastPointUp, pointUp); } lastPointDown = pointDown; lastPointUp = pointUp; } // Download line float downCurY = 0; { long v = m_chart.GetLastDownload(); downCurY = ((v) * (m_chartDY - m_marginTopY)) / maxY; DrawLine(m_colorDownloadLine, 0, m_chartStartY - downCurY, m_chartDX, m_chartStartY - downCurY); DrawStringOutline(Messages.ChartDownload + ": " + ValToDesc(v), m_colorDownloadText, ChartRectangle(0, 0, m_chartDX - 10, m_chartStartY - downCurY), 8); } // Upload line { long v = m_chart.GetLastUpload(); float y = ((v) * (m_chartDY - m_marginTopY)) / maxY; float dly = 0; if (Math.Abs(downCurY - y) < 10) { dly = 15; // Download and upload overwrap, distance it. } DrawLine(m_colorUploadLine, 0, m_chartStartY - y, m_chartDX, m_chartStartY - y); DrawStringOutline(Messages.ChartUpload + ": " + ValToDesc(v), m_colorUploadText, ChartRectangle(0, 0, m_chartDX - 10, m_chartStartY - y - dly), 8); } // Mouse lines { PointF mp = Window.MouseLocationOutsideOfEventStream; mp.X -= this.Frame.Left; mp.Y -= this.Frame.Top; //mp = ParentWindow.ConvertPointToView (mp, this); mp = Invert(mp); //mp = Window.ConvertScreenToBase (mp); if ((mp.X > 0) && (mp.Y < m_chartDX) && (mp.Y > 0) && (mp.Y < m_chartDY)) { DrawLine(m_colorMouse, 0, mp.Y, m_chartDX, mp.Y); DrawLine(m_colorMouse, mp.X, 0, mp.X, m_chartDY); float i = (m_chartDX - (mp.X - m_chartStartX)) / stepX; int t = Conversions.ToInt32(i * m_chart.TimeStep); //float y = mp.Y * maxY / (chartDY - m_marginTopY); float y = (m_chartStartY - (mp.Y - m_marginTopY)) * maxY / m_chartDY; String label = ValToDesc(Conversions.ToInt64(y)) + ", " + Utils.FormatSeconds(t) + " ago"; int formatAlign = 6; RectangleF rect = new RectangleF(); if (DX - mp.X > DX / 2) //if (mp.X < DX - 200) { if (DY - mp.Y > DY / 2) //if (mp.Y < 20) { formatAlign = 0; rect.X = mp.X + 5; rect.Y = mp.Y + 5; rect.Width = DX; rect.Height = DX; } else { formatAlign = 6; rect.X = mp.X + 5; rect.Y = 0; rect.Width = DX; rect.Height = mp.Y - 5; } } else { if (DY - mp.Y > DY / 2) //if (mp.Y < 40) { formatAlign = 2; rect.X = 0; rect.Y = mp.Y; rect.Width = mp.X - 5; rect.Height = DY; } else { formatAlign = 8; rect.X = 0; rect.Y = 0; rect.Width = mp.X - 5; rect.Height = mp.Y - 5; } } DrawStringOutline(label, m_colorMouse, rect, formatAlign); } } }
public void DrawRectangle(Color Color, float StrokeWidth, RectangleF Rectangle, int CornerRadius) { _editorSession.RenderTarget.DrawRoundedRectangle(Convert(Rectangle, CornerRadius), Convert(Color), StrokeWidth); }
private void DrawBackground(Graphics g, System.Drawing.RectangleF rect, StyleInfo si) { LinearGradientBrush linGrBrush = null; SolidBrush sb = null; try { if (si.BackgroundGradientType != BackgroundGradientTypeEnum.None && !si.BackgroundGradientEndColor.IsEmpty && !si.BackgroundColor.IsEmpty) { Color c = si.BackgroundColor; Color ec = si.BackgroundGradientEndColor; switch (si.BackgroundGradientType) { case BackgroundGradientTypeEnum.LeftRight: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); break; case BackgroundGradientTypeEnum.TopBottom: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical); break; case BackgroundGradientTypeEnum.Center: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); break; case BackgroundGradientTypeEnum.DiagonalLeft: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.ForwardDiagonal); break; case BackgroundGradientTypeEnum.DiagonalRight: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.BackwardDiagonal); break; case BackgroundGradientTypeEnum.HorizontalCenter: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Horizontal); break; case BackgroundGradientTypeEnum.VerticalCenter: linGrBrush = new LinearGradientBrush(rect, c, ec, LinearGradientMode.Vertical); break; default: break; } } if (linGrBrush != null) { g.FillRectangle(linGrBrush, rect); linGrBrush.Dispose(); } else if (!si.BackgroundColor.IsEmpty) { sb = new SolidBrush(si.BackgroundColor); g.FillRectangle(sb, rect); sb.Dispose(); } } finally { if (linGrBrush != null) { linGrBrush.Dispose(); } if (sb != null) { sb.Dispose(); } } return; }
public override void SetClip(System.Drawing.RectangleF clipRect) { RawRectangleF rawRectF = TransRectFToRawRectF(clipRect); renderTarget.PushAxisAlignedClip(rawRectF, AntialiasMode.PerPrimitive); }
public override void DrawRect(System.Drawing.RectangleF dirtyRect) { var g = Graphics.FromCurrentContext(); g.Clear(backColor); // PointF point = new PointF(50,50); // var rect = new Rectangle(50,50,20,20); // //g.RotateTransform(-20); // //g.TranslateTransform(5,5); // var size = g.MeasureString("A", this.Font); // rect.Height = (int)size.Height; // rect.Width = (int)size.Width*20; // // int nextLine = (int)(size.Height * 1.2); // // g.DrawRectangle(Pens.Red, rect); // g.DrawString("Test2 without line feed", this.Font, Brushes.Blue, point); // // StringFormat format = new StringFormat(); // format.Alignment = StringAlignment.Center; // // rect.Y += nextLine; // rect.Height = (int)size.Height; // rect.Width = (int)size.Width*20; // g.DrawRectangle(Pens.Red, rect); // g.DrawString("Test2 Centered", this.Font, Brushes.Blue, rect, format); // // format.Alignment = StringAlignment.Far; // rect.Y += nextLine; // rect.Height = (int)size.Height; // rect.Width = (int)size.Width*20; // g.DrawRectangle(Pens.Red, rect); // g.DrawString("Test2 Far", this.Font, Brushes.Blue, rect, format); // // format.Alignment = StringAlignment.Far; // rect.Y += nextLine; // rect.Height = (int)size.Height; // rect.Width = (int)size.Width*3; // g.DrawRectangle(Pens.Red, rect); // g.DrawString("Test2 Far", this.Font, Brushes.Blue, rect, format); // switch (currentView) { case 0: DrawStringPointF(g); break; case 1: DrawStringRectangleF(g); break; case 2: DrawStringPointFFormat(g); break; case 3: DrawStringRectangleFFormat(g); break; case 4: DrawStringFloat(g); break; case 5: DrawStringFloatFormat(g); break; case 6: DrawStringRectangleFFormat1(g); break; case 7: DrawStringRectangleFFormat2(g); break; case 8: DrawStringRectangleFFormat3(g); break; case 9: DrawStringRectangleFFormat4(g); break; case 10: DrawStringRectangleFFormat5(g); break; case 11: DrawStringPointFFormat1(g); break; case 12: DrawStringPointFFormat2(g); break; case 13: DrawStringPointFFormat3(g); break; case 14: DrawStringPointFFormat4(g); break; } g.ResetTransform(); Brush sBrush = Brushes.Black; if (!g.IsClipEmpty) { var clipPoint = PointF.Empty; var clipString = string.Format("Clip-{0}", g.ClipBounds); g.ResetClip(); var clipSize = g.MeasureString(clipString, clipFont); clipPoint.X = (ClientRectangle.Width / 2) - (clipSize.Width / 2); clipPoint.Y = 5; g.DrawString(clipString, clipFont, sBrush, clipPoint); } var anyKeyPoint = PointF.Empty; var anyKey = "Press any key to continue."; var anyKeySize = g.MeasureString(anyKey, anyKeyFont); anyKeyPoint.X = (ClientRectangle.Width / 2) - (anyKeySize.Width / 2); anyKeyPoint.Y = ClientRectangle.Height - (anyKeySize.Height + 10); g.DrawString(anyKey, anyKeyFont, sBrush, anyKeyPoint); anyKeySize = g.MeasureString(title, anyKeyFont); anyKeyPoint.X = (ClientRectangle.Width / 2) - (anyKeySize.Width / 2); anyKeyPoint.Y -= anyKeySize.Height; g.DrawString(title, anyKeyFont, sBrush, anyKeyPoint); g.Dispose(); }
public void FillRectangle(Color Color, RectangleF Rectangle, int CornerRadius) { _editorSession.RenderTarget.FillRoundedRectangle(Convert(Rectangle, CornerRadius), Convert(Color)); }
public void DrawEllipse(Color Color, float StrokeWidth, RectangleF Rectangle) { _editorSession.RenderTarget.DrawEllipse(ToEllipse(Rectangle), Convert(Color), StrokeWidth); }
/// <summary>取得 <see cref="Win32Draw.RectangleF"/> 之複製品</summary> /// <param name="color">欲複製的 <see cref="Win32Draw.RectangleF"/></param> /// <returns><see cref="Win32Draw.RectangleF"/></returns> public static Win32Draw.RectangleF Clone(this Win32Draw.RectangleF rect) { return(new Win32Draw.RectangleF(rect.X, rect.Y, rect.Width, rect.Height)); }
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e) { String ucapan = ""; string nm, almt, tlpn, email; //event printing gUtil.saveSystemDebugLog(globalConstants.MENU_RETUR_PENJUALAN, "printDocument1_PrintPage, print POS size receipt"); Graphics graphics = e.Graphics; Font font = new Font("Courier New", 10); float fontHeight = font.GetHeight(); int startX = 5; int colxwidth = 93; //31x3 int totrowwidth = 310; //310/10=31 int totrowheight = 20; int startY = 5; int Offset = 15; int offset_plus = 3; string sqlCommand = ""; string customer = ""; string tgl = ""; string group = ""; double total = 0; string soInvoice = ""; //HEADER //set allignemnt StringFormat sf = new StringFormat(); sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; //set whole printing area System.Drawing.RectangleF rect = new System.Drawing.RectangleF(startX, startY + Offset, totrowwidth, totrowheight); //set right print area System.Drawing.RectangleF rectright = new System.Drawing.RectangleF(totrowwidth - colxwidth - startX, startY + Offset, colxwidth, totrowheight); //set middle print area System.Drawing.RectangleF rectcenter = new System.Drawing.RectangleF((startX + (totrowwidth / 2) - colxwidth - startX), startY + Offset, (totrowwidth / 2) - startX, totrowheight); loadInfoToko(2, out nm, out almt, out tlpn, out email); graphics.DrawString(nm, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 12; rect.Y = startY + Offset; graphics.DrawString(almt, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 10; rect.Y = startY + Offset; graphics.DrawString(tlpn, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); if (!email.Equals("")) { Offset = Offset + 10; rect.Y = startY + Offset; graphics.DrawString(email, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); } Offset = Offset + 13; rect.Y = startY + Offset; String underLine = "-------------------------------------"; //37 character graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); //end of header //start of content MySqlDataReader rdr; DataTable dt = new DataTable(); DS.mySqlConnect(); //load customer id sqlCommand = "SELECT RS.RS_INVOICE, IFNULL(RS.SALES_INVOICE, '') AS 'INVOICE', C.CUSTOMER_FULL_NAME AS 'CUSTOMER',DATE_FORMAT(RS.RS_DATETIME, '%d-%M-%Y') AS 'DATE',RS.RS_TOTAL AS 'TOTAL', IF(C.CUSTOMER_GROUP=1,'RETAIL',IF(C.CUSTOMER_GROUP=2,'GROSIR','PARTAI')) AS 'GROUP' FROM RETURN_SALES_HEADER RS,MASTER_CUSTOMER C WHERE RS.CUSTOMER_ID = C.CUSTOMER_ID AND RS.RS_INVOICE = '" + returID + "'" + " UNION " + "SELECT RS.RS_INVOICE, IFNULL(RS.SALES_INVOICE, '') AS 'INVOICE', 'P-UMUM' AS 'CUSTOMER', DATE_FORMAT(RS.RS_DATETIME, '%d-%M-%Y') AS 'DATE', RS.RS_TOTAL AS 'TOTAL', 'RETAIL' AS 'GROUP' FROM RETURN_SALES_HEADER RS WHERE RS.CUSTOMER_ID = 0 AND RS.RS_INVOICE = '" + returID + "'" + "ORDER BY DATE ASC"; using (rdr = DS.getData(sqlCommand)) { if (rdr.HasRows) { rdr.Read(); customer = rdr.GetString("CUSTOMER"); tgl = rdr.GetString("DATE"); total = rdr.GetDouble("TOTAL"); group = rdr.GetString("GROUP"); soInvoice = rdr.GetString("INVOICE"); } } DS.mySqlClose(); Offset = Offset + 12; rect.Y = startY + Offset; rect.X = startX + 15; rect.Width = 280; //SET TO LEFT MARGIN sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; ucapan = "RETUR PENJUALAN "; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); //2. CUSTOMER NAME Offset = Offset + 12; rect.Y = startY + Offset; ucapan = "PELANGGAN : " + customer + " [" + group + "]"; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 13; rect.Y = startY + Offset; rect.X = startX; rect.Width = totrowwidth; sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 12; rect.Y = startY + Offset; rect.Width = totrowwidth; ucapan = "BUKTI RETUR "; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 15 + offset_plus; rect.Y = startY + Offset; rect.X = startX + 15; rect.Width = 280; sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; ucapan = "NO. RETUR " + returID; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 15 + offset_plus; rect.Y = startY + Offset; rect.X = startX + 15; rect.Width = 280; sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; ucapan = "NO. INVOICE " + soInvoice; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 12; rect.Y = startY + Offset; ucapan = "TOTAL : " + total.ToString("C2", culture); graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 12; rect.Y = startY + Offset; ucapan = "TANGGAL : " + tgl; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 12; rect.Y = startY + Offset; string nama = ""; loadNamaUser(gUtil.getUserID(), out nama); ucapan = "OPERATOR : " + nama; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 13; rect.Y = startY + Offset; rect.X = startX; rect.Width = totrowwidth; sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); // JUMLAH TOTAL INVOICE sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; // DISPLAY DETAIL FOR RETUR string product_id = ""; string product_name = ""; double product_qty = 0; double product_price = 0; string product_desc = ""; double total_qty = 0; //sqlCommand = "SELECT DATE_FORMAT(PC.PAYMENT_DATE, '%d-%M-%Y') AS 'PAYMENT_DATE', PC.PAYMENT_NOMINAL, PC.PAYMENT_DESCRIPTION FROM PAYMENT_CREDIT PC, CREDIT C WHERE PC.PAYMENT_CONFIRMED = 1 AND PC.CREDIT_ID = C.CREDIT_ID AND C.SALES_INVOICE = '" + selectedSOInvoice + "'"; sqlCommand = "SELECT RD.PRODUCT_ID, MP.PRODUCT_NAME, RD.PRODUCT_SALES_PRICE, RD.PRODUCT_RETURN_QTY, RD.RS_DESCRIPTION, RD.RS_SUBTOTAL " + "FROM RETURN_SALES_DETAIL RD, MASTER_PRODUCT MP " + "WHERE RD.RS_INVOICE = '" + returID + "' AND RD.PRODUCT_ID = MP.PRODUCT_ID"; using (rdr = DS.getData(sqlCommand)) { if (rdr.HasRows) { while (rdr.Read()) { product_id = rdr.GetString("PRODUCT_ID"); product_name = rdr.GetString("PRODUCT_NAME"); product_qty = rdr.GetDouble("PRODUCT_RETURN_QTY"); product_price = rdr.GetDouble("PRODUCT_SALES_PRICE"); product_desc = rdr.GetString("RS_DESCRIPTION"); Offset = Offset + 15; rect.Y = startY + Offset; rect.X = startX + 15; rect.Width = 280; sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; ucapan = product_qty + " X [" + product_id + "] " + product_name; if (ucapan.Length > 30) { ucapan = ucapan.Substring(0, 30); //maximum 30 character } // graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); rectright.Y = Offset - startY; sf.LineAlignment = StringAlignment.Far; sf.Alignment = StringAlignment.Far; ucapan = "@ " + product_price.ToString("C2", culture);//" Rp." + product_price; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rectright, sf); if (product_desc.Length > 0) { Offset = Offset + 15; rect.Y = startY + Offset; rect.X = startX + 15; rect.Width = 280; sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; ucapan = product_desc; if (ucapan.Length > 30) { ucapan = ucapan.Substring(0, 30); //maximum 30 character } // graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); } } } } Offset = Offset + 13; rect.Y = startY + Offset; rect.X = startX; rect.Width = totrowwidth; sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 15; rect.Y = startY + Offset; rect.X = startX + 15; rect.Width = 260; sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; ucapan = " JUMLAH :"; rectcenter.Y = rect.Y; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rectcenter, sf); sf.LineAlignment = StringAlignment.Far; sf.Alignment = StringAlignment.Far; ucapan = total.ToString("C2", culture); rectright.Y = Offset - startY + 1; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rectright, sf); total_qty = Convert.ToDouble(DS.getDataSingleValue("SELECT IFNULL(SUM(PRODUCT_RETURN_QTY), 0) FROM RETURN_SALES_DETAIL RD, MASTER_PRODUCT MP WHERE RD.PRODUCT_ID = MP.PRODUCT_ID AND RD.RS_INVOICE = '" + returID + "'")); Offset = Offset + 25 + offset_plus; rect.Y = startY + Offset; rect.X = startX + 15; rect.Width = 280; sf.LineAlignment = StringAlignment.Near; sf.Alignment = StringAlignment.Near; ucapan = "TOTAL BARANG : " + total_qty; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); //eNd of content //FOOTER Offset = Offset + 13; rect.Y = startY + Offset; rect.X = startX; rect.Width = totrowwidth; sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; graphics.DrawString(underLine, new Font("Courier New", 9), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 15; rect.Y = startY + Offset; ucapan = "TERIMA KASIH ATAS KUNJUNGAN ANDA"; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 15; rect.Y = startY + Offset; ucapan = "MAAF BARANG YANG SUDAH DIBELI"; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); Offset = Offset + 15; rect.Y = startY + Offset; ucapan = "TIDAK DAPAT DITUKAR/ DIKEMBALIKKAN"; graphics.DrawString(ucapan, new Font("Courier New", 7), new SolidBrush(Color.Black), rect, sf); //end of footer }
public extern static void void_objc_msgSendSuper_IntPtr_ref_RectangleF_IntPtr(System.IntPtr receiver, System.IntPtr selector, System.IntPtr arg1, ref System.Drawing.RectangleF arg2, System.IntPtr arg3);
private void Imprimir(object sender, PrintPageEventArgs e) { string sucursal = obtener_nombre_sucursal(paciente.clinica.id_clinica); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; System.Drawing.Font font = new System.Drawing.Font("Courier New", 12, System.Drawing.FontStyle.Bold); System.Drawing.Font titulo = new System.Drawing.Font("Courier New", 12, System.Drawing.FontStyle.Bold); System.Drawing.Font cuerpo = new System.Drawing.Font("Courier New", 9); //MODIFICADORES DE FORMATO DE HOJA/ float margen_izquierdo = 0; float margen_superior = 10; double margen_cuerpo = 0.42; //DESPUES DEL TITULO double tamanio_hoja_horizontal = 3.8; // ----------------------------------/ double abono = Convert.ToDouble(txtPrecio.Text, culture); double efectivo = Convert.ToDouble(txt_efectivo.Text, culture); double cambio = efectivo - abono; //double restante = this.restante - (Int32.Parse(this.txtAbono.Text)); string fecha_inicio = DateTime.Now.ToString("d/M/yyyy"); string fecha_finalizacion = DateTime.Now.AddYears(1).ToString("d/M/yyyy"); string hora = DateTime.Now.ToString("HH:mm:ss") + " hrs"; Abonos a = new Abonos(bandera_online_offline); System.Drawing.Image imagen = System.Drawing.Image.FromFile(System.IO.Path.Combine(@System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName, @"..\..\..\Assets\bs_ticket_imagen.bmp")); System.Drawing.RectangleF rect = new System.Drawing.RectangleF(margen_izquierdo, margen_superior, centimetroAPixel(4), 30);//tamanio_hoja_horizontal en vez de 4 RectangleF rImage = new RectangleF(38, margen_superior, 110, 110); e.Graphics.DrawImage(imagen, rImage); //e.Graphics.FillRectangle(Brushes.Red, rect); usarlo para cada recyangulo rect.Y = (cuerpo.GetHeight(e.Graphics) * 7) + margen_superior; e.Graphics.DrawString("BONITA SMILE", titulo, new SolidBrush(Color.Black), rect, stringFormat); rect.X = Convert.ToSingle(centimetroAPixel(margen_cuerpo)); rect.Width = centimetroAPixel(tamanio_hoja_horizontal); //nuevo rect.Y = (cuerpo.GetHeight(e.Graphics) * 9) + margen_superior; stringFormat.Alignment = StringAlignment.Near; e.Graphics.DrawString("SUCURSAL: " + sucursal, cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 10) + margen_superior; e.Graphics.DrawString("CLIENTE: " + paciente.nombre + " " + paciente.apellidos, cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 12) + margen_superior; e.Graphics.DrawString("FECHA: " + fecha_inicio, cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 13) + margen_superior; e.Graphics.DrawString("HORA: " + hora, cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 15) + margen_superior; e.Graphics.DrawString("MOTIVO: ", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 17) + margen_superior; e.Graphics.DrawString("Membresía", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 18) + margen_superior; e.Graphics.DrawString("PRECIO: $" + txtPrecio.Text.ToString(culture), cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 19) + margen_superior + 10; e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = ((cuerpo.GetHeight(e.Graphics) * 19) + margen_superior + 10) + 5; e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 21) + margen_superior - 5; e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = ((cuerpo.GetHeight(e.Graphics) * 21) + margen_superior - 5) + 5; e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = ((cuerpo.GetHeight(e.Graphics) * 23) + margen_superior); e.Graphics.DrawString("TOTAL: $" + txtPrecio.Text.ToString(culture), cuerpo, new SolidBrush(Color.Black), rect, stringFormat); //rect.Y = (cuerpo.GetHeight(e.Graphics) * 15) + margen_superior; //e.Graphics.DrawString("ABONO: $" + txtAbono.Text, cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 24) + margen_superior; e.Graphics.DrawString("RECIBIDO: $" + txt_efectivo.Text.ToString(culture), cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 25) + margen_superior; e.Graphics.DrawString("CAMBIO: $" + cambio, cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 27) + margen_superior - 5; e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = ((cuerpo.GetHeight(e.Graphics) * 27) + margen_superior - 5) + 5; e.Graphics.DrawString("-------------------", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 29) + margen_superior; e.Graphics.DrawString("PERIODO MEMBRESÍA:", cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 31) + margen_superior; e.Graphics.DrawString("INICIO: " + fecha_inicio, cuerpo, new SolidBrush(Color.Black), rect, stringFormat); rect.Y = (cuerpo.GetHeight(e.Graphics) * 32) + margen_superior; e.Graphics.DrawString("TERMINO: " + fecha_finalizacion, cuerpo, new SolidBrush(Color.Black), rect, stringFormat); e.HasMorePages = false; }
public override void DrawRect(System.Drawing.RectangleF dirtyRect) { Graphics g = Graphics.FromCurrentContext(); int offset = 20; // Scale: Matrix m = new Matrix(1, 2, 3, 4, 0, 1); g.DrawString("Original Matrix:", this.Font, Brushes.Black, 10, 10); DrawMatrix(m, g, 10, 10 + offset); g.DrawString("Scale - Prepend:", this.Font, Brushes.Black, 10, 10 + 2 * offset); m.Scale(1, 0.5f, MatrixOrder.Prepend); DrawMatrix(m, g, 10, 10 + 3 * offset); g.DrawString("Scale - Append:", this.Font, Brushes.Black, 10, 10 + 4 * offset); // Reset m to the original matrix: m = new Matrix(1, 2, 3, 4, 0, 1); m.Scale(1, 0.5f, MatrixOrder.Append); DrawMatrix(m, g, 10, 10 + 5 * offset); // Translation: m = new Matrix(1, 2, 3, 4, 0, 1); g.DrawString("Translation - Prepend:", this.Font, Brushes.Black, 10, 10 + 6 * offset); m.Translate(1, 0.5f, MatrixOrder.Prepend); DrawMatrix(m, g, 10, 10 + 7 * offset); g.DrawString("Translation - Append:", this.Font, Brushes.Black, 10, 10 + 8 * offset); // Reset m to the original matrix: m = new Matrix(1, 2, 3, 4, 0, 1); m.Translate(1, 0.5f, MatrixOrder.Append); DrawMatrix(m, g, 10, 10 + 9 * offset); // Rotation: m = new Matrix(1, 2, 3, 4, 0, 1); g.DrawString("Rotation - Prepend:", this.Font, Brushes.Black, 10, 10 + 10 * offset); m.Rotate(45, MatrixOrder.Prepend); DrawMatrix(m, g, 10, 10 + 11 * offset); g.DrawString("Rotation - Append:", this.Font, Brushes.Black, 10, 10 + 12 * offset); // Reset m to the original matrix: m = new Matrix(1, 2, 3, 4, 0, 1); m.Rotate(45, MatrixOrder.Append); DrawMatrix(m, g, 10, 10 + 13 * offset); // Rotation at (x = 1, y = 2): m = new Matrix(1, 2, 3, 4, 0, 1); g.DrawString("Rotation At - Prepend:", this.Font, Brushes.Black, 10, 10 + 14 * offset); m.RotateAt(45, new PointF(1, 2), MatrixOrder.Prepend); DrawMatrix(m, g, 10, 10 + 15 * offset); g.DrawString("Rotation At - Append:", this.Font, Brushes.Black, 10, 10 + 16 * offset); // Reset m to the original matrix: m = new Matrix(1, 2, 3, 4, 0, 1); m.RotateAt(45, new PointF(1, 2), MatrixOrder.Append); DrawMatrix(m, g, 10, 10 + 17 * offset); // Shear: m = new Matrix(1, 2, 3, 4, 0, 1); g.DrawString("Shear - Prepend:", this.Font, Brushes.Black, 10, 10 + 18 * offset); m.Shear(1, 2, MatrixOrder.Prepend); DrawMatrix(m, g, 10, 10 + 19 * offset); g.DrawString("Shear - Append:", this.Font, Brushes.Black, 10, 10 + 20 * offset); // Reset m to the original matrix: m = new Matrix(1, 2, 3, 4, 0, 1); m.Shear(1, 2, MatrixOrder.Append); DrawMatrix(m, g, 10, 10 + 21 * offset); }
public extern static void void_objc_msgSend_IntPtr_RectangleF_IntPtr(IntPtr receiver, IntPtr selector, IntPtr arg1, System.Drawing.RectangleF arg2, IntPtr arg3);
public extern static System.IntPtr IntPtr_objc_msgSend_IntPtr_RectangleF_IntPtr(System.IntPtr receiver, System.IntPtr selector, System.IntPtr arg1, System.Drawing.RectangleF arg2, System.IntPtr arg3);
public extern static void RectangleF_objc_msgSendSuper_stret_IntPtr_IntPtr_IntPtr(out System.Drawing.RectangleF retval, System.IntPtr receiver, System.IntPtr selector, System.IntPtr arg1, System.IntPtr arg2, System.IntPtr arg3);
public override void DrawRect(System.Drawing.RectangleF dirtyRect) { var g = new Graphics(); g.Clear(backColor); }
public Safari(System.Drawing.RectangleF frame, string frameName, string groupName) : base(frame, frameName, groupName) { }
public void PopClip() { WFRectF cb = clipStack.Pop(); this.g.SetClip(cb); }
/// <summary> /// ѕереопределенное отображение ¤чеек дл¤ раскраски /// </summary> protected override void PaintCell(DevAge.Drawing.GraphicsCache graphics, SourceGrid.CellContext cellContext, System.Drawing.RectangleF drawRectangle) { //if (cellContext.DisplayText != "") cellContext.Cell.View.BackColor = ColorCalcRGB(cellContext.DisplayText); base.PaintCell(graphics, cellContext, drawRectangle); }