From 5b419c5a4fd892b1777e8c5ac584bf2df3cbbb3e Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期五, 28 二月 2025 16:32:12 +0800
Subject: [PATCH] 布局

---
 DevApp/Gs.DevApp/UserControl/showLayOut.cs |  107 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 67 insertions(+), 40 deletions(-)

diff --git a/DevApp/Gs.DevApp/UserControl/showLayOut.cs b/DevApp/Gs.DevApp/UserControl/showLayOut.cs
index 5c881d1..8c05336 100644
--- a/DevApp/Gs.DevApp/UserControl/showLayOut.cs
+++ b/DevApp/Gs.DevApp/UserControl/showLayOut.cs
@@ -1,9 +1,16 @@
-锘縰sing DevExpress.XtraGrid.Columns;
+锘縰sing DevExpress.Utils.DirectXPaint;
+using DevExpress.XtraEditors;
+using DevExpress.XtraEditors.TextEditController;
+using DevExpress.XtraGrid.Columns;
 using DevExpress.XtraGrid.Views.Grid;
+using DevExpress.XtraLayout;
+using Gs.DevApp.DevFrm.QC.Models;
 using Gs.DevApp.ToolBox;
 using Newtonsoft.Json;
 using System;
 using System.Collections.Generic;
+using System.IO;
+using System.Text;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.UserControl
@@ -12,14 +19,17 @@
     {
         string formNamespace = "";
         List<GridView> gridViews = new List<GridView>();
-        public showLayOut(string _formNamespace, List<GridView> _gridViews)
+        List<DevExpress.XtraLayout.LayoutControl> layList = new List<DevExpress.XtraLayout.LayoutControl>();
+        List<DevExpress.XtraEditors.SplitContainerControl> spcList = new List<DevExpress.XtraEditors.SplitContainerControl>();
+        public showLayOut(string _formNamespace, List<GridView> _gridViews, List<DevExpress.XtraLayout.LayoutControl> _layList, List<DevExpress.XtraEditors.SplitContainerControl> _spcList)
         {
             formNamespace = _formNamespace;
             gridViews = _gridViews;
+            layList = _layList;
+            spcList = _spcList;
             InitializeComponent();
             this.btnCancel.Click += BtnCancel_Click;
             this.btnSave.Click += BtnSave_Click;
-           
         }
         private void BtnSave_Click(object sender, EventArgs e)
         {
@@ -31,57 +41,74 @@
             Close();
         }
 
-
         private void _setLyout()
         {
-            //  --col1,100,101,102,103,104,105,1,title&col2,100,101,102,103,104,105,1,title
             if (txt_layOut.SelectedIndex <= 0)
             {
                 MsgHelper.Warning("璇烽�夋嫨閫傜敤鑼冨洿锛�");
                 return;
             }
-
-            System.Text.StringBuilder sb = new System.Text.StringBuilder();
+            List<dynamic> xmlList = new List<dynamic>();
             foreach (GridView gridView1 in gridViews)
             {
-                foreach (GridColumn column in gridView1.Columns)
+                System.IO.Stream stream = new System.IO.MemoryStream();
+                gridView1.SaveLayoutToStream(stream);
+                stream.Seek(0, System.IO.SeekOrigin.Begin);
+                StringBuilder sb = new StringBuilder();
+                using (StreamReader reader = new StreamReader(stream))
                 {
-                    string controlId = column.Name;
-                    int controlPosX = 0;
-                    int controlPosY = 0;
-                    int controlWidth = 0;
-                    int controlMinWidth = column.MinWidth;
-                    int controlMaxWidth = column.MaxWidth;
-                    int controlHeight = 0;
-                    int controlVisible = column.Visible == true ? 1 : 0;
-                    string controlTitle = string.IsNullOrEmpty(column.Caption.Trim()) ? "鏈畾涔�" : column.Caption.Trim();
-                    int controlIdx = column.VisibleIndex;
-                    if (sb.Length > 0)
-                        sb.Append("&");
-                    sb.Append(controlId);
-                    sb.Append(",");
-                    sb.Append(controlPosX);
-                    sb.Append(",");
-                    sb.Append(controlPosY);
-                    sb.Append(",");
-                    sb.Append(controlWidth);
-                    sb.Append(",");
-                    sb.Append(controlMinWidth);
-                    sb.Append(",");
-                    sb.Append(controlMaxWidth);
-                    sb.Append(",");
-                    sb.Append(controlHeight);
-                    sb.Append(",");
-                    sb.Append(controlVisible);
-                    sb.Append(",");
-                    sb.Append(controlTitle);
-                    sb.Append(",");
-                    sb.Append(controlIdx);
+                    char[] buffer = new char[4096]; // 缂撳啿鍖哄ぇ灏忔牴鎹渶瑕佽皟鏁�
+                    int numCharsRead;
+                    while ((numCharsRead = reader.Read(buffer, 0, buffer.Length)) > 0)
+                    {
+                        sb.Append(buffer, 0, numCharsRead);
+                    }
                 }
+                xmlList.Add(
+                       new { idType = "gridview", idName = gridView1.Name, idXml = sb.ToString(), splitterPosition="" }
+                 );
+            }
+            foreach (LayoutControl lay1 in layList)
+            {
+                System.IO.Stream stream = new System.IO.MemoryStream();
+                lay1.SaveLayoutToStream(stream);
+                stream.Seek(0, System.IO.SeekOrigin.Begin);
+                StringBuilder sb = new StringBuilder();
+                using (StreamReader reader = new StreamReader(stream))
+                {
+                    char[] buffer = new char[4096]; // 缂撳啿鍖哄ぇ灏忔牴鎹渶瑕佽皟鏁�
+                    int numCharsRead;
+                    while ((numCharsRead = reader.Read(buffer, 0, buffer.Length)) > 0)
+                    {
+                        sb.Append(buffer, 0, numCharsRead);
+                    }
+                }
+                xmlList.Add(
+                       new { idType = "layoutcontrol ", idName = lay1.Name, idXml = sb.ToString(), splitterPosition="" }
+                 );
+            }
+            foreach (SplitContainerControl splt in spcList)
+            {
+                System.IO.Stream stream = new System.IO.MemoryStream();
+                splt.SaveLayoutToStream(stream);
+                stream.Seek(0, System.IO.SeekOrigin.Begin);
+                StringBuilder sb = new StringBuilder();
+                using (StreamReader reader = new StreamReader(stream))
+                {
+                    char[] buffer = new char[4096]; // 缂撳啿鍖哄ぇ灏忔牴鎹渶瑕佽皟鏁�
+                    int numCharsRead;
+                    while ((numCharsRead = reader.Read(buffer, 0, buffer.Length)) > 0)
+                    {
+                        sb.Append(buffer, 0, numCharsRead);
+                    }
+                }
+                xmlList.Add(
+                       new { idType = "splitcontainercontrol ", idName = splt.Name, idXml = sb.ToString(), splitterPosition= splt.SplitterPosition }
+                 );
             }
             var _obj = new
             {
-                layoutLst = sb.ToString(),
+                xmlList = xmlList,
                 formPath = formNamespace,
                 intType = txt_layOut.SelectedIndex,
             };

--
Gitblit v1.9.3