Example #1
0
        protected override void OnDraw(ref DrawParams p)
        {
            base.OnDraw(ref p);

            testTxt.Position = new Microsoft.Xna.Framework.Vector2(0.6f, 0.9f);
            Screen.DebugText(PositionAbsolute, "Testing LevelIntro");
        }
Example #2
0
        protected override void OnDraw(ref DrawParams p)
        {
            Vector2 pos = Screen.ToPixels(PositionAbsolute);

            // plot text
            Screen.spriteBatch.DrawString(spriteFont, String.Format("{0}", Math.Round(scoreCurrent)), pos, Color.White);
        }
        protected override void OnDraw(ref DrawParams p)
        {
            base.OnDraw(ref p);

            Vector2 origin = Vector2.Zero; // new Vector2(2f * txt.Length, 0f);
            Vector2 pos = Motion.PositionAbsZoomedPixels;
            // draw shadow
            Color shadowDrawColor = Color.Black;
            shadowDrawColor.A = DrawInfo.DrawColor.A;

            // scaling with resolutions
            //             descriptionBox.Motion.Scale = ((float)Screen.WidthPixels) / 1440f; // 768f / ((float)Screen.HeightPixels); // +(((float)Screen.WidthPixels) - 1440f) / 1440f;
            float sc = Motion.ScaleAbs; // *((float)Screen.WidthPixels) / 1440f; // HACK
            float scRatio = (float) (Screen.AspectRatio / 1.6f);
            Vector2 vScale = new Vector2( sc * scRatio, sc );
            try
            {
                MySpriteBatch.DrawString(font, txt, pos + new Vector2(1f, 1f), shadowDrawColor,
                                        Motion.RotateAbs, origin, vScale, SpriteEffects.None, DrawInfo.LayerDepth + 0.00001f); // TODO the const
                MySpriteBatch.DrawString(font, txt, pos, DrawInfo.DrawColor,
                                        Motion.RotateAbs, origin, vScale, SpriteEffects.None, DrawInfo.LayerDepth);
            }
            catch (Exception)
            {
                ;  // e.g. if character to draw not available. // TODO
            }
        }
Example #4
0
 public override void OnDrawEfflet(ref DrawParams p, Microsoft.Xna.Framework.Graphics.RenderTarget2D sourceBuffer)
 {
     Screen.spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque);
     Screen.spriteBatch.Draw(sourceBuffer, Vector2.Zero, Color.White);
     Screen.spriteBatch.Draw(sourceBuffer, Screen.ToPixels(Position ), Color.White);
     Screen.spriteBatch.End();
 }
Example #5
0
 protected override void OnDraw(ref DrawParams p)
 {
     spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Opaque, null, null, null, effect);
     Vector2 ctr = Screen.ToPixelsNS(Center.X * width, Center.Y * height);
     Vector2 pos = Screen.ToPixels(DrawPosition); //DrawPosition);
     spriteBatch.Draw(Texture, pos, null, DrawColor,
            this.RotateAbsolute, ctr, this.DrawScale, SpriteEffects.None, LayerDepth);
     spriteBatch.End();
 }
Example #6
0
 protected override void OnDraw(ref DrawParams p)
 {
     // switch to the Draw technique
     eff.CurrentTechnique = eff.Techniques[2];
     spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, eff);
     spriteBatch.Draw(renderBufInput, Screen.ToPixels(DrawPosition), null, DrawColor,
            this.RotateAbsolute, DrawCenter, DrawScale, SpriteEffects.None, LayerDepth);
     spriteBatch.End();
 }
Example #7
0
        protected override void OnDraw(ref DrawParams p)
        {
            base.OnDraw(ref p);

            // text
            Vector2 pos = PositionAbsolute;
            String s = "<" + Math.Round(pos.X,3) + "," + Math.Round(pos.Y,3) + ">";
            Screen.DebugText(0.4f, 0.95f, s);
        }
Example #8
0
        protected override void OnDraw(ref DrawParams p)
        {
            eff.Parameters["Pan"].SetValue(Position);
            eff.Parameters["Zoom"].SetValue(zoom);
            eff.Parameters["Iterations"].SetValue(iterations);
            eff.Parameters["JuliaSeed"].SetValue(juliaSeed);
            eff.Parameters["Alpha"].SetValue(Alpha);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, eff);
            spriteBatch.Draw(Texture, Screen.ScreenRectangle, null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0.0f);
            spriteBatch.End();
        }
Example #9
0
        protected override void OnDraw(ref DrawParams p)
        {
            Vector2 pos = Screen.ToPixels(DrawPosition );
            int width = (int) Math.Round(131f + 480f/100f * curNrgValue );
            if (width > Texture.Width) width = Texture.Width;
            //Rectangle rect = new Rectangle( posX , posY , posX + width, posY + Texture.Height);
            Rectangle srcRect = new Rectangle(0, 0, width, Texture.Height);
            Screen.spriteBatch.Draw(Texture, pos, srcRect, DrawColor,
                    this.RotateAbsolute, Vector2.Zero, 1.0f, SpriteEffects.None, LayerDepth);

            // plot text percentage
            Vector2 tpos = pos + new Vector2(width, Texture.Height / 2.0f - 10.0f) ;
            Screen.spriteBatch.DrawString(spriteFont, String.Format("{0,3}%", Math.Round(curNrgValue)), tpos, textColor);
        }
Example #10
0
        protected override void OnDraw(ref DrawParams p)
        {
            // create a rectangle representing the screen dimensions of the starfield
            Rectangle drawRect = Screen.ScreenRectangle;
            drawRect.Width = (int) (ScaleAbsolute * (float)drawRect.Width);
            drawRect.Height = (int)(ScaleAbsolute * (float)drawRect.Height);

            Vector2 pos = PositionAbsolute;
            fxPosition.SetValue(new Vector2(pos.X / Screen.AspectRatio, pos.Y));
            fxVelocity.SetValue(VortexVelocity);
            fxTime.SetValue( SimTime );
            fxNoiseLevel.SetValue( noiseLevel );
            fxAlpha.SetValue(Alpha);

            spriteBatch.Begin(spriteSortMode, blendState, null, null, null, eff);
            spriteBatch.Draw(Texture, drawRect, null, DrawColor,
                   RotateAbsolute, DrawCenter, SpriteEffects.None, LayerDepth);
            spriteBatch.End();
        }
Example #11
0
        protected override void OnDraw(ref DrawParams p)
        {
            string msg = "rp.Time: " + Math.Round(musicRp.Time, 3);
            Screen.DebugText(0.05f, 0.025f, msg);

            // draw time
            msg = "Beat: " + Math.Round ( Beat.TimeToBeat( musicRp.Time, musicScript.BPM) , 2) ;
            Screen.DebugText(0.25f, 0.025f, msg);

            // draw music track pos's
            List<SoundEvent> aT = musicScript.Children;
            for (int i = 0; i < aT.Count; i++)
            {
                if (aT[i] is SampleSoundEvent)
                {
                    SampleSoundEvent e = (SampleSoundEvent)aT[i];
                    if (e.LastRenderParams != null)
                    {
                        msg = i + "dMs: " + Math.Round(1000.0 * (e.CurrentPlayTime - musicRp.Time));
                        Screen.DebugText(0.75f, 0.02f + 0.025f * i, msg);
                    }
                }
            }
        }
 public override void MoveTo(DrawParams data)
 {
     base.MoveTo(data);
     customTransform = new Translation(xPos, 0, 0);
     data.RenderContext.MultMatrixModelView(customTransform);
 }
Example #13
0
        protected override void DrawFlat(DrawParams data)
        {
            base.DrawFlat(data);

            DrawSelectedSubItems(data);
        }
Example #14
0
        private void drawcurrentPDFpage()
        {
            if (PDFDoc != null)
            {
                Page pg = PDFDoc.GetPage(currentPDPagenum);

                // Use the CropBox to determine region of the page to display.
                // Some documents may have a CropBox that is not located at the
                // origin of the page.
                Rect cropBox = pg.CropBox;
                int  width   = (int)cropBox.Right - (int)cropBox.Left;
                int  height  = (int)cropBox.Top - (int)cropBox.Bottom;

                // Shift the page display based on the location of the CropBox
                int shiftx = (int)cropBox.Left;
                int shifty = (int)cropBox.Bottom;

                width  = (int)((double)width * scalefactor);
                height = (int)((double)height * scalefactor);
                shiftx = (int)((double)shiftx * scalefactor);
                shifty = (int)((double)shifty * scalefactor);


                if (bitmap != null)
                {
                    bitmap.Dispose();
                }

                // If they try to allocate too large a bitmap,
                // print an error and abandon the draw
                try
                {
                    bitmap = new Bitmap(width, height);
                }
                catch (ArgumentException ex)
                {
                    String message = "File " + PDFDoc.FileName + " is "
                                     + width.ToString() + " x " + height.ToString()
                                     + " pixels -- too large for DisplayPDF to handle.";

                    MessageBox.Show(message, "Document Too Large");
                    return;
                }
                // The bitmap starts out black, so clear it to white

                Graphics graphics = Graphics.FromImage(bitmap);
                graphics.Clear(System.Drawing.Color.White);

                // Must invert the page to get from PDF with origin at lower left,
                // to a bitmap with the origin at upper right.
                // Also, we use the shiftx and shifty to take the location of the CropBox
                // into account.
                Matrix matrix = new Matrix().Scale(1, -1).Translate(-shiftx, -height - shifty).Scale(scalefactor, scalefactor);

                PDFPagepicturebox.Image  = bitmap;
                PDFPagepicturebox.matrix = matrix;
                PDFPagepicturebox.Size   = bitmap.Size;

                // Set the updateRect
                Rect updateRect = new Rect((int)cropBox.LLx,
                                           (int)cropBox.LLy,
                                           (int)cropBox.LLx + width,
                                           (int)cropBox.LLy + height);
#if MONO
                // Draw directly to the bitmap
                pg.DrawContents(bitmap,
                                matrix, // matrix
                                updateRect);
#else
                DrawParams parms = new DrawParams();
                parms.Matrix     = matrix;
                parms.UpdateRect = updateRect;
                parms.Flags      = DrawFlags.DoLazyErase | DrawFlags.UseAnnotFaces;

                pg.DrawContents(graphics, parms);
#endif
                PageNumberTextBox.Text = (currentPDPagenum + 1).ToString();
                PageLabel.Text         = "of " + maxpages.ToString();
            }
        }
        protected override void OnDraw(ref DrawParams p)
        {
            if (timeParam != null)
                timeParam.SetValue(SimTime);
            if (positionParam != null)
                positionParam.SetValue(Motion.Position);

            Color col = DrawInfo.DrawColor;
            if (EffectEnabled)
            {
                // this is a conversion from 'halotime' to the time format that can be given to the pixel shader
                // via the 'draw color' parameter
                int t = (int) (haloTime * 256);
                int c3 = t % 256;
                int c2 = ((t - c3)/256) % 256;
                int c1 = ((t - c2 - c3)/65536) % 256;
                col = new Color(c1, c2, c3, col.A);
            }
            MySpriteBatch.Draw(Texture, DrawInfo.DrawPosition, null, col,
                   Motion.RotateAbs, DrawInfo.DrawCenter, DrawInfo.DrawScale, SpriteEffects.None, DrawInfo.LayerDepth);
        }
Example #16
0
 protected override void DrawSelected(DrawParams drawParams)
 {
     base.Draw(drawParams);
 }
