void queueDownloader_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { QueueParallelDownloader queueDownloader = sender as QueueParallelDownloader; queueDownloader.DownloadCompleted -= queueDownloader_OpenReadCompleted; Canvas body = new Canvas() { Width = 255, 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); MouseButtonEventHandler handler0 = null; closer.Click += handler0 = delegate { closer.Click -= handler0; 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) => { downloader.OpenReadCompleted -= handler; Infos["Language"] = XElement.Load(e2.Result as Stream); if (Submit != null) { Submit(this, null); } }; 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 = 75, CenterWidth = 255, CenterEdgeWidth = 30, SouthCenterWidth = 229, 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); }
public LoginTip() { //this.CacheMode = null; //不这样居然就会出现缝隙??晕,这个GPU太牛了 confirm = new ImageButton() { TotalWidth = 93, TotalHeight = 27, Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/106.png", UriType.Web), Stretch = Stretch.None }, Text = GetLanguagePackContent(2), TextStyle = Application.Current.Resources["TextStyle1"] as Style, TextSize = 14, TextHasEffect = true, TextEffectColor = Colors.Black, TextBrush = new SolidColorBrush(Colors.LightGray), TextHoverBrush = new SolidColorBrush(Colors.White), }; confirm.Click += (s1, e1) => { base.Hide(); if (OK != null) { OK(this, e1); } }; cannel = new ImageButton() { TotalWidth = 93, TotalHeight = 27, Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/106.png", UriType.Web), Stretch = Stretch.None }, Text = GetLanguagePackContent(57), TextStyle = Application.Current.Resources["TextStyle1"] as Style, TextSize = 14, TextHasEffect = true, TextEffectColor = Colors.Black, TextBrush = new SolidColorBrush(Colors.LightGray), TextHoverBrush = new SolidColorBrush(Colors.White), Visibility = Visibility.Collapsed, }; cannel.Click += (s1, e1) => { base.Hide(); if (Cannel != null) { Cannel(this, e1); } }; Grid grid = new Grid() { Width = 240, Height = 102,Background = new ImageBrush() { ImageSource = GlobalMethod.GetImage("UI/105.png", UriType.Web) } }; styleBox = new StyleBox() { HeadHeight = 60, BodyHeight = 100, FootHeight = 15, NorthCenterWidth = 60, CenterWidth = 240, CenterEdgeWidth = 30, SouthCenterWidth = 214, 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 = grid, }; styleBox.HeadText.Foreground = new SolidColorBrush(Colors.White); styleBox.HeadText.Text = GetLanguagePackContent(61); styleBox.HeadText.FontSize = 14; styleBox.HeadText.Margin = new Thickness(0, -20, 0, 0); styleBox.Children.Add(input); Canvas.SetLeft(input, 55); Canvas.SetTop(input, 83); styleBox.Children.Add(confirm); styleBox.Children.Add(cannel); Canvas.SetLeft(cannel, 160); Canvas.SetTop(cannel, 127); grid.Children.Add(content); content.Margin = new Thickness(5, -40, 5, 0); this.Content = styleBox; base.OnResourceReady(this, null); }