Exemple #1
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Frame.DrawArgs drwa = new Frame.DrawArgs();
            drwa.clrBackground     = BackColor;
            drwa.fDrawBackground   = true;
            drwa.fMapSideColors    = Globals.SideColorMappingOn;
            drwa.fShowGrid         = Globals.GridOn;
            drwa.cxGrid            = Globals.GridWidth;
            drwa.cyGrid            = Globals.GridHeight;
            drwa.fShowOrigin       = Globals.ShowOriginPoint;
            drwa.fShowSpecialPoint = Globals.ShowSpecialPoint || (m_mode == PreviewControlMode.SetSpecialPoint);
            drwa.nScale            = Globals.PreviewScale;

            if (Globals.ActiveStrip != null && Globals.ActiveStrip.Count != 0)
            {
                Frame     fr;
                Rectangle rc = new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height);

#if false
                if (m_fOnionSkin && Globals.ActiveFrame > 0)
                {
                    drwa.fShowGrid         = false;
                    drwa.fShowOrigin       = false;
                    drwa.fShowSpecialPoint = false;
                    drwa.nAlpha            = 128;
                    fr = Globals.ActiveStrip[Globals.ActiveFrame - 1];
                    fr.Draw(e.Graphics, rc, drwa, m_ptOffset);
                }
#endif
                fr = Globals.ActiveStrip[Globals.ActiveFrame];
                fr.Draw(e.Graphics, rc, drwa, m_ptOffset);

#if false
                if (m_fOnionSkin && Globals.ActiveFrame < Globals.ActiveStrip.Count - 1)
                {
                    fr = Globals.ActiveStrip[Globals.ActiveFrame + 1];
                    fr.Draw(e.Graphics, rc, drwa, m_ptOffset);
                }
#endif

#if false
                // Draw selection rectangle

                if (m_plcSelected != null)
                {
                    Point ptUpperLeft  = WxyFromFxy(FxyFromBxy(m_plcSelected, new Point(0, 0)));
                    Point ptLowerRight = WxyFromFxy(FxyFromBxy(m_plcSelected,
                                                               new Point(m_plcSelected.XBitmap.Width, m_plcSelected.XBitmap.Height)));
                    e.Graphics.DrawRectangle(new Pen(Color.Black),
                                             ptUpperLeft.X, ptUpperLeft.Y, ptLowerRight.X - ptUpperLeft.X, ptLowerRight.Y - ptUpperLeft.Y);
                }
#endif
            }
            else
            {
                e.Graphics.FillRectangle(new SolidBrush(BackColor), e.ClipRectangle);
            }
        }
Exemple #2
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            if (m_fr == null)
            {
                pe.Graphics.FillRectangle(new SolidBrush(BackColor), pe.ClipRectangle);
            }
            else
            {
                Frame.DrawArgs drwa = new Frame.DrawArgs();
                drwa.clrBackground     = BackColor;
                drwa.fDrawBackground   = true;
                drwa.fMapSideColors    = Globals.SideColorMappingOn;
                drwa.fShowGrid         = false;
                drwa.fShowOrigin       = Globals.ShowOriginPoint;
                drwa.fShowSpecialPoint = Globals.ShowSpecialPoint;
                drwa.nScale            = m_nScale;

                m_fr.Draw(pe.Graphics, ClientRectangle, drwa, m_ptOffset);
            }

            switch (m_bdrs)
            {
            case BorderStyle.FixedSingle:
                Rectangle rc = ClientRectangle;
                rc.Width--;
                rc.Height--;
                pe.Graphics.DrawRectangle(new Pen(m_clrBorder), rc);
                break;

            case BorderStyle.Fixed3D:
                ControlPaint.DrawBorder3D(pe.Graphics, ClientRectangle, Border3DStyle.Raised);
                break;
            }

            // Calling the base class OnPaint