Example #17
0
        private void DrawSelectedSubItems(DrawParams data)
        {
            // Draws the selected triangles over the other triangles
            if (SelectedSubItems.Count == 0)
            {
                return;
            }

            bool popState = false;
            int  alpha    = 255;

            if (data.RenderContext.LightingEnabled())
            {
                if (data.RenderContext.CurrentMaterial.Diffuse.A == 255)
                {
                    data.RenderContext.PushDepthStencilState();
                    data.RenderContext.SetState(depthStencilStateType.DepthTestEqual);
                    popState = true;
                }
                else
                {
                    alpha = data.RenderContext.CurrentMaterial.Diffuse.A;
                }
            }
            else
            {
                if (data.RenderContext.CurrentWireColor.A == 255)
                {
                    data.RenderContext.PushDepthStencilState();
                    data.RenderContext.SetState(depthStencilStateType.DepthTestEqual);
                    popState = true;
                }
                else
                {
                    alpha = data.RenderContext.CurrentWireColor.A;
                }
            }

            var prevCol      = data.RenderContext.CurrentWireColor;
            var prevMatFront = data.RenderContext.CurrentMaterial.Diffuse;
            var prevMatBack  = data.RenderContext.CurrentBackMaterial.Diffuse;

            if (data.RenderContext.LightingEnabled())
            {
                data.RenderContext.SetMaterialFrontAndBackDiffuse(System.Drawing.Color.FromArgb(alpha, System.Drawing.Color.Yellow), true);
            }

            else
            {
                data.RenderContext.SetColorWireframe(System.Drawing.Color.FromArgb(alpha, System.Drawing.Color.Yellow));
            }

            // to properly support multicolor mesh during triangles selection
            if (vp.UseShaders)
            {
                data.RenderContext.PushShader();

                switch (vp.DisplayMode)
                {
                case displayType.Flat:
                case displayType.HiddenLines:
                case displayType.Wireframe:
                    data.RenderContext.SetShader(shaderType.NoLights);
                    break;

                default:
                    data.RenderContext.SetShader(shaderType.Standard);
                    break;
                }
            }

            data.RenderContext.Draw(drawSelectedData);

            if (vp.UseShaders)
            {
                data.RenderContext.PopShader();
            }

            data.RenderContext.SetColorWireframe(prevCol);
            data.RenderContext.SetMaterialFrontDiffuse(prevMatFront);
            data.RenderContext.SetMaterialBackDiffuse(prevMatBack);

            if (popState)
            {
                data.RenderContext.PopDepthStencilState();
            }
        }
Example #18
0
 protected override void OnDraw(ref DrawParams p)
 {
     Vector2 pos = PositionAbsolute;
     Vector2 posPixels = Screen.ToPixels(pos );
     Screen.spriteBatch.DrawString(spriteFont, text, posPixels, this.DrawColor);
 }
Example #19
0
    private Coord findItemBarPosition(DrawParams d, Coord item, int itemOffset)
    {
        Coord itemBar = new Coord();
        itemBar.Y = item.Y;
        itemBar.X = itemOffset;

        if (d.ReflectX)
            itemBar.X = -ItemBarWidth + PanelWidth + itemOffset;

        return itemBar;
    }
Example #20
0
    private Coord findBarPosition(DrawParams d)
    {
        Coord bar = new Coord();

        if (d.ReflectY)
            bar.Y = PanelHeight - BarHeight;

        if (d.ReflectX)
            bar.X = PanelWidth - BarWidth;

        return bar;
    }
Example #21
0
    private void drawExtendedHUD(AD2SpriteBatch sb, DrawParams d, Coord item)
    {
        //back panel
        int hideOffset = (d.ReflectX ? (PanelWidth + -(int)(Extend * PanelWidth)) : (-PanelWidth + (int)(Extend * PanelWidth)));

        sb.DrawTexture(BackPanel, d.HUDX + hideOffset, d.HUDY);

        Coord portrait = findPortraitPosition(d, hideOffset);

        int itemHideOffset = (d.ReflectX ? (ItemFrameWidth + -(int)(Extend * ItemFrameWidth)) : (-ItemFrameWidth + (int)(Extend * ItemFrameWidth)));
        Coord itemBar = findItemBarPosition(d, item, itemHideOffset);

        //portrait
        if (d.ReflectX)
        {
            sb.DrawTextureHFlip(RaceUtils.GetPotrait(Player.Race), d.HUDX + portrait.X, d.HUDY + portrait.Y);
            sb.DrawTextureHFlip(ItemFrameBig, d.HUDX + itemBar.X, d.HUDY + itemBar.Y);
        }
        else
        {
            sb.DrawTexture(RaceUtils.GetPotrait(Player.Race), d.HUDX + portrait.X, d.HUDY + portrait.Y);
            sb.DrawTexture(ItemFrameBig, d.HUDX + itemBar.X, d.HUDY + itemBar.Y);
        }
    }
        protected override void OnDraw(ref DrawParams p)
        {
            Vector2 pos = DrawInfo.DrawPosition;
            double progressValuePercent = 100 * progressValue;
            float drawSc = DrawInfo.DrawScale;
            int width = 1 + (int)Math.Round(ToPixels(DrawInfo.WidthAbs) * progressValue * barWidth );
            int height = (int) Math.Round(ToPixels(DrawInfo.HeightAbs));
            if (width > Texture.Width) width = Texture.Width;

            Rectangle srcRect = new Rectangle(0, 0, width, Texture.Height-2);
            MySpriteBatch.Draw(Texture, pos, srcRect, DrawInfo.DrawColor,
                            Motion.RotateAbs, new Vector2(0f,height/4), drawSc, SpriteEffects.None, DrawInfo.LayerDepth);

            // plot text percentage
            Color textColor = DrawInfo.DrawColor;
            Vector2 tpos = pos + new Vector2(width * drawSc, height/4); //Texture.Height / 2.0f - 10.0f) ;
            Vector2 origin = new Vector2(10f,6f);
            MySpriteBatch.DrawString(spriteFont, String.Format(" {0,3}%", Math.Round(progressValuePercent)), tpos, 
                                     textColor, Motion.RotateAbs, origin, textScale * drawSc * 1.2f, SpriteEffects.None, DrawInfo.LayerDepth);
        }
