Beispiel #1
0
        // ========================================
        // static method
        // ========================================
        internal static MemopadWindowSettings LoadWindowSettings()
        {
            var ret = default(MemopadWindowSettings);

            try {
                if (File.Exists(MemopadConsts.WindowSettingsFilePath))
                {
                    var serializer = new DataContractSerializer(typeof(MemopadWindowSettings));
                    using (
                        var stream = new FileStream(MemopadConsts.WindowSettingsFilePath, FileMode.Open, FileAccess.Read)
                        )
                        using (var reader = XmlReader.Create(stream)) {
                            ret = serializer.ReadObject(reader) as MemopadWindowSettings;
                        }
                }
            } catch (Exception e) {
                Logger.Warn("Window settings load failed", e);
            }

            if (ret == null)
            {
                ret = new MemopadWindowSettings();
            }

            return(ret);
        }
Beispiel #2
0
        internal static void SaveWindowSettings(MemopadWindowSettings windowSettings)
        {
            var serializer = new DataContractSerializer(typeof(MemopadWindowSettings));

            using (var stream = new FileStream(MemopadConsts.WindowSettingsFilePath, FileMode.Create, FileAccess.Write))
                using (var writer = XmlWriter.Create(stream)) {
                    serializer.WriteObject(writer, windowSettings);
                }
        }