private void btSaveLayout_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { System.IO.MemoryStream ms = new System.IO.MemoryStream(); lcMain.SaveLayoutToStream(ms); string English = Config.GetValue("Language").ToString() == "1" ? "_E" : ""; _data.DrTable["FileLayout" + English] = ms.ToArray(); _data.updateLayoutFile(_data.DrTable); } catch { } }
/// <summary> /// 获取布局数据 /// </summary> /// <param name="dockManager">停靠管理器</param> /// <returns>布局数据</returns> public static byte[] GetLayoutData(this LayoutControl control) { using (MemoryStream buffer = new MemoryStream()) { control.SaveLayoutToStream(buffer); return(buffer.ToArray()); } }
private void AddLayoutControl() { int x = 100, y = 80; int fieldCount = _data.DsStruct.Tables[0].Rows.Count; if (fieldCount < 6) { x = 200; y = 160; } this.Width = fieldCount * 50 + x; this.Height = fieldCount * 40 + y; GridControl gcTmp = null; lcMain = new LayoutControl(); string path; string English = Config.GetValue("Language").ToString() == "1" ? "_E" : ""; if (Config.GetValue("DuongDanLayout") == null) { path = Application.StartupPath + "\\Layouts\\" + Config.GetValue("Package").ToString() + English + "\\" + _data.DrTable["TableName"].ToString() + ".xml"; } else { path = Config.GetValue("DuongDanLayout").ToString() + "\\" + Config.GetValue("Package").ToString() + English + "\\" + _data.DrTable["TableName"].ToString() + ".xml"; } lcMain = _frmDesigner.GenLayout3(ref gcTmp, true); //if (fieldCount > 12) // lcMain = _frmDesigner.GenLayout3(ref gcTmp, true); //else // lcMain = _frmDesigner.GenLayout2(ref gcTmp, true); if (_data.DrTable["FileLayout" + English] == DBNull.Value) { if (System.IO.File.Exists(path)) { lcMain.RestoreLayoutFromXml(path); //UpLoad Layout to database System.IO.MemoryStream ms = new MemoryStream(); lcMain.SaveLayoutToStream(ms); _data.DrTable["FileLayout" + English] = ms.ToArray(); _data.updateLayoutFile(_data.DrTable); lcMain.ShowCustomization += lcMain_ShowCustomization; } } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(_data.DrTable["FileLayout" + English] as byte[]); lcMain.RestoreLayoutFromStream(ms); lcMain.ShowCustomization += lcMain_ShowCustomization; } lcMain.MouseUp += FrmSingleDt_MouseUp; this.Controls.Add(lcMain); }
private static string GetLayoutXml(LayoutControl layoutControl) { string xml; using (var stream = new MemoryStream()) { using (var reader = new StreamReader(stream)) { layoutControl.SaveLayoutToStream(stream); stream.Seek(0, SeekOrigin.Begin); xml = reader.ReadToEnd(); } } return(xml); }
protected void InitializeLayoutCustomization(LayoutControl layoutControl) { try { layoutControl.HideCustomization += delegate { try { MemoryStream ms = new MemoryStream(); layoutControl.SaveLayoutToStream(ms); Dictionary <string, byte[]> dic = CacheHelper.Get <Dictionary <string, byte[]> >("layout_" + SysPage.Menu_Id); if (dic == null) { dic = new Dictionary <string, byte[]>(); } dic[layoutControl.Name] = ms.ToBytes(); CacheHelper.Set(dic, "layout_" + SysPage.Menu_Id); } catch (Exception ex) { SharedFunc.RaiseError(ex); } }; this.Shown += delegate { try { Dictionary <string, byte[]> dic = CacheHelper.Get <Dictionary <string, byte[]> >("layout_" + SysPage.Menu_Id); if (dic == null || !dic.ContainsKey(layoutControl.Name)) { return; } Stream ms = ((byte[])dic[layoutControl.Name]).ToStream(); layoutControl.RestoreLayoutFromStream(ms); } catch (Exception ex) { SharedFunc.RaiseError(ex); } }; } catch (Exception ex) { SharedFunc.RaiseError(ex); } }