2015년 8월 7일 금요일

[ C# ] flowlayoutpanel 동적 할당

•for (int i = 0; i < 5; i++) { Button button = new Button(); button.Tag = i; flowLayoutPanel1.Controls.Add(button); }

[ C# ] 폼의 투명도 설정

•this.Opacity = 0.75;

[ C# ] 폼의 종료 버튼을 무효

•protected override System.Windows.Forms.CreateParams CreateParams { get { const int CS_NOCLOSE = 0x200; System.Windows.Forms.CreateParams createParams = base.CreateParams; createParams.ClassStyle |= CS_NOCLOSE; return createParams; } }

[ C# ] 폼을 시스템 메뉴에 표시 않하기

•this.ControlBox = false;

[ C# ] 폼을 Task Bar에 표시 않하기

•this.ShowInTaskbar = false;

[ C# ] 폼 사이즈 변경 불가

•this.FormBorderStyle = FormBorderStyle.FixedSingle;

[ C# ] 폼의 경계선 스타일 변경

•// 크기 변경 불가로 테두리가없는 창
•     this.FormBorderStyle = FormBorderStyle.None;
•
•     // 크기 변경 불가 직선 창
•     this.FormBorderStyle = FormBorderStyle.FixedSingle;
•
•     // 크기 변경 불가의 3D 창
•     this.FormBorderStyle = FormBorderStyle.Fixed3D;
•
•     // 크기 변경 불가 직선 대화
•     this.FormBorderStyle = FormBorderStyle.FixedDialog;
•
•     // 크기 변경 가능한 일반 창 (기본)
•     this.FormBorderStyle = FormBorderStyle.Sizable;
•
•     // 크기 변경 불가의 도구 창
•     this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
•
•     // 크기 변경 가능한 도구 창

•     this.FormBorderStyle = FormBorderStyle.SizableToolWindow;

[ C# ] 폼의 초기 표시 위치를 변경

•// Form1의 새로운 인스턴스를 생성하는
•     Form1 cForm1 = new Form1 ();
•
•     // 폼의 Location 속성에 의해 결정됩니다 (초기 값)
•     cForm1.StartPosition = FormStartPosition.Manual;
•
•     // 화면의 중앙에 표시됩니다
•     cForm1.StartPosition = FormStartPosition.CenterScreen;
•
•     // Windows의 규정 위치에 표시됩니다
•     cForm1.StartPosition = FormStartPosition.WindowsDefaultLocation;
•
•     // Windows의 규정 위치에 표시되며 크기가 설정된 크기로 변경됩니다
•     cForm1.StartPosition = FormStartPosition.WindowsDefaultBounds;
•
•     // 부모 폼의 중앙에 표시됩니다
•     cForm1.StartPosition = FormStartPosition.CenterParent;
•
•     // cForm1보기

•     cForm1.Show ()

[ C# ] 폼의 좌표를 데스크톱의 좌표로 변경

•// 폼의 위치를 데스크톱 좌표 X = 64, Y = 32로 변경
•     this.SetDesktopLocation (64, 32);
•
•     // DesktopLocation 속성을 직접 수정하여도 좋다
•     this.DesktopLocation = new Point (64, 32);
•
•     // 동시에 크기도 변경하려면
•     this.SetDesktopBounds (64, 32, 512, 256);
•
•     // DesktopBounds 속성을 직접 수정하여도 좋다

•     this.DesktopBounds = new Rectangle (64, 32, 512, 256);

[ C# ] 폼이 최대화 되었을 때 위치와 사이즈 조절

•// 최대화했을 때 위치를 X = 32, Y = 16에 크기를 512 x 256로 설정
•     this.MaximizedBounds = new Rectangle (32, 16, 512, 256);
•
•     // Point 구조체와 Size 구조체로 지정하여도 좋다

•     this.MaximizedBounds = new Rectangle (new Point (32, 16), new Size (515, 256));

[ C# ] 폼의 최소 사이즈 설정

•this.MinimumSize = new System.Drawing.Size(256, 128);

[ C# ] 폼의 최대 사이즈 설정

•this.MaximumSize = new System.Drawing.Size(1024, 512);

[ C# ] 폼의 최소화 버튼을 무효화

•this.MinimizeBox = false

[ C# ] 폼을 최소 크기로

•this.WindowState = FormWindowState.Minimized;

[ C# ] 폼을 최대크기로

•this.WindowState = FormWindowState.Maximized;

[ C# ] 폼의 최대화 버튼 무효화 하기

•this.MaximizeBox = false;

[ C# ] 지정한 문자열에 포함되는 값 가져 오기 (Val)

•public sealed class Validation {
•
•  #region Val 메소드 (+2)
•
•    /// ----------------------------------------------- ------------------------------
•    /// <summary>
•    /// 지정된 문자열에 포함 된 숫자를 변환하여 반환합니다. </ summary>
•    /// <param name = "stTarget">
•    /// 유효한 문자열. </ param>
•    /// <returns>
•    /// 지정된 문자열에 포함 된 숫자. </ returns>
•    /// ----------------------------------------------- ------------------------------
•    public static double Val (string stTarget) {
•        // Null 값의 경우는 0을 반환
•        if (stTarget == null) {
•            return 0D;
•        }
•
•        int iCurrent = 0;
•        int iLength = stTarget.Length;
•
•        // 평가되지 않는 문자 건너 뛰기
•        for (iCurrent = 0; iCurrent <iLength; iCurrent ++) {
•            char chOne = stTarget [iCurrent];
•
•            if ((chOne! = '') && (chOne! = '') && (chOne! = '\ t') && (chOne! = '\ n') && (chOne! = '\ r')) {
•                break;
•            }
•        }
•
•        // 종료까지 유효한 문자가 발견되지 않았던 경우는 0을 반환
•        if (iCurrent> = iLength) {
•            return 0D;
•        }
•
•        bool bMinus = false;
•
•        // 맨 위에있는 부호를 판정
•        switch (stTarget [iCurrent]) {
•            case '-':
•                bMinus = true;
•                iCurrent ++;
•                break;
•            case + ':
•                iCurrent ++;
•                break;
•        }
•
•        int ValidLength = 0;
•        int Priod = 0;
•        double dReturn = 0D;
•        bool bDecimal = false;
•        bool bShisuMark = false;
•
•        // 1 문자 씩 유효한 문자 여부 판정
•        while (iCurrent <iLength) {
•            char chCurrent = stTarget [iCurrent];
•
•            if ((chCurrent == '') || (chCurrent == '') || (chCurrent == '\ t') || (chCurrent == '\ n') || (chCurrent == '\ r' )) {
•                iCurrent ++;
•            } else if (chCurrent == '0') {
•                iCurrent ++;
•
•                if ((iValidLength! = 0) || bDecimal) {
•                    iValidLength ++;
•                    dReturn = (dReturn * 10) + double.Parse (chCurrent.ToString ());
•                }
•            } else if ((chCurrent> = '1') && (chCurrent <= '9')) {
•                iCurrent ++;
•                iValidLength ++;
•                dReturn = (dReturn * 10) + double.Parse (chCurrent.ToString ());
•            } else if (chCurrent == '') {
•                iCurrent ++;
•
•                if (bDecimal) {
•                    break;
•                }
•
•                bDecimal = true;
•                iPriod = iValidLength;
•            } else if ((chCurrent == 'e') || (chCurrent == 'E') || (chCurrent == 'd') || (chCurrent == 'D')) {
•                bShisuMark = true;
•                iCurrent ++;
•                break;
•            } else {
•                break;
•            }
•        }
•
•        int iDecimal = 0;
•
•        // 소수점이 판정 된 경우
•        if (bDecimal) {
•            iDecimal = iValidLength - iPriod;
•        }
•
•        // 지수가 판정 된 경우
•        if (bShisuMark) {
•            bool bShisuValid = false;
•            bool bShisuMinus = false;
•            double dCoef = 0D;
•
•            // 지수를 확인하는
•            while (iCurrent <iLength) {
•                char chCurrent = stTarget [iCurrent];
•
•                if ((chCurrent == '') || (chCurrent == '') || (chCurrent == '\ t') || (chCurrent == '\ n') || (chCurrent == '\ r' )) {
•                    iCurrent ++;
•                } else if ((chCurrent> = '0') && (chCurrent <= '9')) {
•                    dCoef = (dCoef * 10) + double.Parse (chCurrent.ToString ());
•                    iCurrent ++;
•                } else if (chCurrent == + ') {
•                    if (bShisuValid) {
•                        break;
•                    }
•
•                    ShisuValid = true;
•                    iCurrent ++;
•                } else if ((chCurrent! = '-') || bShisuValid) {
•                    break;
•                } else {
•                    bShisuValid = true;
•                    bShisuMinus = true;
•                    iCurrent ++;
•                }
•            }
•
•            // 지수의 부호에 따라 거듭 제곱하는
•            if (bShisuMinus) {
•                dCoef + = iDecimal;
•                dReturn * = System.Math.Pow (10 - dCoef);
•            } else {
•                dCoef - = iDecimal;
•                dReturn * = System.Math.Pow (10, dCoef);
•            }
•        } else if (bDecimal && (iDecimal! = 0)) {
•            dReturn / = System.Math.Pow (10, iDecimal);
•        }
•
•        // 무한대의 경우는 0을 반환
•        if (double.IsInfinity (dReturn)) {
•            return 0D;
•        }
•
•        // 마이너스 판정의 경우는 마이너스로 반환
•        if (bMinus) {
•            return -dReturn;
•        }
•
•        return dReturn;
•    }
•
•
•    /// ----------------------------------------------- ------------------------------
•    /// <summary>
•    /// 지정된 문자에 포함 된 숫자를 변환하여 반환합니다. </ summary>
•    /// <param name = "chTarget">
•    /// 유효한 문자. </ param>
•    /// <returns>
•    /// 지정된 문자에 포함 된 수치. </ returns>
•    /// ----------------------------------------------- ------------------------------
•    public static int Val (char chTarget) {
•        return (int) Val (chTarget.ToString ());
•    }
•
•
•    /// ----------------------------------------------- ------------------------------
•    /// <summary>
•    /// 지정된 개체에 포함 된 숫자를 변환하여 반환합니다. </ summary>
•    /// <param name = "oTarget">
•    /// 유효한 오브젝트. </ param>
•    /// <returns>
•    /// 지정된 개체에 포함 된 수치. </ returns>
•    /// ----------------------------------------------- ------------------------------
•    public static double Val (object oTarget) {
•        if (oTarget! = null) {
•            return Val (oTarget.ToString ());
•        }
•
•        return 0D;
•    }
•
•  #endregion
•

•}