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

📄 gdfalleffect.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 GdFallEffect : GapiDrawEffect
    {
        public override void Swap(FlowForm lastForm, FlowForm nextForm, bool opening)
        {
            base.Swap(lastForm, nextForm, opening);

            int multiplier = opening ? -1 : 1;
            GapiSurface surface = TakeScreenShot(-lastForm.Bounds.Y);

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

            GapiSurface surface2 = new GapiSurface(surface.GapiDraw);
            surface2.CreateSurface(surface);
            //clear the form so it looks like a blank one
            GDRect gr = new GDRect(0, lastForm.Bounds.Y, surface2.Width, lastForm.Bounds.Y + lastForm.Height);
            surface2.FillRect(gr, GapiUtility.RGB(nextForm.BackColor));

            int frame = 0;
            gapiDisplay.BackBuffer.SetClipper(0, 0, surface.Width, surface.Height);
            scaleBuffer.SetClipper(0, 0, surface.Width, surface.Height);
            while (frame < surface.Height)// halfwidth )
            {
                if (opening)
                {
                    gapiDisplay.BackBuffer.Blt(surface2, 0, 0);
                    FallDown(frame, scaleBuffer, surface, gapiDisplay.BackBuffer);
                    frame += Math.Max(1, (int)(Math.Abs(frame) * 0.4));
                }
                else
                {
                    gapiDisplay.BackBuffer.Blt(surface, 0, 0);
                    FallDown(surface.Height - frame, scaleBuffer, surface2, gapiDisplay.BackBuffer);
                    frame += Math.Max(1, (int)(Math.Abs(surface.Height - frame) * 0.4));
                }
                gapiDisplay.Flip();
            }

            surface.Dispose();
            scaleBuffer.Dispose();
            surface2.Dispose();
            DrawStartBar();
        }

        private void FallDown(int frame, GapiSurface scaleBuffer, GapiSurface surface, GapiSurface buffer)
        {
            GDRect rect_dest;
            GDRect rect_src;
            GDBLTFX bob = new GDBLTFX();

            Point[] staticTopPath = lineSimple2(0, 0, surface.Width * 2, surface.Height);

            Point[] currLine = lineSimple2(staticTopPath[frame].X, staticTopPath[frame].Y, 0, surface.Height); // draws from left diagonal line going off page left to bottom left corner of screen

            rect_dest = new GDRect(0, 0, surface.Width, surface.Height + frame); // 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, surface.Width + currLine[i].X, currLine[i].Y + 1);
                rect_src = new GDRect(0, i, surface.Width, i + 1);
                buffer.Blt(ref rect_dest, scaleBuffer, ref rect_src, 0, ref bob);
            }
        }

        /// <summary>
        /// this just flips the coords since there is a bug in lineSimple when dx = 0
        /// </summary>
        /// <param name="x0"></param>
        /// <param name="y0"></param>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <returns></returns>
        public Point[] lineSimple2(int x0, int y0, int x1, int y1)
        {
            Point[] p = lineSimple(y0, x0, y1, x1);
            for (int i = 0; i < p.Length; i++)
            {
                int x = p[i].X;
                p[i].X = p[i].Y;
                p[i].Y = x;
            }
            return p;
        }

       
        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 + -