發表文章

目前顯示的是 2月, 2013的文章

Flex – Cairngorm 之初體驗

圖片
最近在看 Flex 的 Framework, 以 Adobe 官方建議的 Cairngorm 做為開始. 1. ModelLocator : 此部份提供了 Model 的功能, 使用Signleton design pattern 的設計把所有的資料都收集到這邊. 2. Command, Event, FrontController: 在 Front Controller 註冊 Command  與對應的 Event, Event Dispatcher 監聽 Event, 爾後操作過程中 dispatch event 觸發 Command 執行動作, 最後 Update Model 更新 View 顯示. 3. Interact with a server : ServiceLocator : 此 Class 提供了 application 將使用的所有 services, 它包含了 HTTPService, WebService, RemoteObject 呼叫. Business Delegate : 此 Class 有三個 Function     to locate the service that is needed     to call a method on the service     to route the result to the specified responder Value Object : 此 Class 一般定義 property 並不需要任何的 methods, 使用來跟 Server 做 transfer strongly-typed complex data object. 4. Responders, Commands, Delegates : Responders : Responders should deal only in strongly-typed application objects. Responders may set values on the model. Commands : Commands never deal directly with server interaction.Commands may set values on the mo

C# – 得知 Server 上 Protocol 是否已開啟

當程式要得知 Server 上的 Protocol 是否已開啟, 可以試著去連接來查看, 下面的程式碼即可得知 Server 上其 Protocol 是否已開啟.下面提供一個簡單的範例. TcpClient client = new TcpClient(); bool isPortExist = false; Random rnd = new Random(); int portId = rnd.Next(10000, 60000); try { client.Connect("localhost", portId); isPortExist = true; } catch (Exception ex) { isPortExist = false; } finally { Console.WriteLine(string.Format("Port Id : {0},protocol {1}", portId, isPortExist ? "opened." : "closed.")); } Console.Read();

WPF - 窺探 Flow Diagram Designer 的設計

最近收到一個很好玩的 Requirement,提供 Data Sources, Charts, Filters 等組件可讓 User 隨意組合這些元件為一個 Flow 並執行取得結果, 這讓我回想到三年前 WPF 出來時在網路上看到有好心人士提供了其作法和 Source Code, 想不到現在有這 Requirement 需要它了, 真的是太感謝這些好心人士了,那在此記錄一下這些相關的文章, 以防之後還有類似的需求時, 好方便瀏覽. Part 1 – Drag, resize and rotate items on a canvas Part 2 – Toolbox, drag & drop, rubberband selection Part 3 – Connecting items Part 4 – Open/Save, Cut/Copy/Past/Delete and print

Javascript – easy UI 的 datetimebox 自定日期時間格式

圖片
在做 Web 的 UI 時, 其 easyUI 這個免費的 Javascript Framework 提供了很多好用的組件,來幫助我們建立豐富及美觀的 Web 畫面, 在日期組件中提供了 datebox, datetimebox 這二種組件, 並提供相對映的 member 讓我們可以自定日期(日期時間)格式, 提供一個 yyyy-MM-dd HH:mm: ss 的時間格式 $("#startDate, #endDate").datetimebox({ formatter: function (date) { return date.getFullYear() + "-" + (date.getMonth() + 1).toString().leftPad("0", 2) + "-" + date.getDate().toString().leftPad("0", 2) + " " + date.getHours().toString().leftPad("0", 2) + ":" + date.getMinutes().toString().leftPad("0", 2) + ":" + date.getSeconds().toString().leftPad("0", 2); }, parser: function (date) { return new Date(Date.parse(date.replace(/-/g, "/"))); } }); 其顯示如下所示: