Thursday, December 30, 2010

Set "Auto" to GridView Colum Width when re-binding data to the GridView

The GridView Colum Width is a headache.

detailView.Columns.OfType<System.Windows.Controls.GridViewColumn>().ToList().ForEach(c => c.Width = c.ActualWidth);
detailView.Columns.OfType<System.Windows.Controls.GridViewColumn>().ToList().ForEach(c => c.Width = Double.NaN);


http://msdn.microsoft.com/en-us/library/system.windows.controls.gridviewcolumn.width.aspx
Double.NaN means auto-size

Wednesday, December 29, 2010

WPF Make a Button invoked by Enter Key, set it as IsDefault=true

In the window, I try to use focus manager to set the button focused to invoke Enter Key, but the focus may lost.

By setting the IsDefault property, problem solved.


public void EnableFinish()
{
    btnNext.Visibility = Visibility.Hidden;
    btnFinish.Visibility = Visibility.Visible;
    btnFinish.IsDefault = true;
}

Tuesday, December 28, 2010

Define width of GridViewColumn by parent window

<GridView ColumnHeaderContainerStyle="{StaticResource CustomHeaderStyle}">
      <GridViewColumn Header="Available Roles"
         Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource FindAncestor, cestorType={x:Type local:ListViewEx}}, Converter={StaticResource gridViewWidthConverter}, ConverterParameter=0.9}">
          

Wednesday, December 15, 2010

Timer vs. DispatcherTimer in WPF

Have you ever wondered what is the difference between Timer and DispatcherTimer in WPF / Silverlight? In this post I will try to explain you the little difference. Timer generates recurring events in an application. DispatcherTimer is a timer that is integrated into theDispatcher queue which is processed at a specified interval of time and at a specified priority. Timers are not guaranteed to execute exactly when the time interval occurs, but are guaranteed not to execute before the time interval occurs. This is becauseDispatcherTimer operations are placed on the Dispatcher queue like other operations. When the DispatcherTimer operation executes, it is dependent of the other jobs in the queue and their priorities.

Monday, December 13, 2010

WPF make a window on top of main window

One way is to set the Topmost property, which is not the best way,
another is to set the Owner property,

ProjectWizardDialog pwd = new ProjectWizardDialog();
                pwd.Owner = Window.GetWindow(this);//steveny: Wizard dialog should always be at the toppest
                pwd.ShowDialog();

Monday, November 15, 2010

NameCheap DNS Server Hostname

freedns1.registrar-servers.com
freedns2.registrar-servers.com
freedns3.registrar-servers.com

Monday, November 1, 2010

Prove that square root of three is an irrational number

The Irrationality of square root of three

Problem:
Prove that
square root of three is an irrational number.
Solution:
The number,
square root of three, is irrational, ie., it cannot be expressed as a ratio of integers a and b. To prove that this statement is true, let us assume that square root of three is rational so that we may write

Thursday, October 28, 2010

typedef

typedef struct node Node, *Tree;
struct node {
    char word[MAXSIZE];
    Tree left;
    Tree middle;
    Tree right;
};

    Node n;
    Node *m;
    //which is equal to
    Tree m;

Sunday, October 17, 2010

Basic DOS commands

Occasionally on your Windows computer, you may need to perform a procedure by typing in commands at the 'Command Prompt'. Entering commands in this way allows you to bypass the Windows graphical user interface and communicate directly with the operating system. You are most likely to need to work in this way if you get an infection and have to disinfect your computer from the command line, for example, using one of the Sophos Resolve tools, or SAV32CLI or SWEEP.EXE.

To communicate through the Windows command line, you will need to use MS-DOS commands. This article lists some basic DOS commands that you are likely to find useful when working from the command line, but there are many more available. To find out more about MS-DOS, consult a book, online dictionary or encyclopedia, or other specialist publication.

Open a New cmd window in cmd

Use the command "start cmd" or "start cmd.exe" to open a new command window in the command line!

By the way, there is a cool console tool for windows http://sourceforge.net/projects/console/

If you want to open a new command window with commands:
"start cmd /k ExecutableFile.exe parameter1, parameter2 ... parameterN"

Friday, October 1, 2010

Configuration Error when running a virtual directory

I encounter this problem today:


Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Monday, September 20, 2010

Sunday, September 19, 2010

Eric Carmen

Like His voice, Run Away!!

Dynamically Allocation Multidimensional Arrays

Doing the ASS of my C programing language, I need to dynamically allocation two dimensional arrays.
 So the method is as below:
int **a; 
int i,m,n; 
scanf("%d %d",&m,&n); 
*a=(int **)malloc(m*sizepf(int *)); 
for (i=0;i<m;i++) 
       a[i]=(int *)malloc(n*sizeof(int)); 
//which is just like in C++: 
int m,n; 
int a[m][n]; 
cin>>m>>n;
very funny!

