自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

關(guān)于Windows Mobile Widget開發(fā)Emulator

移動開發(fā)
關(guān)于Windows Mobile Widget開發(fā)Emulator是本文要介紹的內(nèi)容,主要是來了解并學(xué)習(xí)Windows Mobile Widget開發(fā)應(yīng)用,來看內(nèi)容。

關(guān)于Windows Mobile Widget開發(fā)Emulator是本文要介紹的內(nèi)容,主要是來了解并學(xué)習(xí)Windows Mobile Widget開發(fā)應(yīng)用,今天Vimpyboy在codeplex發(fā)布了Windows Mobile Widget Emulator,具體內(nèi)容的實現(xiàn)來看本文詳解。

這是一個用來調(diào)試Windows Mobile6.5 Widget的工具,我在做Windows Mobile 6.5新功能widget開發(fā)的時候就發(fā)現(xiàn)調(diào)試Widget很麻煩。也有想法做一個Emulator,其實這個Emulator目標(biāo)很明顯,第一個目標(biāo)就是實現(xiàn)MSWidget提供的javascript的menu對象。下面代碼來自于Windows Mobile Widget Emulator。實現(xiàn)menu對象。

  1.     var widget = {  
  2.     menu: {  
  3.         createMenuItem: function(id) {  
  4.             this.id = id;  
  5.             this.text = '';  
  6.             this.onSelect = function() { };  
  7.  
  8.             return this;  
  9.         },  
  10.         setSoftKey: function(menuItem, idx) {  
  11.             var menuItemmenuItemCopy = menuItem.Copy();  
  12.  
  13.             if (idx == 1) {  
  14.                 var el = window.parent.document.getElementById('leftMenu');  
  15.  
  16.                 var newItem = window.parent.document.createElement('li');  
  17.                 var newLink = window.parent.document.createElement('a');  
  18.  
  19.                 newLink.onclick = function() {  
  20.                     menuItemCopy.onSelect()  
  21.                 };  
  22.                 newLink.href = '#';  
  23.                 newLink.innerHTML = menuItemCopy.text;  
  24.  
  25.                 newItem.appendChild(newLink);  
  26.                 el.insertBefore(newItem, el.firstChild);  
  27.  
  28.                 return this;  
  29.             }  
  30.             else {  
  31.                 var el = window.parent.document.getElementById('rightMenu');  
  32.                 var arrlength = widget.menu.menuItems.length;  
  33.  
  34.                 var newItem = window.parent.document.createElement('li');  
  35.                 var newLink = window.parent.document.createElement('a');  
  36.  
  37.                 newLink.onclick = function() {  
  38.                     menuItemCopy.onSelect()  
  39.                 };  
  40.  
  41.                 newLink.setAttribute('id', 'widgetmenu-' + arrlength);  
  42.                 newLink.href = '#';  
  43.                 newLink.innerHTML = menuItemCopy.text;  
  44.  
  45.                 widget.menu.menuItems[arrlength] = menuItemCopy;  
  46.  
  47.                 newItem.appendChild(newLink);  
  48.                 el.insertBefore(newItem, el.firstChild);  
  49.  
  50.                 return this;  
  51.             }  
  52.         },  
  53.         append: function(menuItem) {  
  54.             widget.menu.setSoftKey(menuItem);  
  55.         },  
  56.         clear: function() {  
  57.             var el = window.parent.document.getElementById('rightMenu');  
  58.             el.innerHTML = '';  
  59.         },  
  60.         leftSoftKeyIndex: 1,  
  61.         menuItems: []  
  62.     },  
  63.     preferenceForKey: function(key) {  
  64.         if (document.cookie.length > 0) {  
  65.             idx = document.cookie.indexOf(key + '=');  
  66.             if (idx != -1) {  
  67.                 idxidx = idx + key.length + 1;  
  68.                 idxlast = document.cookie.indexOf(';', idx);  
  69.  
  70.                 if (idxlast == -1) idxlast = document.cookie.length;  
  71.  
  72.                 return unescape(document.cookie.substring(idx, idxlast));  
  73.             }  
  74.         }  
  75.         return '';  
  76.     },  
  77.     setPreferenceForKey: function(value, key) {  
  78.  
  79.         if (!key) return;  
  80.  
  81.         if (!value && key) {  
  82.             var d = new Date();  
  83.             var c = document.cookie.split(";");  
  84.               
  85.             for (var i = 0; i < c.length; i++) {  
  86.                 document.cookie = c[i] + "; expires =" + d.toGMTString();  
  87.             }  
  88.               
  89.             return;  
  90.         }  
  91.  
  92.         var saveValue = value;  
  93.  
  94.         if (value.text) saveValue = value.text;  
  95.  
  96.         if (value.value) saveValue = value.value;  
  97.  
  98.         if (saveValue.length == undefined || saveValue.length < 1) return;  
  99.         if (saveValue.length == undefined || saveValue < 1) return;  
  100.  
  101.         var exdate = new Date();  
  102.         exdate.setFullYear(2020, 12, 31);  
  103.  
  104.         document.cookie = key + '=' + escape(saveValue) + ';expires=' + exdate.toGMTString();  
  105.     },  
  106.     authorEmail: 'Placeholder: E-mail address of author.',  
  107.     authorName: 'Placeholder: Name of author.',  
  108.     authorURL: 'Placeholder: Web site URL for author.',  
  109.     currentIcon: {  
  110.         height: 100,  
  111.         src: 'icon.png',  
  112.         width: 100  
  113.     },  
  114.     description: 'Placeholder: Description of widget.',  
  115.     height: 'Placeholder: Height of widget.',  
  116.     identifier: 'Placeholder: A unique identifier for the widget.',  
  117.     locale: 'Placeholder: Locale of widget.',  
  118.     name: 'Placeholder: Name of widget.',  
  119.     version: 'Placeholder: Version of widget.',  
  120.     width: 'Placeholder: Width of widget.'  
  121. }; 