Example #23
0
        public void CreateBitmap(int w, int h, uint argb, int lineW, string fname)
        {
            DrawContext dc = Controller.DC;

            CadObjectDB db = Controller.DB;

            List <uint> idlist = Controller.DB.GetSelectedFigIDList();

            var figList = new List <CadFigure>();

            idlist.ForEach(id =>
            {
                figList.Add(db.GetFigure(id));
            });

            CadRect r = CadUtil.GetContainsRectScrn(dc, figList);

            CadRect wr = default(CadRect);

            wr.p0 = dc.DevPointToWorldPoint(r.p0);
            wr.p1 = dc.DevPointToWorldPoint(r.p1);

            DrawContextGDIBmp tdc = new DrawContextGDIBmp();

            tdc.WorldScale = dc.WorldScale;

            tdc.SetCamera(dc.Eye, dc.LookAt, dc.UpVector);
            tdc.CalcProjectionMatrix();

            tdc.SetViewSize(w, h);

            tdc.SetViewOrg(new Vector3d(w / 2, h / 2, 0));

            tdc.SetupTools(DrawTools.DrawMode.DARK);

            Pen pen = new Pen(Color.FromArgb((int)argb), lineW);

            DrawPen drawPen = new DrawPen(pen);

            double sw = r.p1.X - r.p0.X;
            double sh = r.p1.Y - r.p0.Y;

            double a = Math.Min(w, h) / (Math.Max(sw, sh) + lineW);

            tdc.DeviceScaleX *= a;
            tdc.DeviceScaleY *= a;

            CadRect tr = CadUtil.GetContainsRectScrn(tdc, figList);

            Vector3d trcp = (Vector3d)((tr.p1 - tr.p0) / 2 + tr.p0);

            Vector3d d = trcp - tdc.ViewOrg;

            tdc.SetViewOrg(tdc.ViewOrg - d);

            DrawParams dp = default;

            dp.LinePen = drawPen;
            dp.EdgePen = drawPen;

            Env.RunOnMainThread((Action)(() =>
            {
                tdc.Drawing.Clear(dc.GetBrush(DrawTools.BRUSH_TRANSPARENT));

                tdc.GdiGraphics.SmoothingMode = SmoothingMode.AntiAlias;

                foreach (CadFigure fig in figList)
                {
                    fig.Draw(tdc, dp);
                }

                if (fname.Length > 0)
                {
                    tdc.Image.Save(fname);
                }
                else
                {
                    BitmapUtil.BitmapToClipboardAsPNG(tdc.Image);
                }

                tdc.Dispose();
                drawPen.Dispose();
            }));
        }
        static void Main(string[] args)
        {
            Console.WriteLine("DrawSeparations Sample:");

            using (Library lib = new Library())
            {
                Console.WriteLine("Initialized the library.");

                String sInput  = Library.ResourceDirectory + "Sample_Input/ducky.pdf";
                String sOutput = "../DrawSeparations-out";

                if (args.Length > 0)
                {
                    sInput = args[0];
                }

                if (args.Length > 1)
                {
                    sOutput = args[1];
                }

                Console.WriteLine("Input file: " + sInput + ", writing output using prefix: " + sOutput);

                Document doc = new Document(sInput);
                Page     pg  = doc.GetPage(0);

                // Get all inks that are present on the page
                List <Ink> inks = (List <Ink>)pg.ListInks();
                List <SeparationColorSpace> colorants = new List <SeparationColorSpace>();

                // Here we decide, which inks should be drawn
                foreach (Ink theInk in inks)
                {
                    // note: if the Ink can't be found in page's resources,
                    // default tintTransform and alternate will be used
                    colorants.Add(new SeparationColorSpace(pg, theInk));
                }

                double width  = pg.MediaBox.Right - pg.MediaBox.Left;
                double height = pg.MediaBox.Top - pg.MediaBox.Bottom;

                // Must invert the page to get from PDF with origin at lower left,
                // to a bitmap with the origin at upper right.
                Matrix matrix = new Matrix().Scale(1, -1).Translate(-pg.MediaBox.Left, -pg.MediaBox.Top);

                DrawParams parms = new DrawParams();
                parms.Matrix   = matrix;
                parms.DestRect = new Rect(0, 0, width, height);
                parms.Flags    = DrawFlags.DoLazyErase | DrawFlags.UseAnnotFaces;

                double bottom = 0;
                if (pg.MediaBox.Bottom != 0)
                {
                    bottom = pg.MediaBox.Bottom < 0 ? -pg.MediaBox.Top : pg.MediaBox.Top;
                }

                parms.UpdateRect = new Rect(pg.MediaBox.Left, bottom, width, height);

                // Acquiring list of separations
                List <Bitmap> separatedColorChannels = pg.DrawContents(parms, colorants);

                for (int i = 0; i < separatedColorChannels.Count; ++i)
                {
                    separatedColorChannels[i].Save(sOutput + i + "-" + colorants[i].SeparationName + ".png", ImageFormat.Png);
                }
            }
        }
        /**
         * printDocument -
         *
         * displays a print dialog in order to print the current document
         */
        public void printDocument()
        {
            // check for a null document
            if (document == null)
            {
                MessageBox.Show("A PDF must be open in order to print.", "Datalogics DotNETViewer");
                return;
            }

            // continuous page printing not supported
            if (PageDisplayMode == PageViewMode.continuousPage)
            {
                MessageBox.Show("Unable to Print in Continuous Page Mode", "Print Error", MessageBoxButtons.OK);
                return;
            }

            try
            {
                double docGreatestWidthInPrinterRezUnits = 0.0;
                double docGreatestWidthInInches          = 0.0;
                double docGreatestWidthInPDFUserUnits    = 0.0;

                double docHeightInInches          = 0.0;
                double docHeightInPrinterRezUnits = 0.0;
                double docHeightInPDFUserUnits    = 0.0;

                Graphics graphics;
                uint     resolutionX;
                uint     resolutionY;

                // DLADD wrl 6/24/08 -- Use DotNET shrinkToFit flag to handle scaling
                bool shrinkToFit = false;

                PrintDocument printDocument = new PrintDocument();

                // create the settings to use while printing
                PrinterSettings printerSettings = printDocument.PrinterSettings;
                printerSettings.MinimumPage = 1;
                printerSettings.MaximumPage = document.NumPages;
                printerSettings.PrintRange  = PrintRange.AllPages;
                printerSettings.FromPage    = 1;
                printerSettings.ToPage      = document.NumPages;

                // create a print dialog
                DotNETPrintDialog dpd = new DotNETPrintDialog();
                dpd.Document       = printDocument;
                dpd.AllowSelection = false;
                dpd.AllowSomePages = true;

                if (PageDisplayMode == PageViewMode.singlePage)
                {
                    dpd.AllowShrinkToFit = true;
                    dpd.ShrinkToFit      = true;
                }

                // display the print dialog if the user does not
                // click "OK" throw a new exception to cancel printing
                if (dpd.ShowDialog() != DialogResult.OK)
                {
                    throw new CancelPrinting();
                }

                shrinkToFit = dpd.ShrinkToFit;

                graphics    = printerSettings.CreateMeasurementGraphics();
                resolutionX = (uint)graphics.DpiX;
                resolutionY = (uint)graphics.DpiY;

                // grab some additional parameters if printing to a file
                if (printerSettings.PrintToFile)
                {
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.DefaultExt = ".plt";
                    saveFileDialog.FileName   = "plot.plt";

                    if (saveFileDialog.ShowDialog() != DialogResult.OK)
                    {
                        throw new CancelPrinting();
                    }
                    else
                    {
                        printerSettings.PrintFileName = saveFileDialog.FileName;
                    }
                }

                // find the dimensions we need for printing
                docGreatestWidthInPDFUserUnits = 0;
                for (int i = 0; i < document.NumPages; ++i)
                {
                    using (Page page = document.GetPage(i)) docGreatestWidthInPDFUserUnits = Math.Max(docGreatestWidthInPDFUserUnits, page.CropBox.Width);
                }
                docHeightInPDFUserUnits = 0;
                for (int i = printerSettings.FromPage - 1; i <= printerSettings.ToPage - 1; ++i)
                {
                    using (Page page = document.GetPage(i)) docHeightInPDFUserUnits += page.CropBox.Height;
                }

                docGreatestWidthInInches = docGreatestWidthInPDFUserUnits / (double)GlobalConsts.pdfDPI;
                docHeightInInches        = docHeightInPDFUserUnits / (double)GlobalConsts.pdfDPI;

                docGreatestWidthInPrinterRezUnits = docGreatestWidthInInches * (double)resolutionX;
                docHeightInPrinterRezUnits        = docHeightInInches * (double)resolutionY;

                if (PageDisplayMode == PageViewMode.singlePage)
                {
#if HAS_DATALOGICS_PRINTING
                    Printer S_printer = new Printer(printerSettings.PrinterName);

                    if (S_printer.HardwareID == "isysij18")
                    {
                        // special workaround for iSys iTerra IJ1800
                        // use our special print controller to print via unmanaged code
                        PrintController pc = new DLPrinterPrintController(S_printer, printDocument.PrinterSettings, document.fileName);
                        printDocument.PrintController = new PrintControllerWithStatusDialog(pc);
                    }
                    else
                    {
                        S_printer.Dispose();
                    }
#endif

                    // User can control printing of OCGs
                    DrawParams drawParams = new DrawParams();

                    for (int j = 0; j < layersManager.ocgStates.Count; j++)
                    {
                        layersManager.ocgStates[j] = layersManager.layersInDocument[j].printLayer.Checked;
                    }

                    layersManager.docLayerContext.SetOCGStates(layersManager.docLayers, layersManager.ocgStates);
                    drawParams.OptionalContentContext = layersManager.docLayerContext;

                    // create the print controller
                    DotNETPrintController ppc = new DotNETPrintController(document, printDocument, drawParams, true, shrinkToFit);

                    // start the printing
                    ppc.Print();
                }
            }
            catch (CancelPrinting)
            {
                // Ignore, user cancelled printing
            }
        }
