星期三, 5月 30, 2007

[C#] PropertyGrid





我一直想要做一個auto property panel

如果能做出來 那許多的property dialog全都可以automatically genearte出來...



有點像Visual Studio .Net 2005的Properpty Panel一樣 只是那時候我也不知他是寫死還是自動產生的



結果我發現C#內建的PropertyGrid就完完全全做到我想做的

而且做的好極了~~~



@@ 只好看一下下面兩篇文章就很清楚知道怎麼做了

現在就只差怎麼去customize propertygrid的UI了

文章裡也有寫相關 但是可能需要更進階



只是真的有點驚訝 @@ 自己的想法還是比他們晚一步 微軟都先做好好的了 :|







充份運用 .NET Framework PropertyGrid 控制項



Make Your Components Really RAD with Visual Studio .NET Property Browser









星期五, 5月 25, 2007

[COM interop] TypeLibConverter



最近一直在想辦法設計一些東西~~



C#擁有Reflection的機制,許多難解的設計都可以很輕鬆的找到方法



但是若得要考慮Native的Code  (C++, ..etc native dll) 的時候,就完全傻眼了



我也想了許多辦法~~ 想要在C++做類似Reflection或是直接用坊間的C++Reflection Library或是...etc



其實都不是那麼方便的方法 後來想說COM的IDispatch機制 也是一種Reflection



但是現在C#與COM最快的方式就是RCW (Runtime callable wrapper)



這種方法卻是Early Binding 所以我想要的設計最好是Late Binding的方式 (例如不用P/Invoke而用LoadLibrary)



但最終還是傻眼........用Reflector一直trace微軟寫的程式 從tlbimp.exe trace到System.Runtime.InteropServices裡



有一個class叫TypeLibConverter 果不其它 他就是想辦法從IDispatch的界面 生出Interop的.net assembly



以下有一篇文章有範例code



COM interop理论/实践 - 漫步 | Manbu's Blog



但是不論如何.........還是很不方便 :s



這個設計的難題 還真的困擾我很久很久...:(





星期六, 5月 19, 2007

JavaFX



既Microsoft的WPF AND SilverLight,Adobe的Apollo Platform之後,這場Rich Internet Applications(RIAs)又加入新的挑戰者,Java陣營的JavaFX



我看了一下FAQ跟一些介紹,似乎目前JavaFX是一整個Family,目前announce的有JavaFX Script跟JavaFX Mobile

而這些都會變成OpenSource,如果想要看一些demo的話, 可以試著從OpenJFX來試 不過記得要灌JRE (java runtime)

因為會從java web start來執行





我發現整個GUI開發整個趨勢是往Markup Language or Declarative Language走去

像是XAML or JavaFX Script or 上次我看到的Openlazlo....都是這類的概念...



讓UI所有的controls/layouts用markup來設計,最後再跟code作整合

所以想當然爾,未來一定也得要有JavaFX Script的design tool..... 才會真的讓大家想要用吧...





Extending Visual Studio 2005





對於Windows Forms或是WPF的build的process我一直很好奇



就是寫User Interface的時候,對於一個Form1 or Window1.xaml



在compile階段其實會根據UI的resource (xaml or resx)來generate出另一個cs file



利用partial的keyword去merge User跟auto generate出來的code成另一個程式



我想找一下這方面的資訊 看有沒有機會我可以自己implement自己想要的build process



不過我用custom build, extend keyword問google 似乎都沒找到我想要的資料



不過倒找到許多extend visual studio的資料



這個link還有許多video教你怎麼extend vs 2005



至於Visual Studio SDK 4.0 可以從這裡Download





後來我的疑問 讓我找到很類似的 叫single file geneartor



好幾個可以參考的地方..... link1, link2, link3, link4





MSBuild Team Blog : How To: Add a custom build action to Visual Studio







星期一, 5月 14, 2007

SSE指令集介紹



最近一直會接觸到Optimization的東西,因為之前對這一塊完全是空白,所以想下定決心慢慢接觸這一塊



對看了一些介紹MMX, 3D Now!, SSE等資訊



在網路上的找到Hotball的SSE介紹,一個很好入門又很清楚的文章



:p 可以快速的入門了解....











powered by performancing firefox

星期二, 5月 08, 2007

[C#] Speed up XmlSerializer



C#的XmlSerializer十分好用簡單,我只寫了幾行,整個複雜的struct整個輕鬆Serialize and Deserialize

不過我發現效率有點慢....



從Google大神中查到了這篇文章,利用Sgen.exe來預先做好Serializer的assembly以加速

十分神奇 :p

星期一, 5月 07, 2007

[C#] XML Serializable Generic Dictionary

C# XML的Serialization很方便

不過對於有些Class本身不支援的話,可能要另外自己寫Serialize的函式



不過在網路上找到這篇文章 

有XML Serializable的Dictionary<T,K>的Example

:p







Powered by ScribeFire.

星期日, 5月 06, 2007

多點觸摸式Screen



我找到兩篇Blog... 有Touch Screen的



對這方面其實十分有興趣...... 因為我也有做過類似的東西



所以對於User Input & Usability十分好奇 也覺得現在的科技還有一大段路要走...



有興趣可以看看以下的Demo ( Touch Desk & 多點觸摸式螢幕)

星期六, 5月 05, 2007

[Web OS] Openlazlo





上上篇我轉錄了一篇Web OS的文章,於是我也花了點時間看了一下OpenLaszlo

大概了解一下他的技術~~ (Flash or AJAX, and ..etc)



整體用他做出來的Web Page真的很好.... 技術細節我就不詳述了

但是如果是Demo的話就還蠻建議玩玩看的



DHTML (or AJAX)做出來的Web UI居然也可以這麼好用....

說實話.... 用一用一度還覺得其實好像RIA (Rich Internet Application)可以不用那麼複雜 (用MS的xbap or Adobe Apollo or ..其它的平台)



Demo請看這裡 有不少個Demo呦



我好奇的是 既然是Open Source,那我們如果想要開商業化的服務 ,可以免費使用嗎?

結果License Info在這裡

是叫什麼open source Common Public License 英文字太多了 所以沒仔細看

不過感覺應該是可以免費使用...:D



有懂license方面的人 再告訴我吧 ^^

Google Maps


Google出了一個Google Map,微軟也出了Live Map,他們分別都有自己的Software版本 就是Google Earch跟MS的Virtual Earth,Yahoo也有自己的Map

不過在台灣來說,Google已經有完整的中文街道圖了,十分方便.....
不論如何,對於一家要對Interface or Web Service的大公司而言,Map是一定要存在的

因為他所能牽涉到的東西實在太廣了.....

最簡單的只是找路,但是再想想
其實「吃喝玩樂」 都跟位置有關
去那吃? 怎麼去? 去那玩? 有什麼好的店?....etc
這樣一看 幾乎無所不包了~~ 未來如果有什麼驚人、好用的新服務 若已經有個現在的Map Service
那就是一股強大的力量~~

所以我想大公司們 一定不會放棄這個重量級的基礎建設.....

其實這種地圖服務,我想是早就有的東西.... 但是對於Web Service方面的東西,時機愈來愈成熟了
所以大場才會又投入做這個...

但是也可以發現 這些有錢的公司做出來的服務就是真的很好 幾個好的地方來討論
一個是提供全球的地圖 (不過其它還有許多不完整的地方)
一個是繪畫很簡潔 (有些公司的map真的很複雜) ,Usability很好 (有些用起來很不順手)
速度快(利用到一些Web技術 像是AJAZ) 這點超重要 找路起來的感受差別很大
加值服務 (可以mark地點 共享 儲存 ...etc)
可以試試另外一家比較一下優劣 (ex. urmap)
我剛試了覺得 覺得速度也做的很好了~~ UI方面倒是可以加強一下 

像我自己最喜歡用的就是Papago軟體~~ 因為真的有台灣超級詳盡的地圖
其實每次用local公司的地圖 都會覺得好可惜
其實明明內容也有了、技術也不會輸別人... 但是用起來整個experience就差了一點
User Interface/Usability真的很重要~~~
然後Business Model也很重要 感覺許多很多時候沒有想清楚 只是把一大堆content丟上去
雜亂無章 我覺得這裡面的商機真的是無限
只是要怎麼讓使用者除了查詢外,還更能join進content的部分
技術都已經ready了~~ 就等著對的商業模式

不過說實話 我所能想到的也不太多 但是我對未來的Map這一塊 真的十分有興趣 也有信心
這方面絕對是重點基礎建設之一......

Google Map











Microsoft Live Map

Web OS



我一直對Web OS十分有興趣,我認為雖不至於最後只剩下Web OS,但是絕對是佔很大部分的趨勢



我們已經漸漸厭倦了重灌OS...Instal軟體、更新....加硬碟..備份......etc



我們也厭倦了資料很難跟著走 (沒辦法cross-computer 一定要有copy的動作)



我想 有很大一部分的軟體 未來 都會被Web OS上的software所取代.....





我看了CNet的這一篇,整理出不少的WebOS相關的公司...「Web OS」只是海市蜃樓嗎?



之後等到逐一研究,我再記錄下來給大家參考



星期三, 5月 02, 2007

[WPF] Application.DoEvents in WPF



在MFC裡有用GetMessage/PeekMessage來避開UI被blocking的問題

在C#是Application.DoEvents

那在WPF呢?

下面的Blog解釋了方法.... HolaMan

Application.DoEvents in WPF


[WPF] Displaying Enum Values using Data Binding

--> DataBinding 到enum valuem, Copy & Paste如下

Some of the FAQs about data binding are:

• How do I bind to a method?

• How do I bind between instantiated controls?

• How do I bind an ItemsControl to an enum?



I put together a quick sample that should answer the above questions:



<Window



  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"



  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"



  xmlns:sys="clr-namespace:System;assembly=mscorlib"



  SizeToContent="WidthAndHeight"



  Title="Show Enums in a ListBox using Binding">



 



  <Window.Resources>



    <ObjectDataProvider MethodName="GetValues"



                        ObjectType="{x:Type sys:Enum}"



                        x:Key="AlignmentValues">



      <ObjectDataProvider.MethodParameters>



        <x:Type TypeName="HorizontalAlignment" />



      </ObjectDataProvider.MethodParameters>



    </ObjectDataProvider>



  </Window.Resources>



 



  <Border Margin="10" BorderBrush="Aqua"



          BorderThickness="3" Padding="8">



    <StackPanel Width="300">



      <TextBlock>Choose the HorizontalAlignment



                 value of the Button:</TextBlock>



      <ListBox Name="myComboBox" SelectedIndex="0" Margin="8"



               ItemsSource="{Binding Source={StaticResource



                                             AlignmentValues}}"/>



      <Button Content="Click Me!"



              HorizontalAlignment="{Binding ElementName=myComboBox,



                                            Path=SelectedItem}"/>



    </StackPanel>



  </Border>



</Window>



The ListBox and the Button are hooked up such that you can “control”

the HorizontalAlignment value of the Button by selecting a value in the

ListBox.

Multithreaded UI: HostVisual





之前為了WPF Multithread的問題,花了不少時間,最後也都想到解法,就是用beginInvoke的方式來溝通



但是前提是,UI controls都是被在不同的windows,被各自的thread所擁有....



限制是不可能在同一個Windows內畫出不同的thread, 但似乎這篇很棒的文章有了很好的解法



:-)

