Silverlight

Using Thai language with Silverlight 2.0

เมื่อคราว Silverlight 1 ออกมา เราก็ใช้ภาษาไทยกับ Silverlight ได้แบบพอถูไถกันไป พอคราว Silverlight 2 Beta 2 ออกมา ทาง GreatFriends ก็ได้แสดงวิธีการใช้งานภาษาไทยใน Silverligh 2 Beta 2 ไปแล้ว คราวนี้เมื่อตัวจริงออกมาเราก็จะมาดูว่าภาษาไทยได้รับการปรับปรุงไปขนาดไหนแล้ว โดยในครั้งนี้เราจะใช้แค่เพียง Expression Blend 2 Service Pack 1 เท่านั้น ถ้ายังไม่มีสามารถดาวน์โหลดได้ที่ http://silverlight.net/GetStarted/

หลังจากเปิด Blend ขึ้นมาแล้วก็ลองสร้างโปรเจคใหม่ชื่อ ThaiLang

createproject

สร้าง TextBox และ TextBlock ขึ้นมาอย่างละอัน ใครขี้เกียจจะใช้ XAML ข้างล่าง

<Grid x:Name="LayoutRoot" Background="#FFBDBDBD">
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <TextBlock Text="TextBlock" TextWrapping="Wrap" Margin="50,10,50,10" Grid.Row="0"/>
    <TextBox HorizontalAlignment="Stretch" Margin="50,10,50,10" Width="Auto" Grid.Row="1" Text="TextBox" TextWrapping="Wrap"/>
</Grid>
2-textblock-textbox

ทีนี้ถ้าเราลองใส่ข้อความภาษาไทยลงไป

๏ เป็นมนุษย์สุดประเสริฐเลิศคุณค่า กว่าบรรดาฝูงสัตว์เดรัจฉาน จงฟันฝ่าพัฒนาวิชาการ อย่าล้างผลาญฤๅเข่นฆ่าบีฑาใคร ไม่ถือโทษโกรธแช่งซัดฮึดฮัดด่า หัดอภัยเหมือนกีฬาอัชฌาสัย ปฏิบัติประพฤติกฎกําหนดใจ พูดจาให้จ๊ะๆ จ๋าๆ น่าฟั งเอยฯ

พ่อปู่พี่ปี่ฎฐุญุกิสมิํธมฺมํเกื็อกป่า

๐๑๒๓๔๕๖๗๘๙ กกๆ ๚ะ๛ A QUICK BROWN FOX JUMPS OVER THE LAZY DOG. a quick brown fox jumps over the lazy dog. 0123456789

เละครับเละ

thai-fail

เพราะว่าฟอนท์ตั้งต้นที่ติดมากับ Silverlight ที่ชื่อ Portable User Interface ไม่สามารถแสดงภาษาไทยได้ก็เลยกลายเป็นสี่เหลี่ยมๆไปหมด แต่ถ้าฟอนท์แสดงภาษาไทยได้ก็สบายเรา

งั้นก็ลองปรับให้ใช้ฟอนท์ที่รองรับภาษาไทยอย่าง Tahoma ดูซิ

font1

เป็นภาษาไทยแล้วล่ะ แต่ Blend จะขึ้นข้อความมาเตือนอะไรบางอย่าง

The font, Tahoma, isn't a built-in silverlight font. You must embed this font for it to display on your Silverlight Application

เมื่อเราติ๊กคำว่า Embed ในแท็บ Properties แล้วข้อความเมื่อกี้ก็หายไป

font2

แต่เราจะได้สิ่งนี้มาแทน

file-explorer

ถ้าเราขยับๆ จะเห็น Silverlight 2.0 รองรับการตัดคำภาษาไทยแล้ว เย่

result

