WP7 Silverlight기반 프로젝트에서 전체화면 페이지를 구성하려면 아래와 같이 상단 트레이와 하단 어플리케이션바를 없애주면 됩니다.
SystemTray.IsVisible = false;
this.ApplicationBar.IsVisible = false;

저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume
아래 코드는 TransformToVisual을 이용해서 현재 페이지 기준으로 특정 Element의 위치를 구하는 코드입니다.
// Obtain transform information based off root element
GeneralTransform gt = element.TransformToVisual(Application.Current.RootVisual);

// Find the four corners of the element
Point topLeft = gt.Transform(new Point(0, 0));
Point topRight = gt.Transform(new Point(element.RenderSize.Width, 0));
Point bottomLeft = gt.Transform(new Point(0, element.RenderSize.Height));
Point bottomRight = gt.Transform(new Point(element.RenderSize.Width, element.RenderSize.Height));

아래는 참고한 사이트입니다~
저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume

Popup클래스에 Orientation을 지원하기 위해서는 2가지 방법이 있는데 첫번째 방법은 Popup을 xaml코드를 이용해서 visual tree에 넣는 방법이고, 두번째 방법은 Behind Code에서 RotateTransform을 이용해서 직접 회전시켜 주는 방법입니다.

첫번째 방법인 xaml을 이용하는 방법은 Panel 컨트롤 등 아래에 Popup을 넣는 방법으로 이렇게 해주면 Orientation이 알아서 적용되고, Popup이 띄워질 위치의 기준은 Panel컨트롤이 됩니다.

아래는 xaml코드의 일부로 Popup안에 Button을 하나 올려놓고, 해당 Popup은 ContentPanel(Grid control) 기준으로 50*50 위치에 팝업되어서 나타납니다.

    
        
    


두번째 방법인 RotateTransform을 이용하는 방법은 Landscape 상태일떄 Popup을 각각 90, -90도 돌려주고, 그에 맞게 VerticalOffset과 HorizontalOffset을 음수 좌표로 변경해줘야합니다.

아래는 Behind code의 일부로 Popup을 전체화면 기준으로 300*300에 팝업되도록 할 때 Orientation이 LandscapeLeft일때 Popup을 설정하는 코드입니다. RotateTransform을 이용해서 90도로 변경하고, VerticalOffset을 음수좌표로 변경하는 코드로 이때 480은 (Landscape기준)화면의 세로 길이입니다.
RotateTransform transform = new RotateTransform();
transform.Angle = 90d;
popup.RenderTransform = transform;

popup.VerticalOffset = 300 - 480;
popup.HorizontalOffset = 300;

아래는 샘플 프로그램의 캡쳐화면이고, 전체소스는 첨부파일에 있습니다~
Portrait

Portrait

LandscapeLeft

LandscapeLeft

LandscapeRight

LandscapeRight



아래는 참고한 사이트입니다~
저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume
Windows Phone 7의 Orientation을 PortraitOrLandscape로 설정했다면 현재의 Orientation을 얻어오거나 Orientation이 변경되는 시점을 알아야할 때가 있습니다.

현재의 Orientation을 얻어오려면 PhoneApplicationPage.Orientation Property를 사용하면 되고, Orientation이 변경되는 시점을 알고 싶으면 PhoneApplicationPage.OrientationChanged Event를 등록해서 사용하면 됩니다.

아래는 샘플코드이고 둘다 PageOrientation enum값을 사용합니다.

public partial class MainPage : PhoneApplicationPage
{
    public MainPage()
    {
        InitializeComponent();

        //Add EventHandler
        this.OrientationChanged += new EventHandler(MainPage_OrientationChanged);
    }

    void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
    {
        PageOrientation orientation = e.Orientation;
        //Check current orientation
        if ((orientation & PageOrientation.Portrait) == (PageOrientation.Portrait))
        {
            // Portrait
        }
        else
        {
            // Landscape
        }
    }

    PageOrientation GetCurrentOrientation()
    {
        return this.Orientation;
    }
}

Orientation에 대한 자세한 정보는 아래 MSDN을 참고하세요~
저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume
Windows Phone 7에서는 세로모드(portrait)와 가로모드(landscape)를 지원하는데 기본적으로는 portrait모드로 설정되어있습니다.

이 Orientation은 페이지별로 설정가능하며 xaml과 Behind code에서 SupportedOrientations 값을 이용해서 설정할 수 있으며 설정될 수 있는 값은 각각 Portrait, LandscapePortraitOrLandscape입니다.

아래 코드는 각각 xaml과 Behind code(C#)를 이용해서 프로그램에서 지원할 Orientation을 설정하는 코드입니다.

//xaml
SupportedOrientations="Portrait"
SupportedOrientations="Landscape"
SupportedOrientations="PortraitOrLandscape"

//Behind code(C#)
this.SupportedOrientations = SupportedPageOrientation.Portrait;
this.SupportedOrientations = SupportedPageOrientation.Landscape;
this.SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume
아래는 wav파일을 재생하는 코드입니다.

우선 VisualStudio의 솔루션 탐색기를 통해서 "Microsoft.Xna.Framework" 어셈블리를 참조합니다.

재생시킬 wav파일은 프로젝트에 추가후에 content로 설정하고, 아래 코드에 있는OpenStream()의 매개변수로 파일명을 설정해줍니다.
var stream = TitleContainer.OpenStream("FileName.wav");
var effect = SoundEffect.FromStream(stream);
FrameworkDispatcher.Update();
effect.Play();

아래는 참고한 사이트입니다~
저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume
TAG Sound, wav
Windows Phone 7에는 현재 Dark/Light 이렇게 2개의 테마가 있는데 아래 코드는 이 2개의 테마를 구분하는 다양한 코드입니다.
// Use PhoneDarkThemeVisibility
Visibility visibilityDark = (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"];
if (visibilityDark == Visibility.Visible)
{
    // Dark theme
}
else if (visibilityDark == Visibility.Collapsed)
{
    // Light theme
}

// Use PhoneLightThemeVisibility
Visibility visibilityLight = (Visibility)Application.Current.Resources["PhoneLightThemeVisibility"];
if (visibilityLight == Visibility.Collapsed)
{
    // Dark theme
}
else if (visibilityLight == Visibility.Visible)
{
    // Light theme
}

// Use PhoneLightThemeOpacity
double opacityDark = (double)Application.Current.Resources["PhoneDarkThemeOpacity"];
if (opacityDark == 1.0)
{
    // Dark theme
}
else if (opacityDark == 0.0)
{
    // Light theme
}

// Use PhoneLightThemeOpacity
double opacityLight = (double)Application.Current.Resources["PhoneLightThemeOpacity"];
if (opacityLight == 0.0)
{
    // Dark theme
}
else if (opacityLight == 1.0)
{
    // Light theme
}

// Use PhoneForegroundColor
Color colorForeground = (Color)Application.Current.Resources["PhoneForegroundColor"];
if (colorForeground.ToString() == "#FFFFFFFF")
{
    // Dark theme
}
else if (colorForeground.ToString() == "#DE000000")
{
    // Light theme
}

// Use PhoneBackgroundColor
Color colorBackground = (Color)Application.Current.Resources["PhoneBackgroundColor"];
if (colorBackground.ToString() == "#FF000000")
{
    // Dark theme
}
else if (colorBackground.ToString() == "#FFFFFFFF")
{
    // Light theme
}

저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume
TAG Dark, light, theme
Windows Phone 7의 Theme는 Dark/Light 2개의 Background를 설정할 수 있고, 10개의 Accent color를 설정할 수 있습니다.

아래는 위의 값들을 얻어오는 방법과 각 값의 ARGB 색상정보입니다.

//Get background color
Color themeBackColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];

//Get foreground color
Color themeForeColor = (Color)Application.Current.Resources["PhoneForegroundColor"];

//Get accent color
Color accentColor = (Color)Application.Current.Resources["PhoneAccentColor"];

Dark/Light theme에 따른 Background/Foreground 색상 정보
 Theme 종류  Background ARGB  Foreground ARGB
 Dark  #FF000000  #FFFFFFFF
 Light  #FFFFFFFF  #DE000000

Accent 색상 정보
 Accent color  ARGB
 magenta  #FFFF0097
 purple  #FFA200FF
 teal  #FF00ABA9
 lime  #FF8CBF26
 brown  #FFA05000
 pink  #FFE671B8
 orange  #FFF09609
 blue  #FF1BA1E2
 red  #FFE51400
 green  #FF339933


저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume
Windows Phone 7 에뮬레이터에서 글씨를 입력하려면 기본적으로 SIP(Soft Input Panel)가 사용됩니다.

기존 Windows Mobile 6.5 에뮬레이터까지는 SIP와 상관없이 컴퓨터의 키보드를 이용해서 입력이 가능했는데 Windows Phone 7 에뮬레이터에서는 SIP 입력과 컴퓨터 키보드 입력이 토글로 설정됩니다.

SIP와 키보드간 토글은 Pause/Break키를 누를 때마다 변경됩니다. 즉, SIP가 뜬 상태에서 Pause/Break키를 누르면 SIP가 내려가는데 이때는 키보드를 이용해서 입력이 가능합니다.
( Pause/Break키 말고도 Page Up/Down 키를 이용해서 키보드를 On/Off 시킬 수 있습니다.)

키보드 입력 이외에 에뮬레이터에서 사용가능한 주요 키보드 키는 아래와 같습니다.
F1, F2, F3 : Windows Phone 7의 주요 하드웨어 키로서 각각 Back, Start, Search와 맵핑.
F7 : Camera 실행.
F9, F10 : Volume Up/Down

위에 언급한 것 이외에 다른 키와 자세한 정보는 아래 사이트에서 확인 가능합니다.

Keyboard Mapping for Windows Phone Emulator

Windows Phone 7 Emulator tips and tricks - Shortcut keys
저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume
Windows Phone Developer Tools Beta를 설치하면 같이 설치되는 express 버전에서 개발을 하거나, vs2010 영문판을 이미 설치했다면 프로젝트 템플릿이 생성되므로 그것을 이용해서 개발이 가능합니다.

하지만 기본적으로 vs2010 한글판을 설치한 경우에는 Windows Phone Developer Tools Beta를 설치해도 템플릿이 나오지 않는데 아래 방법을 이용하면 vs2010 한글판에서도 Windows Phone 7 Beta 개발을 수행할 수 있습니다.
(아래에서 설명한 경로는 Windows 7 64bit에서 기본 설치경로로 설치했다는 가정하에서 설명합니다.)

1. 프로젝트 템플릿 생성
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Silverlight for Windows Phone\
위의 경로에 가시면 1033 이라는 폴더가 있는데 이것을 그대로 복사해서 폴더명을 1042로 변경합니다.

2. 아이템 템플릿 생성
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Silverlight for Windows Phone
위의 경로에 가시면 1033 이라는 폴더가 있는데 이것을 그대로 복사해서 폴더명을 1042로 변경합니다.

3. "시작 -> 모든 프로그램 -> Microsoft Visual Studio 2010 -> Visual Studio Tools -> Visual Studio 명령 프롬프트(2010)"를 실행 하면 나오는 명령 프롬프트 창에서 아래 2줄의 명령어 입력.
devenv.exe /installvstemplates 
devenv.exe /setup 

4. 실행했던 명령 프롬프트 종료 후에 Visual Studio 2010 한글판을 실행하면 아래 화면과 같이 템플릿이 추가된 것을 볼 수 있습니다.

ProjectTemplates

ProjectTemplates


ItemTemplates

ItemTemplates



저작자 표시 비영리
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Gungume