public static void RestoreLayoutExFromXml(this LayoutControl layoutControl, string filePath) { try { ObjectInfoCollection objects = new ObjectInfoCollection(); string filePathForControls = filePath.Replace(".xml", "Controls.xml"); serializer.DeserializeObject(objects, filePathForControls, appName); foreach (ObjectInfo info in objects.Collection) { Control ctrl = info.SerializableObject as Control; if (ctrl != null) { Control[] controls = layoutControl.Controls.Find(ctrl.Name, false); if (controls.Length > 0) { layoutControl.Controls.Remove(controls[0]); } layoutControl.Controls.Add(ctrl); } } layoutControl.RestoreLayoutFromXml(filePath); } catch (Exception exc) { XtraMessageBox.Show(exc.Message); } }
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); }
protected void GetLayOut(LayoutControl layoutControl1, DevExpress.XtraGrid.GridControl gridControl1) { sLayoutHeadPath = sProPath + "\\layout\\" + this.Text.Trim() + "Head.xml"; sLayoutGridPath = sProPath + "\\layout\\" + this.Text.Trim() + "Grid.xml"; if (File.Exists(sLayoutHeadPath)) layoutControl1.RestoreLayoutFromXml(sLayoutHeadPath); if (File.Exists(sLayoutGridPath)) { gridControl1.MainView.RestoreLayoutFromXml(sLayoutGridPath); } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { oFD.ShowDialog(); if (oFD.FileName != string.Empty) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); lcMain.RestoreLayoutFromXml(oFD.FileName); lcMain.SaveLayoutToStream(ms); //UpLoad Layout to database string English = Config.GetValue("Language").ToString() == "1" ? "_E" : ""; _data.DrTable["FileLayout" + English] = ms.ToArray(); _data.updateLayoutFile(_data.DrTable); } }
internal void CargarOGuardarDisenios(LayoutControl control, bool guardar, string usuario, string nombreVista) { string direccion; if (guardar) { direccion = $@"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\{control.Name}{nombreVista}{usuario}.xml"; control.SaveLayoutToXml(direccion); } else { direccion = $@"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}\{control.Name}{nombreVista}{usuario}.xml"; if (File.Exists(direccion)) { control.RestoreLayoutFromXml(direccion); } } }
private void AddLayoutControl() { int fieldCount = _data.DsStruct.Tables[0].Rows.Count; 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"; } if (fieldCount > 3) { lcMain = _frmDesigner.GenLayout3(ref gcMain, true); } else if (fieldCount > 2) { lcMain = _frmDesigner.GenLayout2(ref gcMain, true); } else { lcMain = _frmDesigner.GenLayout1(ref gcMain, 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; } gcMain.DataSource = _bindingSource; gcMain.DataMember = this._data.DrTable["TableName"].ToString(); this.Controls.Add(lcMain); lcMain.BringToFront(); //if (this._frmDesigner.formAction == FormAction.View) //{ // TransparentPanel ptop = new TransparentPanel(); // ptop.BackColor = Color.FromArgb(100, 88, 44, 55); // ptop.Top = 0; ptop.Left = 0; // ptop.TabIndex = 0; // ptop.Width = Screen.PrimaryScreen.Bounds.Width; // ptop.Height = Screen.PrimaryScreen.Bounds.Height; // this.Controls.Add(ptop); ptop.BringToFront(); //} gvMain = gcMain.ViewCollection[0] as DevExpress.XtraGrid.Views.Grid.GridView; gvMain.OptionsView.ShowAutoFilterRow = false; gvMain.OptionsView.ShowGroupPanel = false; //gvMain.OptionsView.ShowFooter = false; //gvMain.BestFitColumns(); //Thêm phần bindingSource cho các Detail for (int i = 0; i < _data._drTableDt.Count; i++) { GridControl gc = _frmDesigner._gcDetail[i]; int position = _bindingSource.Position; gc.DataSource = _bindingSource; _bindingSource.Position = position; gc.DataMember = _data._drTableDt[i]["TableName"].ToString(); } //Thêm phần bindingSource cho các Detail }