8. Windows 8 のアプリ
デスクトップ アプリ Windows ストア アプリ
Windows 8 • 従来通り • 全画面
x86/x64 Win32 API • 新 API “WinRT”
• .NET • C#/VB+XAML
• Silverlight • JavaScript+HTML5
• ほとんどそのまま動作 • C++ + XAMLで
ネイティブ アプリも可
• Windows Store で配布 (原則)
Windows RT × • 審査あり
ARM
VSUG DAY 2012 Winter 2012.12.15
23. 2. Bing Map を使ってみよう
VSUG DAY 2012 Winter 2012.12.15
24. Bing Maps SDK for Windows Store apps
http://visualstudiogallery.msdn.microsoft.com/bb764f67-6b2c-4e14-b2d3-
17477ae1eaca
VSUG DAY 2012 Winter 2012.12.15
25. Bing Maps SDK for Windows Store apps
既存のアプリに NuGet で入れることも出来る
VSUG DAY 2012 Winter 2012.12.15
26. Bing Maps Account Center
http://www.bingmapsportal.com
VSUG DAY 2012 Winter 2012.12.15
49. コードビハインド – C#
public class Book
{
string title = string.Empty;
public string Title { get { return title; } set { title = value; } }
public bool IsValid {
get { return !string.IsNullOrWhiteSpace(Title) && Price >= 0; }
}
public override string ToString() { return Title; }
}
VSUG DAY 2012 Winter 2012.12.15
50. コードビハインド – C#
public sealed partial class BookPage : Page
{
Book book = new Book();
public BookPage()
{
InitializeComponent();
titleTextBox.Text = book.Title;
bookTextBlock.Text = book.ToString();
}
void titleTextBox_LostFocus(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
book.Title = titleTextBox.Text;
titleTextBox.Text = book.Title;
bookTextBlock.Text = book.ToString();
addButton.IsEnabled = book.IsValid;
}
}
VSUG DAY 2012 Winter 2012.12.15
51. ViewModel – C#
public class Book : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
string title = string.Empty;
public string Title {
get { return title; }
set {
if (value != title) {
title = value;
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("Title"));
}
}
}
public bool IsValid { get { return !string.IsNullOrWhiteSpace(Title) && Price >= 0; } }
public AddBookCommand AddBook { get { return new AddBookCommand(this); }}
public override string ToString() { return Title; }
} VSUG DAY 2012 Winter 2012.12.15
52. ViewModel – C#
public class AddBookCommand : ICommand
{
public event EventHandler CanExecuteChanged;
readonly Book book;
public AddBookCommand(Book book)
{
this.book = book;
book.PropertyChanged += delegate {
if (CanExecuteChanged != null)
CanExecuteChanged(this, EventArgs.Empty);
};
}
public bool CanExecute(object parameter)
{
return book.IsValid;
}
} VSUG DAY 2012 Winter 2012.12.15
54. ViewModel その2 – C#
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged<PropertyType>(
Expression<Func<PropertyType>> propertyExpression)
{
var propertyName = ((MemberExpression)propertyExpression.Body).Member.Name;
RaisePropertyChanged(propertyName);
}
void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
VSUG DAY 2012 Winter 2012.12.15
55. ViewModel その2 – C#
public class Book : ViewModelBase
{
// public event PropertyChangedEventHandler PropertyChanged;
string title = string.Empty;
public string Title {
get { return title; }
set {
if (value != title) {
title = value;
//if (PropertyChanged != null)
// PropertyChanged(this, new PropertyChangedEventArgs("Title"));
RaisePropertyChanged(() => Title);
}
}
}
public bool IsValid { get { return !string.IsNullOrWhiteSpace(Title) && Price >= 0; } }
public AddBookCommand AddBook { get { return new AddBookCommand(this); }}
public override string ToString() { return Title; }
} VSUG DAY 2012 Winter 2012.12.15
59. 単体テスト
[TestClass]
public class UnitTest1
{
Book book;
AddBookCommand addCommand;
[TestInitialize]
public void Setup()
{
book = new Book();
addCommand = new AddBookCommand(book);
}
VSUG DAY 2012 Winter 2012.12.15
68. ポータブル ライブラリ
class Super { }
class Sub : Super
{
public int Number { get; set; }
public string Name { get; set; }
}
class Program
{
static void Main()
{
var sub = new Sub();
bool result1 = typeof(Sub).IsSubclassOf(typeof(Super));
bool result2 = sub.GetType().IsSubclassOf(typeof(Super));
bool result3 = sub.GetType().IsAssignableFrom(typeof(Super));
bool result4 = sub is Super;
var properties1 = typeof(Sub).GetProperties();
}
}
VSUG DAY 2012 Winter 2012.12.15
83. 対処: プライバシーポリシー
Privacy Policy
Sho's Software takes the privacy of its users very respectfully. We also comply fully with the Act on the
Protection of Personal Information.
Sho's Software does not collect personally identifiable information (e.g., name, address, telephone
number, e-mail address) unless you provide it to us.
VSUG DAY 2012 Winter 2012.12.15