本站也開始支援SyntaxHighlighter

SyntaxHighlighter是一個在網站上相當好用的東西。我終於也在www.evanlin.comblog把他安裝好了
</br>不過呢~ 由於Window Live Writer 還沒有找到真的讓我覺得很好用的部分
</br>這個Plugin 不好用(更正: 因為不支援最新版本的Syntaxhighlighter 3.0.8.3)
</br>以下是我加入到MT 模板的code(不過這是用VSpaste)先貼的

  <span style="color:green;"><!-- Include required JS files -->
    </span><span style="color:blue;"><</span><span style="color:#a31515;">script </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript" </span><span style="color:red;">src</span><span style="color:blue;">="js/shCore.js"></</span><span style="color:#a31515;">script</span><span style="color:blue;">>
    <</span><span style="color:#a31515;">script </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript" </span><span style="color:red;">src</span><span style="color:blue;">="js/shBrushJScript.js"></</span><span style="color:#a31515;">script</span><span style="color:blue;">>
    <</span><span style="color:#a31515;">script </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript" </span><span style="color:red;">src</span><span style="color:blue;">="js/shBrushCSharp.js"></</span><span style="color:#a31515;">script</span><span style="color:blue;">>
    <</span><span style="color:#a31515;">script </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript" </span><span style="color:red;">src</span><span style="color:blue;">="js/shBrushCss.js"></</span><span style="color:#a31515;">script</span><span style="color:blue;">>
    <</span><span style="color:#a31515;">script </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript" </span><span style="color:red;">src</span><span style="color:blue;">="js/shBrushJava.js"></</span><span style="color:#a31515;">script</span><span style="color:blue;">>
    <</span><span style="color:#a31515;">script </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript" </span><span style="color:red;">src</span><span style="color:blue;">="js/shBrushXml.js"></</span><span style="color:#a31515;">script</span><span style="color:blue;">>

    <</span><span style="color:#a31515;">link </span><span style="color:red;">href</span><span style="color:blue;">="css/shCore.css" </span><span style="color:red;">rel</span><span style="color:blue;">="stylesheet" </span><span style="color:red;">type</span><span style="color:blue;">="text/css" />
    <</span><span style="color:#a31515;">link </span><span style="color:red;">href</span><span style="color:blue;">="css/shThemeDefault.css" </span><span style="color:red;">rel</span><span style="color:blue;">="stylesheet" </span><span style="color:red;">type</span><span style="color:blue;">="text/css" />
    </span><span style="color:green;"><!-- Include required JS files -->

    </span><span style="color:blue;"><</span><span style="color:#a31515;">script </span><span style="color:red;">type</span><span style="color:blue;">="text/javascript">
        </span><span style="color:#a31515;">SyntaxHighlighter.all()
    </span><span style="color:blue;"></</span><span style="color:#a31515;">script</span><span style="color:blue;">>
</span>

話說~ VSpaste 這個plugin 也很好用~ 跨Blog又不用安裝~

不過可能支援語系會少一點

以下是使用這個Windows Live Writer Plugin(Windows Live Writer Source Code plugin for SyntaxHighlighter) , 而且也支援最新版本的syntaxhighlighter 3.0.8.3

  <!-- Include required JS files -->
    <script type="text/javascript" src="js/shCore.js"></script>
    <script type="text/javascript" src="js/shBrushJScript.js"></script>
    <script type="text/javascript" src="js/shBrushCSharp.js"></script>
    <script type="text/javascript" src="js/shBrushCss.js"></script>
    <script type="text/javascript" src="js/shBrushJava.js"></script>
    <script type="text/javascript" src="js/shBrushXml.js"></script>

    <link href="css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <!-- Include required JS files -->

    <script type="text/javascript">
        SyntaxHighlighter.all()
    </script>

How to using google reader API on Windows Phone 7.1

Google data is good API tool for C# or other language to connect with Google related service, however here is no official Google Reader API on document. and Google data don’t support for Windows phone (only for Windows mobile for now).

However it could be found on web for some of unofficial document for Google Reader API as follows:

But however to come out detail implement for Windows Phone, it quit need time to work detail. Allow me try to list some major problems of this.

  • Most important of using HttpWebRequest is the error repose
> > The remote server returned an error: NotFound > >

It is most common error code your will find during you try to login or get any feedback on Window Phone. It could be either you missing your GET parameter or you missing your headers.

Here is some sample code related Login Google Reader and get list from this login. Some more detail communication code about HttpWebRequest, please check http://msdn.microsoft.com/zh-tw/library/system.net.webrequest.begingetrequeststream(v=vs.80).aspx

