Example #1
0
 public object Clone()
 {
     BitmapPlacer plc = new BitmapPlacer();
     plc.m_pt = new Point(m_pt.X, m_pt.Y);
     plc.m_xbm = m_xbm.Clone();
     return plc;
 }
Example #2
0
        public object Clone()
        {
            BitmapPlacer plc = new BitmapPlacer();

            plc.m_pt  = new Point(m_pt.X, m_pt.Y);
            plc.m_xbm = m_xbm.Clone();
            return(plc);
        }
Example #3
0
        // ISerializable interface implementation

        private BitmapPlacerList(SerializationInfo seri, StreamingContext stmc) : this()
        {
            for (int i = 0; i < seri.MemberCount; i++)
            {
                BitmapPlacer plc = (BitmapPlacer)seri.GetValue(i.ToString(), typeof(BitmapPlacer));
                InnerList.Add(plc);
            }
        }
Example #4
0
        private void UndoSetBitmapPosition(object[] aobArgs)
        {
            BitmapPlacer plc = (BitmapPlacer)aobArgs[0];

            plc.X = (int)aobArgs[1];
            plc.Y = (int)aobArgs[2];
            Globals.ActiveDocument.Dirty = true;
            Globals.OnFrameContentChanged(this, new EventArgs());
        }
Example #5
0
 public int Index(BitmapPlacer plc)
 {
     for (int i = 0; i < InnerList.Count; i++)
     {
         if (plc == (BitmapPlacer)InnerList[i])
         {
             return(i);
         }
     }
     return(-1);
 }
Example #6
0
        private void PreviewControl_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            XBitmap[] axbm = (XBitmap[])e.Data.GetData(typeof(XBitmap[]));
            if (axbm == null)
            {
                return;
            }

            BitmapPlacerList plcl = Globals.ActiveStrip[Globals.ActiveFrame].BitmapPlacers;

            foreach (XBitmap xbm in axbm)
            {
                BitmapPlacer plc = new BitmapPlacer();
                plc.X       = 0;
                plc.Y       = 0;
                plc.XBitmap = xbm;
                plcl.Insert(0, plc);
            }

            Globals.ActiveDocument.Dirty = true;
            Globals.OnFrameContentChanged(this, new EventArgs());
        }
Example #7
0
        private void PreviewControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (!m_fDragging)
            {
                return;
            }

            Strip stp = Globals.ActiveStrip;

            if (stp == null)
            {
                return;
            }

            if (m_fFrameRecentering)
            {
                m_ptOffset = m_ptInitialOffset;
                Point ptNew = FxyFromWxy(new Point(e.X, e.Y));
                m_ptOffset.X = m_ptInitialOffset.X + (ptNew.X - m_ptDragStart.X);
                m_ptOffset.Y = m_ptInitialOffset.Y + (ptNew.Y - m_ptDragStart.Y);
                Invalidate();
                Update();

                // Notify anyone who cares that we've changed the Frame offset

                if (FrameOffsetChanged != null)
                {
                    FrameOffsetChanged(this, new FrameOffsetEventArgs(m_ptOffset.X, m_ptOffset.Y));
                }
                return;
            }

            switch (m_mode)
            {
            case PreviewControlMode.SetSpecialPoint:
            {
                Point ptT = FxyFromWxy(new Point(e.X, e.Y));
                Frame fr  = stp[Globals.ActiveFrame];
                fr.SpecialPoint = ptT;
                Globals.ActiveDocument.Dirty = true;
                Globals.OnFrameContentChanged(this, new EventArgs());
            }
            break;

            case PreviewControlMode.RepositionBitmap:
            {
                Point ptT = FxyFromWxy(new Point(e.X, e.Y));
                int   ipl = stp[Globals.ActiveFrame].BitmapPlacers.
                            Index(m_plcSelected);
                int ifr;
                int cfr;
                if (m_fAllFrames)
                {
                    ifr = 0;
                    cfr = stp.Count;
                }
                else
                {
                    ifr = Globals.ActiveFrame;
                    cfr = Globals.ActiveFrameCount;
                }

                for (int ifrT = ifr; ifrT < ifr + cfr; ifrT++)
                {
                    int iplT = ipl;
                    if (iplT >= stp[ifrT].BitmapPlacers.Count)
                    {
                        iplT = 0;
                    }
                    BitmapPlacer plc = stp[ifrT].BitmapPlacers[iplT];
                    plc.X = m_aptPreDragBitmap[ifrT].X + m_ptDragStart.X -
                            ptT.X;
                    plc.Y = m_aptPreDragBitmap[ifrT].Y + m_ptDragStart.Y -
                            ptT.Y;
                }
                m_fRepositionBitmaps         = true;
                Globals.ActiveDocument.Dirty = true;
                Globals.OnFrameContentChanged(this, new EventArgs());
            }
            break;
            }
        }