Video Lectures related to CS Courses

topcode forum上有一篇文章列出一些有趣的video lecture about CS course
Copy & Paste如下 :-) (http://forums.topcoder.com/?module=Thread&threadID=507267&start=0)

TopCoder Forums
I am curious what online resources people have found to be excellent. The ones I frequent are listed below and contain video lectures: 1. Stanford collection of Knuth videos 2. University of Texas collection of Dijkstra videos 3. Vega Video Collection of Feynman Lectures 4. MIT's Open CourseWare - Numerous video lectures are featured here, including full courses in Linear Algebra, Mathematics for Engineering, Differential Equations, and Physics 1, 2, and 3. The Physics lectures are by Walter Lewin who is amazing. 5. Webcast Archive of Berkeley Courses 6. SICP Video Lectures by Abelson and Sussman 7. QMUL Mirror of the ArsDigita courses 8. Clay Math Video Collection - Numerous videos including Timothy Gowers speaking on the importance of mathematics, and Wiles and Witten talking to the 2001 IMO competitors. 9. Archive.org Collection of ArsDigita Colloquia - Includes terrific lectures by Sipser on the history of NP vs P, and Sussman on the legacy of Computer Science. Also includes videos by Richard Stallman.

[C#]確保程式只有一個Instance



在Survey Performance找到的資料.... Copy & Paste 如下





确保程序只有一个实例在运行(C#) - Felix Woo

using System.Threading
using System.Runtime.InteropServices;

public class Form1 : Form
{
[STAThread]
static void Main()
{
bool createdNew;

Mutex m = new Mutex(true, "YourAppName", out createdNew);

if (! createdNew)
{
// app is already running...
MessageBox.Show("Only one instance of this application is allowed at a time.");
return;
}

Application.Run(new Form1());

// keep the mutex reference alive until the normal termination of the program
GC.KeepAlive(m);
}
}



另外 要foreground exising one的話 code below

f your application can run with Full Trust permissions, we can take
this a step further and find the window of the application instnace
already running and bring it to the front for the user:



public class Form1 : Form

{

[STAThread]

static void Main()

{

bool createdNew;



System.Threading.Mutex m = new System.Threading.Mutex(true, "YourAppName", out createdNew);



if (! createdNew)

{

// see if we can find the other app and Bring it to front

IntPtr hWnd = FindWindow("WindowsForms10.Window.8.app3", "YourAppName");



if(hWnd != IntPtr.Zero)

{

Form1.WINDOWPLACEMENT placement = new Form1.WINDOWPLACEMENT();

placement.length = Marshal.SizeOf(placement);



GetWindowPlacement(hWnd, ref placement);



if(placement.showCmd != SW_NORMAL)

{

placement.showCmd = SW_RESTORE;



SetWindowPlacement(hWnd, ref placement);

SetForegroundWindow(hWnd);

}

}



return;

}







Powered by ScribeFire.