- 실버라이트 응용 프로그램의 일부를 모니터의 전체 화면으로 표시하는 기능
- 전체 화면 모드 API
    - IsFullScreen 속성
        - App.Current.Host.Content.IsFullScreen
            - true로 설정되면 전체화면으로 보여짐

- FullScreenChanged 이벤트
    - 전체화면으로 변경될 때마다 발생
    - <ScaleTransform /> 등의 요소를 사용해서 전체화면시 요소의 크기도 동적으로 변경
        - Content_Resized() 내에 아래 코드 구현
            - ScalTransform.ScaleX = App.Current.Host.Content.ActualWidth / this.Width;






'미디어파일'인 "Silverlight.wmv"파일을 복사해서 '솔루션 탐색기'에서 아래그림과 같이 붙여넣는다.











[MainPage.xaml]


<UserControl x:Class="RiaFullScreen.MainPage"

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

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

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

   

    <Grid x:Name="LayoutRoot" Background="White">

        <Grid.RowDefinitions>

            <RowDefinition Height="*" />

            <RowDefinition Height="Auto" />

        </Grid.RowDefinitions>

        <Grid.RenderTransform>

            <TransformGroup>

                <ScaleTransform x:Name="ctlGrid" ScaleX="1" ScaleY="1" />

            </TransformGroup>

        </Grid.RenderTransform>

        <MediaElement x:Name="video" Source="Silverlight.wmv" AutoPlay="True" Volume="0.5" />

        <StackPanel Grid.Row="1" Orientation="Horizontal">

            <Button x:Name="btnStart" Content="시작" />

            <Button x:Name="btnStop" Content="종료" />

            <Button x:Name="btnFullScreen" Content="전체화면" />

        </StackPanel>

    </Grid>

</UserControl>

 

 









[MainPage.xaml.cs]


using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaFullScreen

{   

    public partial class MainPage : UserControl

    {

        private bool _scale = false; //[1] 처음 로드시 일반모드 : _scale true이면 Full Screen

        public MainPage()

        {

            InitializeComponent();

 

            this.Loaded +=new RoutedEventHandler(MainPage_Loaded);

 

            // Event Handler

            btnStart.Click += new RoutedEventHandler(btnStart_Click);

            btnStop.Click += new RoutedEventHandler(btnStop_Click);

            btnFullScreen.Click += new RoutedEventHandler(btnFullScreen_Click);           

        }

 

        void  MainPage_Loaded(object sender, RoutedEventArgs e)

        {

                          if (_scale) // Full Screen 때만...

                          {

                // FullScreen 모드로 변경

                App.Current.Host.Content.FullScreenChanged +=new EventHandler(Content_FullScreenChanged);

                App.Current.Host.Content.Resized +=new EventHandler(Content_FullScreenChanged);

                          }

        }

 

        void Content_FullScreenChanged(object sender, EventArgs e)

        {

            //[2] 전체화면보기로 이동시 사이즈 조정해주는 코드 샘플

            ctlGrid.ScaleX = App.Current.Host.Content.ActualWidth / this.Width;

            ctlGrid.ScaleY = App.Current.Host.Content.ActualHeight / this.Height;

        }

 

        void btnFullScreen_Click(object sender, RoutedEventArgs e)

        {

            //[1] 실버라이트 영역을 전체화면으로 표시해주는 코드샘플 : 기본->전체, 전체->기본

            _scale = !App.Current.Host.Content.IsFullScreen;

            App.Current.Host.Content.IsFullScreen = !App.Current.Host.Content.IsFullScreen;

            if (App.Current.Host.Content.IsFullScreen)

            {

                this.btnFullScreen.Content = "전체화면 끝내기";

            }

            else

            {

                this.btnFullScreen.Content = "전체화면으로 보기";

            }

        }

 

        void btnStop_Click(object sender, RoutedEventArgs e)

        {

            video.Stop();

        }

 

        void btnStart_Click(object sender, RoutedEventArgs e)

        {

            video.Play();

        }

    }

}

 

 























Posted by holland14
: