示例#1
0
        public async Task SaveWindowSettingsAsync(DomainWindowSettings settings)
        {
            string json = await Task.Run(() => JsonConvert.SerializeObject(settings, Formatting.Indented));

            if (!await Task.Run(() => File.Exists(WindowSettingsFile)))
            {
                await Task.Run(() => Directory.CreateDirectory(Path.GetDirectoryName(WindowSettingsFile)));
            }

            await Task.Run(() => File.WriteAllText(WindowSettingsFile, json));
        }
示例#2
0
        public async Task <DomainWindowSettings> LoadWindowSettingsAsync()
        {
            DomainWindowSettings settings;

            if (await Task.Run(() => File.Exists(WindowSettingsFile)))
            {
                settings = await Task.Run(() => JsonConvert.DeserializeObject <DomainWindowSettings>(File.ReadAllText(WindowSettingsFile)));
            }
            else
            {
                settings = new DomainWindowSettings {
                    WindowW = 1024,
                    WindowH = 768,

                    WindowX = 100,
                    WindowY = 100,
                }
            };

            return(settings);
        }