Example #8
0
        private void PreviewControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Strip stp = Globals.ActiveStrip;

            if (stp == null)
            {
                return;
            }

            if (m_fSpaceDown)
            {
                m_fFrameRecentering = true;
                m_fDragging         = true;
                m_ptDragStart       = FxyFromWxy(new Point(e.X, e.Y));
                m_ptInitialOffset   = m_ptOffset;
                Cursor = Globals.GrabCursor;
                return;
            }

            switch (m_mode)
            {
            case PreviewControlMode.SetSpecialPoint:
            {
                m_fDragging        = true;
                m_fSetSpecialPoint = true;
                Point ptT = FxyFromWxy(new Point(e.X, e.Y));
                Frame fr  = stp[Globals.ActiveFrame];
                m_ptPreSetSpecialPoint       = fr.SpecialPoint;
                fr.SpecialPoint              = ptT;
                Globals.ActiveDocument.Dirty = true;
                Globals.OnFrameContentChanged(this, new EventArgs());
            }
            break;

            case PreviewControlMode.RepositionBitmap:
            {
                BitmapPlacer plc = HitTest(e.X, e.Y);
                if (plc == null)
                {
                    break;
                }
                m_plcSelected = plc;

                m_fDragging  = true;
                m_fAllFrames = (ModifierKeys & Keys.Shift) != 0;

                // UNDONE: across frame operations don't really make sense until we have Tracks

                m_aptPreDragBitmap = new Point[stp.Count];
                for (int ifr = 0; ifr < stp.Count; ifr++)
                {
                    Frame fr = stp[ifr];
                    if (fr.BitmapPlacers.Count > 0)
                    {
                        m_aptPreDragBitmap[ifr].X = fr.BitmapPlacers[0].X;
                        m_aptPreDragBitmap[ifr].Y = fr.BitmapPlacers[0].Y;
                    }
                }

                // Special handling for active frame

                m_aptPreDragBitmap[stp.ActiveFrame].X = m_plcSelected.X;
                m_aptPreDragBitmap[stp.ActiveFrame].Y = m_plcSelected.Y;

                m_ptDragStart = FxyFromWxy(new Point(e.X, e.Y));
            }
            break;
            }
        }
Example #9
0
 private Point BxyFromFxy(BitmapPlacer plc, Point ptFrame)
 {
     return(new Point(ptFrame.X + plc.X, ptFrame.Y + plc.Y));
 }
Example #10
0
 public int Add(BitmapPlacer plc)
 {
     return(((IList)this).Add(plc));
 }
Example #11
0
 public void Insert(int iplc, BitmapPlacer plc)
 {
     InnerList.Insert(iplc, plc);
 }
        private void PreviewControl_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            XBitmap[] axbm = (XBitmap[])e.Data.GetData(typeof(XBitmap[]));
            if (axbm == null)
                return;

            BitmapPlacerList plcl = Globals.ActiveStrip[Globals.ActiveFrame].BitmapPlacers;
            foreach (XBitmap xbm in axbm) {
                BitmapPlacer plc = new BitmapPlacer();
                plc.X = 0;
                plc.Y = 0;
                plc.XBitmap = xbm;
                plcl.Insert(0, plc);
            }

            Globals.ActiveDocument.Dirty = true;
            Globals.OnFrameContentChanged(this, new EventArgs());
        }
 private Point FxyFromBxy(BitmapPlacer plc, Point ptBitmap)
 {
     return new Point(ptBitmap.X - plc.X, ptBitmap.Y - plc.Y);
 }
 private Point BxyFromFxy(BitmapPlacer plc, Point ptFrame)
 {
     return new Point(ptFrame.X + plc.X, ptFrame.Y + plc.Y);
 }
Example #15
0
 public void Insert(int iplc, BitmapPlacer plc)
 {
     InnerList.Insert(iplc, plc);
 }
Example #16
0
 public int Add(BitmapPlacer plc)
 {
     return ((IList)this).Add(plc);
 }
