public static void SetBrandData(ShopMallFloorHotspotData shopMallFloorHotspotData)
        {
            brandInfos = new List <BrandInfo>();

            foreach (BrandData brandData in shopMallFloorHotspotData.Brands)
            {
                brandInfos.Add(new BrandInfo()
                {
                    Name          = brandData.Name,
                    FillColor     = ColorFromString.ToColor(brandData.FillColor),
                    BorderColor   = ColorFromString.ToColor(brandData.BorderColor),
                    FontColor     = ColorFromString.ToColor(brandData.FontColor),
                    FillOverColor = ColorFromString.ToColor(brandData.FillOverColor)
                });
            }
        }
Exemplo n.º 2
0
        public static ObservableCollection <CPData> GetAllData(ShopMallFloorHotspotData shopMallFloorData)
        {
            cpDatas.Clear();

            foreach (BrandData brandInfo in shopMallFloorData.Brands)
            {
                CPData cpData = new CPData();
                cpData.Name       = brandInfo.Name;
                cpData.BrandColor = new SolidColorBrush(ColorFromString.ToColor(brandInfo.FillColor));
                Random random = new Random(cpData.GetHashCode());
                cpData.OCP    = random.Next(20, 100);
                cpData.NCP    = cpData.OCP;
                cpData.CPText = string.Format("原有竞争力 : {0}", cpData.OCP);
                cpDatas.Add(cpData);
            }

            return(cpDatas);
        }
Exemplo n.º 3
0
        private TextBlock GetTextBlock(Polygon polygon)
        {
            TextBlock textBlock = new TextBlock();

            textBlock.HorizontalAlignment = HorizontalAlignment.Center;
            textBlock.VerticalAlignment   = VerticalAlignment.Center;
            textBlock.TextAlignment       = TextAlignment.Left;
            textBlock.TextWrapping        = TextWrapping.Wrap;

            textBlock.Inlines.Add(new Run()
            {
                Text = this.Name
            });

            textBlock.FontFamily = new FontFamily("Arial");
            textBlock.Foreground = new SolidColorBrush(ColorFromString.ToColor("#AAFCFA"));


            Canvas.SetLeft(textBlock, this.GetCenterLeft() - textBlock.ActualWidth / 2);
            Canvas.SetTop(textBlock, this.GetCenterTop() - textBlock.ActualHeight / 2);
            Canvas.SetLeft(textBlock, Canvas.GetLeft(textBlock));
            Canvas.SetTop(textBlock, Canvas.GetTop(textBlock));
            Canvas.SetZIndex(textBlock, 1100);

            double centerX = textBlock.ActualWidth / 2;
            double centerY = textBlock.ActualHeight / 2;

            TransformGroup transform = new TransformGroup();

            if (this.IsRotate)
            {
                RotateTransform rotate = new RotateTransform();
                rotate.CenterY = centerY;
                rotate.CenterX = centerX;
                rotate.Angle   = 90;
                transform.Children.Add(rotate);
            }


            double scaleRate = 1;

            if (polygon.Points.Count == 4)
            {
                double polygonX = Math.Min(Math.Abs(polygon.Points[1].X - polygon.Points[0].X), Math.Abs(polygon.Points[2].X - polygon.Points[3].X));
                double polygonY = Math.Min(Math.Abs(polygon.Points[3].Y - polygon.Points[0].Y), Math.Abs(polygon.Points[2].Y - polygon.Points[1].Y));

                double newpolygonX = polygonX * GoldenSectionRate;
                double newpolygonY = polygonY * GoldenSectionRate;

                double textX = textBlock.ActualWidth;
                double textY = textBlock.ActualHeight;

                if (this.IsRotate)
                {
                    textY = textBlock.ActualWidth;
                    textX = textBlock.ActualHeight;
                }

                if (newpolygonX / textX <= newpolygonY / textY)
                {
                    scaleRate = newpolygonX / textX;
                }
                else
                {
                    scaleRate = newpolygonY / textY;
                }
            }

            ScaleTransform scale = new ScaleTransform();

            scale.CenterX = centerX;
            scale.CenterY = centerY;
            scale.ScaleX  = scaleRate;
            scale.ScaleY  = scaleRate;

            transform.Children.Add(scale);

            textBlock.RenderTransform = transform;
            textBlock.Tag             = this;


            textBlock.MouseEnter += new MouseEventHandler(textBlock_OnMouseEnter);

            if (!string.IsNullOrEmpty(this.Comment))
            {
                ToolTipService.SetToolTip(textBlock, this.Comment);
            }

            return(textBlock);
        }
