Esempio n. 1
0
        private static void LoadApplicationSettings()
        {
            try
            {
                if (File.Exists(ApplicationSettingsPath))
                {
                    var doc = new XmlDocument();
                    doc.Load(ApplicationSettingsPath);
                    var root = new XmlElementReader(doc.DocumentElement);
                    if (root.Name == "settings")
                    {
                        var versionText = root["dontCareAboutVersion"].Text;
                        if (!string.IsNullOrEmpty(versionText))
                        {
                            DontCareAboutVersion = new Version(versionText);
                        }
                        InfiniteScrollBounds = root["infiniteScrollBounds"].ToBool(InfiniteScrollBounds);
                        ShowMiniMap          = root["showMiniMap"].ToBool(ShowMiniMap);

                        LastProjectFileName       = root["lastProjectFileName"].Text;
                        LastExportImageFileName   = root["lastExportedImageFileName"].Text;
                        LastExportInform7FileName = root["lastExportedInform7FileName"].Text;
                        LastExportInform6FileName = root["lastExportedInform6FileName"].Text;
                        LastExportTadsFileName    = root["lastExportedTadsFileName"].Text;

                        InvertMouseWheel = root["invertMouseWheel"].ToBool(InvertMouseWheel);
                        DefaultImageType = root["defaultImageType"].ToInt(DefaultImageType);
                        SaveToImage      = root["saveToImage"].ToBool(SaveToImage);
                        SaveToPDF        = root["saveToPDF"].ToBool(SaveToPDF);
                        SaveAt100        = root["saveAt100"].ToBool(SaveAt100);

                        var recentProjects = root["recentProjects"];
                        var fileName       = string.Empty;
                        var index          = 0;
                        do
                        {
                            fileName = recentProjects[string.Format("fileName{0}", index++)].Text;
                            if (!string.IsNullOrEmpty(fileName))
                            {
                                RecentProjects.Append(fileName);
                            }
                        } while (!string.IsNullOrEmpty(fileName));

                        var automap = root["automap"];
                        s_automap.FileName          = automap["transcriptFileName"].ToText(s_automap.FileName);
                        s_automap.VerboseTranscript = automap["verboseTranscript"].ToBool(s_automap.VerboseTranscript);
                        s_automap.AssumeRoomsWithSameNameAreSameRoom = automap["assumeRoomsWithSameNameAreSameRoom"].ToBool(s_automap.AssumeRoomsWithSameNameAreSameRoom);
                        s_automap.GuessExits       = automap["guessExits"].ToBool(s_automap.GuessExits);
                        s_automap.AddObjectCommand = automap["addObjectCommand"].ToText(s_automap.AddObjectCommand);
                        s_automap.AddRegionCommand = automap["addRegionCommand"].ToText(s_automap.AddRegionCommand);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 2
0
        public object BeginLoad(XmlElementReader element)
        {
            switch (element.Attribute("style").Text)
            {
            case "solid":
            default:
                Style = ConnectionStyle.Solid;
                break;

            case "dashed":
                Style = ConnectionStyle.Dashed;
                break;
            }
            switch (element.Attribute("flow").Text)
            {
            case "twoWay":
            default:
                Flow = ConnectionFlow.TwoWay;
                break;

            case "oneWay":
                Flow = ConnectionFlow.OneWay;
                break;
            }
            StartText = element.Attribute("startText").Text;
            MidText   = element.Attribute("midText").Text;
            EndText   = element.Attribute("endText").Text;
            if (element.Attribute("color").Text != "")
            {
                ConnectionColor = ColorTranslator.FromHtml(element.Attribute("color").Text);
            }

            var vertexElementList = new List <XmlElementReader>();

            vertexElementList.AddRange(element.Children);
            vertexElementList.Sort((a, b) => a.Attribute("index").ToInt().CompareTo(b.Attribute("index").ToInt()));

            foreach (var vertexElement in vertexElementList)
            {
                if (vertexElement.HasName("point"))
                {
                    var vertex = new Vertex();
                    vertex.Position = new Vector(vertexElement.Attribute("x").ToFloat(), vertexElement.Attribute("y").ToFloat());
                    VertexList.Add(vertex);
                }
                else if (vertexElement.HasName("dock"))
                {
                    var vertex = new Vertex();
                    // temporarily leave this vertex as a positional vertex;
                    // we can't safely dock it to a port until EndLoad().
                    VertexList.Add(vertex);
                }
            }

            return(vertexElementList);
        }
Esempio n. 3
0
 public void Load(XmlElementReader element)
 {
     Name = element.Attribute("name").Text;
     ClearDescriptions();
     AddDescription(element.Attribute("description").Text);
     Position        = new Vector(element.Attribute("x").ToFloat(), element.Attribute("y").ToFloat());
     Size            = new Vector(element.Attribute("w").ToFloat(), element.Attribute("h").ToFloat());
     IsDark          = element.Attribute("isDark").ToBool();
     Objects         = element["objects"].Text.Replace("|", "\r\n").Replace("\\\r\n", "|");
     ObjectsPosition = element["objects"].Attribute("at").ToCompassPoint(ObjectsPosition);
 }
Esempio n. 4
0
        public bool Load()
        {
            try
            {
                if (new FileInfo(FileName).Length == 0)
                {
                    // this is an empty file, probably thanks to our Explorer New->Trizbort Map menu option.
                    Settings.Reset();
                    return(true);
                }

                var doc = new XmlDocument();
                doc.Load(FileName);
                var root = new XmlElementReader(doc.DocumentElement);

                if (!root.HasName("trizbort"))
                {
                    throw new InvalidDataException(string.Format("Not a {0} map file.", Application.ProductName));
                }

                // file version
                var versionNumber = root.Attribute("version").Text;
                setVersion(versionNumber);

                // load info
                Title       = root["info"]["title"].Text;
                Author      = root["info"]["author"].Text;
                Description = root["info"]["description"].Text;
                History     = root["info"]["history"].Text;

                // load all elements
                var map = root["map"];
                var mapConnectionToLoadState = new Dictionary <Connection, object>();
                foreach (var element in map.Children)
                {
                    if (element.HasName("room"))
                    {
                        // Changed the constructor used for elements when loading a file for a significant speed increase
                        var room = new Room(this, Elements.Count + 1);
                        room.ID = element.Attribute("id").ToInt(room.ID);
                        room.Load(element);
                        Elements.Add(room);
                    }
                    else if (element.HasName("line"))
                    {
                        // Changed the constructor used for elements when loading a file for a significant speed increase
                        var connection = new Connection(this, Elements.Count + 1);
                        connection.ID = element.Attribute("id").ToInt(connection.ID);
                        var loadState = connection.BeginLoad(element);
                        if (loadState != null)
                        {
                            mapConnectionToLoadState.Add(connection, loadState);
                        }
                        Elements.Add(connection);
                    }
                }

                // connect them together
                foreach (var pair in mapConnectionToLoadState)
                {
                    var connection = pair.Key;
                    var state      = pair.Value;
                    connection.EndLoad(state);
                }

                // load settings last, since their load can't be undone
                Settings.Reset();
                Settings.Load(root["settings"]);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(Program.MainForm, string.Format("There was a problem loading the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Esempio n. 5
0
        public bool Load()
        {
            try
            {
                if (new FileInfo(FileName).Length == 0)
                {
                    // this is an empty file, probably thanks to our Explorer New->Trizbort Map menu option.
                    Settings.Reset();
                    return true;
                }

                var doc = new XmlDocument();
                doc.Load(FileName);
                var root = new XmlElementReader(doc.DocumentElement);

                if (!root.HasName("trizbort"))
                    throw new InvalidDataException(string.Format("Not a {0} map file.", Application.ProductName));

                // load info
                Title = root["info"]["title"].Text;
                Author = root["info"]["author"].Text;
                Description = root["info"]["description"].Text;
                History = root["info"]["history"].Text;

                // load all elements
                var map = root["map"];
                var mapConnectionToLoadState = new Dictionary<Connection, object>();
                foreach (var element in map.Children)
                {
                    if (element.HasName("room"))
                    {
                        var room = new Room(this);
                        room.ID = element.Attribute("id").ToInt(room.ID);
                        room.Load(element);
                        Elements.Add(room);
                    }
                    else if (element.HasName("line"))
                    {
                        var connection = new Connection(this);
                        connection.ID = element.Attribute("id").ToInt(connection.ID);
                        var loadState = connection.BeginLoad(element);
                        if (loadState != null)
                        {
                            mapConnectionToLoadState.Add(connection, loadState);
                        }
                        Elements.Add(connection);
                    }
                }

                // connect them together
                foreach (var pair in mapConnectionToLoadState)
                {
                    var connection = pair.Key;
                    var state = pair.Value;
                    connection.EndLoad(state);
                }

                // load settings last, since their load can't be undone
                Settings.Reset();
                Settings.Load(root["settings"]);
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(Program.MainForm, string.Format("There was a problem loading the map:\n\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public object BeginLoad(XmlElementReader element)
        {
            switch (element.Attribute("style").Text)
              {
            case "solid":
            default:
              Style = ConnectionStyle.Solid;
              break;
            case "dashed":
              Style = ConnectionStyle.Dashed;
              break;
              }
              switch (element.Attribute("flow").Text)
              {
            case "twoWay":
            default:
              Flow = ConnectionFlow.TwoWay;
              break;
            case "oneWay":
              Flow = ConnectionFlow.OneWay;
              break;
              }
              StartText = element.Attribute("startText").Text;
              MidText = element.Attribute("midText").Text;
              EndText = element.Attribute("endText").Text;
              if (element.Attribute("color").Text != "") { ConnectionColor = ColorTranslator.FromHtml(element.Attribute("color").Text); }

              var vertexElementList = new List<XmlElementReader>();
              vertexElementList.AddRange(element.Children);
              vertexElementList.Sort((a, b) => a.Attribute("index").ToInt().CompareTo(b.Attribute("index").ToInt()));

              foreach (var vertexElement in vertexElementList)
              {
            if (vertexElement.HasName("point"))
            {
              var vertex = new Vertex();
              vertex.Position = new Vector(vertexElement.Attribute("x").ToFloat(), vertexElement.Attribute("y").ToFloat());
              VertexList.Add(vertex);
            }
            else if (vertexElement.HasName("dock"))
            {
              var vertex = new Vertex();
              // temporarily leave this vertex as a positional vertex;
              // we can't safely dock it to a port until EndLoad().
              VertexList.Add(vertex);
            }
              }

              return vertexElementList;
        }
Esempio n. 9
0
 public void Load(XmlElementReader element)
 {
     Name = element.Attribute("name").Text;
     ClearDescriptions();
     AddDescription(element.Attribute("description").Text);
     Position = new Vector(element.Attribute("x").ToFloat(), element.Attribute("y").ToFloat());
     Size = new Vector(element.Attribute("w").ToFloat(), element.Attribute("h").ToFloat());
     IsDark = element.Attribute("isDark").ToBool();
     Objects = element["objects"].Text.Replace("|","\r\n").Replace("\\\r\n", "|");
     ObjectsPosition = element["objects"].Attribute("at").ToCompassPoint(ObjectsPosition);
 }
Esempio n. 10
0
        static void LoadApplicationSettings()
        {
            try
            {
                if (File.Exists(ApplicationSettingsPath))
                {
                    var doc = new XmlDocument();
                    doc.Load(ApplicationSettingsPath);
                    var root = new XmlElementReader(doc.DocumentElement);
                    if (root.Name == "settings")
                    {
                        var versionText = root["dontCareAboutVersion"].Text;
                        if (!string.IsNullOrEmpty(versionText))
                        {
                            s_dontCareAboutVersion = new Version(versionText);
                        }
                        s_infiniteScrollBounds = root["infiniteScrollBounds"].ToBool(s_infiniteScrollBounds);
                        s_showMinimap = root["showMiniMap"].ToBool(s_showMinimap);

                        s_lastProjectFileName = root["lastProjectFileName"].Text;
                        s_lastExportImageFileName = root["lastExportedImageFileName"].Text;
                        s_lastExportInform7FileName = root["lastExportedInform7FileName"].Text;
                        s_lastExportInform6FileName = root["lastExportedInform6FileName"].Text;
                        s_lastExportTadsFileName = root["lastExportedTadsFileName"].Text;

                        var recentProjects = root["recentProjects"];
                        var fileName = string.Empty;
                        var index = 0;
                        do
                        {
                            fileName = recentProjects[string.Format("fileName{0}", index++)].Text;
                            if (!string.IsNullOrEmpty(fileName))
                            {
                                s_recentProjects.Append(fileName);
                            }
                        } while (!string.IsNullOrEmpty(fileName));

                        var automap = root["automap"];
                        s_automap.FileName = automap["transcriptFileName"].ToText(s_automap.FileName);
                        s_automap.VerboseTranscript = automap["verboseTranscript"].ToBool(s_automap.VerboseTranscript);
                        s_automap.AssumeRoomsWithSameNameAreSameRoom = automap["assumeRoomsWithSameNameAreSameRoom"].ToBool(s_automap.AssumeRoomsWithSameNameAreSameRoom);
                        s_automap.GuessExits = automap["guessExits"].ToBool(s_automap.GuessExits);
                        s_automap.AddObjectCommand = automap["addObjectCommand"].ToText(s_automap.AddObjectCommand);
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
 public void Load(XmlElementReader element)
 {
     Name = element.Attribute("name").Text;
     ClearDescriptions();
     AddDescription(element.Attribute("description").Text);
     Position = new Vector(element.Attribute("x").ToFloat(), element.Attribute("y").ToFloat());
     Size = new Vector(element.Attribute("w").ToFloat(), element.Attribute("h").ToFloat());
     IsDark = element.Attribute("isDark").ToBool();
     if (element.Attribute("roomFill").Text != "") { RoomFill = ColorTranslator.FromHtml(element.Attribute("roomFill").Text); }
     if (element.Attribute("secondFill").Text != "") { SecondFill = ColorTranslator.FromHtml(element.Attribute("secondFill").Text); }
     if (element.Attribute("secondFillLocation").Text != "") { SecondFillLocation = element.Attribute("secondFillLocation").Text; }
     if (element.Attribute("roomBorder").Text != "") { RoomBorder = ColorTranslator.FromHtml(element.Attribute("roomBorder").Text); }
     if (element.Attribute("roomLargeText").Text != "") { RoomLargeText = ColorTranslator.FromHtml(element.Attribute("roomLargeText").Text); }
     if (element.Attribute("roomSmallText").Text != "") { RoomSmallText = ColorTranslator.FromHtml(element.Attribute("roomSmallText").Text); }
     Objects = element["objects"].Text.Replace("|", "\r\n").Replace("\\\r\n", "|");
     ObjectsPosition = element["objects"].Attribute("at").ToCompassPoint(ObjectsPosition);
 }