Esempio n. 1
0
        protected override void InitializeComponents()
        {
            UIMinimapResource resource = new UIMinimapResource();

            this.MinWidth  = resource.NW.Width + resource.NE.Width;
            this.MinHeight = resource.NW.Height + resource.SW.Height;
            this.Width     = this.MinWidth;
            this.Height    = this.MinHeight;
            this.MaxWidth  = 1000;
            this.MaxHeight = 1000;

            Canvas canvas = new Canvas();

            canvas.Background = new NinePatchBrush()
            {
                Resource = resource
            };
            canvas.SetBinding(Canvas.WidthProperty, new Binding(UIMinimap2.WidthProperty)
            {
                Source = this
            });
            canvas.SetBinding(Canvas.HeightProperty, new Binding(UIMinimap2.HeightProperty)
            {
                Source = this
            });
            canvas.Parent = this;
            this.Content  = canvas;

            Border title = new Border();

            title.Height = 17;
            title.SetBinding(Canvas.WidthProperty, new Binding(Canvas.WidthProperty)
            {
                Source = canvas
            });
            canvas.Children.Add(title);
            this.SetDragTarget(title);

            Border mapAreaBorder = new Border();

            mapAreaBorder.Background = new SolidColorBrush(new ColorW(0f, 0f, 0f, 0.6f));
            Canvas.SetLeft(mapAreaBorder, resource.W.Width);
            Canvas.SetTop(mapAreaBorder, resource.N.Height);
            canvas.Children.Add(mapAreaBorder);

            MapArea mapArea = new MapArea();

            mapArea.Name = "mapArea";
            mapArea.SetBinding(MapArea.WidthProperty, new Binding(Border.WidthProperty)
            {
                Source = mapAreaBorder, Mode = BindingMode.TwoWay
            });
            mapArea.SetBinding(MapArea.HeightProperty, new Binding(Border.HeightProperty)
            {
                Source = mapAreaBorder, Mode = BindingMode.TwoWay
            });
            mapAreaBorder.Child = mapArea;
            this.SetBinding(UIMinimap2.MinimapCanvasProperty, new Binding("MinimapTexture")
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.SetBinding(UIMinimap2.MapRegionProperty, new Binding("MapRegion")
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.SetBinding(UIMinimap2.CameraViewPortProperty, new Binding("CameraViewPort")
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.SetBinding(UIMinimap2.IconsProperty, new Binding("Icons")
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });
            this.SetBinding(UIMinimap2.CameraRegionVisibleProperty, new Binding("CameraRegionVisible")
            {
                Source = mapArea, Mode = BindingMode.OneWayToSource
            });

            Image imgMapMark = new Image();

            imgMapMark.SetBinding(Image.SourceProperty, new Binding("MapMark")
            {
                Source = this, Converter = new TextureImageConverter()
            });
            Canvas.SetLeft(imgMapMark, 7);
            Canvas.SetTop(imgMapMark, 17);
            canvas.Children.Add(imgMapMark);

            TextBlock lblStreetName = new TextBlock();

            lblStreetName.Name       = "lblStreetName";
            lblStreetName.FontStyle  = FontStyle.Bold;
            lblStreetName.Foreground = Brushes.White;
            lblStreetName.Padding    = new Thickness(0, 0, 6, 0);
            lblStreetName.SetBinding(TextBlock.TextProperty, new Binding("StreetName")
            {
                Source = this
            });
            lblStreetName.SetResourceReference(TextBlock.FontFamilyProperty, MapRenderResourceKey.DefaultFontFamily);
            lblStreetName.SetResourceReference(TextBlock.FontSizeProperty, MapRenderResourceKey.DefaultFontSize);
            Canvas.SetLeft(lblStreetName, 48);
            Canvas.SetTop(lblStreetName, 20);
            canvas.Children.Add(lblStreetName);

            TextBlock lblMapName = new TextBlock();

            lblMapName.Name       = "lblMapName";
            lblMapName.FontStyle  = FontStyle.Bold;
            lblMapName.Foreground = Brushes.White;
            lblMapName.Padding    = new Thickness(0, 0, 6, 0);
            lblMapName.SetBinding(TextBlock.TextProperty, new Binding("MapName")
            {
                Source = this
            });
            lblMapName.SetResourceReference(TextBlock.FontFamilyProperty, MapRenderResourceKey.DefaultFontFamily);
            lblMapName.SetResourceReference(TextBlock.FontSizeProperty, MapRenderResourceKey.DefaultFontSize);
            Canvas.SetLeft(lblMapName, 48);
            Canvas.SetTop(lblMapName, 34);
            canvas.Children.Add(lblMapName);

            ComboBox cb = new ComboBox();

            cb.Background = new LCRBrush()
            {
                Resource = new ComboBoxBackgroundResource()
            };
            cb.Width      = 150;
            cb.Height     = 17;
            cb.Focusable  = false;
            cb.Visibility = Visibility.Hidden;
            canvas.Children.Add(cb);

            this.resource       = resource;
            this.MapAreaControl = mapArea;
            this.lblStreetName  = lblStreetName;
            this.lblMapName     = lblMapName;

            FontManager.Instance.AddFont(lblStreetName.FontFamily.Source, lblStreetName.FontSize, lblStreetName.FontStyle);
            FontManager.Instance.AddFont(lblMapName.FontFamily.Source, lblMapName.FontSize, lblMapName.FontStyle);
            base.InitializeComponents();
        }