첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Windows;

#region 시스템 매개 변수 정보 처리하기 - SystemParametersInfo(action, parameter, rectangle, update)

/// <summary>
/// 시스템 매개 변수 정보 처리하기
/// </summary>
/// <param name="action">액션</param>
/// <param name="parameter">매개 변수</param>
/// <param name="rectangle">사각형</param>
/// <param name="update">업데이트</param>
/// <returns>처리 결과</returns>
[DllImport("user32", CharSet = CharSet.Auto)]
[ResourceExposure(ResourceScope.None)]
private static extern bool SystemParametersInfo(int action, int parameter, ref RECTANGLE rectangle, int update);

#endregion

/// <summary>
/// 사각형
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct RECTANGLE
{
    //////////////////////////////////////////////////////////////////////////////////////////////////// Field
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region Field

    /// <summary>
    /// 왼쪽
    /// </summary>
    public int Left;

    /// <summary>
    /// 위쪽
    /// </summary>
    public int Top;

    /// <summary>
    /// 오른쪽
    /// </summary>
    public int Right;

    /// <summary>
    /// 아래쪽
    /// </summary>
    public int Bottom;

    #endregion

    //////////////////////////////////////////////////////////////////////////////////////////////////// Property
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 크기 - Size

    /// <summary>
    /// 크기
    /// </summary>
    public Size Size
    {
        get
        {
            return new Size
            (
                Right  - Left,
                Bottom - Top
            );
        }
    }

    #endregion

    //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
    ////////////////////////////////////////////////////////////////////////////////////////// Public

    #region 생성자 - RECTANGLE(left, top, right, bottom)

    /// <summary>
    /// 생성자
    /// </summary>
    /// <param name="left">왼쪽</param>
    /// <param name="top">위쪽</param>
    /// <param name="right">오른쪽</param>
    /// <param name="bottom">아래쪽</param>
    public RECTANGLE(int left, int top, int right, int bottom)
    {
        Left   = left;
        Top    = top;
        Right  = right;
        Bottom = bottom;
    }

    #endregion
    #region 생성자 - RECTANGLE(source)

    /// <summary>
    /// 생성자
    /// </summary>
    /// <param name="source">소스 사각형</param>
    public RECTANGLE(Rect source)
    {
        Left   = (int)source.Left;
        Top    = (int)source.Top;
        Right  = (int)source.Right;
        Bottom = (int)source.Bottom;
    }

    #endregion

    //////////////////////////////////////////////////////////////////////////////////////////////////// Method
    ////////////////////////////////////////////////////////////////////////////////////////// Static
    //////////////////////////////////////////////////////////////////////////////// Public

    #region 사각형 구하기 - GetRectangle(x, y, width, height)

    /// <summary>
    /// 사각형 구하기
    /// </summary>
    /// <param name="x">X</param>
    /// <param name="y">Y</param>
    /// <param name="width">너비</param>
    /// <param name="height">높이</param>
    /// <returns>사각형</returns>
    public static RECTANGLE GetRectangle(int x, int y, int width, int height)
    {
        return new RECTANGLE(x, y, x + width, y + height);
    }

    #endregion
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요