コード例 #1
0
        public static void Load(XmlElementReader element)
        {
            var colors = element["colors"];

            foreach (var color in colors.Children)
            {
                int index;
                if (Colors.FromName(color.Name, out index))
                {
                    Color[index] = color.ToColor(Color[index]);
                }
            }

            var regions = element["regions"];

            Regions = new List <Region>();

            if (regions.Children.Count <= 0)
            {
                Regions.Add(new Region {
                    RColor = System.Drawing.Color.White, TextColor = System.Drawing.Color.Blue, RegionName = Region.DefaultRegion
                });
            }
            else
            {
                foreach (var region in regions.Children)
                {
                    var tRegion = new Region();
                    tRegion.TextColor = region.Attribute("TextColor").Text == string.Empty ? System.Drawing.Color.Blue : ColorTranslator.FromHtml(region.Attribute("TextColor").Text);

                    var node = region.Attribute("name");
                    tRegion.RegionName = node != null && node.Text != string.Empty ? node.Text : region.Name;

                    tRegion.RegionName = tRegion.ClearRegionNameObfuscation();
                    tRegion.RColor     = region.ToColor(System.Drawing.Color.White);
                    Regions.Add(tRegion);
                }
            }
            var fonts = element["fonts"];

            foreach (var font in fonts.Children)
            {
                var style = FontStyle.Regular;
                if (font.Attribute("bold").ToBool())
                {
                    style |= FontStyle.Bold;
                }
                if (font.Attribute("italic").ToBool())
                {
                    style |= FontStyle.Italic;
                }
                if (font.Attribute("underline").ToBool())
                {
                    style |= FontStyle.Underline;
                }
                if (font.Attribute("strikeout").ToBool())
                {
                    style |= FontStyle.Strikeout;
                }
                if (font.Name == "room")
                {
                    LargeFont = new Font(font.ToText(LargeFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LargeFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
                }
                else if (font.Name == "object")
                {
                    SmallFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(SmallFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
                }
                else if (font.Name == "line")
                {
                    LineFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LineFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
                }
            }

            SnapToGrid    = element["grid"]["snapTo"].ToBool(s_snapToGrid);
            IsGridVisible = element["grid"]["visible"].ToBool(s_isGridVisible);
            GridSize      = element["grid"]["size"].ToFloat(s_gridSize);
            ShowOrigin    = element["grid"]["showOrigin"].ToBool(s_showOrigin);

            LineWidth                = element["lines"]["width"].ToFloat(s_lineWidth);
            HandDrawn                = element["lines"]["handDrawn"].ToBool(HandDrawnUnchecked);
            ConnectionArrowSize      = element["lines"]["arrowSize"].ToFloat(s_connectionArrowSize);
            TextOffsetFromConnection = element["lines"]["textOffset"].ToFloat(s_textOffsetFromConnection);

            DarknessStripeSize            = element["rooms"]["darknessStripeSize"].ToFloat(s_darknessStripeSize);
            ObjectListOffsetFromRoom      = element["rooms"]["objectListOffset"].ToFloat(s_objectListOffsetFromRoom);
            ConnectionStalkLength         = element["rooms"]["connectionStalkLength"].ToFloat(s_connectionStalkLength);
            PreferredDistanceBetweenRooms = element["rooms"]["preferredDistanceBetweenRooms"].ToFloat(s_connectionStalkLength * 2); // introduced in v1.2, hence default based on existing setting

            HandleSize        = element["ui"]["handleSize"].ToFloat(s_handleSize);
            SnapToElementSize = element["ui"]["snapToElementSize"].ToFloat(s_snapToElementSize);

            KeypadNavigationCreationModifier   = StringToModifierKeys(element["keypadNavigation"]["creationModifier"].Text, s_keypadNavigationCreationModifier);
            KeypadNavigationUnexploredModifier = StringToModifierKeys(element["keypadNavigation"]["unexploredModifier"].Text, s_keypadNavigationUnexploredModifier);
        }
コード例 #2
0
        public static void Load(XmlElementReader element)
        {
            var colors = element["colors"];

            foreach (var color in colors.Children)
            {
                int index;
                if (Colors.FromName(color.Name, out index))
                {
                    Color[index] = color.ToColor(Color[index]);
                }
            }

            var fonts = element["fonts"];

            foreach (var font in fonts.Children)
            {
                var style = FontStyle.Regular;
                if (font.Attribute("bold").ToBool())
                {
                    style |= FontStyle.Bold;
                }
                if (font.Attribute("italic").ToBool())
                {
                    style |= FontStyle.Italic;
                }
                if (font.Attribute("underline").ToBool())
                {
                    style |= FontStyle.Underline;
                }
                if (font.Attribute("strikeout").ToBool())
                {
                    style |= FontStyle.Strikeout;
                }
                if (font.Name == "room")
                {
                    LargeFont = new Font(font.ToText(LargeFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LargeFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
                }
                else if (font.Name == "object")
                {
                    SmallFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(SmallFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
                }
                else if (font.Name == "line")
                {
                    LineFont = new Font(font.ToText(SmallFont.Name), Numeric.Clamp(font.Attribute("size").ToFloat(LineFont.Size), MinFontSize, MaxFontSize), style, GraphicsUnit.World);
                }
            }

            SnapToGrid    = element["grid"]["snapTo"].ToBool(s_snapToGrid);
            IsGridVisible = element["grid"]["visible"].ToBool(s_isGridVisible);
            GridSize      = element["grid"]["size"].ToFloat(s_gridSize);
            ShowOrigin    = element["grid"]["showOrigin"].ToBool(s_showOrigin);

            LineWidth                = element["lines"]["width"].ToFloat(s_lineWidth);
            HandDrawn                = element["lines"]["handDrawn"].ToBool(s_handDrawn);
            ConnectionArrowSize      = element["lines"]["arrowSize"].ToFloat(s_connectionArrowSize);
            TextOffsetFromConnection = element["lines"]["textOffset"].ToFloat(s_textOffsetFromConnection);

            DarknessStripeSize            = element["rooms"]["darknessStripeSize"].ToFloat(s_darknessStripeSize);
            ObjectListOffsetFromRoom      = element["rooms"]["objectListOffset"].ToFloat(s_objectListOffsetFromRoom);
            ConnectionStalkLength         = element["rooms"]["connectionStalkLength"].ToFloat(s_connectionStalkLength);
            PreferredDistanceBetweenRooms = element["rooms"]["preferredDistanceBetweenRooms"].ToFloat(s_connectionStalkLength * 2); // introduced in v1.2, hence default based on existing setting

            HandleSize        = element["ui"]["handleSize"].ToFloat(s_handleSize);
            SnapToElementSize = element["ui"]["snapToElementSize"].ToFloat(s_snapToElementSize);

            KeypadNavigationCreationModifier   = StringToModifierKeys(element["keypadNavigation"]["creationModifier"].Text, s_keypadNavigationCreationModifier);
            KeypadNavigationUnexploredModifier = StringToModifierKeys(element["keypadNavigation"]["unexploredModifier"].Text, s_keypadNavigationUnexploredModifier);
        }