Ejemplo n.º 1
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			int thumbHeight = 10;
			//graphics2D.Rectangle(LocalBounds, RGBA_Bytes.Black);
			double bottom = textScrollWidget.Position0To1 * (Height - thumbHeight);// the 2 is the border
			RectangleDouble thumb = new RectangleDouble(0, bottom, Width, bottom + thumbHeight);// the 1 is the border
			graphics2D.FillRectangle(thumb, RGBA_Bytes.DarkGray);
			base.OnDraw(graphics2D);
		}
        private double PrintTopOfPage(ImageBuffer plateInventoryImage, Graphics2D plateGraphics)
        {
            plateGraphics.Clear(RGBA_Bytes.White);

            double currentlyPrintingHeightPixels = plateInventoryImage.Height - PageMarginMM.Top * PixelPerMM;

            string logoPathAndFile = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "PartSheetLogo.png");
            if(File.Exists(logoPathAndFile))
            {
                ImageBuffer logoImage = new ImageBuffer();
                ImageIO.LoadImageData(logoPathAndFile, logoImage);
                currentlyPrintingHeightPixels -= logoImage.Height;
                plateGraphics.Render(logoImage, (plateInventoryImage.Width - logoImage.Width) / 2, currentlyPrintingHeightPixels);
            }

            currentlyPrintingHeightPixels -= PartPaddingPixels;

            double underlineHeightMM = 1;
            RectangleDouble lineBounds = new RectangleDouble(0, 0, plateInventoryImage.Width - PageMarginPixels.Left * 2, underlineHeightMM * PixelPerMM);
            lineBounds.Offset(PageMarginPixels.Left, currentlyPrintingHeightPixels - lineBounds.Height);
            plateGraphics.FillRectangle(lineBounds, RGBA_Bytes.Black);

            return currentlyPrintingHeightPixels - (lineBounds.Height + PartPaddingPixels);
        }
Ejemplo n.º 3
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			graphics2D.Circle(Width / 2, Height / 2, Width / 2, RGBA_Bytes.White);
			graphics2D.Circle(Width / 2, Height / 2, Width / 2 - 1, RGBA_Bytes.Red);
			graphics2D.FillRectangle(Width / 2 - 1, Height / 2 - 3, Width / 2 + 1, Height / 2 + 3, RGBA_Bytes.White);
			base.OnDraw(graphics2D);
		}
