■ DisplayInformation 클래스 : 디스플레이 정보 구하기

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


TestProject.zip


MainPage.xaml

 

 

<Page x:Class="TestProject.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"

    FontFamily="나눔고딕코딩"

    FontSize="16">

    <Grid>

        <Grid Name="grid"

            HorizontalAlignment="Center"

            VerticalAlignment="Center">

            <Grid.ColumnDefinitions>

                <ColumnDefinition Width="Auto" />

                <ColumnDefinition Width="Auto" />

            </Grid.ColumnDefinitions>

        </Grid>

    </Grid>

</Page>

 

 

MainPage.xaml.cs

 

 

using Windows.Graphics.Display;

using Windows.UI.Xaml;

using Windows.UI.Xaml.Controls;

 

namespace TestProject

{

    /// <summary>

    /// 메인 페이지

    /// </summary>

    public sealed partial class MainPage : Page

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainPage()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainPage()

        {

            InitializeComponent();

 

            DisplayInformation displayInformation = DisplayInformation.GetForCurrentView();

 

            AddRow(this.grid, "CurrentOrientation"     , displayInformation.CurrentOrientation     );

            AddRow(this.grid, "DiagonalSizeInInches"   , displayInformation.DiagonalSizeInInches   );

            AddRow(this.grid, "LogicalDpi"             , displayInformation.LogicalDpi             );

            AddRow(this.grid, "NativeOrientation"      , displayInformation.NativeOrientation      );

            AddRow(this.grid, "RawDpiX"                , displayInformation.RawDpiX                );

            AddRow(this.grid, "RawDpiY"                , displayInformation.RawDpiY                );

            AddRow(this.grid, "RawPixelsPerViewPixel"  , displayInformation.RawPixelsPerViewPixel  );

            AddRow(this.grid, "ResolutionScale"        , displayInformation.ResolutionScale        );

            AddRow(this.grid, "ScreenHeightInRawPixels", displayInformation.ScreenHeightInRawPixels);

            AddRow(this.grid, "ScreenWidthInRawPixels" , displayInformation.ScreenWidthInRawPixels );

            AddRow(this.grid, "StereoEnabled"          , displayInformation.StereoEnabled          );

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Private

 

        #region 행 추가하기 - AddRow(grid, caption, value)

 

        /// <summary>

        /// 행 추가하기

        /// </summary>

        /// <param name="grid">그리드</param>

        /// <param name="caption">제목</param>

        /// <param name="value"></param>

        private void AddRow(Grid grid, string caption, object value)

        {

            grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });

 

            int rowIndex = grid.RowDefinitions.Count - 1;

 

            TextBlock textBlock = new TextBlock();

 

            textBlock.Margin              = new Thickness(0, 1, 10, 1);

            textBlock.HorizontalAlignment = HorizontalAlignment.Right;

            textBlock.VerticalAlignment   = VerticalAlignment.Center;

 

            textBlock.Text = caption;

 

            grid.Children.Add(textBlock);

 

            Grid.SetRow   (textBlock, rowIndex);

            Grid.SetColumn(textBlock, 0       );

 

            TextBox textBox = new TextBox();

 

            textBox.Margin              = new Thickness(0, 1, 0, 1);

            textBox.HorizontalAlignment = HorizontalAlignment.Left;

            textBox.VerticalAlignment   = VerticalAlignment.Center;

 

 

            textBox.Text = value.ToString();

 

            grid.Children.Add(textBox);

 

            Grid.SetRow   (textBox, rowIndex);

            Grid.SetColumn(textBox, 1       );

        }

 

        #endregion

    }

}

 

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

Posted by 사용자 icodebroker

댓글을 달아 주세요