示例#1
0
 public void Save(XmlScribe scribe)
 {
     scribe.Attribute("name", Name);
     scribe.Attribute("x", Position.X);
     scribe.Attribute("y", Position.Y);
     scribe.Attribute("w", Size.X);
     scribe.Attribute("h", Size.Y);
     if (IsDark)
     {
         scribe.Attribute("isDark", IsDark);
     }
     scribe.Attribute("description", PrimaryDescription);
     if (!string.IsNullOrEmpty(Objects) || ObjectsPosition != DefaultObjectsPosition)
     {
         scribe.StartElement("objects");
         if (ObjectsPosition != DefaultObjectsPosition)
         {
             scribe.Attribute("at", ObjectsPosition);
         }
         if (!string.IsNullOrEmpty(Objects))
         {
             scribe.Value(Objects.Replace("\r", string.Empty).Replace("|", "\\|").Replace("\n", "|"));
         }
         scribe.EndElement();
     }
 }
示例#2
0
 private void SaveElement(XmlScribe scribe, Element element)
 {
     if (element is Room)
     {
         scribe.StartElement("room");
         scribe.Attribute("id", element.ID);
         ((Room)element).Save(scribe);
         scribe.EndElement();
     }
     else if (element is Connection)
     {
         scribe.StartElement("line");
         scribe.Attribute("id", element.ID);
         ((Connection)element).Save(scribe);
         scribe.EndElement();
     }
 }
示例#3
0
 private static void saveElement(XmlScribe scribe, Element element)
 {
     if (element.GetType() == typeof(Room))
     {
         scribe.StartElement("room");
         scribe.Attribute("id", element.ID);
         ((Room)element).Save(scribe);
         scribe.EndElement();
     }
     else if (element.GetType() == typeof(Connection))
     {
         scribe.StartElement("line");
         scribe.Attribute("id", element.ID);
         ((Connection)element).Save(scribe);
         scribe.EndElement();
     }
 }
示例#4
0
 private static void SaveFont(XmlScribe scribe, Font font, string name)
 {
     scribe.StartElement(name);
     scribe.Attribute("size", font.Size);
     if ((font.Style & FontStyle.Bold) == FontStyle.Bold)
     {
         scribe.Attribute("bold", true);
     }
     if ((font.Style & FontStyle.Italic) == FontStyle.Italic)
     {
         scribe.Attribute("italic", true);
     }
     if ((font.Style & FontStyle.Underline) == FontStyle.Underline)
     {
         scribe.Attribute("underline", true);
     }
     if ((font.Style & FontStyle.Strikeout) == FontStyle.Strikeout)
     {
         scribe.Attribute("strikeout", true);
     }
     scribe.Value(Drawing.FontName(font));
     scribe.EndElement();
 }
示例#5
0
 private void SaveElement(XmlScribe scribe, Element element)
 {
     if (element is Room)
     {
         scribe.StartElement("room");
         scribe.Attribute("id", element.ID);
         ((Room)element).Save(scribe);
         scribe.EndElement();
     }
     else if (element is Connection)
     {
         scribe.StartElement("line");
         scribe.Attribute("id", element.ID);
         ((Connection)element).Save(scribe);
         scribe.EndElement();
     }
 }
示例#6
0
 private static void saveElement(XmlScribe scribe, Element element)
 {
     if (element.GetType() == typeof(Room))
       {
     scribe.StartElement("room");
     scribe.Attribute("id", element.ID);
     ((Room) element).Save(scribe);
     scribe.EndElement();
       }
       else if (element.GetType() == typeof(Connection))
       {
     scribe.StartElement("line");
     scribe.Attribute("id", element.ID);
     ((Connection) element).Save(scribe);
     scribe.EndElement();
       }
 }
