卡西卡的小寶庫
寶庫寶庫寶庫

Google Map API (1)

Posted In: . By 卡西卡

Google 地圖

  1. 申請 Google Maps API Key
    網址:Sign Up for the Google Maps API
  2. 網頁編碼要用 UTF-8
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  3. 基本程式 [GMap2]
  4. 增加功能:
    • 滑鼠滾輪拉近拉遠
      map.enableScrollWheelZoom();
    • 地圖大小、移動控制項
      map.addControl(new GLargeMapControl());
      map.addControl(new GSmallMapControl());
    • 地圖型態控制項(地圖、衛星、混合地圖、地形)
      map.addControl(new GMapTypeControl());
      map.addMapType(G_PHYSICAL_MAP); //增加地形圖 (參考:GMapType.Constants)
      map.setMapType(G_NORMAL_MAP); //設定預設地圖型態
    • 地圖型態控制項(下拉式)
      map.addControl(new GMenuMapTypeControl());
    • 鳥瞰圖
      map.addControl(new GOverviewMapControl());
    • 比例尺
      map.addControl(new GScaleControl());
  5. 在地圖上插上標籤 [GLatLng, GMarker, ]
    // 中正紀念堂
    var pos = new GLatLng(25.036772,121.520269);
    var mark = new GMarker(pos);
    map.addOverlay(mark);
  6. 插上自訂標籤 [GIcon, GMarkerOptions, GSize, GPoint, ]
    // 自訂標籤
    var icon=new GIcon();
    icon.image = "mark.gif";
    icon.iconSize = new GSize(16,16);
    icon.iconAnchor = new GPoint(8,8);
    icon.shadow = "mark.gif";
    icon.shadowSize = new GSize(1,1);
    icon.infoWindowAnchor = new GPoint(8, 8);
    icon.infoShadowAnchor = new GPoint(8, 8);
    // 中正紀念堂
    var pos = new GLatLng(25.036772,121.520269);
    var mark = new GMarker(pos, {icon:icon});
    map.addOverlay(mark);
  7. 點擊標籤顯示訊息
    // 處理mark的click事件
    GEvent.addListener(mark, "click", function() {mark.openInfoWindowHtml('中正紀念堂<br>可用HTML'); });
  8. 程式移動地圖
    // 5秒後移至台北火車站
    window.setTimeout(function() {
      map.panTo(new GLatLng(25.048708,121.516128));
    }, 5000);
     

參考資料:

 

[未完成]SQL CE筆記

Posted In: , . By 卡西卡

  • SqlCE3 的 SqlCeParameter 有BUG,NVarChar長度超過255都會被截掉。
    if (size <= 255)
      return new SqlCeParameter(name, SqlDbType.NVarChar, size);
    else
      return new SqlCeParameter(name, SqlDbType.NVarChar);

    據說
    • binary 和 varbinary 只能到 510
    • SqlCE 3.5以後才有解決。
    參考
     
  • CREATE TABLE 的語法中只能有一個欄位指定為 PRIMARY KEY
    若要指定多個欄位是PK必須使用ALTER ...
    "ALTER TABLE [" + TABLE_NAME + "] ADD CONSTRAINT [PK_" + TABLE_NAME + @"] PRIMARY KEY (
    SITE_PIDENT,PARAM_CODE,HOURLY_DATE )"
  • 讓ASP.NET可以用SqlCE必須加上
    AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true)
  • 不支援 TRUNCATE TABLE

其它參考:

 

SQL Server Compact Edition, SQL Server Mobile

 

Gestures:滑鼠(觸控筆)手勢,用動作來執行命令。

原文網址|摘要:

筆記:

  1. 要先安裝 OpenNETCF Smart Device Framework ( 2.2 Community Edition )
  2. 如果要套用到自己的程式碼
    1. 引用using vbAccelerator.Components.Win32;
      using OpenNETCF.Windows.Forms;
    2. 修改 Main() Application2.Run(new Form1()); // OpenNETCF.Windows.Forms.Application2
    3. form的建構式,InitializeComponent()之後加上 MouseGestureFilter mgf = new MouseGestureFilter();
      Application2.AddMessageFilter(mgf);
      mgf.MouseGesture+=new MouseGestureEventHandler(mgf_MouseGesture);
    4. 加上 mgf_MouseGesture private void mgf_MouseGesture(object sender, MouseGestureEventArgs args) {...}
  3. 可以在DataGrid上使用,但第一個MOUSE_DOWN的事件也會被datagrid收到,CurrentCell會改變。

    Screen02

  4. 雖然可以辨識手勢,但還做不到像TouchFLO的效果。
  5. 若將 args.AcceptGesture = true; 則所有事件都會被吞掉,不會向下傳到其它元件。
  6. 修改過的source[Box.net]

 