Exemplo n.º 4
0
        public ShopHotSpot(ROSHotSpot rosHotSpot, Canvas canvas, Mode mode, MainPage mainPage)
            : base(Guid.NewGuid())
        {
            this.DataID   = rosHotSpot.ShopNO;
            this.Brand    = rosHotSpot.GetBrandInfo().Name;
            this.Name     = rosHotSpot.TextInfo.Text;
            this.IsRotate = rosHotSpot.TextInfo.TextIsVertical;

            ShopInfo shopInfo = ShopInfo.GetBySeatNo(this.DataID);

            if (shopInfo != null)
            {
                if (rosHotSpot.TextInfo != null)
                {
                    rosHotSpot.TextInfo.Text = shopInfo.ShowText;
                }
                this.Comment = shopInfo.ShowTooltip;
            }

            showPolygon = new Polygon();

            foreach (Point hotSpotPoint in rosHotSpot.HotSpotPoints)
            {
                showPolygon.Points.Add(hotSpotPoint);
                HostSpotArea.Add(hotSpotPoint);
            }

            showPolygon.Stroke          = new SolidColorBrush(rosHotSpot.GetBrandInfo().BorderColor);
            showPolygon.StrokeThickness = 1;
            showPolygon.Fill            = new SolidColorBrush(rosHotSpot.GetBrandInfo().FillColor);

            showPolygon.MouseEnter += new MouseEventHandler(polygon_OnMouseEnter);
            showPolygon.MouseLeave += new MouseEventHandler(polygon_OnMouseLeave);

            showTextBlock = new TextBlock();

            showTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
            showTextBlock.VerticalAlignment   = VerticalAlignment.Center;
            showTextBlock.TextAlignment       = TextAlignment.Left;
            showTextBlock.TextWrapping        = TextWrapping.Wrap;

            //textBlock.Foreground =  new SolidColorBrush(rosHotSpot.GetBrandInfo().FontColor);
            showTextBlock.FontFamily = new FontFamily("Arial");
            showTextBlock.Foreground = new SolidColorBrush(ColorFromString.ToColor("#AAFCFA"));

            showTextBlock.Inlines.Add(rosHotSpot.TextInfo.Text);

            Canvas.SetLeft(showTextBlock, rosHotSpot.TextInfo.TextLeft);
            Canvas.SetTop(showTextBlock, rosHotSpot.TextInfo.TextTop);

            TransformGroup transformGroup = new TransformGroup();

            ScaleTransform scaleTransform = new ScaleTransform();

            scaleTransform.CenterX = rosHotSpot.TextInfo.TextScaleCenterX;
            scaleTransform.CenterY = rosHotSpot.TextInfo.TextScaleCenterY;
            scaleTransform.ScaleX  = rosHotSpot.TextInfo.TextScaleX;
            scaleTransform.ScaleY  = rosHotSpot.TextInfo.TextScaleY;

            transformGroup.Children.Add(scaleTransform);

            if (rosHotSpot.TextInfo.TextIsVertical)
            {
                RotateTransform rotateTransform = new RotateTransform();

                rotateTransform.CenterX = rosHotSpot.TextInfo.TextVerticalCenterX;
                rotateTransform.CenterY = rosHotSpot.TextInfo.TextVerticalCenterY;
                rotateTransform.Angle   = rosHotSpot.TextInfo.TextVerticalAngle;
                transformGroup.Children.Add(rotateTransform);
            }

            showTextBlock.RenderTransform = transformGroup;

            showTextBlock.MouseEnter += new MouseEventHandler(textBlock_OnMouseEnter);

            showPolygon.Tag   = this;
            showTextBlock.Tag = this;


            AddContextMenu(showTextBlock, mode, mainPage);
            AddContextMenu(showPolygon, mode, mainPage);



            ToolTipService.SetToolTip(showPolygon, this.Comment);
            ToolTipService.SetToolTip(ShowTextBlock, this.Comment);

            canvas.Children.Add(showPolygon);
            canvas.Children.Add(showTextBlock);
        }