//			base.OnPaint(pe);
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (Globals.ActiveStrip == null || Globals.ActiveStrip.Count == 0) {
                e.Graphics.FillRectangle(new SolidBrush(BackColor), e.ClipRectangle);
                return;
            }

            Frame.DrawArgs drwa = new Frame.DrawArgs();
            drwa.clrBackground = BackColor;
            drwa.fDrawBackground = true;
            drwa.fMapSideColors = Globals.SideColorMappingOn;
            drwa.fShowGrid = Globals.GridOn;
            drwa.cxGrid = Globals.GridWidth;
            drwa.cyGrid = Globals.GridHeight;
            drwa.fShowOrigin = Globals.ShowOriginPoint;
            drwa.fShowSpecialPoint = Globals.ShowSpecialPoint;
            drwa.nScale = Globals.PreviewScale;

            Rectangle rcClient = new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height);

            Graphics g = e.Graphics;

            int xCenter = rcClient.Width / 2;
            int yCenter = rcClient.Height / 2;

            int cxT = ((rcClient.Width + drwa.nScale - 1) / drwa.nScale) + 2;
            int cyT = ((rcClient.Height + drwa.nScale - 1) / drwa.nScale) + 2;
            int xCenterT = cxT / 2;
            int yCenterT = cyT / 2;

            // Create a temporary bitmap for compositing the grid, frames, origin indicator, etc into

            using (Bitmap bmT = new Bitmap(cxT, cyT)) {
                Point ptSpecial = new Point(0, 0);

                for (int i = 0; i < m_astp.Length; i++) {

                    // Draw the frame and its indicators (grid, center point, special point, etc)

                    Strip stp = m_astp[i];
                    if (stp == null)
                        continue;

                    Frame fr = stp[m_aifr[i]];
                    Point ptOffset = new Point(m_ptOffset.X + ptSpecial.X, m_ptOffset.Y + ptSpecial.Y);
                    fr.DrawUnscaled(bmT, cxT, cyT, drwa, ptOffset);

                    drwa.fDrawBackground = false;
                    drwa.fShowGrid = false;

                    ptSpecial = fr.SpecialPoint;
                }

                // Force a nice simple fast old-school stretchblt

                InterpolationMode imOld = g.InterpolationMode;
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                // NOTE: _without_ this the first row and column are only scaled by half!

                PixelOffsetMode pomOld = g.PixelOffsetMode;
                g.PixelOffsetMode = PixelOffsetMode.Half;

                // StretchBlt the temporary composite to the passed-in Graphic

                g.DrawImage(bmT, rcClient.Left - ((xCenterT * drwa.nScale) - xCenter),
                        rcClient.Top - ((yCenterT * drwa.nScale) - yCenter),
                        cxT * drwa.nScale, cyT * drwa.nScale);

                // Restore the Graphics' state

                g.PixelOffsetMode = pomOld;
                g.InterpolationMode = imOld;
            }
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (Globals.ActiveStrip == null || Globals.ActiveStrip.Count == 0)
            {
                e.Graphics.FillRectangle(new SolidBrush(BackColor), e.ClipRectangle);
                return;
            }

            Frame.DrawArgs drwa = new Frame.DrawArgs();
            drwa.clrBackground     = BackColor;
            drwa.fDrawBackground   = true;
            drwa.fMapSideColors    = Globals.SideColorMappingOn;
            drwa.fShowGrid         = Globals.GridOn;
            drwa.cxGrid            = Globals.GridWidth;
            drwa.cyGrid            = Globals.GridHeight;
            drwa.fShowOrigin       = Globals.ShowOriginPoint;
            drwa.fShowSpecialPoint = Globals.ShowSpecialPoint;
            drwa.nScale            = Globals.PreviewScale;

            Rectangle rcClient = new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height);

            Graphics g = e.Graphics;

            int xCenter = rcClient.Width / 2;
            int yCenter = rcClient.Height / 2;

            int cxT      = ((rcClient.Width + drwa.nScale - 1) / drwa.nScale) + 2;
            int cyT      = ((rcClient.Height + drwa.nScale - 1) / drwa.nScale) + 2;
            int xCenterT = cxT / 2;
            int yCenterT = cyT / 2;

            // Create a temporary bitmap for compositing the grid, frames, origin indicator, etc into

            using (Bitmap bmT = new Bitmap(cxT, cyT)) {
                Point ptSpecial = new Point(0, 0);

                for (int i = 0; i < m_astp.Length; i++)
                {
                    // Draw the frame and its indicators (grid, center point, special point, etc)

                    Strip stp = m_astp[i];
                    if (stp == null)
                    {
                        continue;
                    }

                    Frame fr       = stp[m_aifr[i]];
                    Point ptOffset = new Point(m_ptOffset.X + ptSpecial.X, m_ptOffset.Y + ptSpecial.Y);
                    fr.DrawUnscaled(bmT, cxT, cyT, drwa, ptOffset);

                    drwa.fDrawBackground = false;
                    drwa.fShowGrid       = false;

                    ptSpecial = fr.SpecialPoint;
                }

                // Force a nice simple fast old-school stretchblt

                InterpolationMode imOld = g.InterpolationMode;
                g.InterpolationMode = InterpolationMode.NearestNeighbor;

                // NOTE: _without_ this the first row and column are only scaled by half!

                PixelOffsetMode pomOld = g.PixelOffsetMode;
                g.PixelOffsetMode = PixelOffsetMode.Half;

                // StretchBlt the temporary composite to the passed-in Graphic

                g.DrawImage(bmT, rcClient.Left - ((xCenterT * drwa.nScale) - xCenter),
                            rcClient.Top - ((yCenterT * drwa.nScale) - yCenter),
                            cxT * drwa.nScale, cyT * drwa.nScale);

                // Restore the Graphics' state

                g.PixelOffsetMode   = pomOld;
                g.InterpolationMode = imOld;
            }
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            Frame.DrawArgs drwa = new Frame.DrawArgs();
            drwa.clrBackground = BackColor;
            drwa.fDrawBackground = true;
            drwa.fMapSideColors = Globals.SideColorMappingOn;
            drwa.fShowGrid = Globals.GridOn;
            drwa.cxGrid = Globals.GridWidth;
            drwa.cyGrid = Globals.GridHeight;
            drwa.fShowOrigin = Globals.ShowOriginPoint;
            drwa.fShowSpecialPoint = Globals.ShowSpecialPoint || (m_mode == PreviewControlMode.SetSpecialPoint);
            drwa.nScale = Globals.PreviewScale;

            if (Globals.ActiveStrip != null && Globals.ActiveStrip.Count != 0) {
                Frame fr;
                Rectangle rc = new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height);

            #if false
                if (m_fOnionSkin && Globals.ActiveFrame > 0) {
                    drwa.fShowGrid = false;
                    drwa.fShowOrigin = false;
                    drwa.fShowSpecialPoint = false;
                    drwa.nAlpha = 128;
                    fr = Globals.ActiveStrip[Globals.ActiveFrame - 1];
                    fr.Draw(e.Graphics, rc, drwa, m_ptOffset);
                }
            #endif
                fr = Globals.ActiveStrip[Globals.ActiveFrame];
                fr.Draw(e.Graphics, rc, drwa, m_ptOffset);

            #if false
                if (m_fOnionSkin && Globals.ActiveFrame < Globals.ActiveStrip.Count - 1) {
                    fr = Globals.ActiveStrip[Globals.ActiveFrame + 1];
                    fr.Draw(e.Graphics, rc, drwa, m_ptOffset);
                }
            #endif

            #if false
                // Draw selection rectangle

                if (m_plcSelected != null) {
                    Point ptUpperLeft = WxyFromFxy(FxyFromBxy(m_plcSelected, new Point(0, 0)));
                    Point ptLowerRight = WxyFromFxy(FxyFromBxy(m_plcSelected,
                            new Point(m_plcSelected.XBitmap.Width, m_plcSelected.XBitmap.Height)));
                    e.Graphics.DrawRectangle(new Pen(Color.Black),
                            ptUpperLeft.X, ptUpperLeft.Y, ptLowerRight.X - ptUpperLeft.X, ptLowerRight.Y - ptUpperLeft.Y);
                }
            #endif
            } else {
                e.Graphics.FillRectangle(new SolidBrush(BackColor), e.ClipRectangle);
            }
        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (m_stp == null || m_stp.Count == 0)
                return;

            Frame.DrawArgs drwa = new Frame.DrawArgs();
            drwa.clrBackground = this.BackColor;
            drwa.fDrawBackground = true;
            drwa.fMapSideColors = Globals.SideColorMappingOn;
            drwa.fShowGrid = Globals.GridOn;
            drwa.cxGrid = Globals.GridWidth;
            drwa.cyGrid = Globals.GridHeight;
            drwa.fShowOrigin = Globals.ShowOriginPoint;
            drwa.fShowSpecialPoint = Globals.ShowSpecialPoint;
            drwa.nScale = Globals.StripScale;

            Pen penInactive = new Pen(Color.Black);
            Pen penActive = new Pen(Color.Red);
            Font fnt = new Font("Arial", 8);
            Brush brBlack = new SolidBrush(Color.Black);

            int cyFrame = sb.Top - 1;

            Bitmap bmT = new Bitmap(ClientRectangle.Width, cyFrame + 1);
            Graphics gT = Graphics.FromImage(bmT);
            gT.Clear(drwa.clrBackground);

            int ifr = sb.Value / m_cxFrame;
            int x = -(sb.Value % m_cxFrame);

            for (; x < ClientRectangle.Width && ifr < m_stp.Count; x += m_cxFrame, ifr++) {

                // Draw a frame around the Frame

                gT.DrawRectangle(penInactive, x, 0, m_cxFrame, cyFrame);

                // Set up a clip box so the scaled frame won't draw anywhere we don't want it to

                gT.SetClip(new Rectangle(x + 1, 1, m_cxFrame - 1, cyFrame - 1));

                // Draw the scaled Frame

                Frame fr = m_stp[ifr];
                Rectangle rc = new Rectangle(x, 0, m_cxFrame, cyFrame);
                fr.Draw(gT, rc, drwa, m_ptOffset);

                // Draw the frame's hold count

                if (fr.HoldCount != 0) {
                    string strT = fr.HoldCount.ToString();
                    SizeF sizf = e.Graphics.MeasureString(strT, fnt);
                    gT.DrawString(strT, fnt, brBlack, x + m_cxFrame - sizf.Width - 1, cyFrame - fnt.Height);
                }

                // Clear out our special clip region

                gT.ResetClip();
            }

            // Draw a special frame around the active Frame

            for (int ifrT = m_stp.ActiveFrame; ifrT < m_stp.ActiveFrame +
                    m_stp.ActiveFrameCount; ifrT++) {
                Rectangle rcT = new Rectangle((ifrT * m_cxFrame) - sb.Value, 0, m_cxFrame, cyFrame);
                gT.DrawRectangle(penActive, rcT);
                rcT.Inflate(-1, -1);
                gT.DrawRectangle(penActive, rcT);
            }

            // Draw the insertion point, if any

            if (m_ifrInsertionPoint != -1) {
                Brush br = new SolidBrush(Color.Red);
                int xT = (m_ifrInsertionPoint * m_cxFrame) - sb.Value;
                gT.FillRectangle(br, xT, 0, 1, cyFrame);
                gT.FillRectangle(br, xT - 2, 0, 5, 1);
                gT.FillRectangle(br, xT - 1, 1, 3, 1);
                gT.FillRectangle(br, xT - 1, cyFrame - 2, 3, 1);
                gT.FillRectangle(br, xT - 2, cyFrame - 1, 5, 1);
            }

            // Copy the buffered Strip to the screen

            e.Graphics.DrawImageUnscaled(bmT, 0, 0);

            gT.Dispose();
            bmT.Dispose();
        }
