private static UIElement CreateMessageBoxControlFunc(UIElement parent) { Grid screenBg = new Grid(); screenBg.HorizontalAlignment = HorizontalAlignment.Center; screenBg.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); screenBg.SetBinding(Control.BackgroundProperty, new Binding(Control.BackgroundProperty) { Source = parent }); screenBg.Parent = parent; screenBg.Foreground = EmptyKeys.UserInterface.Media.Brushes.White; Grid grid = new Grid(); grid.Width = 260; grid.SetResourceReference(Control.BackgroundProperty, MapRenderResourceKey.MessageBoxBackgroundBrush); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); screenBg.Children.Add(grid); Grid.SetColumn(grid, 0); Border border = new Border(); grid.Children.Add(border); Grid.SetRow(border, 0); ContentPresenter pnlTitle = CommonHelpers.CreateContentPresenter(parent, "Title"); pnlTitle.Height = 26; pnlTitle.Margin = new Thickness(0, 4, 0, 0); pnlTitle.HorizontalAlignment = HorizontalAlignment.Center; pnlTitle.VerticalAlignment = VerticalAlignment.Center; pnlTitle.IsHitTestVisible = false; pnlTitle.Name = "PART_WindowTitle"; border.Child = pnlTitle; ContentPresenter pnlContent = CommonHelpers.CreateContentPresenter(parent, "Content"); pnlContent.Margin = new Thickness(20, 8, 20, 0); pnlContent.Name = "PART_WindowContent"; grid.Children.Add(pnlContent); Grid.SetRow(pnlContent, 1); Window msgBox = parent as Window; if (msgBox != null) { msgBox.Visible += MsgBox_Visible; msgBox.SizeChanged += MsgBox_SizeChanged; var style = MapRenderButtonStyle.CreateMapRenderButtonStyle(); style.TargetType = typeof(Button); msgBox.Resources[typeof(Button)] = style; } return(screenBg); }
private void InitGlobalResource() { //初始化字体 var fontList = MapRenderFonts.DefaultFonts; var config = MapRender.Config.MapRenderConfig.Default; var resDict = ResourceDictionary.DefaultDictionary; var fontIndex = config.DefaultFontIndex; if (fontIndex < 0 || fontIndex >= fontList.Count) { fontIndex = 0; } resDict[MapRenderResourceKey.FontList] = fontList; resDict[MapRenderResourceKey.DefaultFontFamily] = new FontFamily(fontList[fontIndex]); resDict[MapRenderResourceKey.DefaultFontSize] = 12f; //初始化style resDict[MapRenderResourceKey.MapRenderButtonStyle] = MapRenderButtonStyle.CreateMapRenderButtonStyle(); resDict[MapRenderResourceKey.TextBoxExStyle] = TextBoxEx.CreateStyle(); }