示例#7
0
        public static void Save(XmlScribe scribe)
        {
            // save colors
            scribe.StartElement("colors");
            for (var index = 0; index < Colors.Count; ++index)
            {
                string colorName;
                if (Colors.ToName(index, out colorName))
                {
                    scribe.Element(colorName, Color[index]);
                }
            }
            scribe.EndElement();

            scribe.StartElement("regions");
            foreach (var region in Regions.OrderBy(p => p.RegionName))
            {
                scribe.StartElement(region.FixupRegionNameForSave());
                scribe.Attribute("Name", region.RegionName);
                scribe.Attribute("TextColor", region.TextColor);
                scribe.Value(region.RColor);
                scribe.EndElement();
            }
            scribe.EndElement();

            // save fonts
            scribe.StartElement("fonts");
            SaveFont(scribe, s_largeFont, "room");
            SaveFont(scribe, s_smallFont, "object");
            SaveFont(scribe, s_lineFont, "line");
            scribe.EndElement();

            scribe.StartElement("grid");
            scribe.Element("snapTo", s_snapToGrid);
            scribe.Element("visible", s_isGridVisible);
            scribe.Element("showOrigin", s_showOrigin);
            scribe.Element("size", s_gridSize);
            scribe.EndElement();

            scribe.StartElement("lines");
            scribe.Element("width", s_lineWidth);
            scribe.Element("handDrawn", HandDrawnUnchecked);
            scribe.Element("arrowSize", s_connectionArrowSize);
            scribe.Element("textOffset", s_textOffsetFromConnection);
            scribe.EndElement();

            scribe.StartElement("rooms");
            scribe.Element("darknessStripeSize", s_darknessStripeSize);
            scribe.Element("objectListOffset", s_objectListOffsetFromRoom);
            scribe.Element("connectionStalkLength", s_connectionStalkLength);
            scribe.Element("preferredDistanceBetweenRooms", s_preferredDistanceBetweenRooms);
            scribe.EndElement();

            scribe.StartElement("ui");
            scribe.Element("handleSize", s_handleSize);
            scribe.Element("snapToElementSize", s_snapToElementSize);
            scribe.EndElement();

            scribe.StartElement("keypadNavigation");
            scribe.Element("creationModifier", ModifierKeysToString(s_keypadNavigationCreationModifier));
            scribe.Element("unexploredModifier", ModifierKeysToString(s_keypadNavigationUnexploredModifier));
            scribe.EndElement();

            SaveApplicationSettings();
        }
示例#8
0
        public void Save(XmlScribe scribe)
        {
            if (ConnectionColor != Color.Transparent)
            {
                scribe.Attribute("color", Colors.SaveColor(ConnectionColor));
            }

            if (Style != DefaultStyle)
            {
                switch (Style)
                {
                case ConnectionStyle.Solid:
                    scribe.Attribute("style", "solid");
                    break;

                case ConnectionStyle.Dashed:
                    scribe.Attribute("style", "dashed");
                    break;
                }
            }
            if (Flow != DefaultFlow)
            {
                switch (Flow)
                {
                case ConnectionFlow.OneWay:
                    scribe.Attribute("flow", "oneWay");
                    break;

                case ConnectionFlow.TwoWay:
                    scribe.Attribute("flow", "twoWay");
                    break;
                }
            }

            if (!string.IsNullOrEmpty(StartText))
            {
                scribe.Attribute("startText", StartText);
            }
            if (!string.IsNullOrEmpty(MidText))
            {
                scribe.Attribute("midText", MidText);
            }
            if (!string.IsNullOrEmpty(EndText))
            {
                scribe.Attribute("endText", EndText);
            }

            var index = 0;

            foreach (var vertex in VertexList)
            {
                if (vertex.Port != null)
                {
                    scribe.StartElement("dock");
                    scribe.Attribute("index", index);
                    scribe.Attribute("id", vertex.Port.Owner.ID);
                    scribe.Attribute("port", vertex.Port.ID);
                    scribe.EndElement();
                }
                else
                {
                    scribe.StartElement("point");
                    scribe.Attribute("index", index);
                    scribe.Attribute("x", vertex.Position.X);
                    scribe.Attribute("y", vertex.Position.Y);
                    scribe.EndElement();
                }
                ++index;
            }
        }
示例#9
0
        public void Save(XmlScribe scribe)
        {
            if (ConnectionColor != Color.Transparent)
            scribe.Attribute("color", Colors.SaveColor(ConnectionColor));

              if (Style != DefaultStyle)
              {
            switch (Style)
            {
              case ConnectionStyle.Solid:
            scribe.Attribute("style", "solid");
            break;
              case ConnectionStyle.Dashed:
            scribe.Attribute("style", "dashed");
            break;
            }
              }
              if (Flow != DefaultFlow)
              {
            switch (Flow)
            {
              case ConnectionFlow.OneWay:
            scribe.Attribute("flow", "oneWay");
            break;
              case ConnectionFlow.TwoWay:
            scribe.Attribute("flow", "twoWay");
            break;
            }
              }

              if (!string.IsNullOrEmpty(StartText))
              {
            scribe.Attribute("startText", StartText);
              }
              if (!string.IsNullOrEmpty(MidText))
              {
            scribe.Attribute("midText", MidText);
              }
              if (!string.IsNullOrEmpty(EndText))
              {
            scribe.Attribute("endText", EndText);
              }

              var index = 0;
              foreach (var vertex in VertexList)
              {
            if (vertex.Port != null)
            {
              scribe.StartElement("dock");
              scribe.Attribute("index", index);
              scribe.Attribute("id", vertex.Port.Owner.ID);
              scribe.Attribute("port", vertex.Port.ID);
              scribe.EndElement();
            }
            else
            {
              scribe.StartElement("point");
              scribe.Attribute("index", index);
              scribe.Attribute("x", vertex.Position.X);
              scribe.Attribute("y", vertex.Position.Y);
              scribe.EndElement();
            }
            ++index;
              }
        }