第二個目標(biāo)是可以動態(tài)調(diào)整resolution。Windows Mobile Widget Emulator也實現(xiàn)了,和我想法是一樣的。

widget1
widget2

我當(dāng)初的想法是直接使用MS的emulator的圖片,這些圖片保存在C:\ProgramFiles\Windows Mobile6SDK\PocketPC\DeviceemulationV650下,而且每個emulator都有XML定義文件,可以直接取出這些定義文件和圖片進(jìn)行resolution的選擇。

第三個要實現(xiàn)的目標(biāo)是,不需要修改開發(fā)中的widget的源代碼,直接可以調(diào)試。這個我想比較難實現(xiàn),我開始想用firefox的addon來實現(xiàn),可是firefox的javascript和ie有區(qū)別,在ff調(diào)試通過不一定在ie能用,可能做ie的addon可以解決這個問題。

Windows Mobile WidgetEmulator也沒有解決這個問題,需要修改iframe和增加一個javascript的引用。原文如下

  1. How to use  
  2.  
  3. Put your widget in a new folder in the widgets folder.   
  4. Modify the iframe in index.html to show your widget.   
  5. Add this code to the html file used by your widget:   
  6. <script src="http://www.cnblogs.com/assets/Widget.js" type="text/javascript"></script> 

Anyway,很高興Windows Mobile Widget Emulator的發(fā)布。以后開發(fā)widget我會使用他進(jìn)行調(diào)試。

小結(jié):關(guān)于Windows Mobile Widget開發(fā)Emulator的內(nèi)容介紹完了,希望通過Windows Mobile Widget開發(fā)內(nèi)容的學(xué)習(xí)能對你有所幫助。

責(zé)任編輯:zhaolei 來源: 博客園
相關(guān)推薦

2011-09-08 10:04:07

Windows MobWidget

2010-03-31 16:36:35

Windows CE

2011-09-08 10:18:09

Windows MobWidgets

2012-02-13 15:50:59

2009-03-05 18:08:01

Windows Mob升級

2010-05-23 10:29:29

Widget開發(fā)

2009-08-14 15:02:09

Visual Stud

2009-08-10 09:26:56

2009-06-23 10:06:03

2011-04-25 16:40:21

開發(fā)環(huán)境搭建Windows Mob

2011-09-07 13:42:36

Android Wid實例

2009-09-18 10:02:23

Windows Mob

2009-04-16 08:05:27

Windows Mob微軟移動OS

2009-05-18 09:06:37

微軟WMWindows Mob

2011-09-09 20:14:58

Android Wid

2011-05-03 15:13:23

BlackBerryWidget

2010-07-13 09:02:19

Widget開發(fā)

2009-05-17 10:48:19

微軟Windows Mob移動OS

2009-12-07 17:42:07

Windows Mob

2009-12-15 15:31:47

點贊
收藏

51CTO技術(shù)棧公眾號