Friday, June 26, 2009

C# Double Decimal Place using String Format

String Format for Double [C#]

The following examples show how to format float numbers to string in C#. You can use static method String.Format or instance methods double.ToString and float.ToString.

Digits after decimal point

This example formats double to string with fixed number of decimal places. For two decimal places use pattern „0.00“. If a float number has less decimal places, the rest digits on the right will be zeroes. If it has more decimal places, the number will be rounded.

[C#]

// just two decimal places
String.Format("{0:0.00}", 123.4567); // "123.46"
String.Format("{0:0.00}", 123.4); // "123.40"
String.Format("{0:0.00}", 123.0); // "123.00"


Next example formats double to string with floating number of decimal places. E.g. for maximal two decimal places use pattern „0.##“.



[C#]



// max. two decimal places
String.Format("{0:0.##}", 123.4567); // "123.46"
String.Format("{0:0.##}", 123.4); // "123.4"
String.Format("{0:0.##}", 123.0); // "123"


Digits before decimal point



If you want a float number to have any minimal number of digits before decimal point use N-times zero before decimal point. E.g. pattern „00.0“ formats a float number to string with at least two digits before decimal point and one digit after that.



[C#]



// at least two digits before decimal point
String.Format("{0:00.0}", 123.4567); // "123.5"
String.Format("{0:00.0}", 23.4567); // "23.5"
String.Format("{0:00.0}", 3.4567); // "03.5"
String.Format("{0:00.0}", -3.4567); // "-03.5"


Thousands separator



To format double to string with use of thousands separator use zero and comma separator before an usual float formatting pattern, e.g. pattern „0,0.0“ formats the number to use thousands separators and to have one decimal place.



[C#]



String.Format("{0:0,0.0}", 12345.67);     // "12,345.7"
String.Format("{0:0,0}", 12345.67); // "12,346"


Zero



Float numbers between zero and one can be formatted in two ways, with or without leading zero before decimal point. To format number without a leading zero use # before point. For example „#.0“ formats number to have one decimal place and zero to N digits before decimal point (e.g. „.5“ or „123.5“).



Following code shows how can be formatted a zero (of double type).



[C#]



String.Format("{0:0.0}", 0.0);            // "0.0"
String.Format("{0:0.#}", 0.0); // "0"
String.Format("{0:#.0}", 0.0); // ".0"
String.Format("{0:#.#}", 0.0); // ""


Align numbers with spaces



To align float number to the right use comma „,“ option before the colon. Type comma followed by a number of spaces, e.g. „0,10:0.0“ (this can be used only in String.Format method, not in double.ToString method). To align numbers to the left use negative number of spaces.



[C#]



String.Format("{0,10:0.0}", 123.4567);    // "     123.5"
String.Format("{0,-10:0.0}", 123.4567); // "123.5 "
String.Format("{0,10:0.0}", -123.4567); // " -123.5"
String.Format("{0,-10:0.0}", -123.4567); // "-123.5 "


Custom formatting for negative numbers and zero



If you need to use custom format for negative float numbers or zero, use semicolon separator;“ to split pattern to three sections. The first section formats positive numbers, the second section formats negative numbers and the third section formats zero. If you omit the last section, zero will be formatted using the first section.



[C#]



String.Format("{0:0.00;minus 0.00;zero}", 123.4567);   // "123.46"
String.Format("{0:0.00;minus 0.00;zero}", -123.4567); // "minus 123.46"
String.Format("{0:0.00;minus 0.00;zero}", 0.0); // "zero"


Some funny examples



As you could notice in the previous example, you can put any text into formatting pattern, e.g. before an usual pattern „my text 0.0“. You can even put any text between the zeroes, e.g. „0aaa.bbb0“.



[C#]



String.Format("{0:my number is 0.0}", 12.3);   // "my number is 12.3"
String.Format("{0:0aaa.bbb0}", 12.3); // "12aaa.bbb3"

Wednesday, June 24, 2009

Wireless cellular network, packet scheduling, multi-user diversity effect, opportunity scheduling

It has been several decades since the existence of wireless cellular network, which has brought tremendous conveniences to the world society with the developments on top. At present, the traditional telecommunications market is gradually merging its business with data together. As a result, the next-generation wireless cellular networks are heading towards the direction of all-IP packet networks. In addition, the proportion that data division business holds within all business of cellular network will become more importantly, which then makes the packet scheduling mechanisms become more important. With an increasing demand for the end-to-end quality of service, and the contradictions of significant increase in data traffic with the limited resources of the wireless resources, such as video, file transfer, and other data services, all of which are challenging the scheduling mechanisms in the network environment. Furthermore, how to improve the wireless cellular network system throughput to meet the requirements of the user's Quality of Service (QoS), how to provide a fair service to all users, have become the major issues which need to be addressed in the packet scheduling mechanisms for wireless cellular network.

The packet scheduling mechanism for the wireless cellular network is based on cross-layer design concept, which will consider all layers to make scheduling decisions. For example, the physical layer, will have a multi-user diversity effect due to varying characteristics(无线衰落信道具有时变特性). Using (exploit) multi-user diversity effect (多用户分集效应) can effectively enhance the data throughput of the wireless cellular system. Scheduling such as the opportunity scheduling, is commonly used in the packet scheduling mechanism for the wireless cellular networks. This thesis mainly focus on the theoretical model of opportunity scheduling and its specific algorithms.

With Regards to the theoretical model of opportunity scheduling, the author has classified and summarized the various existing theoretical models, including the division-level model and flow-level models. In terms of opportunity scheduling performance indicators and the typical opportunity scheduling algorithm in the division-level model and flow-level model of performance evaluation, experiment has also been conducted to analyse the existing methods and results. Finally, the author gives an predicting analysis of the theoretical tools that can be used in future in this area.

Regarding the specific algorithms used in opportunity scheduling, existing algorithms were summarized and compared, including the scheduling algorithm which uses OFDM technology in the wireless cellular network. The author discovered that the traditional method usually pay more attention to improve system throughput, however fails to provide a fair and user-satisfactory QoS. A new algorithm, without the sacrificing of system throughput ,was presented, to ensure the relatively fairness between all users and each user's QoS demand are met.

Sunday, June 21, 2009

C# open folder dialog (FolderBrowserDialog)

In .Net GUI Applications, Interaction with User on selecting files is a very basic topic. In the following code samples, I have demonstrate how to select files ( in comment code), more importantly, give an example code on how to get a folder name form the windows open dialog box. Something Interesting here is that you actually can’t get the folder name easily. (I mean select a folder, you can still select the file then get the full path, which include the folder name) The best option is to use FolderBrowserDialog !

Ok, now here is the sample code. Enjoy.

        private void importToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
string startupPath = Application.StartupPath;
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
dialog.Description = "Open a folder which contains the xml output";
dialog.ShowNewFolderButton = false;
dialog.RootFolder = Environment.SpecialFolder.MyComputer;
if(dialog.ShowDialog() == DialogResult.OK)
{
string folder = dialog.SelectedPath;
foreach (string fileName in Directory.GetFiles(folder, "*.xml", SearchOption.TopDirectoryOnly))
{
SQLGenerator.GenerateSQLTransactions(Path.GetFullPath(fileName));
}
}
}
//using (OpenFileDialog dialog = new OpenFileDialog())
//{
// dialog.Filter = "xml files (*.xml)|*.xml";
// dialog.Multiselect = false;
// dialog.InitialDirectory = ".";
// dialog.Title = "Select file (only in XML format)";
// if (dialog.ShowDialog() == DialogResult.OK)
// {
// SQLGenerator.GenerateSQLTransactions(Application.StartupPath + Settings.Default.xmlFile);
// }
//}
}
catch (Exception exc)
{
MessageBox.Show("Import failed because " + exc.Message + " , please try again later.");
}

}

Friday, June 19, 2009

For Daniel and Victorial

Two friends of mine will soon be moving to UK.  As a reader of getting down under forum, I would like them to read this post:

---------------------------------------

As the British economy hits rock bottom, thousands of skilled workers are looking abroad to start up a brighter, more stable life in a different economy.

Traditionally, Australia and New Zealand have been a favourite destination for British skilled migrants, but it seems now their economies are also feeling the rippling effects of the American and British recessions.

There has been much debate as to whether Senator Chris Evans (Minister for Immigration and Citizenship) would lower the record rates of immigration to Australia in the 2009-10 Budget in response to his country’s prospective financial troubles.

Evans has decided to keep this year’s record 133,000 skilled visas as a ceiling until the Government assesses the country’s economic situation in time for the mid-year Budget.

This means that Australia still has plenty of places for skilled workers to move to Australia, and you could be joining the thirty-odd thousand other Britons moving to Australia permanently every year through the Australian migration program.

Now we all know Australia has a better climate, nicer beaches, and the promise of a more comfortable, outdoor lifestyle than the UK, but, in this economic climate would skilled workers actually be better off by moving from the UK to Australia?

How much money can you earn in Australia compared to the UK

The following is a comparative table showing the median salaries for selected jobs in Australia and the UK, sourced from payscale.com (updated February 2009).  The results are based on the person having 10-19 years experience in that job, and the Australian salaries have been converted using the curencyconverter.com tool. 

The following is a comparative table showing the median salaries for selected jobs in Australia and the UK, sourced from payscale.com (updated February 2009).  The results are based on the person having 10-19 years experience in that job, and the Australian salaries have been converted using the curencyconverter.com tool.

A quick look at the table suggests the trend for higher salaries in Australia for skilled positions is evident, excluding the rather major difference for solicitors.

Cost of living in Australia versus the cost of living in the uk

A higher salary doesn’t mean much if you are paying higher prices for the everyday basics.  The following table shows the cost of basics as supplied by the Office of National Statistics (ONS) and the Australian Bureau of Statistics (ABS) for December 2008.

Cost of living in Australia versus the cost of living in the uk. A higher salary doesn't mean much if you are paying higher prices for the everyday basics.  The following table shows the cost of basics as supplied by the Office of National Statistics (ONS) and the Australian Bureau of Statistics (ABS) for December 2008

The table shows Australia is not the winner in every case, and in fact, the UK is the cheapest place in the world to buy bread.  Yet, although the overall picture gives the impression that the cost of living in Australia and the UK is vacillating, a closer look shows that the expensive staple items are considerably cheaper in Australia than in the UK, which would keep your wallet plumper for longer.

For example, a family of four that consumes 2kgs of beef a week could save up to £303 after migrating to Australia from the UK, and a person filling up a car with 30L of petrol every week could save up to £280 per year.  These are substantial savings.

Whereas milk, bread and flour may be cheaper to buy in the UK, the items that you need to outlay more cash on a weekly basis (such as meat and petrol) are cheaper in Australia.

The Economist’s Big Mac index makes things loud and clear to understand.  The famous index compares the cost of a Big Mac in hundreds of countries as a way of comparing the cost of living around the world.  During February 2009, the index showed that a Big Mac was cheaper to buy in Australia than in the UK.

A cheaper cost of living coupled with a higher chance of getting a better salary in Australia means that you would have more spending power and an increased cash flow.

Australia property prices compared to the UK

In most countries, an increased cash flow means a higher standard of living and the opportunity of living in a nicer home.

Property prices across Australia have a huge variance, particularly because there is a massive difference between rural, coastal and city houses.  The same can be said for the UK, where just in the city of London, house prices can be almost triple the cost of similar types of houses elsewhere in the UK. 

As a result, it becomes difficult to compare accurately house prices from specific regions in Australia with regions in the UK.  Yet the Reserve Bank of Australia has released a report that shows the trend in housing prices and affordability, called “Some Observations on the Cost of Housing in Australia”, written by the Head of Economic Analysis Department Anthony Richards.

The following table is extracted from this report, which shows that Australia has been better off internationally than its major competitors in terms of income and relative house prices, despite there being a low level of housing accessibility and persistently high level of average housing prices.

Australia property prices compared to the UK, Canada and the United States (US). The Real Estate Institute of Australia (REIA) confirmed in December 2008 that the Australian average median house price reached $447,659 (£203,660) in the September quarter - a decrease of $459,795 from the June quarter - with only Sydney having a median house price above $450,000

The Real Estate Institute of Australia (REIA) confirmed in December 2008 that the Australian average median house price reached $447,659 (£203,660) in the September quarter – a decrease of $459,795 from the June quarter – with only Sydney having a median house price above $450,000.  In the Department for Communities and Local Government live tables, the average median house price in the September quarter for 2008 was sitting at £233,459.

This difference in average house prices and the trend to have better income ratios in Australia and the UK means you would have a great chance of a better lifestyle in Australia, living in a nicer home with an increased cash flow.

The Australian weather compared to the UK

It will come as no surprise that Australia gets far more sun than the UK.  In fact, Australia gets around 300 days of sunshine annually, which is 70% of the year.  Moreover, when the rains come rolling in from the ocean or across the desert plains, it is not something the locals complain about; the tropical storms can give hours of entertainment and can be a quick relief for stifling heat.

See below for a breakdown of how averages of temperature (degrees) compare in UK and Australian cities:

The Australian weather compared to the UK - breakdown of how averages of temperature (degrees) compare in UK and Australian cities

How many public holidays do you get in Australia compared to the UK?

In Australia, be prepared to put your feet up for longer.  In the UK, along with the standard annual leave provided by employers, the Government provides workers eight annual public holidays.  In Australia, most workplaces give the same leave entitlements as UK companies, but the Australian Government has been slightly more generous.  Each state or territory has a different amount of public holidays, but all have at least 10 days off or more.  For example, in Tasmania you’ll be given 21 days off every year, plus your 4 weeks annual leave. 

The following shows the amount of public annual holidays in the UK and each Australian state or territory:

How many public holidays do you get in Australia compared to the UK?

Sound appetising?  It’s advised that you beat the Budget and submit your application before the Australian Government considers restricting its migration program, and before you know it you’ll be enjoying a beer on the beach and soaking up the Australian sun!

Friday, June 12, 2009

夫妻相的多种解释

说起夫妻相,估计谁都说得头头是道,但如果告诉你这个词背后还蕴藏了人体基因设置的重重机关,以前大脑活动和视觉悟之间的相互作用,估计没有几个人能说出其中的原委。
当你初见一对夫妻,最先闪入脑子里的是什么?相信大多数人都会琢磨一下这两个人有没有“夫妻相”。现如今,在不少人的心目中,有没有“夫妻相”意义重,甚至成了有没有“夫妻缘”的重要指标,更有甚者双双跑去整容,为的就是整个夫妻相来。
虽然整容的形为有点极端,但是,却真实地反映出“夫妻相”这个古老词语在现代人心中鲜活的生命力。别说普通人,就连古今中外的人人也逃不出这个“潜规则”,他们为世人所熟悉的面孔,早以演绎出诸多关于夫妻相的谈资。
先看看孙中山和宋庆龄吧,孙中山是典型的国字脸,颧骨以下的肉比较突出,看上去很有魅力,目光深沉却明亮如炬。宋庆龄则是丰满的鹅蛋脸,鼻子很高,目光坚定,从两人的合影来看,五官比例、形状、神态、配合的天衣无缝。
“夫妻相”是不分种族和国界的,最有名的典型,要数甲壳虫乐队歌手约翰-列侬和日本艺术家大野洋子,尽管他们一个是西方人,一个是东方人,本来想长出“夫妻相”来就是天方夜潭。可是现实中,他们不但十分相像,还十分恩爱。那两张脸,任何人都无法否定他们是多么的相似。充满灵感的眼晴,高高的鼻梁,坚定锐利的下巴……无怪乎他们的结合以后,总是在艺术界爆出惊人之举。
有人认为,仅仅“是貌似”其实还不能够达标,光绪和珍妃就是一对苦命的“貌合神离”的夫妻,光绪长得是丰满的国字脸,办女相,而珍妃则长了一个方圆大脸,发人男相,二人神态光绪被囚,珍妃惨死的悲惨命运。夫妻的命运是否真的跟他们的长相有关,还仅仅是后人的演绎罢了?也就是说,人类在选择配偶时,究竟有没有“夫妻相”这个原因,夫妻相似到底有巧合还是确有科学依据?一些科学研究或许能给我们更加理性的推断俗话说:“不是一家人不进一家门。”夫妻相是怎么回事呢?
其实夫妻相的大抵意思是因为常常接触,心灵相倾,习惯趋同,相互影响,以致到了面容相像。下面为大家进一步进行科学分析:

 

说法一:视角倾斜和视力误差的结果!

所谓“夫妻相”,只是人们视角的倾斜和视力的误差。正如外国人看到中国人都长的一样,我们看一群麻雀没有分别一样,对于一对夫妻,我们首先在心里就已经给他们下了定义,自然就着力去发现他们面貌上相像的地方,而很少去注意它们的不同。其实,人类男女间无论是谁,相貌的一个个“零件”上都是有一定的一致性的,特别是同种族、同一种肤色、同一地域间的人,更是在身材、面相上有更多的相似处。就不是夫妻,相貌某一点上相当者也不会少,何况大部分夫妻,生活在同一环境条件下,这种相似会更多一点。把这种种相似粘贴在一起,加上我们先入为主的心理认知,认为夫妻夫妻,应该相像,这本不足为奇。实际上,在不知情的情况下,误认一双男女为夫妻的也很多。事实上,“夫妻相”并不能说明什么,而夫妻间包括相貌在内的各种差异才是绝对的。

说法二:夫妻相不一定是最好的夫妻
有“夫妻相”的男女不一定就能是夫妻。找对像时人们大多要考虑相貌,但绝少有以自己的模样为标准找面相相似的另一半的。相貌上男的英俊,女的妩媚;男的有棱有角,女的楚楚动人,等等,这才是男女追求的目标。真的面貌相像的两口子则很少即便相像,这样的两口子也并不一定就是最好的夫妻。看那些“夕阳红”幸福晚霞中的老夫妻们,面貌相似的见不到几个。看不出“夫妻相”能在一个美满婚姻家庭生活中起到什么作用。即便是天赶地凑出一对“夫妻相”的夫妻,就一定能是幸福美满的夫妻么?生活中的夫妻不是图画上的夫妻,最实际的夫妻幸福应该是性格的相容,心灵的相慰,生活的相互关心,困难面前的相互支撑,富有面前的相互珍惜和提醒。没有这些内涵的夫妻,再相像又能怎么样呢?或许也有这样的相像而又美满的夫妻,但这样的例子毕竟太少了。 真实的社会生活中,在外人看来门当户对、郎才女貌的夫妻同床异梦并不少见;生活几十年,风过了雨过了一朝把手分的夫妻也不让人奇怪。一些夫妻高矮胖瘦俏平不一,但生活里却各有自己的幸福,各有各的快乐,平平安安地度过了一生;有的夫妻打打闹闹大半辈子,到老了儿孙满堂,相携相拥,满面幸福。这些情形,就不是相貌异同所能解释得了的。

说法三:夫妻相貌不同很普遍

夫妻间相貌的不同是普遍的。或许这种不同才是我们人类自身健康繁衍所真正需要的。在取长补短中,在基因匹配中,在凸凹相交中,在你来我往中,在心心相印里,在相对的貌相的丑与美的交融中,夫妻生活的质量才能得到提高,后代的体貌才得以优化。如果失去自然选择,人们以貌相配,那就不知道人类还能延续几日了。生活中的夫妻面貌相异,性格大多也有急有缓,生活中有磕磕碰碰的语言行为也是极正常的。有人面善而心硬,有的貌美而行不一定端。面貌固然可以在一定程度上反映人的特点,但以貌取人往往也是不牢靠、不准确的。“夫妻相”也是如此。趋同,趋像的本不足信,如果再以此为凭说明夫妻是否恩爱,家庭是否和睦,也就更站不住脚了。

说法四:两情相悦才重要

相像固然可爱,不同才显风流。容貌只是表象,内容才见端详。面容相像是别人评说的,两心相悦才是切身体会的。不管是否有“夫妻相”,但我确信,夫妻间你中有我,我中有你,相濡以沫,幸福美满是存在的。夫妻气味相投,两情相悦,一定会在生活方式上融合,行为举止上趋同,语言习惯上相似。如果说这就是“夫妻”的话,这是不容置疑的。至于“夫妻本是同林鸟,大难到来各自飞”的,即使长得似双胞胎一般,也是没有用处的。因为生活在一起就可以影响到对方相貌改变,形成相貌相近的“夫妻相”的说法,至今还得不到令人信服的理论和事实依据的支持。

说法五:夫妻相有类型.

1.和谐型夫妻相,有着和谐型面相的男女很容易被对方吸引。这个面相的关键是比例,有和谐面相的两个人脸上的三组数据大致相同,即额头的高度,人中的长度,下颌的长度。只拥有这个面相的人可能并不像,除非他们同时拥有回应型面相

2.回应型夫妻相

拥有回应型面相的人看起来很像对方,也就是人们常说的夫妻相,因为他们五官、脸型以及上眼睑线、上唇线和眉毛三部分的形状很相似。有着回应型面相的双方常常是同一类人,他们心灵相通,互为知己.

3.亲缘型夫妻相

一位拥有亲缘型面相的人,会让对方感到像亲人,这个人可能是他的姐妹、母亲或者奶奶。如果男方认为女方像亲人,他们会互相信任,有很深的依恋感

4.集成型夫妻相
以上三种面相的集合。
5 自我定义型夫妻相

也许你们不属于上述的任何一种夫妻相,究竟属于哪一种,只有你们商量着,自我定义了

很多时候相处的时间越长的夫妻,人们对他们的评价也就越相似,许多结婚前并无特别相似之处的夫妻,经过10-25年以上的磨合以后相貌会变得很相像。这可能就是所谓的习惯成自然,相有心生吧

Wednesday, June 10, 2009

Yet Another Android Mobile Phone HelloWorld Tutorial

注明:版权归德明泰所有。此为转载。

开eclipse,新建一个android工程。
先得用xml画布局。可以拿个例子干写,可以用我发的那个可视化工具,eclipse自己也有个大米花的功能,可以给控件设属性,总之配合着来吧,反正最终的xml也简单。写一个xml就行了,位置是res/layout/main.xml
这是我写的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<EditText
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
>
</EditText>
<Button
android:id="@+id/button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click Me"
>
</Button>
</LinearLayout>
最外层是一个Layout的大面板,控件往上扔就行了。我弄了一个文本框一个按钮。layout属性的fill_parent表示是跟爸爸一样,就是填满。wrap_content的意思好像是根据内容定长度。其他的都简单。那个id要选好,前面的@+id/是固定的,后面要起一个名字,程序里就用丫。
ec里能看到设计图。图懒得贴了,自己执行了看吧。
然后就写代码呗。我就贴关键部分。其中带底色的是建了and工程自动生成的,其他是我写的。
public class helloworld extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        clickMe = (Button)this.findViewById(R.id.button);
        editText = (TextView)this.findViewById(R.id.text);
        clickMe.setOnClickListener(new OnClickListener(){
            @Override
            public void onClick(View v) {
                editText.setText("Hello world!!!");               
            }});
    }
    private Button clickMe;
    private TextView editText;
}
先声明俩变量,按钮和文本框的。然后用this.findViewById,把控件找出来,id就是前面你丫写xml时候设的id。要用一个强制转换。这样那变量就跟实际的控件连上了,以后用就行了。
下面就简单了,弄上个listener,不多说了。其实除了那画xml跟)this.findViewById,真没啥新鲜玩意儿了。。。跟写普通java程序一样了。
简单吧!!!!
最后来个效果图

俩控件的水平方向layout都是fill_parent,所以撑满了

Saturday, June 6, 2009

DataGridView EditMode EditProgrammatically

Problem: Whenever you want to write your own double click event for datagridview control, chances are, you will actually end up in edit mode. 

How to solve: DataGridView EditMode property.

From the MSDN,

DataGridView EditMode Property : Gets or sets a value indicating how to begin editing a cell.

The catch is:

All DataGridViewEditMode values except for EditProgrammatically also allow a user to double-click a cell to begin editing it.

Aha, that’s why the problem occur!! So, how do i use Edit EditProgrammatically?

MSDN give the following explaination:

Editing begins only when the BeginEdit method is called.

So I implemented the following event handler to call BeginEdit method.

private void dataGridView_ContextMenuViewEditCell(object sender, EventArgs e)
{
dataGridView.BeginEdit(true);
}




Then use contexmenu to register the event.




dataGridView.ContextMenuStrip.Items.Add(
new ToolStripMenuItem(Resources.Common_Label_Edit, Resources.Image_16_Edit,
new EventHandler(this.dataGridView_ContextMenuViewEditCell)));




And finnally,  contexmenu only pop up when right click, so focus needs to be set, same as left click.




DataGridView.HitTestInfo hti = this.dataGridView.HitTest(e.X, e.Y);
if (hti.RowIndex >= 0 && hti.RowIndex < dataGridView.Rows.Count)
{
dataGridView.CurrentCell = dataGridView[hti.ColumnIndex,hti.RowIndex];
}


Monday, June 1, 2009

Subversion Trac rules tutorial

A guide that I worte for company staff to follow.

SVN:

  • Use TortoiseSVN client.
  • Our subversion has the usual trunk/branches/tags layout. Never develop on trunk! Do your part in branches and merge it back to trunk.
  • Recommended check in frequency is every hour! Comment is a MUST.
  • Exclude unnecessary files that are not required in compile. (eg, obj, exe) Pay attention to check-in huge files that can’t be re-versioned!
  • ONLY merge changes that can be compiled and tested into truck. ( and reviewed! Will have detailed discussion about this.)
  • Commit changes as a single logical change set for one purpose. Thus all code changes for a single bug fix or enhancement should be checked-in together. This allows one to better follow the history log of changes.
  • Check-in code at the directory level and all changed files, recursively in the directory and subdirectories will be checked in together.
  • Using Trac integrated with Subversion, refer to the Trac ticket in the Subversion check-in comment using a "#" in front of the Trac ticket number (eg. #65). This generates a hyperlink when the Subversion logs are viewed in Trac.
  • The "tags" branches are NOT to be used as working branches but are snapshots of an existing branch. The "tags" are for historical reference such as a release, well tested version or progress milestone.

Trac:

  • Document project based information in Trac wiki. (eg, Anything that isn't obvious to fresh eyes gets documented on the Trac Wiki.)
  • Spend at least 0.5 hour a day documenting on the Wiki. This should get placed in the "Documentation" category on the time-tracking software.
  • Using Subversion integrated with Trac, refer to the Subversion specific revision in tickets using a “r” in front of the revision number (eg r103). This generates a hyperlink to view the source in Trac.

Google Pagerank 3 NOW

hurry :)

Display Pagerank

I think it won’t be very hard to achieve if you keep publishing original articles.