示例#10
0
文件: Room.cs 项目: ChrisPC/trizbort
 public void Save(XmlScribe scribe)
 {
     scribe.Attribute("name", Name);
     scribe.Attribute("x", Position.X);
     scribe.Attribute("y", Position.Y);
     scribe.Attribute("w", Size.X);
     scribe.Attribute("h", Size.Y);
     if (IsDark)
     {
         scribe.Attribute("isDark", IsDark);
     }
     scribe.Attribute("description", PrimaryDescription);
     if (!string.IsNullOrEmpty(Objects) || ObjectsPosition != DefaultObjectsPosition)
     {
         scribe.StartElement("objects");
         if (ObjectsPosition != DefaultObjectsPosition)
         {
             scribe.Attribute("at", ObjectsPosition);
         }
         if (!string.IsNullOrEmpty(Objects))
         {
             scribe.Value(Objects.Replace("\r", string.Empty).Replace("|", "\\|").Replace("\n","|"));
         }
         scribe.EndElement();
     }
 }
示例#11
0
 private static void SaveFont(XmlScribe scribe, Font font, string name)
 {
     scribe.StartElement(name);
     scribe.Attribute("size", font.Size);
     if ((font.Style & FontStyle.Bold) == FontStyle.Bold)
     {
         scribe.Attribute("bold", true);
     }
     if ((font.Style & FontStyle.Italic) == FontStyle.Italic)
     {
         scribe.Attribute("italic", true);
     }
     if ((font.Style & FontStyle.Underline) == FontStyle.Underline)
     {
         scribe.Attribute("underline", true);
     }
     if ((font.Style & FontStyle.Strikeout) == FontStyle.Strikeout)
     {
         scribe.Attribute("strikeout", true);
     }
     scribe.Value(Drawing.FontName(font));
     scribe.EndElement();
 }
示例#12
0
        public static void Save(XmlScribe scribe)
        {
            // save colors
              scribe.StartElement("colors");
              for (var index = 0; index < Colors.Count; ++index)
              {
            string colorName;
            if (Colors.ToName(index, out colorName))
            {
              scribe.Element(colorName, Color[index]);
            }
              }
              scribe.EndElement();

              scribe.StartElement("regions");
              foreach (var region in Regions.OrderBy(p=>p.RegionName))
              {
            scribe.StartElement(region.FixupRegionNameForSave());
            scribe.Attribute("Name", region.RegionName);
            scribe.Attribute("TextColor", region.TextColor);
            scribe.Value(region.RColor);
            scribe.EndElement();
              }
              scribe.EndElement();

              // save fonts
              scribe.StartElement("fonts");
              SaveFont(scribe, s_largeFont, "room");
              SaveFont(scribe, s_smallFont, "object");
              SaveFont(scribe, s_lineFont, "line");
              scribe.EndElement();

              scribe.StartElement("grid");
              scribe.Element("snapTo", s_snapToGrid);
              scribe.Element("visible", s_isGridVisible);
              scribe.Element("showOrigin", s_showOrigin);
              scribe.Element("size", s_gridSize);
              scribe.EndElement();

              scribe.StartElement("lines");
              scribe.Element("width", s_lineWidth);
              scribe.Element("handDrawn", HandDrawnUnchecked);
              scribe.Element("arrowSize", s_connectionArrowSize);
              scribe.Element("textOffset", s_textOffsetFromConnection);
              scribe.EndElement();

              scribe.StartElement("rooms");
              scribe.Element("darknessStripeSize", s_darknessStripeSize);
              scribe.Element("objectListOffset", s_objectListOffsetFromRoom);
              scribe.Element("connectionStalkLength", s_connectionStalkLength);
              scribe.Element("preferredDistanceBetweenRooms", s_preferredDistanceBetweenRooms);
              scribe.EndElement();

              scribe.StartElement("ui");
              scribe.Element("handleSize", s_handleSize);
              scribe.Element("snapToElementSize", s_snapToElementSize);
              scribe.EndElement();

              scribe.StartElement("keypadNavigation");
              scribe.Element("creationModifier", ModifierKeysToString(s_keypadNavigationCreationModifier));
              scribe.Element("unexploredModifier", ModifierKeysToString(s_keypadNavigationUnexploredModifier));
              scribe.EndElement();

              SaveApplicationSettings();
        }