แต่ก็มาตกม้าตายตอนท้ายเพราะว่าพอลองใช้ TextBox ว่าพอกดปุ่มสระปุ๊บก็เละครับ Silverlight Object หายไปเลย ทางแก้ง่ายมาก ก็อย่าเพิ่งใช้ Silverlight กับงานที่ต้องกรอกข้อมูลหรือไม่ก็ใช้วิธีเดียวกับ Silverlight 1.0 คือเอา HTML input textbox มาใช้แทน แล้วก็อย่าลืมเข้าไปดูที่บักนี้ แล้วเพิ่มลง watchlist ด้วย เค้าจะได้รู้ว่าเรารอให้เค้าแก้บักนี้กันหลายคนเหมือนกัน

Blend to ASPX

ให้ตายสิไมโครซอฟท์ ออก Microsoft Expression Blend มาให้ใช้ แต่กลับไม่มีวิธีง่ายๆในการฝังไฟล์ Silverlight ลงใน ASP.NET !!!

เรื่องเริ่มต้นที่ว่าตอนหัดใช้ Silverlight ก็ต้องมานั่งแกะเองทีละขั้น ตอนนั้นก็คิดว่า ของใหม่เครื่องมือยังห่วยอยู่ ใช้งานยาก ก็น่าให้อภัย แต่ก็คิดว่า ซักวันมันต้องมีคนมาถามแน่ๆเลยว่าจะเอา XAML ไปใช้ยังไง

วันนี้เพื่อนมาถาม

นาย ม. says: วีน ถามหน่อย สมมุติทำของใน blend เส็ดแล้ว จะใส่เข้าไปใน aspx ยังไง

โอ้...พระเจ้า ไมโครซอฟท์ทำสิ่งที่เราฝันไว้ได้จริงๆด้วย

ภาษาไทยกับ Silverlight

หลังจากที่ Silverlight 1.0 ออกมาแล้ว 11 เดือนก็ยังไม่ได้เคยลองเอามาใช้แบบจริงๆจังๆซักที จะมีลองเล่นๆก็คือตอน BarCamp ครั้งนู้น แต่ว่าช่วงนี้ได้งานมางานหนึ่งซึ่งต้องใช้ Silverlight 1.0 ในการพัฒนาเลยได้ลองใช้ของจริงเลย

ปัญหาอย่างหนึ่งที่พบตั้งแต่เมื่อ 11 เดือนก่อนแล้วไม่คิดว่ามันจะแก้ไขได้ง่ายแบบนี้คือเรื่องการแสดงผลภาษาไทย

Silverlight 1.0 and Expression Blend 2.5 March Preview compatibility

Recently, I have involved in a small silverlight project. As the rest of team has no experience with Silverlight but have played with WPF for a while, I suggest them to use shiny new Expression 2.5 with Silverlight 2.0 runtime at first. Unfortunately, using beta software is unbearable by the project owner aka client. Therefore we fall backed to the released Silverlight 1.0 runtime.

The development was progressed smoothly and all bugs we had found was fixed. With the help of Expression 2.5, the development was easier than earlier version. However, when the user acceptance testing had begun, a very serious bug was introduced in some user machines. No one in development team had seen this bug before . The only error message I had at that time was

ParserError- Unknown attribute Ignorable on element Canvas. File: LoadingPage.xaml, line 8 character 3

This bug is obviously related to XAML parsing. So I fired up notepad and went to the problem line. Then I realized the attribute was added by Expression Blend 2.5. But I didn't sure enough to conclude this was the cause as we, the development team, could run it perfectly both in development machines and my computer at home.

In order to reproduce the bug, I decided to uninstall my Silverlight runtime from the computer and found out the root of problem. Silverlight 1.0 and 1.1 runtime do not handle XAML file as a normal XML file. They parse XAML file as XAML file. If you introduce any new namespace to the file, parser will struck and you will got parser error. Though you can use Expression Blend to create and design Silverlight 1.0, the XAML code still cannot be utilized by Silverlight 1.0 runtime. Furthermore, if I correct understand, Silverlight 2.0 javascript API has been changed and Rectangle has the actualWidth attribute as TextBlock element. Because my javascript also caused an error after I fixed the XAML namespace bug.

Since this new namespace was introduced by Expression Blend 2.5 Preview, this can be concluded that Expression Blend 2.5 Preview is not fully backward compatible with Silverlight 1.0. Although in the system requirement page states Silverlight 2.0 beta 1 is required, I think it is for development machine and should not require the 2.0 runtime to be installed in the client box. As this version is just preview, I don't think this bug is Microsoft fault. I blog this for everyone who wanna try the software to be concern.

PS. This issue has been reported to Microsoft.

Silverlight 2.0 license

Last week, the new Silverlight 2.0 runtime and SDK have been released for Mix08. It is the first update to Silverlight 1.1/2.0 since last year Mix07. It took really long time for Microsoft to update this version as they want to build Silverlight awareness with their 1.0 release first.

Today, I emailed golive@microsoft.com to inquire further information about usage license of Silverlight 2.0. I got this email from the Silverlight 2.0 license agreement page and then I sent my question to that address. Within two minutes, what a short period, I got the reply.

This is an automatically generated Delivery Status Notification

Delivery to the following recipient failed permanently:

golive@microsoft.com

Technical details of permanent failure: PERM_FAILURE: SMTP Error (state 13): 550 5.1.1 User unknown

Did I do a mistake?

PS. Actually, I just want to know whether I can use Silverlight 2.0 in my part time project or not. It is just a Silverlight quiz game.

Hangman on Silverlight

หลังจากติดค้างพี่ป๊อกมานาน ก็ได้เวลาใช้หนี้ซักที

เรามาดูกันดีกว่าว่าไอ้เจ้า Hangman นี่มันเขียนยากมั้ย

Free ebooks from MS Press

As a new year gift (maybe), Microsoft Press is giving away its 3 ebooks freely included

Register today to download. Here

VS2008 is coming to town

Get ready and grab it here.

PS. It's just beta 2. Try it at your own risk.

Update 7/28/2007 : Silverlight tools for VS 2008 and ASP.NET Futures (July 2007) have followed. Get them while they're still hot.

 

Second class citizen

C# กลายเป็นพลเมืองชั้นสองใน Silverlight ไปแล้วเหรอเนี่ย

InfoQ is reporting that:

"First of all, C# won't be fully supported in Silverlight. Unlike VB, Python, Ruby, and JavaScript, C# does not support the Dynamic Language Runtime and cannot be hosted for runtime compilation in Silverlight."

This is a bit of a stretch. What happens is that Silverlight will ship with compiler/interpreters that can compile source code written in Javascript, Python, Ruby and Visual Basic to native code.

But Silverlight will not include a C# compiler on the client side. You will still be able to author libraries and assemblies with C# and write your application with it, you just wont be able to dump a C# source file over the network and expect that to be compiled and ran on the client machine.

via Miguel's Blog

Technorati Tags: , ,

Mix 06 &gt; Mix 07 &gt; Mix 08

ปีที่แล้ว ธีมหลักของ  Mix 06 เป็นเรื่องของ WPF, ASP.NET มี AJAX แล้วก็เสนอ WPF/E เข้ามาหน่อยนึง

ปีนี้ ธีมหลักของ Mix 07 เป็น Silverlight แล้วแซม VS Orcas มาด้วย (แล้วก็มี Don Box มาพูดถึง REST หน่อยนึงด้วย)

ปีหน้า Mix 08 คาดว่าก็คงเป็นเรื่อง Silverlight vNext, VS Orcas ตัวเต็ม, Windows 2008 + IIS 7 , Media Support แล้วก็น่าจะแซมด้วย WPF vNext กับ ASP.NET AJAX vNext + Astoria แน่ๆเลย

คนที่อยากดู video mix นี่ก็เข้าไปที่ http://visitmix.com ได้ เค้า เปิดให้ดูตั้งแต่งาน mix ยังไม่จบด้วยซ้ำ

หวังว่าถึงตอนนั้นจะมีพลังพอนั่งเรียนรู้ไอ้พวกนี้นะ