<dfn id="is4kg"></dfn>
  • <ul id="is4kg"></ul>
  • <abbr id="is4kg"></abbr>
  • <ul id="is4kg"></ul>
    <bdo id="is4kg"></bdo>

    曙海教育集團論壇3G手機技術專區Windows Mobile手機開發 → Windows mobile 開發入門—開發絢麗滑動效果


      共有6213人關注過本帖樹形打印

    主題:Windows mobile 開發入門—開發絢麗滑動效果

    美女呀,離線,留言給我吧!
    wangxinxin
      1樓 個性首頁 | 博客 | 信息 | 搜索 | 郵箱 | 主頁 | UC


    加好友 發短信
    等級:青蜂俠 帖子:1393 積分:14038 威望:0 精華:0 注冊:2010-11-12 11:08:23
    Windows mobile 開發入門—開發絢麗滑動效果  發帖心情 Post By:2010-12-4 9:38:16

    前言
        在這里制作一個9宮格的小程序,如果超過9個,那么就自動翻頁。翻頁采用劃動實現,并且有慣性作用。

    原理
    mobile手機里滑動效果主要是原理是支持屏幕的觸摸,當我們按下、松開時系統分別可以捕捉到相應的坐標位置,然后動態的改變布局,從而達到劃動的效果。
    圖型button

    由于mobile還沒有支持圖片button,所以我們做出一個輔佐類,當按下、彈開時分別使用鋼筆繪制不同的圖片到屏幕。


    Code
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Drawing.Imaging;


    namespace iPhoneUI
    {
        public class ImageButton  
        {
            internal Rectangle clientArea;
            internal Form owner;
            internal Bitmap image;
            internal Bitmap imageDown;
            internal bool pushed = false;
            internal Point location;
            internal Point start;
            internal int h=30,w=30;
            internal bool Enable = false;
            private double pressTime = Environment.TickCount;
            internal bool pushedOneTime = false;

            public string Name {get;set;}

            public bool IsPressedOneTime
            {
                get { return pushedOneTime; }
                set { pushedOneTime = value; }
            }

            public event System.EventHandler Click;
            public event System.EventHandler DoubleClick;

            public ImageButton(Form owner,int w,int h)
            {
                this.w = w;
                this.h = h;
                
                this.owner = owner;
                Attach(owner);         
            }
            public ImageButton(Form owner,Point location)
            {
                this.owner = owner;
                Attach(owner);
                this.location = location;
                this.clientArea = new Rectangle(location.X, location.Y, h, w);
            }

            public Point Location
            {
                set
                {
                    this.location = value;
                    this.clientArea = new Rectangle(location.X, location.Y, w, h);
                
                }
                get { return location; }         
             
            }      

            public Bitmap Image
            {
                get { return image;}
                set  
                {  
                    image = value;
                    if (image != null)
                    {
                        clientArea = new Rectangle(location.X, location.Y, image.Width, image.Height);
                    }
                }
            }

            public Bitmap ImageDown
            {
                get { return imageDown;}
                set { imageDown = value; }
            }
          
            public bool HitTest(int x, int y)
            {
                return clientArea.Contains(x, y);
            }

            private void Attach(Form owner)
            {            
                owner.MouseDown += new MouseEventHandler(owner_MouseDown);         
                owner.MouseUp += new MouseEventHandler(owner_MouseUp);
                owner.DoubleClick += new EventHandler(owner_DoubleClick);
            }

            void owner_DoubleClick(object sender, EventArgs e)
            {
               
                
            }

            public virtual void owner_MouseUp(object sender, MouseEventArgs e)
            {
                if (!Enable)
                    return;

                if (pushed)
                {
                    using (Graphics gx = owner.CreateGraphics())
                    {
                        this.pushed = false;
                        this.Paint(gx);
                        owner.Invalidate();
                    }
                    pushed = false;

                    if ((Environment.TickCount - pressTime) < 100)
                    {
                        if (Click != null)
                            Click(this, e);
                    }
                }

    //            SendMessage(ButtonCode, "Button Pressed");
            }

            public virtual void owner_MouseDown(object sender, MouseEventArgs e)
            {
                if (!Enable)
                    return;

                if (this.HitTest(e.X, e.Y))
                {
                    using (Graphics gx = owner.CreateGraphics())
                    {
                        this.pushed = true;
                        IsPressedOneTime = true;
                        this.Paint(gx);

                        if ((Environment.TickCount - pressTime) < 300)
                        {
                            if (DoubleClick != null)
                                DoubleClick(this, e);
                        }

                        pressTime = Environment.TickCount;
                    }
                    start = new Point(e.X, e.Y);            
                }
            }
         
            public void Paint(Graphics gx)
            {
                if (!Enable)
                    return;
                //gx.Clear(Color.White);

                ImageAttributes attrib = new ImageAttributes();
                Color color = GetTransparentColor(image);
                attrib.SetColorKey(color, color);

                if (!pushed || imageDown == null)
                    gx.DrawImage(image, clientArea, 0, 0, clientArea.Width, clientArea.Height, GraphicsUnit.Pixel, attrib);
                     
                else
                {     
                    gx.DrawImage(imageDown, clientArea, 0, 0, clientArea.Width, clientArea.Height, GraphicsUnit.Pixel, attrib);      
                            
                }
                Brush b = new SolidBrush(Color.Black);
               
                int txtX=clientArea.Location.X;
                if(Name.Length<5)//右移5個PIX
                    txtX+=5;
                gx.DrawString(this.Name, owner.Font, b, txtX, clientArea.Bottom);

            }

            internal Color GetTransparentColor(Bitmap image)
            {
                return image.GetPixel(0, 0);
            }
         
        }
    }


    當mouse按下時,判斷是否在圖像所在的區域內,就執行按下時繪制圖像。并且判斷兩次按下時間小于300毫秒,就認為是雙擊,發出注冊雙擊事件。當mouse彈起時,恢復按前的圖像,并且如果按下時間間隔不超過100毫秒,認為是單擊。

    初使化按扭


    Code
      1<?xml version="1.0" standal?>
      2<DocumentElement>  
      3  <menu>
      4    <Name>測試1</Name>
      5   
      6    <path>Chat 46x46.bmp</path>
      7    <pressPath>Chat 46x46.bmp</pressPath>
      8  </menu>
      9    <menu>
    10    <Name>測試1a</Name>
    11   
    12    <path>Chat 46x46.bmp</path>
    13    <pressPath>Chat 46x46.bmp</pressPath>
    14  </menu>
    15  <menu>
    16    <Name>測試1b</Name>
    17   
    18    <path>lock 46x46.bmp</path>
    19    <pressPath>lock 46x46_pressed.bmp</pressPath>
    20  </menu>
    21   <menu>
    22    <Name>測試1c</Name>
    23   
    24    <path>Internet Explorer 46x46.bmp</path>
    25    <pressPath>Internet Explorer 46x46_pressed.bmp</pressPath>
    26  </menu>
    27  <menu>
    28    <Name>測試1d</Name>
    29   
    30    <path>Close 46x46.bmp</path>
    31    <pressPath>Close 46x46_pressed.bmp</pressPath>
    32  </menu>
    33   <menu>
    34    <Name>測試1e</Name>
    35  
    36    <path>Chat 46x46.bmp</path>
    37    <pressPath>Chat 46x46_pressed.bmp</pressPath>
    38  </menu>
    39  <menu>
    40    <Name>測試1f</Name>
    41   
    42    <path>Camera 46x46.bmp</path>
    43    <pressPath>Camera 46x46_pressed.bmp</pressPath>
    44  </menu>
    45  <menu>
    46    <Name>測試1g</Name>
    47   
    48    <path>Camera 46x46.bmp</path>
    49    <pressPath>Camera 46x46_pressed.bmp</pressPath>
    50  </menu>
    51    <menu>
    52    <Name>
    53        測試1h
    54    </Name>
    55  
    56    <path>Camera 46x46.bmp</path>
    57    <pressPath>Camera 46x46_pressed.bmp</pressPath>
    58  </menu>

    支持(0中立(0反對(0單帖管理 | 引用 | 回復 回到頂部

    返回版面帖子列表

    Windows mobile 開發入門—開發絢麗滑動效果








    簽名
    主站蜘蛛池模板: 国产免费av片在线观看| 手机在线免费视频| 免费涩涩在线视频网| 香蕉视频在线观看黄| 天天影视综合网色综合国产| 久久最近最新中文字幕大全| 欧美日韩国产码高清综合人成| 四虎影视成人永久免费观看视频| 16女性下面无遮挡免费| 多人交换伦交视频| 久久久久999| 日韩色视频在线观看| 亚洲色成人WWW永久网站| 精品国产区一区二区三区在线观看 | 天天干天天干天天天天天天爽| 久久精品人人做人人爽电影蜜月 | 国产欧美一区二区精品久久久 | 男人j插入女人p| 国产亚洲国产bv网站在线| 8x成年视频在线观看| 天天摸天天摸色综合舒服网| 久久久久人妻精品一区二区三区| 最近最新中文字幕2018中文字幕mv | 国产亚洲视频网站| **aaaaa毛片免费| 国产麻豆媒一区一区二区三区| 中文字幕一区视频一线| 日韩视频在线观看中字| 亚洲欧美日韩国产综合高清| 精品无码成人片一区二区| 国产在线精品一区二区在线看 | 无码人妻丰满熟妇啪啪网站| 亚洲ts人妖网站| 欧美天堂在线观看| 免费a级在线观看完整片| 精品久久久久国产免费| 国产丰满麻豆videossexhd | 日本免费网站视频www区| 亚洲乱码在线播放| 欧美国产在线看| 亚洲香蕉免费有线视频|