2020-02-10 21:59:51 +08:00
|
|
|
#include "pch.h"
|
2020-07-22 16:39:13 +08:00
|
|
|
|
2020-02-10 21:59:51 +08:00
|
|
|
#include "JsonHelpers.h"
|
2020-07-22 16:39:13 +08:00
|
|
|
#include "FancyZonesDataTypes.h"
|
2020-02-18 00:40:02 +08:00
|
|
|
#include "trace.h"
|
2020-07-22 16:39:13 +08:00
|
|
|
#include "util.h"
|
2020-02-10 21:59:51 +08:00
|
|
|
|
|
|
|
#include <filesystem>
|
2020-07-22 16:39:13 +08:00
|
|
|
#include <optional>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
// Non-Localizable strings
|
|
|
|
namespace NonLocalizable
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
const wchar_t ActiveZoneSetStr[] = L"active-zoneset";
|
|
|
|
const wchar_t AppPathStr[] = L"app-path";
|
|
|
|
const wchar_t AppZoneHistoryStr[] = L"app-zone-history";
|
|
|
|
const wchar_t CanvasStr[] = L"canvas";
|
|
|
|
const wchar_t CellChildMapStr[] = L"cell-child-map";
|
|
|
|
const wchar_t ColumnsPercentageStr[] = L"columns-percentage";
|
|
|
|
const wchar_t ColumnsStr[] = L"columns";
|
|
|
|
const wchar_t CustomZoneSetsStr[] = L"custom-zone-sets";
|
|
|
|
const wchar_t DeletedCustomZoneSetsStr[] = L"deleted-custom-zone-sets";
|
|
|
|
const wchar_t DeviceIdStr[] = L"device-id";
|
|
|
|
const wchar_t DevicesStr[] = L"devices";
|
|
|
|
const wchar_t EditorShowSpacingStr[] = L"editor-show-spacing";
|
|
|
|
const wchar_t EditorSpacingStr[] = L"editor-spacing";
|
|
|
|
const wchar_t EditorZoneCountStr[] = L"editor-zone-count";
|
|
|
|
const wchar_t GridStr[] = L"grid";
|
|
|
|
const wchar_t HeightStr[] = L"height";
|
|
|
|
const wchar_t HistoryStr[] = L"history";
|
|
|
|
const wchar_t InfoStr[] = L"info";
|
|
|
|
const wchar_t NameStr[] = L"name";
|
|
|
|
const wchar_t RefHeightStr[] = L"ref-height";
|
|
|
|
const wchar_t RefWidthStr[] = L"ref-width";
|
|
|
|
const wchar_t RowsPercentageStr[] = L"rows-percentage";
|
|
|
|
const wchar_t RowsStr[] = L"rows";
|
|
|
|
const wchar_t TypeStr[] = L"type";
|
|
|
|
const wchar_t UuidStr[] = L"uuid";
|
|
|
|
const wchar_t WidthStr[] = L"width";
|
|
|
|
const wchar_t XStr[] = L"X";
|
|
|
|
const wchar_t YStr[] = L"Y";
|
|
|
|
const wchar_t ZoneIndexSetStr[] = L"zone-index-set";
|
|
|
|
const wchar_t ZoneIndexStr[] = L"zone-index";
|
|
|
|
const wchar_t ZoneSetUuidStr[] = L"zoneset-uuid";
|
|
|
|
const wchar_t ZonesStr[] = L"zones";
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
namespace
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
json::JsonArray NumVecToJsonArray(const std::vector<int>& vec)
|
|
|
|
{
|
|
|
|
json::JsonArray arr;
|
|
|
|
for (const auto& val : vec)
|
|
|
|
{
|
|
|
|
arr.Append(json::JsonValue::CreateNumberValue(val));
|
|
|
|
}
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<int> JsonArrayToNumVec(const json::JsonArray& arr)
|
|
|
|
{
|
|
|
|
std::vector<int> vec;
|
|
|
|
for (const auto& val : arr)
|
|
|
|
{
|
|
|
|
vec.emplace_back(static_cast<int>(val.GetNumber()));
|
|
|
|
}
|
|
|
|
|
|
|
|
return vec;
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
std::optional<FancyZonesDataTypes::AppZoneHistoryData> ParseSingleAppZoneHistoryItem(const json::JsonObject& json)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
FancyZonesDataTypes::AppZoneHistoryData data;
|
|
|
|
if (json.HasKey(NonLocalizable::ZoneIndexSetStr))
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
data.zoneIndexSet = {};
|
|
|
|
for (auto& value : json.GetNamedArray(NonLocalizable::ZoneIndexSetStr))
|
2020-05-27 22:52:59 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
data.zoneIndexSet.push_back(static_cast<int>(value.GetNumber()));
|
2020-05-27 22:52:59 +08:00
|
|
|
}
|
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
else if (json.HasKey(NonLocalizable::ZoneIndexStr))
|
2020-06-05 23:25:52 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
data.zoneIndexSet = { static_cast<int>(json.GetNamedNumber(NonLocalizable::ZoneIndexStr)) };
|
2020-06-05 23:25:52 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
data.deviceId = json.GetNamedString(NonLocalizable::DeviceIdStr);
|
|
|
|
data.zoneSetUuid = json.GetNamedString(NonLocalizable::ZoneSetUuidStr);
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
if (!IsValidGuid(data.zoneSetUuid) || !IsValidDeviceId(data.deviceId))
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
return data;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
inline bool DeleteTmpFile(std::wstring_view tmpFilePath)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return DeleteFileW(tmpFilePath.data());
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
}
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
namespace JSONHelpers
|
|
|
|
{
|
|
|
|
json::JsonObject CanvasLayoutInfoJSON::ToJson(const FancyZonesDataTypes::CanvasLayoutInfo& canvasInfo)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject infoJson{};
|
|
|
|
infoJson.SetNamedValue(NonLocalizable::RefWidthStr, json::value(canvasInfo.lastWorkAreaWidth));
|
|
|
|
infoJson.SetNamedValue(NonLocalizable::RefHeightStr, json::value(canvasInfo.lastWorkAreaHeight));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray zonesJson;
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
for (const auto& [x, y, width, height] : canvasInfo.zones)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject zoneJson;
|
|
|
|
zoneJson.SetNamedValue(NonLocalizable::XStr, json::value(x));
|
|
|
|
zoneJson.SetNamedValue(NonLocalizable::YStr, json::value(y));
|
|
|
|
zoneJson.SetNamedValue(NonLocalizable::WidthStr, json::value(width));
|
|
|
|
zoneJson.SetNamedValue(NonLocalizable::HeightStr, json::value(height));
|
|
|
|
zonesJson.Append(zoneJson);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
infoJson.SetNamedValue(NonLocalizable::ZonesStr, zonesJson);
|
|
|
|
return infoJson;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
std::optional<FancyZonesDataTypes::CanvasLayoutInfo> CanvasLayoutInfoJSON::FromJson(const json::JsonObject& infoJson)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
FancyZonesDataTypes::CanvasLayoutInfo info;
|
|
|
|
info.lastWorkAreaWidth = static_cast<int>(infoJson.GetNamedNumber(NonLocalizable::RefWidthStr));
|
|
|
|
info.lastWorkAreaHeight = static_cast<int>(infoJson.GetNamedNumber(NonLocalizable::RefHeightStr));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray zonesJson = infoJson.GetNamedArray(NonLocalizable::ZonesStr);
|
|
|
|
uint32_t size = zonesJson.Size();
|
|
|
|
info.zones.reserve(size);
|
|
|
|
for (uint32_t i = 0; i < size; ++i)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject zoneJson = zonesJson.GetObjectAt(i);
|
|
|
|
const int x = static_cast<int>(zoneJson.GetNamedNumber(NonLocalizable::XStr));
|
|
|
|
const int y = static_cast<int>(zoneJson.GetNamedNumber(NonLocalizable::YStr));
|
|
|
|
const int width = static_cast<int>(zoneJson.GetNamedNumber(NonLocalizable::WidthStr));
|
|
|
|
const int height = static_cast<int>(zoneJson.GetNamedNumber(NonLocalizable::HeightStr));
|
|
|
|
FancyZonesDataTypes::CanvasLayoutInfo::Rect zone{ x, y, width, height };
|
|
|
|
info.zones.push_back(zone);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
return info;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject GridLayoutInfoJSON::ToJson(const FancyZonesDataTypes::GridLayoutInfo& gridInfo)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject infoJson;
|
|
|
|
infoJson.SetNamedValue(NonLocalizable::RowsStr, json::value(gridInfo.m_rows));
|
|
|
|
infoJson.SetNamedValue(NonLocalizable::ColumnsStr, json::value(gridInfo.m_columns));
|
|
|
|
infoJson.SetNamedValue(NonLocalizable::RowsPercentageStr, NumVecToJsonArray(gridInfo.m_rowsPercents));
|
|
|
|
infoJson.SetNamedValue(NonLocalizable::ColumnsPercentageStr, NumVecToJsonArray(gridInfo.m_columnsPercents));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray cellChildMapJson;
|
|
|
|
for (int i = 0; i < gridInfo.m_cellChildMap.size(); ++i)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
cellChildMapJson.Append(NumVecToJsonArray(gridInfo.m_cellChildMap[i]));
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
infoJson.SetNamedValue(NonLocalizable::CellChildMapStr, cellChildMapJson);
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
return infoJson;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
std::optional<FancyZonesDataTypes::GridLayoutInfo> GridLayoutInfoJSON::FromJson(const json::JsonObject& infoJson)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
FancyZonesDataTypes::GridLayoutInfo info(FancyZonesDataTypes::GridLayoutInfo::Minimal{});
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
info.m_rows = static_cast<int>(infoJson.GetNamedNumber(NonLocalizable::RowsStr));
|
|
|
|
info.m_columns = static_cast<int>(infoJson.GetNamedNumber(NonLocalizable::ColumnsStr));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray rowsPercentage = infoJson.GetNamedArray(NonLocalizable::RowsPercentageStr);
|
|
|
|
json::JsonArray columnsPercentage = infoJson.GetNamedArray(NonLocalizable::ColumnsPercentageStr);
|
|
|
|
json::JsonArray cellChildMap = infoJson.GetNamedArray(NonLocalizable::CellChildMapStr);
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
if (rowsPercentage.Size() != info.m_rows || columnsPercentage.Size() != info.m_columns || cellChildMap.Size() != info.m_rows)
|
2020-02-17 23:28:49 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
info.m_rowsPercents = JsonArrayToNumVec(rowsPercentage);
|
|
|
|
info.m_columnsPercents = JsonArrayToNumVec(columnsPercentage);
|
|
|
|
for (const auto& cellsRow : cellChildMap)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
const auto cellsArray = cellsRow.GetArray();
|
|
|
|
if (cellsArray.Size() != info.m_columns)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
info.cellChildMap().push_back(JsonArrayToNumVec(cellsArray));
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
return info;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
|
|
|
}
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject CustomZoneSetJSON::ToJson(const CustomZoneSetJSON& customZoneSet)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject result{};
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.SetNamedValue(NonLocalizable::UuidStr, json::value(customZoneSet.uuid));
|
|
|
|
result.SetNamedValue(NonLocalizable::NameStr, json::value(customZoneSet.data.name));
|
|
|
|
switch (customZoneSet.data.type)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
case FancyZonesDataTypes::CustomLayoutType::Canvas:
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
result.SetNamedValue(NonLocalizable::TypeStr, json::value(NonLocalizable::CanvasStr));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
FancyZonesDataTypes::CanvasLayoutInfo info = std::get<FancyZonesDataTypes::CanvasLayoutInfo>(customZoneSet.data.info);
|
|
|
|
result.SetNamedValue(NonLocalizable::InfoStr, CanvasLayoutInfoJSON::ToJson(info));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FancyZonesDataTypes::CustomLayoutType::Grid:
|
|
|
|
{
|
|
|
|
result.SetNamedValue(NonLocalizable::TypeStr, json::value(NonLocalizable::GridStr));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
FancyZonesDataTypes::GridLayoutInfo gridInfo = std::get<FancyZonesDataTypes::GridLayoutInfo>(customZoneSet.data.info);
|
|
|
|
result.SetNamedValue(NonLocalizable::InfoStr, GridLayoutInfoJSON::ToJson(gridInfo));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
break;
|
|
|
|
}
|
2020-02-18 00:40:02 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
return result;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
std::optional<CustomZoneSetJSON> CustomZoneSetJSON::FromJson(const json::JsonObject& customZoneSet)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
try
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
CustomZoneSetJSON result;
|
|
|
|
|
|
|
|
result.uuid = customZoneSet.GetNamedString(NonLocalizable::UuidStr);
|
|
|
|
if (!IsValidGuid(result.uuid))
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
|
|
|
}
|
2020-03-04 04:48:22 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.data.name = customZoneSet.GetNamedString(NonLocalizable::NameStr);
|
2020-04-08 21:43:19 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject infoJson = customZoneSet.GetNamedObject(NonLocalizable::InfoStr);
|
|
|
|
std::wstring zoneSetType = std::wstring{ customZoneSet.GetNamedString(NonLocalizable::TypeStr) };
|
|
|
|
if (zoneSetType.compare(NonLocalizable::CanvasStr) == 0)
|
|
|
|
{
|
|
|
|
if (auto info = CanvasLayoutInfoJSON::FromJson(infoJson); info.has_value())
|
2020-05-27 22:52:59 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
result.data.type = FancyZonesDataTypes::CustomLayoutType::Canvas;
|
|
|
|
result.data.info = std::move(info.value());
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
else
|
2020-05-27 22:52:59 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
else if (zoneSetType.compare(NonLocalizable::GridStr) == 0)
|
2020-06-05 23:25:52 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
if (auto info = GridLayoutInfoJSON::FromJson(infoJson); info.has_value())
|
2020-06-05 23:25:52 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
result.data.type = FancyZonesDataTypes::CustomLayoutType::Grid;
|
|
|
|
result.data.info = std::move(info.value());
|
2020-06-05 23:25:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
2020-06-05 23:25:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::nullopt;
|
2020-06-05 23:25:52 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
|
|
|
{
|
|
|
|
return std::nullopt;
|
2020-06-05 23:25:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject ZoneSetDataJSON::ToJson(const FancyZonesDataTypes::ZoneSetData& zoneSet)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
json::JsonObject result{};
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.SetNamedValue(NonLocalizable::UuidStr, json::value(zoneSet.uuid));
|
|
|
|
result.SetNamedValue(NonLocalizable::TypeStr, json::value(TypeToString(zoneSet.type)));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
std::optional<FancyZonesDataTypes::ZoneSetData> ZoneSetDataJSON::FromJson(const json::JsonObject& zoneSet)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
FancyZonesDataTypes::ZoneSetData zoneSetData;
|
|
|
|
zoneSetData.uuid = zoneSet.GetNamedString(NonLocalizable::UuidStr);
|
|
|
|
zoneSetData.type = FancyZonesDataTypes::TypeFromString(std::wstring{ zoneSet.GetNamedString(NonLocalizable::TypeStr) });
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
if (!IsValidGuid(zoneSetData.uuid))
|
2020-03-17 05:29:13 +08:00
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
2020-02-10 21:59:51 +08:00
|
|
|
return zoneSetData;
|
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
json::JsonObject AppZoneHistoryJSON::ToJson(const AppZoneHistoryJSON& appZoneHistory)
|
|
|
|
{
|
|
|
|
json::JsonObject result{};
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.SetNamedValue(NonLocalizable::AppPathStr, json::value(appZoneHistory.appPath));
|
2020-05-26 22:01:12 +08:00
|
|
|
|
2020-06-05 23:25:52 +08:00
|
|
|
json::JsonArray appHistoryArray;
|
|
|
|
for (const auto& data : appZoneHistory.data)
|
2020-05-26 22:01:12 +08:00
|
|
|
{
|
2020-06-05 23:25:52 +08:00
|
|
|
json::JsonObject desktopData;
|
|
|
|
json::JsonArray jsonIndexSet;
|
|
|
|
for (int index : data.zoneIndexSet)
|
|
|
|
{
|
|
|
|
jsonIndexSet.Append(json::value(index));
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
desktopData.SetNamedValue(NonLocalizable::ZoneIndexSetStr, jsonIndexSet);
|
|
|
|
desktopData.SetNamedValue(NonLocalizable::DeviceIdStr, json::value(data.deviceId));
|
|
|
|
desktopData.SetNamedValue(NonLocalizable::ZoneSetUuidStr, json::value(data.zoneSetUuid));
|
2020-06-05 23:25:52 +08:00
|
|
|
|
|
|
|
appHistoryArray.Append(desktopData);
|
2020-05-26 22:01:12 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.SetNamedValue(NonLocalizable::HistoryStr, appHistoryArray);
|
2020-02-10 21:59:51 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<AppZoneHistoryJSON> AppZoneHistoryJSON::FromJson(const json::JsonObject& zoneSet)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
AppZoneHistoryJSON result;
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.appPath = zoneSet.GetNamedString(NonLocalizable::AppPathStr);
|
|
|
|
if (zoneSet.HasKey(NonLocalizable::HistoryStr))
|
2020-05-26 22:01:12 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
auto appHistoryArray = zoneSet.GetNamedArray(NonLocalizable::HistoryStr);
|
2020-06-05 23:25:52 +08:00
|
|
|
for (uint32_t i = 0; i < appHistoryArray.Size(); ++i)
|
2020-05-26 22:01:12 +08:00
|
|
|
{
|
2020-06-05 23:25:52 +08:00
|
|
|
json::JsonObject json = appHistoryArray.GetObjectAt(i);
|
|
|
|
if (auto data = ParseSingleAppZoneHistoryItem(json); data.has_value())
|
|
|
|
{
|
|
|
|
result.data.push_back(std::move(data.value()));
|
|
|
|
}
|
2020-05-26 22:01:12 +08:00
|
|
|
}
|
|
|
|
}
|
2020-06-05 23:25:52 +08:00
|
|
|
else
|
2020-05-26 22:01:12 +08:00
|
|
|
{
|
2020-06-05 23:25:52 +08:00
|
|
|
// handle previous file format, with single desktop layout information per application
|
|
|
|
if (auto data = ParseSingleAppZoneHistoryItem(zoneSet); data.has_value())
|
|
|
|
{
|
|
|
|
result.data.push_back(std::move(data.value()));
|
|
|
|
}
|
2020-05-26 22:01:12 +08:00
|
|
|
}
|
2020-06-05 23:25:52 +08:00
|
|
|
if (result.data.empty())
|
2020-03-17 05:29:13 +08:00
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
2020-02-10 21:59:51 +08:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
json::JsonObject DeviceInfoJSON::ToJson(const DeviceInfoJSON& device)
|
|
|
|
{
|
|
|
|
json::JsonObject result{};
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.SetNamedValue(NonLocalizable::DeviceIdStr, json::value(device.deviceId));
|
|
|
|
result.SetNamedValue(NonLocalizable::ActiveZoneSetStr, JSONHelpers::ZoneSetDataJSON::ToJson(device.data.activeZoneSet));
|
|
|
|
result.SetNamedValue(NonLocalizable::EditorShowSpacingStr, json::value(device.data.showSpacing));
|
|
|
|
result.SetNamedValue(NonLocalizable::EditorSpacingStr, json::value(device.data.spacing));
|
|
|
|
result.SetNamedValue(NonLocalizable::EditorZoneCountStr, json::value(device.data.zoneCount));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<DeviceInfoJSON> DeviceInfoJSON::FromJson(const json::JsonObject& device)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
DeviceInfoJSON result;
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.deviceId = device.GetNamedString(NonLocalizable::DeviceIdStr);
|
|
|
|
if (!IsValidDeviceId(result.deviceId))
|
2020-03-17 05:29:13 +08:00
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
if (auto zoneSet = JSONHelpers::ZoneSetDataJSON::FromJson(device.GetNamedObject(NonLocalizable::ActiveZoneSetStr)); zoneSet.has_value())
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
result.data.activeZoneSet = std::move(zoneSet.value());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
result.data.showSpacing = device.GetNamedBoolean(NonLocalizable::EditorShowSpacingStr);
|
|
|
|
result.data.spacing = static_cast<int>(device.GetNamedNumber(NonLocalizable::EditorSpacingStr));
|
2020-02-10 21:59:51 +08:00
|
|
|
result.data.zoneCount = static_cast<int>(
|
2020-07-22 16:39:13 +08:00
|
|
|
device.GetNamedNumber(NonLocalizable::EditorZoneCountStr));
|
2020-02-10 21:59:51 +08:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject GetPersistFancyZonesJSON(const std::wstring& zonesSettingsFileName, const std::wstring& appZoneHistoryFileName)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
auto result = json::from_file(zonesSettingsFileName);
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
if (!result->HasKey(NonLocalizable::AppZoneHistoryStr))
|
|
|
|
{
|
|
|
|
auto appZoneHistory = json::from_file(appZoneHistoryFileName);
|
|
|
|
if (appZoneHistory)
|
|
|
|
{
|
|
|
|
result->SetNamedValue(NonLocalizable::AppZoneHistoryStr, appZoneHistory->GetNamedArray(NonLocalizable::AppZoneHistoryStr));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result->SetNamedValue(NonLocalizable::AppZoneHistoryStr, json::JsonArray());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return *result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return json::JsonObject();
|
|
|
|
}
|
|
|
|
}
|
2020-05-29 15:38:29 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
void SaveFancyZonesData(const std::wstring& zonesSettingsFileName,
|
|
|
|
const std::wstring& appZoneHistoryFileName,
|
|
|
|
const TDeviceInfoMap& deviceInfoMap,
|
|
|
|
const TCustomZoneSetsMap& customZoneSetsMap,
|
|
|
|
const TAppZoneHistoryMap& appZoneHistoryMap)
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
{
|
|
|
|
json::JsonObject root{};
|
|
|
|
json::JsonObject appZoneHistoryRoot{};
|
|
|
|
|
|
|
|
appZoneHistoryRoot.SetNamedValue(NonLocalizable::AppZoneHistoryStr, JSONHelpers::SerializeAppZoneHistory(appZoneHistoryMap));
|
|
|
|
root.SetNamedValue(NonLocalizable::DevicesStr, JSONHelpers::SerializeDeviceInfos(deviceInfoMap));
|
|
|
|
root.SetNamedValue(NonLocalizable::CustomZoneSetsStr, JSONHelpers::SerializeCustomZoneSets(customZoneSetsMap));
|
|
|
|
|
|
|
|
auto before = json::from_file(zonesSettingsFileName);
|
|
|
|
if (!before.has_value() || before.value().Stringify() != root.Stringify())
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
Trace::FancyZones::DataChanged();
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
|
|
|
|
json::to_file(zonesSettingsFileName, root);
|
|
|
|
json::to_file(appZoneHistoryFileName, appZoneHistoryRoot);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
TAppZoneHistoryMap ParseAppZoneHistory(const json::JsonObject& fancyZonesDataJSON)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
TAppZoneHistoryMap appZoneHistoryMap{};
|
|
|
|
auto appLastZones = fancyZonesDataJSON.GetNamedArray(NonLocalizable::AppZoneHistoryStr);
|
2020-05-29 15:38:29 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
for (uint32_t i = 0; i < appLastZones.Size(); ++i)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonObject appLastZone = appLastZones.GetObjectAt(i);
|
|
|
|
if (auto appZoneHistory = AppZoneHistoryJSON::FromJson(appLastZone); appZoneHistory.has_value())
|
|
|
|
{
|
|
|
|
appZoneHistoryMap[appZoneHistory->appPath] = std::move(appZoneHistory->data);
|
|
|
|
}
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
|
|
|
|
return std::move(appZoneHistoryMap);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return {};
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray SerializeAppZoneHistory(const TAppZoneHistoryMap& appZoneHistoryMap)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray appHistoryArray;
|
|
|
|
|
|
|
|
for (const auto& [appPath, appZoneHistoryData] : appZoneHistoryMap)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
appHistoryArray.Append(AppZoneHistoryJSON::ToJson(AppZoneHistoryJSON{ appPath, appZoneHistoryData }));
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
|
|
|
|
return appHistoryArray;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
TDeviceInfoMap ParseDeviceInfos(const json::JsonObject& fancyZonesDataJSON)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
try
|
|
|
|
{
|
|
|
|
TDeviceInfoMap deviceInfoMap{};
|
|
|
|
auto devices = fancyZonesDataJSON.GetNamedArray(NonLocalizable::DevicesStr);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < devices.Size(); ++i)
|
|
|
|
{
|
|
|
|
if (auto device = DeviceInfoJSON::DeviceInfoJSON::FromJson(devices.GetObjectAt(i)); device.has_value())
|
|
|
|
{
|
|
|
|
deviceInfoMap[device->deviceId] = std::move(device->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::move(deviceInfoMap);
|
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return {};
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray SerializeDeviceInfos(const TDeviceInfoMap& deviceInfoMap)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray DeviceInfosJSON{};
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
for (const auto& [deviceID, deviceData] : deviceInfoMap)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
if (deviceData.activeZoneSet.type != FancyZonesDataTypes::ZoneSetLayoutType::Blank)
|
|
|
|
{
|
|
|
|
DeviceInfosJSON.Append(DeviceInfoJSON::DeviceInfoJSON::ToJson(DeviceInfoJSON{ deviceID, deviceData }));
|
|
|
|
}
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
return DeviceInfosJSON;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
TCustomZoneSetsMap ParseCustomZoneSets(const json::JsonObject& fancyZonesDataJSON)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
TCustomZoneSetsMap customZoneSetsMap{};
|
|
|
|
auto customZoneSets = fancyZonesDataJSON.GetNamedArray(NonLocalizable::CustomZoneSetsStr);
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
for (uint32_t i = 0; i < customZoneSets.Size(); ++i)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
if (auto zoneSet = CustomZoneSetJSON::FromJson(customZoneSets.GetObjectAt(i)); zoneSet.has_value())
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
customZoneSetsMap[zoneSet->uuid] = std::move(zoneSet->data);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
return std::move(customZoneSetsMap);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
catch (const winrt::hresult_error&)
|
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
return {};
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray SerializeCustomZoneSets(const TCustomZoneSetsMap& customZoneSetsMap)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
json::JsonArray customZoneSetsJSON{};
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
for (const auto& [zoneSetId, zoneSetData] : customZoneSetsMap)
|
2020-05-27 22:52:59 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
customZoneSetsJSON.Append(CustomZoneSetJSON::ToJson(CustomZoneSetJSON{ zoneSetId, zoneSetData }));
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
return customZoneSetsJSON;
|
|
|
|
}
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
void SerializeDeviceInfoToTmpFile(const JSONHelpers::DeviceInfoJSON& deviceInfo, std::wstring_view tmpFilePath)
|
|
|
|
{
|
|
|
|
json::JsonObject deviceInfoJson = JSONHelpers::DeviceInfoJSON::ToJson(deviceInfo);
|
|
|
|
json::to_file(tmpFilePath, deviceInfoJson);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
std::optional<DeviceInfoJSON> ParseDeviceInfoFromTmpFile(std::wstring_view tmpFilePath)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
std::optional<DeviceInfoJSON> result{ std::nullopt };
|
|
|
|
if (std::filesystem::exists(tmpFilePath))
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
if (auto zoneSetJson = json::from_file(tmpFilePath); zoneSetJson.has_value())
|
2020-03-17 05:29:13 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
if (auto deviceInfo = JSONHelpers::DeviceInfoJSON::FromJson(zoneSetJson.value()); deviceInfo.has_value())
|
|
|
|
{
|
|
|
|
result = std::move(deviceInfo);
|
|
|
|
}
|
2020-03-17 05:29:13 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
}
|
2020-05-27 22:52:59 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
DeleteTmpFile(tmpFilePath);
|
|
|
|
return result;
|
|
|
|
}
|
2020-02-10 21:59:51 +08:00
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
std::optional<CustomZoneSetJSON> ParseCustomZoneSetFromTmpFile(std::wstring_view tmpFilePath)
|
|
|
|
{
|
|
|
|
std::optional<CustomZoneSetJSON> result{ std::nullopt };
|
|
|
|
if (std::filesystem::exists(tmpFilePath))
|
|
|
|
{
|
|
|
|
try
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
if (auto customZoneSetJson = json::from_file(tmpFilePath); customZoneSetJson.has_value())
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
if (auto customZoneSet = JSONHelpers::CustomZoneSetJSON::FromJson(customZoneSetJson.value()); customZoneSet.has_value())
|
|
|
|
{
|
|
|
|
result = std::move(customZoneSet);
|
|
|
|
}
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
catch (const winrt::hresult_error&)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
result = std::nullopt;
|
|
|
|
}
|
|
|
|
|
|
|
|
DeleteTmpFile(tmpFilePath);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::wstring> ParseDeletedCustomZoneSetsFromTmpFile(std::wstring_view tmpFilePath)
|
|
|
|
{
|
|
|
|
std::vector<std::wstring> result{};
|
|
|
|
if (std::filesystem::exists(tmpFilePath))
|
|
|
|
{
|
|
|
|
auto deletedZoneSetsJson = json::from_file(tmpFilePath);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
auto deletedCustomZoneSets = deletedZoneSetsJson->GetNamedArray(NonLocalizable::DeletedCustomZoneSetsStr);
|
|
|
|
for (auto zoneSet : deletedCustomZoneSets)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
2020-07-22 16:39:13 +08:00
|
|
|
std::wstring uuid = L"{" + std::wstring{ zoneSet.GetString() } + L"}";
|
|
|
|
result.push_back(uuid);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
catch (const winrt::hresult_error&)
|
2020-02-10 21:59:51 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-22 16:39:13 +08:00
|
|
|
DeleteTmpFile(tmpFilePath);
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
2020-07-22 16:39:13 +08:00
|
|
|
|
|
|
|
return result;
|
2020-02-10 21:59:51 +08:00
|
|
|
}
|
|
|
|
}
|