示例#13
0
文件: Room.cs 项目: Tymian/trizbort
        public void Save(XmlScribe scribe)
        {
            scribe.Attribute("name", Name);
            scribe.Attribute("x", Position.X);
            scribe.Attribute("y", Position.Y);
            scribe.Attribute("w", Size.X);
            scribe.Attribute("h", Size.Y);
            if (IsDark)
            {
                scribe.Attribute("isDark", IsDark);
            }
            scribe.Attribute("description", PrimaryDescription);
            // Added for room specific fill color, down to the next comment
            string rValue = "";
            string bValue = "";
            string gValue = "";
            if (RoomFill.R < 16)
            { rValue = "0" + RoomFill.R.ToString("X"); }
            else
            { rValue = RoomFill.R.ToString("X"); }
            if (RoomFill.G < 16)
            { gValue = "0" + RoomFill.G.ToString("X"); }
            else
            { gValue = RoomFill.G.ToString("X"); }
            if (RoomFill.B < 16)
            { bValue = "0" + RoomFill.B.ToString("X"); }
            else
            { bValue = RoomFill.B.ToString("X"); }

            string colorValue = "#" + rValue + "" + gValue + "" + bValue;
            scribe.Attribute("roomFill", colorValue);

            if (SecondFill.R < 16)
            { rValue = "0" + SecondFill.R.ToString("X"); }
            else
            { rValue = SecondFill.R.ToString("X"); }
            if (SecondFill.G < 16)
            { gValue = "0" + SecondFill.G.ToString("X"); }
            else
            { gValue = SecondFill.G.ToString("X"); }
            if (SecondFill.B < 16)
            { bValue = "0" + SecondFill.B.ToString("X"); }
            else
            { bValue = SecondFill.B.ToString("X"); }

            colorValue = "#" + rValue + "" + gValue + "" + bValue;
            scribe.Attribute("secondFill", colorValue);
            scribe.Attribute("secondFillLocation", SecondFillLocation);

            if (RoomBorder.R < 16)
            { rValue = "0" + RoomBorder.R.ToString("X"); }
            else
            { rValue = RoomBorder.R.ToString("X"); }
            if (RoomBorder.G < 16)
            { gValue = "0" + RoomBorder.G.ToString("X"); }
            else
            { gValue = RoomBorder.G.ToString("X"); }
            if (RoomBorder.B < 16)
            { bValue = "0" + RoomBorder.B.ToString("X"); }
            else
            { bValue = RoomBorder.B.ToString("X"); }

            colorValue = "#" + rValue + "" + gValue + "" + bValue;
            scribe.Attribute("roomBorder", colorValue);

            if (RoomLargeText.R < 16)
            { rValue = "0" + RoomLargeText.R.ToString("X"); }
            else
            { rValue = RoomLargeText.R.ToString("X"); }
            if (RoomLargeText.G < 16)
            { gValue = "0" + RoomLargeText.G.ToString("X"); }
            else
            { gValue = RoomLargeText.G.ToString("X"); }
            if (RoomLargeText.B < 16)
            { bValue = "0" + RoomLargeText.B.ToString("X"); }
            else
            { bValue = RoomLargeText.B.ToString("X"); }

            colorValue = "#" + rValue + "" + gValue + "" + bValue;
            scribe.Attribute("roomLargeText", colorValue);

            if (RoomSmallText.R < 16)
            { rValue = "0" + RoomSmallText.R.ToString("X"); }
            else
            { rValue = RoomSmallText.R.ToString("X"); }
            if (RoomSmallText.G < 16)
            { gValue = "0" + RoomSmallText.G.ToString("X"); }
            else
            { gValue = RoomSmallText.G.ToString("X"); }
            if (RoomSmallText.B < 16)
            { bValue = "0" + RoomSmallText.B.ToString("X"); }
            else
            { bValue = RoomSmallText.B.ToString("X"); }

            colorValue = "#" + rValue + "" + gValue + "" + bValue;
            scribe.Attribute("roomSmallText", colorValue);
            // Up to this point was added to turn colors to Hex code for xmpl saving/loading

            if (!string.IsNullOrEmpty(Objects) || ObjectsPosition != DefaultObjectsPosition)
            {
                scribe.StartElement("objects");
                if (ObjectsPosition != DefaultObjectsPosition)
                {
                    scribe.Attribute("at", ObjectsPosition);
                }
                if (!string.IsNullOrEmpty(Objects))
                {
                    scribe.Value(Objects.Replace("\r", string.Empty).Replace("|", "\\|").Replace("\n", "|"));
                }
                scribe.EndElement();
            }
        }