Saturday, September 18, 2010

Use EclipseCDT in Windows

http://www.cs.umanitoba.ca/~eclipse/7-EclipseCDT.pdf


use MinGW

SyntaxHighlighter in Blogger

SyntaxHighlighter is awesome.

if u wanna use it in blogger, do the following steps:

Download and find a place to host the library files for SyntaxHighlighter. A free choice is, of course, google sites

Use grep to search strings in files

GREP is a powerful tool to search in linux, as there is no good search tools in windows.

A simple example:

$ grep "some string" /home/steven/*.txt

Search all subdirectories recursively

$ grep "some string" /home/steven

-i ignore case

wanna know more things it can do just:

grep --help

Friday, September 17, 2010

Win7 is very user friendly

There is a lot of things win7 amazed me.
when I use the remote desktop connect to another server, I can just drag the bar.:

Boot!! Win7 and ubuntu 10.04

Finally reinstall the grub.
http://goo.gl/mKMY

One thing DropBox Need to Improve

Just fount out one thing that DropBox need to improve:
When I move one folder into another on the web, the DropBox have to download all of the folder from the net. What a wast! Just do the mv operation on the computer.

Wednesday, September 8, 2010

Gonna Sleep

Java is Powerful. I am not efficiency in writing java code, but that's all right.Finish it tomorrow!

Just try to publish a post through email

Just try to publish a post through email, 
nothing else.

--
/**
 *@You Silin
 *More Info:
 *http://www.google.com/profiles/yousilin
 *My Blog:

Useful Eclipse Shortcut Keys

Ctrl+Shift+T

Find Java Type

Start typing the name and the list gets smaller. Try typing the capital letters of the class only (e.g. type "CME" to find "ConcurrentModificationException")

Ctrl+Shift+R

Find Resource

Use this to look for XML files, text files, or files of any other type. which are in your workspace.

Ctrl+E

Open Editor Drop-Down

Presents a popup window listing currently opened files. Start typing to limit the list or simply use the down arrow key.

Ctrl+O

Quick Outline

Use this to find a method or a member variable in a class. Start typing to limit the choices. Press Ctrl+O a second time to include inherited methods.

Ctrl+Space

Content Assist

Context sensitive content completion suggestions while editing Java code.

Tuesday, September 7, 2010

TOO LATE

EVERY TIME, IT IS TOO LATE WHEN YOU SLEEP

windows netsh command

netsh interface ipv4 show interfaces

Example result:
Idx Met MTU State Name
--- --- ----- ----------- -------------------
1 50 4294967295 connected Loopback Pseudo-Interface 1
9 20 1500 connected Local Area Connection


netsh interface ipv4 show interface 9
Example result:
Interface Local Area Connection Parameters
----------------------------------------------
IfLuid : ethernet_7
IfIndex : 9
Compartment Id : 1
State : connected
Metric : 20
Link MTU : 1500 bytes
Reachable Time : 19000 ms Base Reachable Time : 30000 ms Retransmission Interval : 1000 ms
DAD Transmits : 3 Site Prefix Length : 64 Site Id : 1 Forwarding : disabled
Advertising : disabled Neighbor Discovery : enabled Neighbor Unreachability
Detecion : enabled Router Discovery : dhcp Managed Address Configuration :
enabled Other Stateful Configuration : enabled Weak Host Sends : disabled Weak
Host Receives : disabled Use Automatic Metric : enabled Ignore Default routes :
disabled

Why is there no ARP reply in the packet trace

>Hello
> I'm having a situation concerning Arp where i am seeing no Arp
>reply's to many arp requests on my network when i evaluate with a
>protocol analyzer. I think the arp traffic may be at a level where it
>is disrupting traffic on the network and nodes are dropping off as a
>result. It is a microsoft 2000/xp network running active directory.
>The sniffs show alot of whois arp traffic and i see little or no arp
>reply's with the mac address. I'm wondering what this could be due
>too. It is a flat network with 175 nodes running a class b subnet.
>Wins and Dns are configured. The workstation nodes are mixed
>win2k/xp(majority being 2k), The servers are win2k. Is this high
>amount of arp traffic(between 60 to 90 percent at a server)normal and
>if not what could i do to facilitate the arp reply's. Thanks


How is your protocol analyzer connected to the network? If you're on a
switch, it would be logical that you don't see ARP reply's.

The ARP requests are in the fowm of a broadcast, so sent to every
port. However, the reply is sent as an unicast to the host which made
the ARP request.

Unless you configured a SPAN por, you won't see this traffic on a
switched network. This would also explain why you see such a high
percentage of ARP requests: the unicast traffic isn't captured by your
protocol analyzer.


With kind regards,

Patrick

The ARP Command -s

arp -s InetAddr EtherAddr

allows you to manually add an entry to the ARP cache that resolves the IP address InetAddr to the physical address EtherAddr.