發表文章

Silverlight – URI 中 UriKind 的差別.

在 Silverlight 中使用 WebClient 時需提供 Uri 跟 Server 端做溝通,在 Uri 中有 UriKind.Absolute / UriKind.Relative 的部份,但這二部份的差別為何呢? 在 UriKind.Absolute 這個比較沒有問題,就是給完整的路徑即可.那 UriKind.Relative 呢? new Uri("test.jpg”, UriKind.Relative) <- page.xaml 所在目錄下 new Uri(“/test.jpg”, UriKind.Relative) <- .xap 所在目錄下 如果不是包含在 .xap 中的 Resource 的話,需使用後面的方式才可從 Server 端取得資料,也可以使用 new Uri(App.Current.Host.Source, "test.jpg") 來取得 Server 端的資料.

Silverlight – Deploy on IIS 6

圖片
Silverlight Deploy on II6 時需要註冊 XAP 的 MIME Type 至 IIS 中,讓 IIS 可以認得 XAP 的 MIME Type,才不會導致 Silverlight 無法顯示的問題,如下所示:

Java – Hibernate 之 手動執行 Batch Update

Hibernate 在 ORM 的部份替開發人員節省不少的時間,但有時遇到因執行 Insert 完後呼叫 Stored Procedure 時因 Batch Update 的關係, Hibernate 還沒有執行 Insert 的動作,故此時需手動執行 Batch Update 的動作.在 Hibernate 中如何執行 Batch Update 呢?在程式碼中加入下面程式即可手動的執行 Batch Update. ((org.hibernate.impl.StatelessSessionImpl)this.session).getBatcher().executeBatch();

Silverlight - 使用 Serializer 來實現 Clone 的功能.

在 Silverlight 中並不包括 ICloneable Interface 來實現複製的功能,故如需要複製的功能就需使用 Serializer 來實現了,此部份是使用 Json Serizlizer 來實作此部份. 首先 Model 需加上 DataContract / DataMember Attribute的部份. [DataContract] public class Circle { [DataMember] public double Radius { set; get; } [DataMember] public double Shrink { set; get; } public Circle() { Radius = 150; } 其次使用下面的 Class 來達到 Serialize / Deserialize. public static class JsonSerializer { public static string Serialize<T>(T obj) { string jsonString = string.Empty; using (MemoryStream ms = new MemoryStream()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T)); serializer.WriteObject(ms, obj); ms.Position = 0; using (StreamReader reader = new StreamReader(ms)) { jsonString = reader.ReadToEnd();...

Silverlight – InkPresenter 上程式畫圓

圖片
一直以來都是使用 component 來畫圓,InkPresenter 只提供由點來組成各種形狀,那需自行畫圓時,如何取得圓弧上各點的X,Y座標呢?X: cos(角度) * r, Y: sin(角度) * r,利用此公式就可以取得圓弧上各點的X,Y座標. XAML: <InkPresenter x:Name="ink" Width="600" Height="600" MouseLeftButtonUp="ink_MouseLeftButtonUp"> </InkPresenter> C#: System.Windows.Ink.Stroke newStroke = new System.Windows.Ink.Stroke(); newStroke.DrawingAttributes.Color = Color.FromArgb(255, 0, 0, 0); newStroke.DrawingAttributes.Width = 1; newStroke.DrawingAttributes.Height = 1; for (int i = 0; i <= 360; i+=5) { newStroke.StylusPoints.Add( new StylusPoint() { X = 300 - 300 * Math.Cos(Math.PI * i / 180), Y = 300 - 300 * Math.Sin(Math.PI * i / 180) } ); } ink.Strokes.Add(newStroke);   其結果如下所示:

[轉貼] - Flash vs Silverlight: Simple Drawing

圖片
With the advantage of rendering speed, Flash and Silverlight can provide a richer experience in drawing and image filtering. Moreover, by using the Timer Event, real time replay of drawing bring us into another generation of art. Recently, I got quite many application requests. I think a implementation list will be made to give you a better idea what will happen in the next few days. Comparison Flash implementation: 1 hour 10 minutes   Silverlight implementation: 1 hour 30 minutes  What’s the difference? Line Drawing: moveTo, LineTo [AS3] vs System.Windows.Shapes.Line [C#] Source codes    Simple Drawing [Flash 9, AS3] (16.2 KiB, 2,278 hits)    Simple Drawing [Silverlight 2, C#] (48.8 KiB, 3,360 hits) Flash Silverlight Line: moveTo, LineTo [AS3] vs System.Windows.Shapes.Line [C#] I think drawing in AS3 is pretty straight forward and easy. It’s...

jQuery – 在 Form 做submit 時附加額外的 Parameters

當 Form 在 submit 時要附加額外的 Parameters 時,在 jQuery 中可以使用 appendTo Function 來達到這個功能,提供一下範例供參考. $("<input />").attr("type", "hidden").attr("name", "myname").attr("value", myvalue).appendTo(".formCssClass"); 在 Form 的 javascript 的 onsumbit 所觸發的 Function 加入上面的程式碼即可達到此功能. PS : 當name使用 array (ex: myname[] ) 時,回傳至 Server 端的資料則像 Select 設為 multi 的方式是一樣的.