private void InitJson() { string getJson = JsonSerializer.GetLastShortcutsJson(); Config shortcutsConfig = null; try { shortcutsConfig = Serializer.DeserializeConfig(getJson); } catch { shortcutsConfig = new Config(); getJson = Serializer.SerializeConfig(shortcutsConfig); JsonSerializer.SaveLastShortcutsJson(getJson); } JsonViewManager.SetJson(getJson); ShortcutListArea.LoadShortcuts(shortcutsConfig.Shortcuts); }
private static void ResetJson(bool shouldReset) { if (shouldReset) { string getJson = JsonSerializer.GetLastShortcutsJson(); Config shortcutsConfig = null; try { shortcutsConfig = Serializer.DeserializeConfig(getJson); } catch { shortcutsConfig = new Config(); getJson = Serializer.SerializeConfig(shortcutsConfig); JsonSerializer.SaveLastShortcutsJson(getJson); } JsonViewManager.SetJson(getJson); ShortcutListArea.LoadShortcuts(shortcutsConfig.Shortcuts); Wind.ValiationError.Visibility = Visibility.Collapsed; } }
public static void JsonButtonPressed(object sender, RoutedEventArgs args) { if (DialogManager.OpenDialogSession != null) { return; } if (inJsonView) { // Attempt to Deserialize Json string json = Wind.textEditor.Text; Config config = null; try { config = Serializer.DeserializeConfig(json); } catch (Exception e) { Dialogs.MessageDialog.SetMessage("Json Error", e.Message); DialogManager.Show(Structures.DialogTypes.MessageDialog); return; } ShortcutListArea.LoadShortcuts(config.Shortcuts); Wind.JsonView.Visibility = Visibility.Collapsed; Wind.NonJsonView.Visibility = Visibility.Visible; Wind.ValiationError.Visibility = Visibility.Collapsed; } else { LoadJsonFromShortcuts(); Wind.JsonView.Visibility = Visibility.Visible; Wind.NonJsonView.Visibility = Visibility.Collapsed; } inJsonView = !inJsonView; }