Exemplo n.º 1
0
        public void Save()
        {
            var apps = _sharedConfig.Nodes[0].Node("Software").Node("Valve").Node("Steam").Node("apps");

            foreach (var app in Apps)
            {
                var vdfApp = apps.Node(app.Id.ToString());
                if (vdfApp == null)
                {
                    vdfApp = new VDFNode(app.Id.ToString(), _sharedConfig, apps);
                    apps.Nodes.Add(vdfApp);
                }
                var tagsNode = vdfApp.Node("tags");
                if (tagsNode != null)
                {
                    foreach (var key in tagsNode.Keys.Select(k => k.Name).ToArray())
                    {
                        tagsNode.Keys.CleanRemoveKey(key);
                    }
                }
                int keyIndex = 0;
                foreach (var tag in app.Tags.Where(p => p.Value).Select(p => p.Key))
                {
                    if (tagsNode == null)
                    {
                        tagsNode = new VDFNode("tags", _sharedConfig, vdfApp);
                    }
                    tagsNode.Keys.Add(new VDFKey(keyIndex.ToString(), tag, tagsNode));
                    keyIndex++;
                }
            }
            _sharedConfig.SaveToFile(_sharedConfigPath, true);
        }
        private void btnSaveToFile_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = saveFileDialog.ShowDialog(this); //Show our save file dialog and store its result on a variable.
            string       fileName     = saveFileDialog.FileName;         //Cache our filename as we are going to reset the dialogbox

            ClearDialogBoxes();
            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }
            vdfData.SaveToFile(fileName, true);
        }