Example #1
1
 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);
     }
 }
        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;
            }
        }
	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;
	}
        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();
        }
 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 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 ImageScrollView (RectangleF frame) : base (frame)
	{
		ShowsVerticalScrollIndicator = false;
		ShowsHorizontalScrollIndicator = false;
		BouncesZoom = true;
		DecelerationRate = UIScrollView.DecelerationRateFast;
	}
Example #8
0
        // 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 byte[] GetImageAsJpeg(RectangleF roi)
        {
            var buf = _contents[_index];
            _index = (_index + 1) % _contents.Count;

            return buf;
        }
Example #10
0
		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 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);
        }
Example #12
0
        /// <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 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);
		}
Example #14
0
 public Physics(Point p, RectangleF boundingBox)
 {
     startPosition = p;
     position = startPosition;
     this.boundingBox = boundingBox;
     visible = true;
 }
Example #15
0
        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);
        }
Example #16
0
        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);
                }
            }
        }
	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 ());
		}
	}
Example #18
0
	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);
	}
Example #19
0
        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;
        }
Example #20
0
		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);
		}
 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 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);
            }
        }
Example #23
0
 public static void DrawRoundedRectangle(this Graphics g, Pen pen, RectangleF rect, float cornerRadius)
 {
     using(var gp = GraphicsUtility.GetRoundedRectangle(rect, cornerRadius))
     {
         g.DrawPath(pen, gp);
     }
 }
Example #24
0
 public static void FillRoundedRectangle(this Graphics g, Brush brush, RectangleF rect, float cornerRadius)
 {
     using(var gp = GraphicsUtility.GetRoundedRectangle(rect, cornerRadius))
     {
         g.FillPath(brush, gp);
     }
 }
Example #25
0
 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 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));
 }
Example #27
0
        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);
        }
Example #28
0
        // 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");
        }
Example #29
0
        /// <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 ;
                }
            }
        }
Example #30
0
 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);
 }