Something need to note before enter detail code.(check red part)

  • Need to authentication to get Auth_ID and SID for all API access.

  • Don’t miss your “Headers” when you trying to get API.

  • Http method need follow as document.

    public void LoginGoogleReader() { string email = “YOUR_EMAIL”; string passwd = “YOUR_PASSWORD”; string auth_params = string.Format(“https://www.google.com/accounts/ClientLogin?accountType=HOSTED_OR_GOOGLE&Email=” + email + “&Passwd=” + passwd + “&service=reader&source=J-MyReader-1.0”); HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(auth_params);

    httpRequest.Method = "POST";
            RequestState myRequestState = new RequestState();
            myRequestState.request = httpRequest;
            IAsyncResult result =
                (IAsyncResult)httpRequest.BeginGetResponse(new AsyncCallback(AuthRespCallback), myRequestState);
        }
    
        public void GetGoogleReaderPreferenceList()
        {
            string auth_params = string.Format("https://www.google.com/reader/api/0/preference/list?<font color="#ff0000">client=scroll&ck=1293954081436</font>");
    
    HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(auth_params);
    </br> httpRequest.Method = "GET"; httpRequest.Headers["Authorization"] = "GoogleLogin auth=" + UserAuth; httpRequest.Headers["Cookie"] = "SID=" + UserSid;
            RequestState myRequestState = new RequestState();
            myRequestState.request = httpRequest;
    
            IAsyncResult result =
                (IAsyncResult)httpRequest.BeginGetResponse(new AsyncCallback(AuthRespCallback), myRequestState);
        }
    

About Metro app Suspend/Resume and system sleep/Hibernate

According to Metro Application Lifetime sample and related document, it description about Metro app about suspend/resume.

However, I also find I could not make my Metro app enter suspend mode, so I try to figure out some answer from MSFT forum. Refer here and here.

Here is my summary for this:

  1. When leave app about 5 sec or trigger another app about 5 sec, the “suspend” event will called.

  2. “Suspends”/”Resume” event will trigger automatically when you not attach debugger on release build. See “Star without Debugging” on “debug” tab.

  3. If you using debugger, you only trigger “suspend” manually.

  4. Sleep/Hibernate will trigger “Suspend” if your app is release version without debugger attach.

HOW TO COMMUNICATE BETWEEN METRO UI AND DESKTOP UI ON WIN8 (part2)

From last article “HOW TO COMMUNICATE BETWEEN METRO UI AND DESKTOP UI ON WIN8”, it talking about to pass the control between Metro/Desktop application.

However during programing on Metro and Desktop, you might need some communication mechanism for Metro/Desktop application.

I just provide my experience for this kind of question, here is my solution for communicate between Metro and Desktop on Win8 Customer Preview.  (I also feedback on MSFT forum here)

  1. Write a application to listen TCP as information center which call “DesktopSvr” (ex: here)

  2. Metro app try to send message to localhost via streamsocket (P.S. localhost is not work, but 127.0.0.1 work well).

  3. “DesktopSvr” will pass desktop app via IPC or anyway you familiar.

Metro application communication guidline:

  • Desktop might also pass some data to “DesktopSvr” it will be our information center.

  • Metro:

    • Since Metro UI will not get any TCP feedback if app under suspends, so communicate between metro app via TCP seems not possible here.

    • Metro app only get TCP event when it is remain as alive. (ex: StreamSocket.)

    • Metro app only take feedback and response when event register. (ex: SystemTriggerType), so Metro app might need take more pooling query information to our “DesktopSvr”.

    • Metro app might not to communicate to another Metro app, it is possible for “Metro A” to pass to “DesktopSvr” and “Metro B” also try to retrival information to “Desktop”.

  • Desktop:

    • Desktop is easy to communicate with other desktop app via original way.

    • Desktop might also need pass information to “DesktopSvr” first, and Metro app will try to get it from “DesktopSvr”.

How to communicate between Metro UI and Desktop UI on Win8

It just a summarize to explain MSFT sample: Association launching sample.

  • Metro UI to call Desktop UI

    • File extension call:

      • Add default open on registry if you want create new one.

        • [HKEY_CLASSES_ROOT.XXX]
      • Using Windows.System.Launcher.launchFileAsync

    • Protocol call: (such as “http://”, “mailto://”)

      • Add default protocol on registry if you want create new one.

        • [HKEY_CLASSES_ROOT%PROTOCOL%] [HKEY_CLASSES_ROOT\%PROTOCOL%DefaultIcon] @=”C:\Program Files\XXX.exe,0”[HKEY_CLASSES_ROOT\%PROTOCOL%shell] @=”play”

[HKEY_CLASSES_ROOT\%PROTOCOL%shellopen] @=””

[HKEY_CLASSES_ROOT\%PROTOCOL%shellopencommand] @=”“C:\Program Files\XXX.exe” %1”

[HKEY_CLASSES_ROOT%PROTOCOL%shellplaycommand] @=”“C:\Program Files\XXX.exe” %1”

  * Using Windows.System.Launcher.launchUriAsync

P.S.: Since it is Async, please note you might need handle it well to make it work. :)

Metro UI to call Desktop UI

* 

File extension call

  * 

Add on “package.appxmanifest” “Declarations” to add “Protocol”.

  * 

Handle callback feedback and launch this app.

  * 

Double click file on desktop UI.

* 

Protocol call: (such as “http://”, “mailto://”)

  * 

Add on “package.appxmanifest” “Declarations” to add “File Type Associations”. (ex: “sampleApp://”)

  * 

Handle callback feedback and launch this app.

  * 

Type “sampleApp://” on file browser or IE.

  * 

You could using code “ShellExecute(NULL, _T(“open”), _T(“sampleApp://”), NULL, NULL, SW_SHOWNORMAL);”

How we use it?

To transfer control between Metro/Desktop.

To Write a launcher on Metro UI for your desktop application.

Express app on Metro UI and Pro app on desktop.

Refer:

Windows 8- 8250 note

  1. Windows 8 8250 is official Win8 beta which release on 02/29

  2. It not include VS2011 which vs2011 beta also release.

  3. Only VS2011 Express for Win8 has “Store” publish.

  4. ACK/HCK is not include with Win8 beta but include on VS2011 beta