Ejemplo n.º 4
0
 public override void OnDraw(Graphics2D graphics2D)
 {
     RectangleDouble barBounds = bar.BoundsRelativeToParent;
     graphics2D.FillRectangle(barBounds.Left, barBounds.Bottom, barBounds.Left + barBounds.Width * PercentComplete / 100.0, barBounds.Top, ActiveTheme.Instance.PrimaryAccentColor);
     graphics2D.Rectangle(barBounds, RGBA_Bytes.Black);
     base.OnDraw(graphics2D);
 }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            // first we will show how to use the simple drawing functions in graphics 2D
            {
                ImageBuffer simpleImage           = new ImageBuffer(640, 480, 32, new BlenderBGRA());
                Graphics2D  simpleImageGraphics2D = simpleImage.NewGraphics2D();
                // clear the image to white
                simpleImageGraphics2D.Clear(Color.White);
                // draw a circle
                simpleImageGraphics2D.Circle(50, 50, 30, Color.Blue);
                // draw a line
                simpleImageGraphics2D.Line(10, 100, 520, 50, new Color(20, 200, 200));
                // draw a filled box
                simpleImageGraphics2D.FillRectangle(60, 260, 200, 280, Color.Yellow);
                // and an outline around it
                simpleImageGraphics2D.Rectangle(60, 260, 200, 280, Color.Magenta);
                // draw some text
                simpleImageGraphics2D.DrawString("A Simple Example", 300, 400, 20);

                // and save this image out
                ImageTgaIO.Save(simpleImage, "SimpleDrawAndSave.tga");
            }

            // now we will we will show how to use the render function to draw more complex things
            {
                ImageBuffer lessSimpleImage           = new ImageBuffer(640, 480, 32, new BlenderBGRA());
                Graphics2D  lessSimpleImageGraphics2D = lessSimpleImage.NewGraphics2D();
                // clear the image to white
                lessSimpleImageGraphics2D.Clear(Color.White);
                // draw a circle
                Ellipse ellipseTest = new Ellipse(0, 0, 100, 50);
                for (double angleDegrees = 0; angleDegrees < 180; angleDegrees += 22.5)
                {
                    VertexSourceApplyTransform rotatedTransform = new VertexSourceApplyTransform(ellipseTest, Affine.NewRotation(MathHelper.DegreesToRadians(angleDegrees)));
                    VertexSourceApplyTransform rotatedAndTranslatedTransform = new VertexSourceApplyTransform(rotatedTransform, Affine.NewTranslation(lessSimpleImage.Width / 2, 150));
                    lessSimpleImageGraphics2D.Render(rotatedAndTranslatedTransform, Color.Yellow);
                    Stroke ellipseOutline = new Stroke(rotatedAndTranslatedTransform, 3);
                    lessSimpleImageGraphics2D.Render(ellipseOutline, Color.Blue);
                }

                // and a little polygon
                VertexStorage littlePoly = new VertexStorage();
                littlePoly.MoveTo(50, 50);
                littlePoly.LineTo(150, 50);
                littlePoly.LineTo(200, 200);
                littlePoly.LineTo(50, 150);
                littlePoly.LineTo(50, 50);
                lessSimpleImageGraphics2D.Render(littlePoly, Color.Cyan);

                // draw some text
                TypeFacePrinter textPrinter    = new TypeFacePrinter("Printing from a printer", 30, justification: Justification.Center);
                IVertexSource   translatedText = new VertexSourceApplyTransform(textPrinter, Affine.NewTranslation(new Vector2(lessSimpleImage.Width / 2, lessSimpleImage.Height / 4 * 3)));
                lessSimpleImageGraphics2D.Render(translatedText, Color.Red);
                Stroke strokedText = new Stroke(translatedText);
                lessSimpleImageGraphics2D.Render(strokedText, Color.Black);

                IVertexSource rotatedText           = new VertexSourceApplyTransform(textPrinter, Affine.NewRotation(MathHelper.DegreesToRadians(90)));
                IVertexSource rotatedTranslatedText = new VertexSourceApplyTransform(rotatedText, Affine.NewTranslation(new Vector2(40, lessSimpleImage.Height / 2)));
                lessSimpleImageGraphics2D.Render(rotatedTranslatedText, Color.Black);

                // and save this image out
                ImageTgaIO.Save(lessSimpleImage, "LessSimpleDrawAndSave.tga");
            }
        }
		public override void OnDraw(Graphics2D graphics2D)
		{
			graphics2D.FillRectangle(0, 0, Width * currentPercent / 100, Height, completeColor);

			base.OnDraw(graphics2D);
		}
Ejemplo n.º 7
0
        public override void OnDraw(Graphics2D graphics2D)
        {
#if false
            if (firstDraw)
            {
                firstDraw = false;
                SystemWindow testAbout = new SystemWindow(600, 300);

                string path = Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "OEMSettings", "AboutPage.html");
                string htmlText = File.ReadAllText(path);
                HTMLCanvas canvas = new HTMLCanvas(htmlText);
                canvas.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                canvas.AddReplacementString("textColor", RGBA_Bytes.White.GetAsHTMLString());

                canvas.AnchorAll();
                testAbout.AddChild(canvas);

                testAbout.ShowAsSystemWindow();
            }
#endif

            graphics2D.FillRectangle(new RectangleDouble(0, this.Height - 1, this.Width, this.Height), RGBA_Bytes.White);
            base.OnDraw(graphics2D);
        }
Ejemplo n.º 8
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            if(needRedraw)
            {
                needRedraw = false;
                rayTraceScene();
            }
            trackBallTransform.AxisToWorld = trackBallController.GetTransform4X4();

            graphics2D.FillRectangle(new rect_d(0, 0, 1000, 1000), RGBA_Bytes.Red);
            graphics2D.Render(destImage, 0, 0);
            trackBallController.DrawRadius(graphics2D);

            graphics2D.DrawString("Ray Trace: " + renderTime.ElapsedMilliseconds.ToString(), 20, 10);

            base.OnDraw(graphics2D);
        }
