protected void SaveConfig() { //todo - do not save if not modified CloseAllHiddenContents(); FrwConfig.Instance.SetPropertyValue(FrwSimpleWinCRUDConfig.APPLICATION_FONT, Font); string configFile = GetContentConfigFileName(); MemoryStream xmlStream = new MemoryStream(); dockPanel.SaveAsXml(xmlStream, Encoding.UTF8); string newConfigLayoutStr = Encoding.UTF8.GetString(xmlStream.ToArray()); if (newConfigLayoutStr.Equals(configLayoutStr) == false) { File.WriteAllText(configFile, newConfigLayoutStr); configLayoutStr = newConfigLayoutStr; //Log.ProcessDebug("@@@@@ Saved config for main window " + DocPanelIndex); } //////////////////////////////////////////////// try { string filename = GetStateConfigFileName(); DocPanelState state = new DocPanelState(); SaveUserSettings(state.UserSettings); string newConfigStr = JsonSerializeHelper.SaveToString(state); if (newConfigStr.Equals(configFileStr) == false) { File.WriteAllText(filename, newConfigStr, Encoding.UTF8); configFileStr = newConfigStr; //Log.ProcessDebug("@@@@@ Saved json config for main window " + DocPanelIndex); } } catch (Exception ex) { Log.LogError("Can not write config for " + GetType().ToString(), ex); } }
protected void LoadConfig() { ///////////////////////////////////////////////// try { string filename = GetStateConfigFileName(); if (File.Exists(filename)) { configFileStr = File.ReadAllText(filename, Encoding.UTF8); DocPanelState state = JsonSerializeHelper.LoadFromString <DocPanelState>(configFileStr); LoadUserSettings(state.UserSettings); } } catch (Exception ex) { Log.LogError("Can not read config for " + GetType().ToString(), ex); } string configFile = GetContentConfigFileName(); if (File.Exists(configFile)) { configLayoutStr = File.ReadAllText(configFile); Stream xmlStream = new MemoryStream(Encoding.UTF8.GetBytes(configLayoutStr)); dockPanel.LoadFromXml(xmlStream, m_deserializeDockContent); //xmlStream.Close(); } try { // Font installation for all forms WinFormsUtils.SetNewControlFont(this, (Font)FrwConfig.Instance.GetPropertyValue(FrwSimpleWinCRUDConfig.APPLICATION_FONT));//if this.AutoScaleMode = Font - Setting the font will change the size of the window } catch (Exception ex) { Log.LogError("Can not set font ", ex); } }