Exemple #7
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (m_stp == null || m_stp.Count == 0)
            {
                return;
            }

            Frame.DrawArgs drwa = new Frame.DrawArgs();
            drwa.clrBackground     = this.BackColor;
            drwa.fDrawBackground   = true;
            drwa.fMapSideColors    = Globals.SideColorMappingOn;
            drwa.fShowGrid         = Globals.GridOn;
            drwa.cxGrid            = Globals.GridWidth;
            drwa.cyGrid            = Globals.GridHeight;
            drwa.fShowOrigin       = Globals.ShowOriginPoint;
            drwa.fShowSpecialPoint = Globals.ShowSpecialPoint;
            drwa.nScale            = Globals.StripScale;

            Pen   penInactive = new Pen(Color.Black);
            Pen   penActive   = new Pen(Color.Red);
            Font  fnt         = new Font("Arial", 8);
            Brush brBlack     = new SolidBrush(Color.Black);

            int cyFrame = sb.Top - 1;

            Bitmap   bmT = new Bitmap(ClientRectangle.Width, cyFrame + 1);
            Graphics gT  = Graphics.FromImage(bmT);

            gT.Clear(drwa.clrBackground);

            int ifr = sb.Value / m_cxFrame;
            int x   = -(sb.Value % m_cxFrame);

            for (; x < ClientRectangle.Width && ifr < m_stp.Count; x += m_cxFrame, ifr++)
            {
                // Draw a frame around the Frame

                gT.DrawRectangle(penInactive, x, 0, m_cxFrame, cyFrame);

                // Set up a clip box so the scaled frame won't draw anywhere we don't want it to

                gT.SetClip(new Rectangle(x + 1, 1, m_cxFrame - 1, cyFrame - 1));

                // Draw the scaled Frame

                Frame     fr = m_stp[ifr];
                Rectangle rc = new Rectangle(x, 0, m_cxFrame, cyFrame);
                fr.Draw(gT, rc, drwa, m_ptOffset);

                // Draw the frame's hold count

                if (fr.HoldCount != 0)
                {
                    string strT = fr.HoldCount.ToString();
                    SizeF  sizf = e.Graphics.MeasureString(strT, fnt);
                    gT.DrawString(strT, fnt, brBlack, x + m_cxFrame - sizf.Width - 1, cyFrame - fnt.Height);
                }

                // Clear out our special clip region

                gT.ResetClip();
            }

            // Draw a special frame around the active Frame

            for (int ifrT = m_stp.ActiveFrame; ifrT < m_stp.ActiveFrame +
                 m_stp.ActiveFrameCount; ifrT++)
            {
                Rectangle rcT = new Rectangle((ifrT * m_cxFrame) - sb.Value, 0, m_cxFrame, cyFrame);
                gT.DrawRectangle(penActive, rcT);
                rcT.Inflate(-1, -1);
                gT.DrawRectangle(penActive, rcT);
            }

            // Draw the insertion point, if any

            if (m_ifrInsertionPoint != -1)
            {
                Brush br = new SolidBrush(Color.Red);
                int   xT = (m_ifrInsertionPoint * m_cxFrame) - sb.Value;
                gT.FillRectangle(br, xT, 0, 1, cyFrame);
                gT.FillRectangle(br, xT - 2, 0, 5, 1);
                gT.FillRectangle(br, xT - 1, 1, 3, 1);
                gT.FillRectangle(br, xT - 1, cyFrame - 2, 3, 1);
                gT.FillRectangle(br, xT - 2, cyFrame - 1, 5, 1);
            }

            // Copy the buffered Strip to the screen

            e.Graphics.DrawImageUnscaled(bmT, 0, 0);

            gT.Dispose();
            bmT.Dispose();
        }
        protected override void OnPaint(PaintEventArgs pe)
        {
            if (m_fr == null) {
                pe.Graphics.FillRectangle(new SolidBrush(BackColor), pe.ClipRectangle);
            } else {
                Frame.DrawArgs drwa = new Frame.DrawArgs();
                drwa.clrBackground = BackColor;
                drwa.fDrawBackground = true;
                drwa.fMapSideColors = Globals.SideColorMappingOn;
                drwa.fShowGrid = false;
                drwa.fShowOrigin = Globals.ShowOriginPoint;
                drwa.fShowSpecialPoint = Globals.ShowSpecialPoint;
                drwa.nScale = m_nScale;

                m_fr.Draw(pe.Graphics, ClientRectangle, drwa, m_ptOffset);
            }

            switch (m_bdrs) {
            case BorderStyle.FixedSingle:
                Rectangle rc = ClientRectangle;
                rc.Width--;
                rc.Height--;
                pe.Graphics.DrawRectangle(new Pen(m_clrBorder), rc);
                break;

            case BorderStyle.Fixed3D:
                ControlPaint.DrawBorder3D(pe.Graphics, ClientRectangle, Border3DStyle.Raised);
                break;
            }

            // Calling the base class OnPaint
            //			base.OnPaint(pe);
        }