⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdflipeffect.cs.svn-base

📁 这是一个windows mobile程序能够实现窗体运货效果非常不错
💻 SVN-BASE
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using Aspecto.GapiDrawNet;
using System.Drawing;
using System.Collections;

namespace Aspecto.FlowFX
{
    [Obsolete("Use PocketFrog (Pf) Effects")]
    public class GdFlipEffect : GapiDrawEffect
    {
        public override void Swap(FlowForm lastForm, FlowForm nextForm, bool opening)
        {
            base.Swap(lastForm, nextForm, opening);

            GapiSurface surface = TakeScreenShot(-lastForm.Bounds.Y);

            GapiSurface scaleBuffer = new GapiSurface(surface.GapiDraw);
            scaleBuffer.CreateSurface(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

            int halfwidth = surface.Width / 2;
            int frame = 1; // chose 1 instead of 0 to save it drawing the current view again
            gapiDisplay.BackBuffer.SetClipper(0, 0, surface.Width, surface.Height);
            while (frame <  halfwidth )
            {
                gapiDisplay.BackBuffer.FillRect(0);
                if(opening)
                    FlipOut(frame, scaleBuffer, surface, gapiDisplay.BackBuffer);
                else
                    FlipIn(halfwidth - frame - 1, scaleBuffer, surface, gapiDisplay.BackBuffer);
                gapiDisplay.Flip();
                frame += Math.Max(1, (int)(Math.Abs(frame) * 0.4));
            }

            //clear the form so it looks like a blank one
            GDRect gr;
            if (opening)
                gr = new GDRect(0, nextForm.Bounds.Y, surface.Width, nextForm.Bounds.Y + nextForm.Height);
            else
                gr = new GDRect(0, lastForm.Bounds.Y, surface.Width, lastForm.Bounds.Y + lastForm.Height);

            surface.FillRect(gr, GapiUtility.RGB(nextForm.BackColor));

            halfwidth = surface.Width / 2;
            frame = 1;

            while (frame < halfwidth)
            {
                gapiDisplay.BackBuffer.FillRect(0);
                if(opening)
                    FlipIn(frame, scaleBuffer, surface, gapiDisplay.BackBuffer);
                else
                    FlipOut(halfwidth - frame - 1, scaleBuffer, surface, gapiDisplay.BackBuffer);
                gapiDisplay.Flip();
                frame += Math.Max(1, (int)(Math.Abs(halfwidth - frame) * 0.4));
            }

            surface.Dispose();
            scaleBuffer.Dispose();

            //needed on pocket pc everytime. Needed on smartphone to clear the gapidraw evaluation logo when that appears. but ptr 0
            DrawStartBar();
        }

        private void FlipIn(int frame, GapiSurface scaleBuffer, GapiSurface surface, GapiSurface buffer)
        {
            int halfwidth = surface.Width / 2;

            GDRect rect_dest;
            GDRect rect_src;
            GDBLTFX bob = new GDBLTFX();

            Point[] staticTopPath = lineSimple(halfwidth, 0, 0, 0); // moves left along top from middle
            Point[] staticTopLeftPath = lineSimple(halfwidth, 60, surface.Width, 0); // moves from top middle to top right

            //then we draw a new line connecting them per frame/ starting with line from top left, to top right

            if (frame < halfwidth)
            {
                Point[] currLine = lineSimple(staticTopLeftPath[frame].X, staticTopLeftPath[frame].Y, staticTopPath[frame].X, staticTopPath[frame].Y);

                rect_dest = new GDRect(0, 0, frame * 2, surface.Height); // shrinks by 2 
                rect_src = new GDRect(0, 0, surface.Width, surface.Height);

                scaleBuffer.Blt(ref rect_dest, surface, ref rect_src, 0, ref bob);

                for (int i = 0; i < currLine.Length - 1; i++)
                {
                    rect_dest = new GDRect(currLine[i].X, currLine[i].Y, currLine[i].X + 1, surface.Height - currLine[i].Y);
                    rect_src = new GDRect(currLine.Length - i - 1, 0, currLine.Length - i, surface.Height);
                    buffer.Blt(ref rect_dest, scaleBuffer, ref rect_src, 0, ref bob);
                }
            }

        }


        private void FlipOut(int frame,GapiSurface scaleBuffer,GapiSurface surface, GapiSurface buffer)
        {
            int halfwidth = surface.Width / 2;

            GDRect rect_dest;
            GDRect rect_src;
            GDBLTFX bob = new GDBLTFX();

            Point[] staticTopPath = lineSimple(surface.Width, 0, 0, 0); // moves left along top
            Point[] staticTopLeftPath = lineSimple(0, 0, halfwidth, 60); // moves from top left, to top middle

            //then we draw a new line connecting them per frame/ starting with line from top left, to top right

            if (frame < halfwidth)
            {
                Point[] currLine = lineSimple(staticTopLeftPath[frame].X, staticTopLeftPath[frame].Y, staticTopPath[frame].X, staticTopPath[frame].Y);

                rect_dest = new GDRect(0, 0, surface.Width - frame * 2, surface.Height); // shrinks by 2 
                rect_src = new GDRect(0, 0, surface.Width, surface.Height);

                scaleBuffer.Blt(ref rect_dest, surface, ref rect_src, 0, ref bob);

                for (int i = 0; i < currLine.Length - 1; i++)
                {
                    rect_dest = new GDRect(currLine[i].X, currLine[i].Y, currLine[i].X + 1, surface.Height - currLine[i].Y);
                    rect_src = new GDRect(i, 0, i + 1, surface.Height);
                    buffer.Blt(ref rect_dest, scaleBuffer, ref rect_src, 0, ref bob);
                }
            }
        }

        public Point[] lineSimple(int x0, int y0, int x1, int y1)
        {
            ArrayList points = new ArrayList();
            int dx = x1 - x0;
            int dy = y1 - y0;

            points.Add(new Point(x0, y0));
            if (dx != 0)
            {
                float m = (float)dy / (float)dx;
                float b = y0 - m * x0;
                dx = (x1 > x0) ? 1 : -1;
                while (x0 != x1)
                {
                    x0 += dx;
                    y0 = (int)Math.Round(m * x0 + b);
                    points.Add(new Point(x0, y0));
                }
            }
            return (Point[])points.ToArray(typeof(Point));
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -