Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        protected override void InitializeComponents()
        {
            var grid = new Grid();

            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1f, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(28)
            });
            grid.SetBinding(Canvas.WidthProperty, new Binding(UIChatBox.WidthProperty)
            {
                Source = this
            });
            grid.SetBinding(Canvas.HeightProperty, new Binding(UIChatBox.HeightProperty)
            {
                Source = this
            });
            this.Content = grid;

            var border1 = new Border();

            border1.Name             = Part_Resize;
            border1.IsHitTestVisible = true;
            border1.Background       = new TCBBrush()
            {
                Resource = GetBackgroundResource()
            };
            Grid.SetRow(border1, 0);
            grid.Children.Add(border1);

            var stackPanel = new StackPanel();

            stackPanel.Orientation = Orientation.Vertical;
            stackPanel.Margin      = new Thickness(0);
            this.pnlMessage        = stackPanel;

            var scrollViewer = new ScrollViewer();

            scrollViewer.Style  = CreateScrollViewerStyle();
            scrollViewer.Margin = new Thickness(8, 10, 8, 4);
            scrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Visible;
            scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            scrollViewer.Content = stackPanel;
            border1.Child        = scrollViewer;
            this.scrollView      = scrollViewer;

            var border2 = new Border();

            border2.Background = new ImageBrush()
            {
                ImageSource = new BitmapImage()
                {
                    TextureAsset = nameof(MRes.StatusBar3_img_chat_ingame_input_layer_backgrnd)
                }
            };
            Grid.SetRow(border2, 1);
            grid.Children.Add(border2);

            var textBox = new TextBoxEx();

            textBox.Background = new ImageBrush()
            {
                ImageSource = new BitmapImage()
                {
                    TextureAsset = nameof(MRes.StatusBar3_img_chat_ingame_input_layer_chatEnter)
                }
            };
            textBox.SelectionBrush  = Brushes.Blue;
            textBox.CaretBrush      = Brushes.White;
            textBox.IMEEnabled      = true;
            textBox.IsTabStop       = false;
            textBox.BorderThickness = new Thickness(0);
            textBox.Width           = 471;
            textBox.Height          = 20;
            border2.Child           = textBox;
            this.TextBoxChat        = textBox;

            this.Width     = 574;
            this.Height    = 80;
            this.MinHeight = 80;
            ImageManager.Instance.AddImage(nameof(MRes.StatusBar3_img_chat_ingame_input_layer_backgrnd));
            ImageManager.Instance.AddImage(nameof(MRes.StatusBar3_img_chat_ingame_input_layer_chatEnter));
            base.InitializeComponents();
        }