另一個Gestures相關的文章:CodeProject: Optimizing Screen Area using Mouse Gestures.

 

Detecting Internet Explorer More Effectively
http://msdn2.microsoft.com/en-us/library/ms537509.aspx
Understanding User-Agent Strings
http://msdn2.microsoft.com/en-us/library/ms537503(VS.85).aspx
About Conditional Comments
http://msdn2.microsoft.com/en-us/library/ms537512(VS.85).aspx

 

怎麼使"<div>"顯示到dropdownlist或listbox 的前面?
在div裡加iframe:
<div>
<iframe src="javascript:false" style="Z-INDEX:-1; FILTER:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0); LEFT:0px; VISIBILITY:inherit; WIDTH:158px; POSITION:absolute; TOP:0px; HEIGHT:110px">
</iframe>
</div>

 

問題:DateTime.Today.ToString("yyyy/MM/dd") 的結果一定是"2006/03/05"嗎?

OS: Windows Mobile 6 Professional (ASUS P750)

在「開始\設定\系統\區域設定」中,「中文(台灣的)」的「日期」日曆類型有三種,其中有一個「臺灣曆(中文)」會讓ToString吐出民國年,"97/03/05"!

不正確的日期字串導致不預期的錯誤啊……

Screen23
臺灣曆(中文)
Screen21
97/03/05
Screen19
西曆(英文)
Screen18
2008/03/05

DateTime.Parse 也有相同的情況。

 

ASP.NET 1.1及2.0的RegularExpressionValidator都無法指定是否區分大小寫(RegexOptions.IgnoreCase)。

要檢查上傳的副檔名,其正規表示式如下
^[a-zA-Z]:(\\.+)(\.pps|\.sql|\.dat)$  

為處理大小寫須改成
^[a-zA-Z]:(\\.+)(\.[pP][pP][sS]|\.[sS][qQ][lL]|\.[dD][aA][tT])$

可用程式
filter = "\.ppt|\.sql|\.dat";
for ( int i='a'; i<='z' ; i++ )
{
  string ls = new string((char)i,1);
  string us = new string((char)(i-32),1);
  filter = filter.Replace(ls,"["+ls+us+"]");
} // for
RegularExpressionValidator1.ValidationExpression = @"^[a-zA-Z]:(\\.+)("+filter+")$";

 

目標:由playlist.mp3控制播放內容(可空或多首),播完10秒後重新載入本頁。

說明:

  1. playlist.mp3可以是真的mp3音樂檔,或是內容為多首mp3網址(一行一首)的文字檔。
  2. playlist.mp3的內容由server端控制,可依警報或時間或隨機產生內容。
[body]
<OBJECT id=player type=application/x-oleobject height=1 width=1
classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' >
<PARAM NAME="URL" VALUE="playlist.mp3">
<PARAM NAME="rate" VALUE="1">
<PARAM NAME="playCount" VALUE="1">
<PARAM NAME="autoStart" VALUE="true">
<PARAM NAME="baseURL" VALUE="">
<PARAM NAME="volume" VALUE="100">
<PARAM NAME="mute" VALUE="0">
<PARAM NAME="uiMode" VALUE="none">
</OBJECT>
[/body]

接收PlayStateChange[msdn]事件

[script]
window.onload = function() {
  var player = document.getElementById('player');
  player.attachEvent("playstatechange",MediaPlayer_playStateChange);
}
function MediaPlayer_playStateChange(newState) {
  if ( newState == 10/*Ready*/ ) {
    // 10秒後重新載入
    window.setTimeout("document.location.reload();", 1000*10);
  } // if
}
[/script]

參考資料:

  • Windows Media Player Reference - W3Schools
  • Using the Windows Media Player Control with Firefox - MSDN
  • Player.playState - MSDN
    Value State Description
    0 Undefined Windows Media Player is in an undefined state.
    1 Stopped Playback of the current media item is stopped.
    2 Paused Playback of the current media item is paused. When a media item is paused, resuming playback begins from the same location.
    3 Playing The current media item is playing.
    4 ScanForward The current media item is fast forwarding.
    5 ScanReverse The current media item is fast rewinding.
    6 Buffering The current media item is getting additional data from the server.
    7 Waiting Connection is established, but the server is not sending data. Waiting for session to begin.
    8 MediaEnded Media item has completed playback.
    9 Transitioning Preparing new media item.
    10 Ready Ready to begin playing.
    11 Reconnecting Reconnecting to stream.
  • ASX Elements Reference - MSDN
    Advanced Stream Redirector (ASX) files are based on the Extensible Markup Language (XML) syntax, and are made up of various elements with their associated tags and attributes.