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

📄 pfflipeffect.cs.svn-base

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

namespace Aspecto.FlowFX
{
    public class PfFlipEffect : PocketFrogEffect
    {
        public override void Swap(FlowForm lastForm, FlowForm nextForm, bool opening)
        {
            base.Swap(lastForm, nextForm, opening);

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

            Surface scaleBuffer = new Surface(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

            display.GetBackBuffer();
            display.SetClipping(new Rect(0, 0, display.GetWidth(), display.GetHeight()));

            while (frame < halfwidth)
            {
                display.GetBackBuffer();
                display.Clear(0);
                if (opening)
                    FlipOut(frame, scaleBuffer, surface, display);
                else
                    FlipIn(halfwidth - frame - 1, scaleBuffer, surface,display );
                display.Update();
                frame += Math.Max(1, (int)(Math.Abs(frame) * 0.6));
            }

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

            Rasterizer surfaceR = new Rasterizer(surface);

            surfaceR.FillRect(gr, PFUtility.RGB(nextForm.BackColor));

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

            while (frame < halfwidth)
            {
                display.GetBackBuffer();
                display.Clear(0);
                if (opening)
                    FlipIn(frame, scaleBuffer, surface, display);
                else
                    FlipOut(halfwidth - frame - 1, scaleBuffer, surface, display);
                display.Update();
                frame += Math.Max(1, (int)(Math.Abs(halfwidth - frame) * 0.6));
            }

            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, Surface scaleBuffer, Surface surface, Display buffer)
        {
            int halfwidth = surface.Width / 2;

            Rect rect_dest;
            Rect rect_src;


            System.Drawing.Point[] staticTopPath = lineSimple(halfwidth, 0, 0, 0); // moves left along top from middle
            System.Drawing.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
            Rasterizer scaleBufferR = new Rasterizer(scaleBuffer);
            if (frame < halfwidth)
            {
                System.Drawing.Point[] currLine = lineSimple(staticTopLeftPath[frame].X, staticTopLeftPath[frame].Y, staticTopPath[frame].X, staticTopPath[frame].Y);

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

                scaleBufferR.BlitStretch( rect_dest, surface, rect_src);

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

        }


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

            Rect rect_dest;
            Rect rect_src;

            System.Drawing.Point[] staticTopPath = lineSimple(surface.Width, 0, 0, 0); // moves left along top
            System.Drawing.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
            Rasterizer scaleBufferR = new Rasterizer(scaleBuffer);
           
            if (frame < halfwidth)
            {
                System.Drawing.Point[] currLine = lineSimple(staticTopLeftPath[frame].X, staticTopLeftPath[frame].Y, staticTopPath[frame].X, staticTopPath[frame].Y);

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

                scaleBufferR.BlitStretch(rect_dest, surface,  rect_src);

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

        public System.Drawing.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 System.Drawing.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 System.Drawing.Point(x0, y0));
                }
            }
            return (System.Drawing.Point[])points.ToArray(typeof(System.Drawing.Point));
        }
    }
}

⌨️ 快捷键说明

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