Exemple #1
0
        public static void Save()
        {
            string regpath = string.Format(Utils.REG_USRSETTING, Constants.CODELIBRARY);

            LastOpenedDir  = string.IsNullOrEmpty(LastOpenedDir) ? string.Empty : LastOpenedDir;
            LastOpenedFile = string.IsNullOrEmpty(LastOpenedFile) ? string.Empty : LastOpenedFile;


            Utils.SetCurrentUserRegisterKey(regpath, Constants.THEME, Theme.ToString());
            Utils.SetCurrentUserRegisterKey(regpath, Constants.SORTMODE, SortMode.ToString());
            Utils.SetCurrentUserRegisterKey(regpath, Constants.BACKUPMODE, BackupMode.ToString());
            Utils.SetCurrentUserRegisterKey(regpath, Constants.LASTOPENEDDIR, LastOpenedDir);
            Utils.SetCurrentUserRegisterKey(regpath, Constants.LASTOPENEDFILE, LastOpenedFile);
            Utils.SetCurrentUserRegisterKey(regpath, Constants.BACKUPLOCATION, BackupLocation);
            Utils.SetCurrentUserRegisterKey(regpath, Constants.OPENDEFAULTONSTART, OpenDefaultOnStart.ToString());
            Utils.SetCurrentUserRegisterKey(regpath, Constants.ZOOM, Zoom.ToString());
            Utils.SetCurrentUserRegisterKey(regpath, Constants.SPLITTERDISTANCE, SplitterDistance.ToString());

            if (string.IsNullOrEmpty(DefaultNoteType))
            {
                DefaultNoteType = string.Empty;
            }
            Utils.SetCurrentUserRegisterKey(regpath, Constants.DEFAULT_NOTE_TYPE, DefaultNoteType);
            Utils.SetCurrentUserRegisterKey(regpath, Constants.PLUGINPATH, PluginPath);

            if (!Directory.Exists(AppFolder))
            {
                Directory.CreateDirectory(AppFolder);
            }

            if (File.Exists(FavoriteFile))
            {
                File.Delete(FavoriteFile);
            }

            string _json = Utils.ToJson <List <string> >(FavoriteLibs);

            File.WriteAllText(FavoriteFile, _json);

            StyleCollection.Instance.Save(RtfStylesFile);

            try
            {
                VersionNumber _version       = new VersionNumber(Assembly.GetEntryAssembly().GetName().Version.ToString());
                string        _versionString = _version.ToString();
                if (string.IsNullOrEmpty(_versionString))
                {
                    _versionString = string.Empty;
                }
                Utils.SetCurrentUserRegisterKey(regpath, Constants.VERSION, _versionString);
            }
            catch { }
        }
Exemple #2
0
        /// <summary>
        /// Save settings into the given file.
        /// </summary>
        /// <param name="fileName">file to save settings to</param>
        /// <param name="syncPathList">list with paths to synchronize</param>
        public void SaveJob(string fileName, SyncPathList syncPathList)
        {
            XmlAttribute attr;
            XmlElement   root;
            XmlNode      node;
            XmlDocument  doc     = new XmlDocument();
            XmlNode      xmlnode = doc.CreateNode(XmlNodeType.XmlDeclaration, "", "");

            doc.AppendChild(xmlnode);

            root = doc.CreateElement("InZync");

            // save paths to synchronize
            node = doc.CreateElement("SourcePaths");
            foreach (PathPair pp in syncPathList)
            {
                XmlNode pathNode = doc.CreateElement("Path");
                attr       = doc.CreateAttribute("source");
                attr.Value = pp.Source;
                pathNode.Attributes.Append(attr);
                attr       = doc.CreateAttribute("destination");
                attr.Value = pp.Destination;
                pathNode.Attributes.Append(attr);
                node.AppendChild(pathNode);
            }
            root.AppendChild(node);

            node           = doc.CreateElement("ShowLog");
            node.InnerText = ShowLogWindow.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("SaveLog");
            node.InnerText = SaveLog.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("AppendLog");
            node.InnerText = AppendLog.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("LogFile");
            node.InnerText = LogFile;
            root.AppendChild(node);

            node           = doc.CreateElement("ReadOnly");
            node.InnerText = RemoveReadOnlyFlag.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("DirectoriesLikeFiles");
            node.InnerText = DirectoriesLikeFiles.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("SubDirectories");
            node.InnerText = SubDirectories.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("HiddenFiles");
            node.InnerText = ProcessHiddenFiles.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("SystemFiles");
            node.InnerText = ProcessSystemFiles.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("TerminateApp");
            node.InnerText = TerminateApp.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("RunSilent");
            node.InnerText = RunSilent.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("Extensions");
            node.InnerText = ExtensionList;
            root.AppendChild(node);

            node           = doc.CreateElement("ExcludedExtensions");
            node.InnerText = ExcludedExtensionList;
            root.AppendChild(node);

            node           = doc.CreateElement("SourceNewer");
            node.InnerText = SourceNewer.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("SourceMissing");
            node.InnerText = SourceMissing.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("DestNewer");
            node.InnerText = DestNewer.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("DestMissing");
            node.InnerText = DestMissing.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("BackupMode");
            node.InnerText = BackupMode.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("Template");
            node.InnerText = Template.ToString();
            root.AppendChild(node);

            node           = doc.CreateElement("ShowOnlyDifferentFiles");
            node.InnerText = ShowOnlyDifferentFiles.ToString();
            root.AppendChild(node);

            // save context menu entries
            node = doc.CreateElement("ContextMenuEntries");
            for (int i = 0; i < ContextMenu.Count; i++)
            {
                string[] cme      = ContextMenu[i].Split('\t');
                XmlNode  pathNode = doc.CreateElement("ContextMenuEntry");
                attr       = doc.CreateAttribute("caption");
                attr.Value = cme[0];
                pathNode.Attributes.Append(attr);
                attr       = doc.CreateAttribute("file");
                attr.Value = cme[1];
                pathNode.Attributes.Append(attr);

                if (i == ContextDblClickIdx)
                {
                    attr = doc.CreateAttribute("DblClick");
                    //attr.Value = cme[1];
                    pathNode.Attributes.Append(attr);
                }

                node.AppendChild(pathNode);
            }
            root.AppendChild(node);

            doc.AppendChild(root);
            doc.Save(fileName);
        }