Пример #1
0
        /// <summary>
        /// Create drawer to further decorate a village drawn by <see cref="CreateVillageDrawer"/>
        /// </summary>
        /// <param name="data">The shape of the drawer</param>
        /// <param name="colors">The colors for the drawer</param>
        /// <param name="mainData">The data for the main drawer (used for BorderDrawer)</param>
        public DrawerBase CreateVillageDecoratorDrawer(DecoratorDrawerData data, BackgroundDrawerData mainData)
        {
            Debug.Assert(SupportDecorators);
            DrawerBase drawer = CreateVillageDecoratorDrawerCore(data, mainData);

            return(drawer);
        }
Пример #2
0
        public DrawerBase GetDecoratorDrawer(DrawerFactoryBase drawerFactory, Village village, BackgroundDrawerData mainData)
        {
            DecoratorDrawerData data = _cache
                                       .Where(x => village.Type.HasFlag(x.Key))
                                       .Select(x => x.Value)
                                       .FirstOrDefault();

            if (data == null)
            {
                return(null);
            }

            return(drawerFactory.CreateVillageDecoratorDrawer(data, mainData));
        }
Пример #3
0
        protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData)
        {
            if (data.Shape == null)
            {
                return(null);
            }

            switch (data.Shape.Drawer)
            {
            case "BorderDrawer":
                var drawer = mainData.ShapeDrawer == "EllipseDrawer" ? BorderDrawer.EllipseDrawer : BorderDrawer.RectangleDrawer;
                return(new BorderDrawer(data.Shape.Color, drawer));

            default:
                throw new Exception("Not implemented: " + data.Shape.Drawer);
            }
        }
Пример #4
0
        public override void ReadDrawerXml(XElement drawer)
        {
            DecoratorDrawerData.IconData  icon  = null;
            DecoratorDrawerData.ShapeData shape = null;

            var villageType = (VillageType)Enum.Parse(typeof(VillageType), drawer.Attribute("VillageType").Value);

            var xShape = drawer.Element("Shape");

            if (xShape != null)
            {
                shape = new DecoratorDrawerData.ShapeData(
                    xShape.Attribute("Drawer").Value,
                    XmlHelper.GetColor(xShape.Attribute("Color").Value));
            }

            var xIcon = drawer.Element("Icon");

            if (xIcon != null)
            {
                Color?backgroundColor  = null;
                var   xBackgroundColor = xIcon.Attribute("Background");
                if (xBackgroundColor != null)
                {
                    backgroundColor = XmlHelper.GetColor(xBackgroundColor.Value);
                }

                icon = new DecoratorDrawerData.IconData(
                    xIcon.Attribute("Icon").Value,
                    (IconOrientation)Enum.Parse(typeof(IconOrientation), xIcon.Attribute("Orientation").Value),
                    backgroundColor);
            }

            var data = new DecoratorDrawerData(shape, icon);

            _cache.Add(villageType, data);
        }
Пример #5
0
 public IconDrawerDecorator(DecoratorDrawerData.IconData data)
 {
     _data = data;
 }
Пример #6
0
 protected override DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData)
 {
     return(null);
 }
Пример #7
0
 protected abstract DrawerBase CreateVillageDecoratorDrawerCore(DecoratorDrawerData data, BackgroundDrawerData mainData);