Ejemplo n.º 9
0
		private double PrintTopOfPage(ImageBuffer plateInventoryImage, Graphics2D plateGraphics)
		{
			plateGraphics.Clear(RGBA_Bytes.White);

			double currentlyPrintingHeightPixels = plateInventoryImage.Height - PageMarginMM.Top * PixelPerMM;

			// TODO: Application should not save data back to StaticDataPath - use application data dir instead
			string logoPathAndFile = "PartSheetLogo.png";
			if (StaticData.Instance.FileExists(logoPathAndFile))
			{
				ImageBuffer logoImage = StaticData.Instance.LoadImage(logoPathAndFile);
				currentlyPrintingHeightPixels -= logoImage.Height;
				plateGraphics.Render(logoImage, (plateInventoryImage.Width - logoImage.Width) / 2, currentlyPrintingHeightPixels);
			}

			currentlyPrintingHeightPixels -= PartPaddingPixels;

			double underlineHeightMM = 1;
			RectangleDouble lineBounds = new RectangleDouble(0, 0, plateInventoryImage.Width - PageMarginPixels.Left * 2, underlineHeightMM * PixelPerMM);
			lineBounds.Offset(PageMarginPixels.Left, currentlyPrintingHeightPixels - lineBounds.Height);
			plateGraphics.FillRectangle(lineBounds, RGBA_Bytes.Black);

			return currentlyPrintingHeightPixels - (lineBounds.Height + PartPaddingPixels);
		}
Ejemplo n.º 10
0
 public void DoDrawBeforeChildren(Graphics2D graphics2D)
 {
     // erase to the background color
     graphics2D.FillRectangle(GetTotalBounds(), BackgroundColor);
 }
Ejemplo n.º 11
0
 public override void OnDraw(Graphics2D graphics2D)
 {
     graphics2D.Circle(Width / 2, Height / 2, Width / 2, RGBA_Bytes.White);
     graphics2D.Circle(Width / 2, Height / 2, Width / 2 - 1, RGBA_Bytes.Red);
     graphics2D.FillRectangle(Width / 2 - 1, Height / 2 - 3, Width / 2 + 1, Height / 2 + 3, RGBA_Bytes.White);
     //graphics2D.DrawString("1", Width / 2, Height / 2 + 1, 8, Justification.Center, Baseline.BoundsCenter, RGBA_Bytes.White);
     base.OnDraw(graphics2D);
 }
Ejemplo n.º 12
0
        public override void OnDraw(Graphics2D graphics2D)
        {
            MatterCadWidget_OnDraw.Start();
            graphics2D.Clear(RGBA_Bytes.White);
            rect_d rect = new rect_d(Width - 40, 10, Width - 10, 40);
            graphics2D.FillRectangle(rect, previewWindowRayTrace.mouseOverColor);
            graphics2D.Rectangle(rect, RGBA_Bytes.Black);
            Invalidate(rect);

            base.OnDraw(graphics2D);
            MatterCadWidget_OnDraw.Stop();
        }
Ejemplo n.º 13
0
		public override void OnDraw(Graphics2D graphics2D)
		{
			Matrix4X4 currentRenderMatrix = trackballTumbleWidget.ModelviewMatrix;
			if (lastRenderedMatrix != currentRenderMatrix)
			{
				Stopwatch traceTime = new Stopwatch();
				traceTime.Start();
				rayTraceScene();
				traceTime.Stop();

				timingStrings.Add("Time to trace BVH {0:0.0}s".FormatWith(traceTime.Elapsed.TotalSeconds));
			}
			//allObjectsHolder.AxisToWorld = trackBallController.GetTransform4X4();

			graphics2D.FillRectangle(new RectangleDouble(0, 0, 1000, 1000), RGBA_Bytes.Red);
			graphics2D.Render(destImage, 0, 0);
			//trackBallController.DrawRadius(graphics2D);
			totalTime.Stop();
			timingStrings.Add("Total Time {0:0.0}s".FormatWith(totalTime.Elapsed.TotalSeconds));

			if (!SavedTimes)
			{
				SavedTimes = true;
				File.WriteAllLines("timing.txt", timingStrings.ToArray());
			}

			graphics2D.DrawString("Ray Trace: " + renderTime.ElapsedMilliseconds.ToString(), 20, 10);

			base.OnDraw(graphics2D);
			currentRenderMatrix = lastRenderedMatrix;
		}