public static void LoadSetting(string filePath) { try { // 読み込み using (StreamReader sr = new StreamReader(filePath)) { FusenConfig cfg = new FusenConfig(); cfg = JsonSerializer.Deserialize <FusenConfig>(sr.ReadToEnd()); frameMargin = cfg.FrameMargin; adsorbMargin = cfg.AdsorbMargin; dataFilePath = cfg.DataFilePath; importSettingFilePath = cfg.ImportSettingFilePath; exportSettingFilePath = cfg.ExportSettingFilePath; importDataFilePath = cfg.ImportDataFilePath; exportDataFilePath = cfg.ExportDataFilePath; userColors.FromHtmlString(cfg.UserColors); } } catch (System.IO.FileNotFoundException) { } catch (Exception ee) { MessageBox.Show(string.Format("{0}\r\n{1}\r\n{2}", ee.Message, ee.Source, ee.StackTrace)); } }
public static void SaveSetting(string filePath) { // 全体 FusenConfig cfg = new FusenConfig() { FrameMargin = frameMargin, AdsorbMargin = adsorbMargin, DataFilePath = dataFilePath, ImportSettingFilePath = importSettingFilePath, ExportSettingFilePath = exportSettingFilePath, ImportDataFilePath = importDataFilePath, ExportDataFilePath = exportDataFilePath, UserColors = userColors.ToHtmlString() }; using (StreamWriter sw = new StreamWriter(filePath)) { sw.Write(JsonSerializer.PrettyPrint(JsonSerializer.Serialize(cfg))); } }