Example #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("DrawToBitmap Sample");

            try
            {
                using (Library lib = new Library())
                {
                    Console.WriteLine("Initialized the library.");

                    String sInput = "../../Resources/Sample_Input/ducky.pdf";

                    if (args.Length > 0)
                    {
                        sInput = args[0];
                    }

                    Console.WriteLine("Input file: " + sInput);

                    using (Document doc = new Document(sInput))
                    {
                        using (Page pg = doc.GetPage(0))
                        {
                            //
                            // Must tumble the page to get from PDF with origin at lower left
                            // to a Bitmap with the origin at upper left.
                            //

                            double scaleFactor = resolution / 72.0;
                            double width       = (pg.MediaBox.Width * scaleFactor);
                            double height      = (pg.MediaBox.Height * scaleFactor);
                            Matrix matrix      = new Matrix().Scale(scaleFactor, -scaleFactor).Translate(0, -pg.MediaBox.Height);

                            bool enableBlackPointCompensation = true;

                            using (DrawParams parms = ConstructDrawParams(matrix, pg.MediaBox, enableBlackPointCompensation))
                            {
#if !MONO
                                // Draw to Graphics
                                Console.WriteLine(String.Format("DrawToGraphicsWithMatrix: {0} {1} {2}", matrix.ToString(), width, height));
                                DrawToGraphicsWithMatrix(pg, matrix, width, height);    // Will NOT drive SampleRenderProgress(Cancel)Proc

                                // Draw to Graphics using DrawParams with turned on black point compensation
                                Console.WriteLine(String.Format("DrawToGraphicsWithDrawParams: {0} {1} {2}", parms.Matrix.ToString(), parms.UpdateRect.Width, parms.UpdateRect.Height));
                                DrawToGraphicsWithDrawParams(pg, parms);    // Will drive SampleRenderProgress(Cancel)Proc

                                // Demonstrate drawing to Graphics with params and OCGs
                                // Demonstrate drawing layers
                                Console.WriteLine(String.Format("DrawLayersToGraphics: {0} {1} {2}", parms.Matrix.ToString(), parms.UpdateRect.Width, parms.UpdateRect.Height));
                                DrawLayersToGraphics(doc, pg, parms);   // Will NOT drive SampleRenderProgress(Cancel)Proc
#endif
                                // Demonstrate drawing to Bitmaps with params and OCGs
                                // Demonstrate drawing layers
                                Console.WriteLine(String.Format("DrawLayersToBitmap: {0} {1} {2}", parms.Matrix.ToString(), parms.UpdateRect.Width, parms.UpdateRect.Height));
                                DrawLayersToBitmap(doc, pg, parms); // Will NOT drive SampleRenderProgressProc

                                // Make a Bitmap
                                Console.WriteLine(String.Format("DrawToBitmapWithMatrix: {0} {1} {2}", matrix.ToString(), width, height));
                                DrawToBitmapWithMatrix(pg, matrix, width, height);  // Will NOT drive SampleRenderProgress(Cancel)Proc

                                // Make a Bitmap using DrawParams with black point compensation turned on
                                Console.WriteLine(String.Format("DrawToBitmapWithDrawParams: {0} {1} {2}", parms.Matrix.ToString(), parms.UpdateRect.Width, parms.UpdateRect.Height));
                                DrawToBitmapWithDrawParams(pg, parms);  // Will drive SampleRenderProgress(Cancel)Proc

                                // Demonstrate drawing to a byte array
                                Console.WriteLine(String.Format("DrawToByteArray: {0} {1} {2}", matrix.ToString(), width, height));
                                DrawToByteArray(pg, width, height, matrix); // Will drive SampleRenderProgress(Cancel)Proc
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(@"An exception occurred. Here is the related information:");
                Console.Write(ex.ToString());
            }
        }
Example #27
0
 protected override void DrawIsocurves(DrawParams data)
 {
     data.RenderContext.Draw(drawData);
 }
Example #28
0
        protected override void DrawHiddenLines(DrawParams data)
        {
            base.DrawHiddenLines(data);

            DrawSelectedSubItems(data);
        }
        static void Main(string[] args)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) &&
                !System.IO.File.Exists("/usr/local/lib/libgdiplus.dylib"))
            {
                Console.WriteLine("Please install libgdiplus first to access the System.Drawing namespace on macOS.");
                return;
            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) &&
                !System.IO.File.Exists("/usr/lib64/libgdiplus.so") &&
                !System.IO.File.Exists("/usr/lib/libgdiplus.so"))
            {
                Console.WriteLine("Please install libgdiplus first to access the System.Drawing namespace on Linux.");
                return;
            }

            Console.WriteLine("DrawToBitmap Sample");

            try
            {
                // ReSharper disable once UnusedVariable
                using (Library lib = new Library())
                {
                    Console.WriteLine("Initialized the library.");

                    String sInput = Library.ResourceDirectory + "Sample_Input/ducky.pdf";

                    if (args.Length > 0)
                    {
                        sInput = args[0];
                    }

                    Console.WriteLine("Input file: " + sInput);

                    using (Document doc = new Document(sInput))
                    {
                        using (Page pg = doc.GetPage(0))
                        {
                            //
                            // Must tumble the page to get from PDF with origin at lower left
                            // to a Bitmap with the origin at upper left.
                            //

                            double scaleFactor = resolution / 72.0;
                            double width       = (pg.MediaBox.Width * scaleFactor);
                            double height      = (pg.MediaBox.Height * scaleFactor);

                            //When the MediaBox's origin isn't at the lower-left of the page we can't use the 'Height' member and
                            //instead used the 'Top'.
                            double ty = pg.MediaBox.Height;
                            if (pg.MediaBox.Bottom != 0)
                            {
                                ty = pg.MediaBox.Top;
                            }

                            Matrix matrix = new Matrix().Scale(scaleFactor, -scaleFactor).Translate(0, -ty);

                            bool enableBlackPointCompensation = true;

                            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                            using (DrawParams parms =
                                       ConstructDrawParams(matrix, pg.MediaBox, enableBlackPointCompensation))
                            {
                                // Draw to Graphics
                                Console.WriteLine("DrawToGraphicsWithMatrix: {0} {1} {2}", matrix, width, height);
                                DrawToGraphicsWithMatrix(pg, matrix, width,
                                                         height); // Will NOT drive SampleRenderProgress(Cancel)Proc

                                // Draw to Graphics using DrawParams with turned on black point compensation
                                Console.WriteLine("DrawToGraphicsWithDrawParams: {0} {1} {2}", parms.Matrix,
                                                  parms.UpdateRect.Width, parms.UpdateRect.Height);
                                DrawToGraphicsWithDrawParams(pg, parms); // Will drive SampleRenderProgress(Cancel)Proc

                                // Demonstrate drawing to Graphics with params and OCGs
                                // Demonstrate drawing layers
                                Console.WriteLine("DrawLayersToGraphics: {0} {1} {2}", parms.Matrix,
                                                  parms.UpdateRect.Width, parms.UpdateRect.Height);
                                DrawLayersToGraphics(doc, pg, parms); // Will NOT drive SampleRenderProgress(Cancel)Proc

                                // Demonstrate drawing to Bitmaps with params and OCGs
                                // Demonstrate drawing layers
                                Console.WriteLine("DrawLayersToBitmap: {0} {1} {2}", parms.Matrix,
                                                  parms.UpdateRect.Width, parms.UpdateRect.Height);
                                DrawLayersToBitmap(doc, pg, parms); // Will NOT drive SampleRenderProgressProc

                                // Make a Bitmap
                                Console.WriteLine("DrawToBitmapWithMatrix: {0} {1} {2}", matrix, width, height);
                                DrawToBitmapWithMatrix(pg, matrix, width,
                                                       height); // Will NOT drive SampleRenderProgress(Cancel)Proc

                                // Make a Bitmap using DrawParams with black point compensation turned on
                                Console.WriteLine("DrawToBitmapWithDrawParams: {0} {1} {2}", parms.Matrix,
                                                  parms.UpdateRect.Width, parms.UpdateRect.Height);
                                DrawToBitmapWithDrawParams(pg, parms); // Will drive SampleRenderProgress(Cancel)Proc

                                // Demonstrate drawing to a byte array
                                Console.WriteLine("DrawToByteArray: {0} {1} {2}", matrix, width, height);
                                DrawToByteArray(pg, matrix); // Will drive SampleRenderProgress(Cancel)Proc
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(@"An exception occurred. Here is the related information:");
                Console.Write(ex.ToString());
            }
        }
Example #30
0
        public void Paint(DrawParams drawParams, Pen pen, System.Windows.Forms.PaintEventArgs e)
        {
            Vector2 end = Vector2.FromAngle(direction) * 40 * drawParams.scale + origin;

            e.Graphics.DrawLine(pen, origin.ToPoint(drawParams), end.ToPoint(drawParams));
        }
Example #31
0
        protected override void OnDraw(ref DrawParams p)
        {
            // determine the movement vector of the stars
            // -- for the purposes of the parallax eff, 
            //    this is the opposite direction as the position movement.
            Vector2 movement = -1.0f * (Position - lastPosition);

            // create a rectangle representing the screen dimensions of the starfield
            Rectangle starfieldRectangle = Screen.ScreenRectangle;

            Vector2 pos = Parent.PositionAbsolute;
            int posOffsetX = (int)Screen.ToPixels(pos.X);
            int posOffsetY = (int)Screen.ToPixels(pos.Y);

            // if we've moved too far, then reset, as the stars will be moving too fast
            if (movement.Length() > maximumMovementPerUpdate)
            {
                Reset(Position);
                return;
            }

            // draw all of the stars
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
            for (int i = 0; i < stars.Length; i++)
            {
                // move the star based on the depth
                int depth = i % movementFactors.Length;
                stars[i] += movement * movementFactors[depth];

                // wrap the stars around
                if (stars[i].X < starfieldRectangle.X)
                {
                    stars[i].X = starfieldRectangle.X + starfieldRectangle.Width;
                    stars[i].Y = starfieldRectangle.Y +
                        RandomMath.Random.Next(starfieldRectangle.Height);
                }
                if (stars[i].X > (starfieldRectangle.X + starfieldRectangle.Width))
                {
                    stars[i].X = starfieldRectangle.X;
                    stars[i].Y = starfieldRectangle.Y +
                        RandomMath.Random.Next(starfieldRectangle.Height);
                }
                if (stars[i].Y < starfieldRectangle.Y)
                {
                    stars[i].X = starfieldRectangle.X +
                        RandomMath.Random.Next(starfieldRectangle.Width);
                    stars[i].Y = starfieldRectangle.Y + starfieldRectangle.Height;
                }
                if (stars[i].Y >
                    (starfieldRectangle.Y + Screen.HeightPixels))
                {
                    stars[i].X = starfieldRectangle.X +
                        RandomMath.Random.Next(starfieldRectangle.Width);
                    stars[i].Y = starfieldRectangle.Y;
                }

                // draw the star
                Screen.spriteBatch.Draw(starTexture,
                    new Rectangle((int)stars[i].X + posOffsetX, (int)stars[i].Y + posOffsetY, starSize, starSize),
                    null, layerColors[depth], Rotate, Vector2.Zero, SpriteEffects.None, LayerDepth);
            }
            //spriteBatch.End();
        }
Example #32
0
        public void Draw(SpriteBatch spriteBatch, BattleTurn.ActionArgs[] actions, Player[] players, DrawParams textures)
        {
            //pass in the information about actions -- draw for each one. This information does not need to be stored here too.


            //draw underlying alpha box for the box containing text.
            textBox.Draw(spriteBatch);
            //calculate the size of the text
            Vector2 nameSize = textFont.MeasureString(text);
            //calculate the position where the text needs to be drawn to be central
            //  to the text box.
            Vector2 namePos = textBox.GetCentrePos() - 0.5f * new Vector2(nameSize.X, nameSize.Y);

            //draw the text
            spriteBatch.DrawString(textFont, text, namePos, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f);

            foreach (RectBox box in actionBoxes)
            {
                box.Draw(spriteBatch);
            }

            //draw respective information about each action
            for (int i = 0; i < actions.Length; i++)
            {
                BattleTurn.ActionArgs action = actions[i];
                RectBox boxDrawingTo         = actionBoxes[i];
                Vector2 boxPos = boxDrawingTo.GetPos();

                Color boxColor = (action.ActingUnit.OwnerId == 3) ?
                                 Color.Gray :
                                 players.Where(player => player.Id == action.ActingUnit.OwnerId).First().Colour; //set the color to Ai color/player color


                //draw a coloured block to specify which player the acting unit belongs to.
                //Using a single pixel texture instead of a non-disposable object (say my RectBox class for instance)
                // eliminates memory leak issues.
                spriteBatch.Draw(emptyRect, new Rectangle(boxDrawingTo.GetPos().ToPoint(), new Point(10, actionBoxHeight)), color: boxColor);

                Texture2D actingUnitSprite = action.ActingUnit.GetSprite(textures.unitSprites);


                //draw the units involved in each action, and the icons displaying the type of action.
                if (action.IsAttack)
                {
                    //draw the attacking unit
                    spriteBatch.Draw(actingUnitSprite,
                                     position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(actingUnitSprite.Bounds),
                                     scale: spriteScaleVector
                                     );

                    //draw the attack icon
                    spriteBatch.Draw(textures.attackIcon,
                                     position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2),
                                     scale: iconScaleVector
                                     );

                    //draw the target unit
                    Texture2D targetUnitSprite = action.TargetUnit.GetSprite(textures.unitSprites);
                    spriteBatch.Draw(targetUnitSprite,
                                     position: boxPos + new Vector2(2.5f * width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(targetUnitSprite.Bounds),
                                     scale: spriteScaleVector
                                     );

                    //draw the defense icon
                    spriteBatch.Draw(textures.defenseIcon,
                                     position: boxPos + new Vector2(2.5f * width / 5, boxDrawingTo.GetHeight() / 2) - iconScale * new Vector2(textures.defenseIcon.Width, 0),
                                     scale: iconScaleVector
                                     );

                    //draw the skull icon if the target unit died as a result of the action.
                    if (action.TargetFainted)
                    {
                        spriteBatch.Draw(textures.skullIcon,
                                         position: boxPos + new Vector2(3.5f * width / 5, boxDrawingTo.GetHeight() / 2) - iconScale / 2 * UiTools.BoundsToVector(textures.skullIcon.Bounds),
                                         scale: iconScaleVector * 2
                                         );
                    }
                }
                else if (action.IsMove)
                {
                    //draw acting unit
                    spriteBatch.Draw(actingUnitSprite,
                                     position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(actingUnitSprite.Bounds),
                                     scale: spriteScaleVector
                                     );

                    //draw move icon
                    spriteBatch.Draw(textures.moveIcon,
                                     position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2),
                                     scale: iconScaleVector
                                     );

                    //draw target unit
                    Texture2D targetUnitSprite = action.TargetUnit.GetSprite(textures.unitSprites);
                    spriteBatch.Draw(targetUnitSprite,
                                     position: boxPos + new Vector2(2.5f * width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(targetUnitSprite.Bounds),
                                     scale: spriteScaleVector
                                     );

                    //draw targetting icon
                    spriteBatch.Draw(textures.targetIcon,
                                     position: boxPos + new Vector2(2.5f * width / 5, boxDrawingTo.GetHeight() / 2) - iconScale * new Vector2(textures.targetIcon.Width, 0),
                                     scale: iconScaleVector
                                     );
                }
                else //(No move)
                {
                    //Draw the unit trying to act
                    spriteBatch.Draw(actingUnitSprite,
                                     position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2) - spriteScale / 2 * UiTools.BoundsToVector(actingUnitSprite.Bounds),
                                     scale: spriteScaleVector
                                     );

                    //Draw no act icon (cant move)
                    spriteBatch.Draw(textures.noMoveIcon,
                                     position: boxPos + new Vector2(width / 5, boxDrawingTo.GetHeight() / 2),
                                     scale: iconScaleVector
                                     );
                }
            }

            //draw dividing line
            divisorA.Draw(spriteBatch);
        }
Example #33
0
 protected override void OnDraw(ref DrawParams p)
 {
     base.OnDraw(ref p);
 }
Example #34
0
    private Coord findItemPosition(DrawParams d, Coord bar)
    {
        Coord item = new Coord();
           item.Y = bar.Y + BarHeight + (-1);
           item.X = 0;

        if (d.ReflectY)
            item.Y = PanelHeight + -BarHeight + -ItemFrameHeight + (1);

        if (d.ReflectX)
            item.X = PanelWidth + -ItemFrameHeight;

        return item;
    }
Example #35
0
        protected override void OnDraw(ref DrawParams p)
        {
            Rectangle drawRect = Screen.ScreenRectangle;

            effectRingColor.SetValue(RingColor);
            effectPositions.SetValue(aPositions); 
            effectSizes.SetValue(aSizes);
            effectWidths.SetValue(aWidths);

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, null, null, eff);
            spriteBatch.Draw(texture, drawRect, null, Color.White, 0.0f,
                Vector2.Zero, SpriteEffects.None, 0.0f);
            spriteBatch.End();
        }
Example #36
0
 protected override void OnDraw(ref DrawParams p)
 {
     base.OnDraw(ref p);
 }
Example #37
0
    private Coord findPortraitPosition(DrawParams d, int hideOffset)
    {
        Coord portrait = new Coord();
        portrait.Y = 1;
        portrait.X = PanelWidth +- (PortraitWidth) + -1 + hideOffset;

        if (d.ReflectY)
            portrait.Y = PanelHeight + -PortraitHeight  + -1;

        if (d.ReflectX)
            portrait.X = 1 + hideOffset;

        return portrait;
    }
Example #38
0
    private DrawParams generateDrawParams()
    {
        DrawParams d = new DrawParams();

        switch (Ccorner)
        {
            case Corner.TOPLEFT:
                d.NameX = NameX;
                d.NameY = NameY;
                d.HUDX = 0;
                d.HUDY = NameSpaceY;
                d.ReflectX = false;
                d.ReflectY = false;
                break;

            case Corner.TOPRIGHT:
                //fake
                d.NameX = CastleSpire.BaseWidth - Utils.DefaultFont.GetWidth(Player.Name, true);
                d.NameY = NameY;
                d.HUDX = CastleSpire.BaseWidth - PanelWidth;
                d.HUDY = NameSpaceY;
                d.ReflectX = true;
                d.ReflectY = false;
                break;

            case Corner.BOTTOMLEFT:
                d.NameX = NameX;
                d.NameY = CastleSpire.BaseHeight - NameSpaceY + 1;
                d.HUDX = 0;
                d.HUDY = CastleSpire.BaseHeight + -NameSpaceY + -PanelHeight;
                d.ReflectX = false;
                d.ReflectY = true;
                break;

            case Corner.BOTTOMRIGHT:
                d.NameX = CastleSpire.BaseWidth - Utils.DefaultFont.GetWidth(Player.Name, true);
                d.NameY = CastleSpire.BaseHeight + -NameSpaceY + 1;
                d.HUDX = CastleSpire.BaseWidth - PanelWidth;
                d.HUDY = CastleSpire.BaseHeight + -NameSpaceY + -PanelHeight;
                d.ReflectX = true;
                d.ReflectY = true;
                break;
        }
        return d;
    }
Example #39
0
 protected override void OnDraw(ref DrawParams p)
 {
     Vector2 posPixels = Screen.ToPixels(PositionAbsolute );
     Screen.spriteBatch.DrawString(spriteFont, text, posPixels, this.DrawColor, RotateAbsolute,
             Vector2.Zero, ScaleAbsolute, SpriteEffects.None, LayerDepth);
 }