Example #17
0
 public int Index(BitmapPlacer plc)
 {
     for (int i = 0; i < InnerList.Count; i++) {
         if (plc == (BitmapPlacer)InnerList[i]) {
             return i;
         }
     }
     return -1;
 }
        private void PreviewControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Strip stp = Globals.ActiveStrip;
            if (stp == null)
                return;

            if (m_fSpaceDown) {
                m_fFrameRecentering = true;
                m_fDragging = true;
                m_ptDragStart = FxyFromWxy(new Point(e.X, e.Y));
                m_ptInitialOffset = m_ptOffset;
                Cursor = Globals.GrabCursor;
                return;
            }

            switch (m_mode) {
            case PreviewControlMode.SetSpecialPoint:
                {
                    m_fDragging = true;
                    m_fSetSpecialPoint = true;
                    Point ptT = FxyFromWxy(new Point(e.X, e.Y));
                    Frame fr = stp[Globals.ActiveFrame];
                    m_ptPreSetSpecialPoint = fr.SpecialPoint;
                    fr.SpecialPoint = ptT;
                    Globals.ActiveDocument.Dirty = true;
                    Globals.OnFrameContentChanged(this, new EventArgs());
                }
                break;

            case PreviewControlMode.RepositionBitmap:
                {
                    BitmapPlacer plc = HitTest(e.X, e.Y);
                    if (plc == null)
                        break;
                    m_plcSelected = plc;

                    m_fDragging = true;
                    m_fAllFrames = (ModifierKeys & Keys.Shift) != 0;

                    // UNDONE: across frame operations don't really make sense until we have Tracks

                    m_aptPreDragBitmap = new Point[stp.Count];
                    for (int ifr = 0; ifr < stp.Count; ifr++) {
                        Frame fr = stp[ifr];
                        if (fr.BitmapPlacers.Count > 0) {
                            m_aptPreDragBitmap[ifr].X = fr.BitmapPlacers[0].X;
                            m_aptPreDragBitmap[ifr].Y = fr.BitmapPlacers[0].Y;
                        }
                    }

                    // Special handling for active frame

                    m_aptPreDragBitmap[stp.ActiveFrame].X = m_plcSelected.X;
                    m_aptPreDragBitmap[stp.ActiveFrame].Y = m_plcSelected.Y;

                    m_ptDragStart = FxyFromWxy(new Point(e.X, e.Y));
                }
                break;
            }
        }
Example #19
0
 private Point FxyFromBxy(BitmapPlacer plc, Point ptBitmap)
 {
     return(new Point(ptBitmap.X - plc.X, ptBitmap.Y - plc.Y));
 }
Example #20
0
        public void DrawUnscaled(Bitmap bmDst, int cx, int cy, DrawArgs drwa, Point ptOffset)
        {
            Graphics gDst = Graphics.FromImage(bmDst);

            int xCenter = cx / 2;
            int yCenter = cy / 2;

            // Draw background (if enabled)

            if (drwa.fDrawBackground)
            {
                gDst.Clear(drwa.clrBackground);
            }

#if false
            // Draw background bitmap, if any

            if (m_bmBackground != null)
            {
                gT.DrawImage(m_bmBackground, xCenter - (m_bmBackground.Width / 2) + m_ptBackgroundOffset.X,
                             yCenter - (m_bmBackground.Height / 2) + m_ptBackgroundOffset.Y,
                             m_bmBackground.Width, m_bmBackground.Height);
            }
#endif
            // Draw grid (if enabled)
            // UNDONE: use alpha to draw grid (e.g., brighten or darken)

            if (drwa.fShowGrid)
            {
                int cxGrid = drwa.cxGrid;
                int cyGrid = drwa.cyGrid;
//						Brush br = new SolidBrush(Color.FromKnownColor(KnownColor.LightGray));
                Brush br = new SolidBrush(Color.FromArgb(256 / 3, 255, 255, 255));
                for (int x = (xCenter + ptOffset.X) % cxGrid; x < cx; x += cxGrid)
                {
                    gDst.FillRectangle(br, x, 0, 1, cy);
                }

                for (int y = (yCenter + ptOffset.Y) % cyGrid; y < cy; y += cyGrid)
                {
                    gDst.FillRectangle(br, 0, y, cx, 1);
                }
            }

            BitmapData bmdDst = bmDst.LockBits(
                new Rectangle(0, 0, bmDst.Width, bmDst.Height),
                ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

            // Draw bitmaps from bottom up

            for (int i = BitmapPlacers.Count - 1; i >= 0; i--)
            {
                BitmapPlacer plc = BitmapPlacers[i];
                XBitmap      xbm = plc.XBitmap;
                xbm.SuperBlt(0, 0, bmdDst,
                             xCenter - plc.X + ptOffset.X,
                             yCenter - plc.Y + ptOffset.Y,
                             xbm.Bitmap.Width, xbm.Bitmap.Height,
                             drwa.fMapSideColors);
            }

            bmDst.UnlockBits(bmdDst);

            // Draw origin point (if enabled)

            if (drwa.fShowOrigin)
            {
                // This is really weird but if we don't do our own clipping then SetPixel will
                // raise an exception!

                int x = xCenter + ptOffset.X;
                int y = yCenter + ptOffset.Y;
                if (x >= 0 && y >= 0 && x < bmDst.Width && y < bmDst.Height)
                {
                    bmDst.SetPixel(x, y, Color.FromKnownColor(KnownColor.Orange));
                }
            }

            // Draw special point (if enabled)

            if (drwa.fShowSpecialPoint)
            {
                // This is really weird but if we don't do our own clipping then SetPixel will
                // raise an exception!

                int x = xCenter + ptOffset.X + m_ptSpecial.X;
                int y = yCenter + ptOffset.Y + m_ptSpecial.Y;
                if (x >= 0 && y >= 0 && x < bmDst.Width && y < bmDst.Height)
                {
                    bmDst.SetPixel(x, y, Color.FromArgb(0, 255, 0));
                }
            }

            gDst.Dispose();
        }