///
<summary>
///
游戏语言选择
///
</summary>
public
sealed
class
LanguageChoicer : WindowBase {
///
<summary>
///
提交
///
</summary>
public
event
MouseButtonEventHandler Submit;
public
LanguageChoicer() {
this
.Loaded
+=
(s, e)
=>
{
QueueParallelDownloader queueDownloader
=
new
QueueParallelDownloader();
queueDownloader.DownloadCompleted
+=
new
OpenReadCompletedEventHandler(queueDownloader_OpenReadCompleted);
queueDownloader.OpenReadAsync(GetResourceList(
"
LanguageChoicer
"
),
null
,
false
,
300
);
};
}
void
queueDownloader_OpenReadCompleted(
object
sender, OpenReadCompletedEventArgs e) {
QueueParallelDownloader queueDownloader
=
sender
as
QueueParallelDownloader;
queueDownloader.DownloadCompleted
-=
queueDownloader_OpenReadCompleted;
Canvas body
=
new
Canvas() {
Width
=
254
,
Height
=
200
,
Background
=
new
ImageBrush() { ImageSource
=
GlobalMethod.GetImage(
"
UI/105.png
"
, UriType.Web) }
};
RadioButton[] languages
=
new
RadioButton[
5
];
languages[
0
]
=
new
RadioButton() {
Tag
=
"
zh-cn
"
,
Content
=
new
TextBlock() {
Text
=
"
简体中文
"
,
Style
=
Application.Current.Resources[
"
TextStyle0
"
]
as
Style,
TextWrapping
=
TextWrapping.Wrap,
Foreground
=
new
SolidColorBrush(Color.FromArgb(
255
,
239
,
255
,
208
)),
},
FontSize
=
14
,
GroupName
=
"
Language
"
,
IsChecked
=
true
,
};
languages[
1
]
=
new
RadioButton() {
Tag
=
"
zh-tw
"
,
Content
=
new
TextBlock() {
Text
=
"
繁體中文
"
,
Style
=
Application.Current.Resources[
"
TextStyle0
"
]
as
Style,
TextWrapping
=
TextWrapping.Wrap,
Foreground
=
new
SolidColorBrush(Color.FromArgb(
255
,
239
,
255
,
208
)),
},
FontSize
=
14
,
GroupName
=
"
Language
"
,
};
languages[
2
]
=
new
RadioButton() {
Tag
=
"
us
"
,
Content
=
new
TextBlock() {
Text
=
"
English
"
,
Style
=
Application.Current.Resources[
"
TextStyle0
"
]
as
Style,
TextWrapping
=
TextWrapping.Wrap,
Foreground
=
new
SolidColorBrush(Color.FromArgb(
255
,
239
,
255
,
208
)),
},
FontSize
=
14
,
GroupName
=
"
Language
"
};
languages[
3
]
=
new
RadioButton() {
Tag
=
"
jp
"
,
Content
=
new
TextBlock() {
Text
=
"
日本語
"
,
Style
=
Application.Current.Resources[
"
TextStyle0
"
]
as
Style,
TextWrapping
=
TextWrapping.Wrap,
Foreground
=
new
SolidColorBrush(Color.FromArgb(
255
,
239
,
255
,
208
)),
},
FontSize
=
14
,
GroupName
=
"
Language
"
};
languages[
4
]
=
new
RadioButton() {
Tag
=
"
kr
"
,
Content
=
new
TextBlock() {
Text
=
"
한국의
"
,
Style
=
Application.Current.Resources[
"
TextStyle0
"
]
as
Style,
TextWrapping
=
TextWrapping.Wrap,
Foreground
=
new
SolidColorBrush(Color.FromArgb(
255
,
239
,
255
,
208
)),
},
FontSize
=
14
,
GroupName
=
"
Language
"
};
for
(
int
i
=
0
; i
<=
languages.GetUpperBound(
0
); i
++
) {
body.Children.Add(languages[i]);
Canvas.SetLeft(languages[i],
86
); Canvas.SetTop(languages[i],
-
5
+
i
*
35
);
}
ImageButton closer
=
new
ImageButton() {
TotalWidth
=
93
,
TotalHeight
=
27
,
Background
=
new
ImageBrush() { ImageSource
=
GlobalMethod.GetImage(
"
UI/106.png
"
, UriType.Web), Stretch
=
Stretch.None },
Text
=
"
提交(OK)
"
,
TextStyle
=
Application.Current.Resources[
"
TextStyle1
"
]
as
Style,
TextSize
=
14
,
TextHasEffect
=
true
,
TextEffectColor
=
Colors.Black,
TextBrush
=
new
SolidColorBrush(Colors.LightGray),
TextHoverBrush
=
new
SolidColorBrush(Colors.White),
};
body.Children.Add(closer); Canvas.SetLeft(closer,
73
); Canvas.SetTop(closer,
167
);
closer.Click
+=
(s1, e1)
=>
{
//
LoginManager.loading.Show();
for
(
int
i
=
0
; i
<=
languages.GetUpperBound(
0
); i
++
) {
if
(languages[i].IsChecked.Value) {
ParallelDownloader downloader
=
new
ParallelDownloader();
OpenReadCompletedEventHandler handler
=
null
;
downloader.OpenReadCompleted
+=
handler
=
(s2, e2)
=>
{
Infos[
"
Language
"
]
=
XElement.Load(e2.Result
as
Stream);
if
(Submit
!=
null
) { Submit(
this
, e1); }
//
LoginManager.loading.Hide();
};
downloader.OpenReadAsync(
string
.Format(GlobalMethod.WebPath(
"
Language/{0}.xml
"
), languages[i].Tag.ToString()), DownloadPriority.Highest,
null
,
false
,
0
);
break
;
}
}
};
StyleBox styleBox
=
new
StyleBox() {
HeadHeight
=
60
,
BodyHeight
=
200
,
FootHeight
=
15
,
NorthCenterWidth
=
74
,
CenterWidth
=
254
,
CenterEdgeWidth
=
30
,
SouthCenterWidth
=
228
,
NorthEdgeImageSource
=
GlobalMethod.GetImage(
"
UI/100.png
"
, UriType.Web),
NorthImageSource
=
GlobalMethod.GetImage(
"
UI/101.png
"
, UriType.Web),
CenterEdgeImageSource
=
GlobalMethod.GetImage(
"
UI/102.png
"
, UriType.Web),
SouthEdgeImageSource
=
GlobalMethod.GetImage(
"
UI/103.png
"
, UriType.Web),
SouthImageSource
=
GlobalMethod.GetImage(
"
UI/104.png
"
, UriType.Web),
CenterContent
=
body,
};
styleBox.HeadText.Foreground
=
new
SolidColorBrush(Colors.White);
styleBox.HeadText.Text
=
"
选 择 语 言
"
;
styleBox.HeadText.FontSize
=
14
;
styleBox.HeadText.Margin
=
new
Thickness(
0
,
-
20
,
0
,
0
);
Body
=
styleBox;
base
.OnResourceReady(
this
, e);
}
}