Exemple #1
0
        public static void Save()
        {
            string FileName = Path.Combine(FiddlerControls.Options.AppDataPath, FiddlerControls.Options.ProfileName);

            XmlDocument    dom  = new XmlDocument();
            XmlDeclaration decl = dom.CreateXmlDeclaration("1.0", "utf-8", null);

            dom.AppendChild(decl);
            XmlElement sr = dom.CreateElement("Options");

            XmlComment comment = dom.CreateComment("Output Path");

            sr.AppendChild(comment);
            XmlElement elem = dom.CreateElement("OutputPath");

            elem.SetAttribute("path", FiddlerControls.Options.OutputPath.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("ItemSize controls the size of images in items tab");
            sr.AppendChild(comment);
            elem = dom.CreateElement("ItemSize");
            elem.SetAttribute("width", FiddlerControls.Options.ArtItemSizeWidth.ToString());
            elem.SetAttribute("height", FiddlerControls.Options.ArtItemSizeHeight.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("ItemClip images in items tab shrinked or clipped");
            sr.AppendChild(comment);
            elem = dom.CreateElement("ItemClip");
            elem.SetAttribute("active", FiddlerControls.Options.ArtItemClip.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("CacheData should mul entries be cached for faster load");
            sr.AppendChild(comment);
            elem = dom.CreateElement("CacheData");
            elem.SetAttribute("active", Files.CacheData.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("NewMapSize Felucca/Trammel width 7168?");
            sr.AppendChild(comment);
            elem = dom.CreateElement("NewMapSize");
            elem.SetAttribute("active", Map.Felucca.Width == 7168 ? true.ToString() : false.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("UseMapDiff should mapdiff files be used");
            sr.AppendChild(comment);
            elem = dom.CreateElement("UseMapDiff");
            elem.SetAttribute("active", Map.UseDiff.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("Alternative layout in item/landtile/texture tab?");
            sr.AppendChild(comment);
            elem = dom.CreateElement("AlternativeDesign");
            elem.SetAttribute("active", FiddlerControls.Options.DesignAlternative.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("Use Hashfile to speed up load?");
            sr.AppendChild(comment);
            elem = dom.CreateElement("UseHashFile");
            elem.SetAttribute("active", Files.UseHashFile.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("Should an Update Check be done on startup?");
            sr.AppendChild(comment);
            elem = dom.CreateElement("UpdateCheck");
            elem.SetAttribute("active", UpdateCheckOnStart.ToString());
            sr.AppendChild(elem);

            comment = dom.CreateComment("Definies the cmd to send Client to loc");
            sr.AppendChild(comment);
            comment = dom.CreateComment("{1} = x, {2} = y, {3} = z, {4} = mapid, {5} = mapname");
            sr.AppendChild(comment);
            elem = dom.CreateElement("SendCharToLoc");
            elem.SetAttribute("cmd", FiddlerControls.Options.MapCmd);
            elem.SetAttribute("args", FiddlerControls.Options.MapArgs);
            sr.AppendChild(elem);

            comment = dom.CreateComment("Definies the map names");
            sr.AppendChild(comment);
            elem = dom.CreateElement("MapNames");
            elem.SetAttribute("map0", FiddlerControls.Options.MapNames[0]);
            elem.SetAttribute("map1", FiddlerControls.Options.MapNames[1]);
            elem.SetAttribute("map2", FiddlerControls.Options.MapNames[2]);
            elem.SetAttribute("map3", FiddlerControls.Options.MapNames[3]);
            elem.SetAttribute("map4", FiddlerControls.Options.MapNames[4]);
            elem.SetAttribute("map5", FiddlerControls.Options.MapNames[5]);
            sr.AppendChild(elem);

            comment = dom.CreateComment("Extern Tools settings");
            sr.AppendChild(comment);
            if (ExternTools != null)
            {
                foreach (ExternTool tool in ExternTools)
                {
                    XmlElement xtool = dom.CreateElement("ExternTool");
                    xtool.SetAttribute("name", tool.Name);
                    xtool.SetAttribute("path", tool.FileName);
                    for (int i = 0; i < tool.Args.Count; i++)
                    {
                        XmlElement xarg = dom.CreateElement("Args");
                        xarg.SetAttribute("name", tool.ArgsName[i]);
                        xarg.SetAttribute("arg", tool.Args[i]);
                        xtool.AppendChild(xarg);
                    }
                    sr.AppendChild(xtool);
                }
            }

            comment = dom.CreateComment("Loaded Plugins");
            sr.AppendChild(comment);
            if (FiddlerControls.Options.PluginsToLoad != null)
            {
                foreach (string plug in FiddlerControls.Options.PluginsToLoad)
                {
                    XmlElement xplug = dom.CreateElement("Plugin");
                    xplug.SetAttribute("name", plug);
                    sr.AppendChild(xplug);
                }
            }

            comment = dom.CreateComment("Pathsettings");
            sr.AppendChild(comment);
            elem = dom.CreateElement("RootPath");
            elem.SetAttribute("path", Files.RootDir);
            sr.AppendChild(elem);
            List <string> sorter = new List <string>(Files.MulPath.Keys);

            sorter.Sort();
            foreach (string key in sorter)
            {
                XmlElement path = dom.CreateElement("Paths");
                path.SetAttribute("key", key.ToString());
                path.SetAttribute("value", Files.MulPath[key].ToString());
                sr.AppendChild(path);
            }
            dom.AppendChild(sr);

            comment = dom.CreateComment("Disabled Tab Views");
            sr.AppendChild(comment);
            foreach (KeyValuePair <int, bool> kvp in FiddlerControls.Options.ChangedViewState)
            {
                if (!kvp.Value)
                {
                    XmlElement viewstate = dom.CreateElement("TabView");
                    viewstate.SetAttribute("tab", kvp.Key.ToString());
                    sr.AppendChild(viewstate);
                }
            }

            comment = dom.CreateComment("ViewState of the MainForm");
            sr.AppendChild(comment);
            elem = dom.CreateElement("ViewState");
            elem.SetAttribute("Active", StoreFormState.ToString());
            elem.SetAttribute("Maximised", MaximisedForm.ToString());
            elem.SetAttribute("PositionX", FormPosition.X.ToString());
            elem.SetAttribute("PositionY", FormPosition.Y.ToString());
            elem.SetAttribute("Height", FormSize.Height.ToString());
            elem.SetAttribute("Width", FormSize.Width.ToString());
            sr.AppendChild(elem);

            dom.Save(FileName);
        }
Exemple #2
0
        public static void SaveProfile()
        {
            if (Options.ProfileName is null)
            {
                Logger.Warning("SaveProfile - ProfileName is null!");
                return;
            }

            string fileName = Path.Combine(Options.AppDataPath, Options.ProfileName);

            Logger.Information("SaveProfile - start {filename}", fileName);

            XmlDocument    dom  = new XmlDocument();
            XmlDeclaration decl = dom.CreateXmlDeclaration("1.0", "utf-8", null);

            dom.AppendChild(decl);
            XmlElement sr = dom.CreateElement("Options");

            XmlComment comment = dom.CreateComment("Output Path");

            sr.AppendChild(comment);
            XmlElement elem = dom.CreateElement("OutputPath");

            elem.SetAttribute("path", Options.OutputPath);
            sr.AppendChild(elem);
            comment = dom.CreateComment("ItemSize controls the size of images in items tab");
            sr.AppendChild(comment);
            elem = dom.CreateElement("ItemSize");
            elem.SetAttribute("width", Options.ArtItemSizeWidth.ToString());
            elem.SetAttribute("height", Options.ArtItemSizeHeight.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("ItemClip images in items tab shrinked or clipped");
            sr.AppendChild(comment);
            elem = dom.CreateElement("ItemClip");
            elem.SetAttribute("active", Options.ArtItemClip.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("CacheData should mul entries be cached for faster load");
            sr.AppendChild(comment);
            elem = dom.CreateElement("CacheData");
            elem.SetAttribute("active", Files.CacheData.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("NewMapSize Felucca/Trammel width 7168?");
            sr.AppendChild(comment);
            elem = dom.CreateElement("NewMapSize");
            elem.SetAttribute("active", Map.Felucca.Width == 7168 ? true.ToString() : false.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("UseMapDiff should mapdiff files be used");
            sr.AppendChild(comment);
            elem = dom.CreateElement("UseMapDiff");
            elem.SetAttribute("active", Map.UseDiff.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("Make the right panel in sounds tab visible");
            sr.AppendChild(comment);
            elem = dom.CreateElement("RightPanelInSoundsTab");
            elem.SetAttribute("active", Options.RightPanelInSoundsTab.ToString());
            sr.AppendChild(elem);
            comment = dom.CreateComment("Should an Update Check be done on startup?");
            sr.AppendChild(comment);
            elem = dom.CreateElement("UpdateCheck");
            elem.SetAttribute("active", UpdateCheckOnStart.ToString());
            sr.AppendChild(elem);

            comment = dom.CreateComment("Defines the cmd to send Client to loc");
            sr.AppendChild(comment);
            comment = dom.CreateComment("{1} = x, {2} = y, {3} = z, {4} = mapid, {5} = mapname");
            sr.AppendChild(comment);
            elem = dom.CreateElement("SendCharToLoc");
            elem.SetAttribute("cmd", Options.MapCmd);
            elem.SetAttribute("args", Options.MapArgs);
            sr.AppendChild(elem);

            comment = dom.CreateComment("Defines the map names");
            sr.AppendChild(comment);
            elem = dom.CreateElement("MapNames");
            elem.SetAttribute("map0", Options.MapNames[0]);
            elem.SetAttribute("map1", Options.MapNames[1]);
            elem.SetAttribute("map2", Options.MapNames[2]);
            elem.SetAttribute("map3", Options.MapNames[3]);
            elem.SetAttribute("map4", Options.MapNames[4]);
            elem.SetAttribute("map5", Options.MapNames[5]);
            sr.AppendChild(elem);

            comment = dom.CreateComment("Extern Tools settings");
            sr.AppendChild(comment);

            if (ExternTools != null)
            {
                foreach (ExternTool tool in ExternTools)
                {
                    XmlElement externalToolElement = dom.CreateElement("ExternTool");
                    externalToolElement.SetAttribute("name", tool.Name);
                    externalToolElement.SetAttribute("path", tool.FileName);

                    for (int i = 0; i < tool.Args.Count; i++)
                    {
                        XmlElement argsElement = dom.CreateElement("Args");
                        argsElement.SetAttribute("name", tool.ArgsName[i]);
                        argsElement.SetAttribute("arg", tool.Args[i]);
                        externalToolElement.AppendChild(argsElement);
                    }
                    sr.AppendChild(externalToolElement);
                }
            }

            comment = dom.CreateComment("Loaded Plugins");
            sr.AppendChild(comment);
            if (Options.PluginsToLoad != null)
            {
                foreach (string plugIn in Options.PluginsToLoad)
                {
                    Logger.Information("SaveProfile - saving plugin {plugIn}", plugIn);
                    XmlElement xmlPlugin = dom.CreateElement("Plugin");
                    xmlPlugin.SetAttribute("name", plugIn);
                    sr.AppendChild(xmlPlugin);
                }
            }

            comment = dom.CreateComment("Path settings");
            sr.AppendChild(comment);
            elem = dom.CreateElement("RootPath");
            elem.SetAttribute("path", Files.RootDir);
            sr.AppendChild(elem);
            List <string> sorter = new List <string>(Files.MulPath.Keys);

            sorter.Sort();
            foreach (string key in sorter)
            {
                XmlElement path = dom.CreateElement("Paths");
                path.SetAttribute("key", key);
                path.SetAttribute("value", Files.MulPath[key]);
                sr.AppendChild(path);
            }
            dom.AppendChild(sr);

            comment = dom.CreateComment("Disabled Tab Views");
            sr.AppendChild(comment);
            foreach (KeyValuePair <int, bool> kvp in Options.ChangedViewState)
            {
                if (kvp.Value)
                {
                    continue;
                }

                XmlElement viewState = dom.CreateElement("TabView");
                viewState.SetAttribute("tab", kvp.Key.ToString());
                sr.AppendChild(viewState);
            }

            comment = dom.CreateComment("ViewState of the MainForm");
            sr.AppendChild(comment);
            elem = dom.CreateElement("ViewState");
            elem.SetAttribute("Active", StoreFormState.ToString());
            elem.SetAttribute("Maximised", MaximisedForm.ToString());
            elem.SetAttribute("PositionX", FormPosition.X.ToString());
            elem.SetAttribute("PositionY", FormPosition.Y.ToString());
            elem.SetAttribute("Height", FormSize.Height.ToString());
            elem.SetAttribute("Width", FormSize.Width.ToString());
            sr.AppendChild(elem);

            comment = dom.CreateComment("TileData Options");
            sr.AppendChild(comment);
            elem = dom.CreateElement("TileDataDirectlySaveOnChange");
            elem.SetAttribute("value", Options.TileDataDirectlySaveOnChange.ToString());
            sr.AppendChild(elem);

            dom.Save(fileName);
            Logger.Information("SaveProfile - done {filename}", fileName);
        }