private void SaveLayout() { if (UserInterfaceLayoutRepository == null || string.IsNullOrWhiteSpace(LayoutName)) { return; } if (_userInterfaceLayoutModel == null) { _userInterfaceLayoutModel = new UserInterfaceLayoutModel { LayoutName = LayoutName }; } using (MemoryStream stream = new MemoryStream()) { AssociatedObject.SaveLayout(stream); stream.Position = 0; using (StreamReader sr = new StreamReader(stream)) { _userInterfaceLayoutModel.MainViewDockingData = sr.ReadToEnd(); UserInterfaceLayoutRepository.Save(_userInterfaceLayoutModel); } } }
private void LoadLayout(string layoutName) { if (AssociatedObject == null) { return; } if (UserInterfaceLayoutRepository == null) { AssociatedObject.LoadLayout(StringResources.XmlOriginalLayout); return; } _userInterfaceLayoutModel = UserInterfaceLayoutRepository.FindSingle(model => model.LayoutName == layoutName); if (_userInterfaceLayoutModel == null) { return; } PropertyInfo pi = _userInterfaceLayoutModel.GetType().GetProperty(LayoutDataPropertyName); if (pi == null) { return; } string layoutData = pi.GetValue(_userInterfaceLayoutModel, null) as string; if (layoutData == null) { return; } try { AssociatedObject.LoadLayout(layoutData); } catch (Exception) { Dev2Logger.Log.Info("Invalid user interface layout file encountered, reverting to default layout."); } }