[FZEditor]Fix missing file error message regression (#32088)

This commit is contained in:
Seraphima Zykova
2024-03-26 22:11:18 +01:00
committed by GitHub
parent 0a316370d8
commit 88c2f3022a

View File

@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Text.Json; using System.Text.Json;
using System.Windows; using System.Windows;
using FancyZonesEditor.Models; using FancyZonesEditor.Models;
@@ -153,10 +154,13 @@ namespace FancyZonesEditor.Utils
try try
{ {
LayoutHotkeys parser = new LayoutHotkeys(); LayoutHotkeys parser = new LayoutHotkeys();
if (!File.Exists(parser.File))
{
return new ParsingResult(true);
}
var layoutHotkeys = parser.Read(parser.File); var layoutHotkeys = parser.Read(parser.File);
bool layoutHotkeysParsingResult = SetLayoutHotkeys(layoutHotkeys); bool layoutHotkeysParsingResult = SetLayoutHotkeys(layoutHotkeys);
if (!layoutHotkeysParsingResult) if (!layoutHotkeysParsingResult)
{ {
return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Layout_Hotkeys_Message); return new ParsingResult(false, FancyZonesEditor.Properties.Resources.Error_Parsing_Layout_Hotkeys_Message);
@@ -178,8 +182,12 @@ namespace FancyZonesEditor.Utils
try try
{ {
LayoutTemplates parser = new LayoutTemplates(); LayoutTemplates parser = new LayoutTemplates();
var templates = parser.Read(parser.File); if (!File.Exists(parser.File))
{
return new ParsingResult(true);
}
var templates = parser.Read(parser.File);
bool parsingResult = SetTemplateLayouts(templates.LayoutTemplates); bool parsingResult = SetTemplateLayouts(templates.LayoutTemplates);
if (parsingResult) if (parsingResult)
{ {
@@ -202,8 +210,12 @@ namespace FancyZonesEditor.Utils
try try
{ {
CustomLayouts parser = new CustomLayouts(); CustomLayouts parser = new CustomLayouts();
var wrapper = parser.Read(parser.File); if (!File.Exists(parser.File))
{
return new ParsingResult(true);
}
var wrapper = parser.Read(parser.File);
bool parsingResult = SetCustomLayouts(wrapper.CustomLayouts); bool parsingResult = SetCustomLayouts(wrapper.CustomLayouts);
if (parsingResult) if (parsingResult)
{ {
@@ -226,8 +238,12 @@ namespace FancyZonesEditor.Utils
try try
{ {
DefaultLayouts parser = new DefaultLayouts(); DefaultLayouts parser = new DefaultLayouts();
var wrapper = parser.Read(parser.File); if (!File.Exists(parser.File))
{
return new ParsingResult(true);
}
var wrapper = parser.Read(parser.File);
bool parsingResult = SetDefaultLayouts(wrapper.DefaultLayouts); bool parsingResult = SetDefaultLayouts(wrapper.DefaultLayouts);
if (parsingResult) if (parsingResult)
{ {