Posted
Filed under C#
[원문]http://www.dotnetspider.com/resources/5478-How-Show-Network-Traffic-using-C-dot.aspx



private static void ShowNetworkTraffic()
{
    PerformanceCounterCategory performanceCounterCategory = new PerformanceCounterCategory("Network Interface");
    string instance = performanceCounterCategory.GetInstanceNames()[0]; // 1st NIC !
    PerformanceCounter performanceCounterSent = new PerformanceCounter("Network Interface", "Bytes Sent/sec", instance);
    PerformanceCounter performanceCounterReceived = new PerformanceCounter("Network Interface", "Bytes Received/sec", instance);

    for (int i = 0; i < 10; i++)
    {
        Console.WriteLine("bytes sent: {0}k\tbytes received: {1}k", performanceCounterSent.NextValue() / 1024, performanceCounterReceived.NextValue() / 1024);
        Thread.Sleep(500);
    }
}
2012/07/10 10:19 2012/07/10 10:19
Posted
Filed under C#
    private static void killps(string processName)
        {
            Process[] process = Process.GetProcessesByName(processName);
            Process currentProcess = Process.GetCurrentProcess();
            foreach (Process p in process)
            {
                if (p.Id != currentProcess.Id)
                    p.Kill();
            }
        }
2011/11/25 13:07 2011/11/25 13:07
Posted
Filed under C#
Process.Start (@"C:\Program Files\");
2011/11/25 13:06 2011/11/25 13:06
Posted
Filed under C#

[출처]- http://dragonwind.egloos.com/4849313

1. ASP.net 1.0 기준으로 web form 에서 이미지를 합쳐서 저장하기.
---------------------------------------------------------------------------
Bitmap bmap = new Bitmap(100, 100);
Graphics g = Graphics.FromImage(bmap);

System.Drawing.Image img = Bitmap.FromFile("d:\\hoonslogo.gif");
System.Drawing.Image img2 = Bitmap.FromFile("d:\\btn_individual.gif");

g.DrawImage(img, 0, 0);
g.DrawImage(img2, 50, 50);

bmap.Save("d:\\MyTest.gif", System.Drawing.Imaging.ImageFormat.Jpeg);
---------------------------------------------------------------------------

http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=17&MAEULNo=8&no=49092&ref=49092

2. win form 에서 이미지 합치고, picturebox 에 쓰기
---------------------------------------------------------------------------
        private void menuItem2_Click(object sender, System.EventArgs e)
        {
            //select files...
            openFileDialog1.ShowDialog();          

            if( openFileDialog1.FileNames.Length > 0 )
            {
                Bitmap canvas = new Bitmap(50,50*openFileDialog1.FileNames.Length);
                int index = 0;
                System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(canvas);
                foreach( string filename in openFileDialog1.FileNames )
                {
                    System.Drawing.Image img = System.Drawing.Image.FromFile(filename);
                    g.DrawImage(img,0,50*index,50,50);
                    index++;
                }          

                Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(thumbnailCallback);

                pictureBox1.Image = canvas.GetThumbnailImage(50,50*openFileDialog1.FileNames.Length,myCallback,IntPtr.Zero);

                canvas.Save("temp.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
            }          
        }

        public bool thumbnailCallback()
        {
            return false;
        }


2010/10/08 15:45 2010/10/08 15:45
Posted
Filed under C#
[원문] - http://firstpolaris.tistory.com/?page=7

private
string[] ArrayDistinct(string[] source)

        {

            // generic버전

            //List<string> temp = new List<string>();

            //temp.AddRange(source);

            //IEnumerable<string> distinct = temp.Distinct();

            //return distinct.ToArray<string>();

 

            // .. 버전

            string destination = string.Empty;//임시 필드

            // 중복제거

            for (int i = 0; i < source.Length; i++)

            {

                for (int j = 0; j < source.Length; j++)

                {

                    if (source[i] == source[j] && i != j) source[j] = string.Empty;

                }

            }

 

            // ,를 구분자로 문자열 생성

            for (int i = 0; i < source.Length; i++)

            {

                if (!source[i].Equals(string.Empty)) destination += source[i] + ",";

            }

 

            // 마지막에 붙은 ,하나 제거

            destination = destination.Substring(0, destination.Length - 1);


            return destination.Split(',');

 

        }

2010/10/08 15:43 2010/10/08 15:43
Posted
Filed under C#

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

Use SendKeys to send keystrokes and keystroke combinations to the active application. This class cannot be instantiated. To send a keystroke to a class and immediately continue with the flow of your program, use Send. To wait for any processes started by the keystroke, use SendWait.

Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter A, pass in the string "A" to the method. To represent more than one character, append each additional character to the one preceding it. To represent the letters A, B, and C, specify the parameter as "ABC".

The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses () have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use "{+}". To specify brace characters, use "{{}" and "{}}". Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that might be significant when dynamic data exchange (DDE) occurs.

To specify characters that aren't displayed when you press a key, such as ENTER or TAB, and keys that represent actions rather than characters, use the codes in the following table.

Key Code
BACKSPACE {BACKSPACE}, {BS}, or {BKSP}
BREAK {BREAK}
CAPS LOCK {CAPSLOCK}
DEL or DELETE {DELETE} or {DEL}
DOWN ARROW {DOWN}
END {END}
ENTER {ENTER}or ~
ESC {ESC}
HELP {HELP}
HOME {HOME}
INS or INSERT {INSERT} or {INS}
LEFT ARROW {LEFT}
NUM LOCK {NUMLOCK}
PAGE DOWN {PGDN}
PAGE UP {PGUP}
PRINT SCREEN {PRTSC} (reserved for future use)
RIGHT ARROW {RIGHT}
SCROLL LOCK {SCROLLLOCK}
TAB {TAB}
UP ARROW {UP}
F1 {F1}
F2 {F2}
F3 {F3}
F4 {F4}
F5 {F5}
F6 {F6}
F7 {F7}
F8 {F8}
F9 {F9}
F10 {F10}
F11 {F11}
F12 {F12}
F13 {F13}
F14 {F14}
F15 {F15}
F16 {F16}
Keypad add {ADD}
Keypad subtract {SUBTRACT}
Keypad multiply {MULTIPLY}
Keypad divide {DIVIDE}

To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes.

Key Code
SHIFT +
CTRL ^
ALT %

To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify to hold down SHIFT while E and C are pressed, use "+(EC)". To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use "+EC".

To specify repeating keys, use the form {key number}. You must put a space between key and number. For example, {LEFT 42} means press the LEFT ARROW key 42 times; {h 10} means press H 10 times.

Note   Because there is no managed method to activate another application, you can either use this class within the current application or use native Windows methods, such as FindWindow and SetForegroundWindow, to force focus on other applications.


// Clicking Button1 causes a message box to appear.
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        MessageBox.Show("Click here!");
    }


    // Use the SendKeys.Send method to trigger the Button1 click event
    // and display the message box.
    private void Form1_DoubleClick(object sender, System.EventArgs e)
    {

        // Send the enter key; since the tab stop of Button1 is 0, this
        // will trigger the click event.
        SendKeys.Send("{ENTER}");
    }
2010/07/13 23:04 2010/07/13 23:04
Posted
Filed under C#
모든 페이지가 로딩 한 시점을 잡아 내기 위해서 다음과 같이 처리 한다.
프레임에 프레임이 들어 있는 페이지 같으 경우 다음과 같이 처리 하지 않는다면, 브라우저가 로딩 되어지는 정확한 시점을 찾아 낼 수 없다.

페이지 스크립팅 할 때 유용하게 이용할 수 있을거 같다.

if (browser.ReadyState == WebBrowserReadyState.Complete{
                //TODO 내용 구현
}
2010/06/09 20:45 2010/06/09 20:45
Posted
Filed under C#
1. Microsoft.JScript 어셈블리를 참조한다.
2.
  escape    => Microsoft.JScript.GlobalObject.escape("바꿀 문자열");
  unescape => Microsoft.JScript.GlobalObject.unescape("바꿀 문자열");

2010/05/25 02:15 2010/05/25 02:15
Posted
Filed under C#
사용자 삽입 이미지





















System.Diagnostics.Process.Start("shutdown.exe","-s");
optionr값 은 보고 적당히 설정 하면 된다.
2010/04/09 20:14 2010/04/09 20:14