예제 #1
0
        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);
        }
예제 #2
0
        private void LoadLayoutSettings(LayoutControl layoutControl)
        {
            var pivotSettings = ((IModelPivotListView)View.Model).PivotSettings;

            if (!string.IsNullOrEmpty(pivotSettings.LayoutSettings))
            {
                var ms = new MemoryStream(Encoding.UTF8.GetBytes(pivotSettings.LayoutSettings));
                layoutControl.RestoreLayoutFromStream(ms);
            }
        }
예제 #3
0
 /// <summary>
 /// 设置布局数据
 /// </summary>
 /// <param name="dockManager">停靠管理器</param>
 /// <param name="layoutData">布局数据</param>
 public static void SetLayoutData(this LayoutControl control, byte[] layoutData)
 {
     if (layoutData.IsNullOrEmpty())
     {
         return;
     }
     using (MemoryStream buffer = new MemoryStream(layoutData)) {
         control.RestoreLayoutFromStream(buffer);
     }
 }
예제 #4
0
        private void ApplySpecialLayout(LayoutControl layoutControl, Form form, string layoutFileName)
        {
            Type   type      = form.GetType();
            string nameSpace = type.Namespace;

            using (Stream s = Assembly.GetAssembly(type).GetManifestResourceStream(nameSpace + "." + layoutFileName))
            {
                Debug.Assert(s != null, "RessourceStream not found");
                if (s != null)
                {
                    var reader = new StreamReader(s);
                    layoutControl.RestoreLayoutFromStream(reader.BaseStream);
                }
            }
        }
예제 #5
0
 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);
     }
 }
예제 #6
0
        //获取单个layout的布局配置
        static public void SetLayoutString(LayoutControl layout, string config)
        {
            layout.Items.Clear();
            layout.Controls.Clear();

            if (string.IsNullOrEmpty(config))
            {
                return;
            }

            using (MemoryStream ms = new MemoryStream())
                using (StreamWriter sw = new StreamWriter(ms))
                {
                    sw.Write(config);
                    sw.Flush();

                    ms.Position = 0;

                    layout.RestoreLayoutFromStream(ms);
                }
        }
예제 #7
0
        private static void SetLayoutXml(this LayoutControl layoutControl, string xml)
        {
            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                {
                    layoutControl.BeginInit();
                    layoutControl.BeginUpdate();
                    try
                    {
                        writer.Write(xml);
                        writer.Flush();
                        stream.Seek(0, SeekOrigin.Begin);

                        layoutControl.RestoreLayoutFromStream(stream);
                    }
                    finally
                    {
                        layoutControl.EndUpdate();
                        layoutControl.EndInit();
                    }
                }
            }
        }
예제 #8
0
        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
        }