浏览代码

更新报告程序恢复元素列表的排序功能

zhangjiaxin 9 月之前
父节点
当前提交
3d12e9c747

+ 54 - 63
OTSIncAReportApp/1-UI/ElementSubscript.cs

@@ -112,69 +112,60 @@ namespace OTSIncAReportApp._1_UI
 
         public string Getsubscriptstring(string str)
         {
-            string[] strarray = str.Split('-');
-            string strSubscript = "";
-            for (int j=0;j< strarray.Length;j++)
-            {
-                char[] strCharArr = strarray[j].ToCharArray();
-                string Escape = "";
-                for (int i = 0; i < strCharArr.Length; i++)
-                {
-                    if (i < 2)
-                    {
-                        Escape = Escape + strCharArr[i];
-                        continue;
-                    }
-                    else
-                    {
-                        if (System.Text.RegularExpressions.Regex.IsMatch(strCharArr[i].ToString(), @"^[+-]?\d*[.]?\d*$"))
-                        {
-                            Escape = Escape + Getsubscript(strCharArr[i].ToString());
-                        }
-                        else
-                        {
-                            Escape = Escape + strCharArr[i];
-                        }
-                    }
-                }
-                strSubscript = strSubscript + Escape+"-";
-            }
-
-
-
-            string[] vs = strSubscript.Split('-');
-            string output = "";
-
-
-         
-
-            
-            if (vs.Length>2)
-            {
-                for (int i = 0; i < vs.Length - 1; i++)
-                {
-                    if (i == vs.Length - 2)
-                    {
-                        output = output + vs[i].ToString();
-                    }
-                    else
-                    {
-                        output = output + vs[i].ToString() + "-";
-                    }
-
-                }
-            }
-            else
-            {
-               
-                for (int i = 0; i < vs.Length - 1; i++)
-                {
-                    output = output + vs[i].ToString();
-                }
-            }
-
-
-            return output;
+            return str;
+
+            //下标转换
+            //string[] strarray = str.Split('-');
+            //string strSubscript = "";
+            //for (int j=0;j< strarray.Length;j++)
+            //{
+            //    char[] strCharArr = strarray[j].ToCharArray();
+            //    string Escape = "";
+            //    for (int i = 0; i < strCharArr.Length; i++)
+            //    {
+            //        if (i < 2)
+            //        {
+            //            Escape = Escape + strCharArr[i];
+            //            continue;
+            //        }
+            //        else
+            //        {
+            //            if (System.Text.RegularExpressions.Regex.IsMatch(strCharArr[i].ToString(), @"^[+-]?\d*[.]?\d*$"))
+            //            {
+            //                Escape = Escape + Getsubscript(strCharArr[i].ToString());
+            //            }
+            //            else
+            //            {
+            //                Escape = Escape + strCharArr[i];
+            //            }
+            //        }
+            //    }
+            //    strSubscript = strSubscript + Escape+"-";
+            //}
+            //string[] vs = strSubscript.Split('-');
+            //string output = "";
+            //if (vs.Length>2)
+            //{
+            //    for (int i = 0; i < vs.Length - 1; i++)
+            //    {
+            //        if (i == vs.Length - 2)
+            //        {
+            //            output = output + vs[i].ToString();
+            //        }
+            //        else
+            //        {
+            //            output = output + vs[i].ToString() + "-";
+            //        }
+            //    }
+            //}
+            //else
+            //{
+            //    for (int i = 0; i < vs.Length - 1; i++)
+            //    {
+            //        output = output + vs[i].ToString();
+            //    }
+            //}
+            //return output;
         }
     }
     public class subscript

+ 128 - 0
OTSIncAReportApp/1-UI/OTSReportExport/ClassificationOrderAdjuster.Designer.cs

@@ -0,0 +1,128 @@
+
+namespace OTSIncAReportApp._1_UI.OTSReportExport
+{
+    partial class ClassificationOrderAdjuster
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.listView_select = new System.Windows.Forms.ListView();
+            this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+            this.button_up = new System.Windows.Forms.Button();
+            this.button_down = new System.Windows.Forms.Button();
+            this.button4 = new System.Windows.Forms.Button();
+            this.button3 = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // listView_select
+            // 
+            this.listView_select.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+            this.columnHeader2});
+            this.listView_select.HideSelection = false;
+            this.listView_select.Location = new System.Drawing.Point(35, 12);
+            this.listView_select.Name = "listView_select";
+            this.listView_select.Size = new System.Drawing.Size(226, 426);
+            this.listView_select.TabIndex = 20;
+            this.listView_select.UseCompatibleStateImageBehavior = false;
+            this.listView_select.View = System.Windows.Forms.View.Details;
+            // 
+            // columnHeader2
+            // 
+            this.columnHeader2.Text = "";
+            this.columnHeader2.Width = 210;
+            // 
+            // button_up
+            // 
+            this.button_up.Font = new System.Drawing.Font("宋体", 9F);
+            this.button_up.Location = new System.Drawing.Point(10, 108);
+            this.button_up.Name = "button_up";
+            this.button_up.Size = new System.Drawing.Size(19, 98);
+            this.button_up.TabIndex = 18;
+            this.button_up.Text = "▲";
+            this.button_up.UseVisualStyleBackColor = true;
+            this.button_up.Click += new System.EventHandler(this.button_up_Click);
+            // 
+            // button_down
+            // 
+            this.button_down.Font = new System.Drawing.Font("宋体", 9F);
+            this.button_down.Location = new System.Drawing.Point(10, 212);
+            this.button_down.Name = "button_down";
+            this.button_down.Size = new System.Drawing.Size(19, 98);
+            this.button_down.TabIndex = 19;
+            this.button_down.Text = "▼";
+            this.button_down.UseVisualStyleBackColor = true;
+            this.button_down.Click += new System.EventHandler(this.button_down_Click);
+            // 
+            // button4
+            // 
+            this.button4.Location = new System.Drawing.Point(186, 444);
+            this.button4.Name = "button4";
+            this.button4.Size = new System.Drawing.Size(75, 23);
+            this.button4.TabIndex = 25;
+            this.button4.Text = "取消";
+            this.button4.UseVisualStyleBackColor = true;
+            this.button4.Click += new System.EventHandler(this.button4_Click);
+            // 
+            // button3
+            // 
+            this.button3.Location = new System.Drawing.Point(105, 444);
+            this.button3.Name = "button3";
+            this.button3.Size = new System.Drawing.Size(75, 23);
+            this.button3.TabIndex = 24;
+            this.button3.Text = "确定";
+            this.button3.UseVisualStyleBackColor = true;
+            this.button3.Click += new System.EventHandler(this.button3_Click);
+            // 
+            // ClassificationOrderAdjuster
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(276, 478);
+            this.Controls.Add(this.button4);
+            this.Controls.Add(this.button3);
+            this.Controls.Add(this.listView_select);
+            this.Controls.Add(this.button_up);
+            this.Controls.Add(this.button_down);
+            this.MaximumSize = new System.Drawing.Size(292, 517);
+            this.MinimumSize = new System.Drawing.Size(292, 517);
+            this.Name = "ClassificationOrderAdjuster";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+            this.Text = "分类排序";
+            this.Load += new System.EventHandler(this.ClassificationOrderAdjuster_Load);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.ListView listView_select;
+        private System.Windows.Forms.ColumnHeader columnHeader2;
+        private System.Windows.Forms.Button button_up;
+        private System.Windows.Forms.Button button_down;
+        private System.Windows.Forms.Button button4;
+        private System.Windows.Forms.Button button3;
+    }
+}

+ 129 - 0
OTSIncAReportApp/1-UI/OTSReportExport/ClassificationOrderAdjuster.cs

@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace OTSIncAReportApp._1_UI.OTSReportExport
+{
+    public partial class ClassificationOrderAdjuster : Form
+    {
+        public List<string> OutElementList = new List<string>();
+        private List<string> OriginalClassificationSet = new List<string>();
+        public ClassificationOrderAdjuster(List<string> a_ElementList)
+        {
+            InitializeComponent();
+            for (int i = 0; i < a_ElementList.Count; i++)
+            {
+                ListViewItem item = new ListViewItem(a_ElementList[i]);
+                listView_select.Items.Add(item);
+            }
+            OriginalClassificationSet = a_ElementList;
+        }
+
+        private void ClassificationOrderAdjuster_Load(object sender, EventArgs e)
+        {
+           
+        }
+
+
+        private void MoveSelectedItemUp()
+        {
+            // 确保ListView中有选中的项,并且不是第一项  
+            if (listView_select.SelectedItems.Count > 0 && listView_select.SelectedIndices[0] > 0)
+            {
+                // 获取选中的项  
+                ListViewItem selectedItem = listView_select.SelectedItems[0];
+                // 在上一行的位置插入新的项(使用保存的数据)  
+                int newIndex = selectedItem.Index - 1; // 上一行的索引 
+                // 保存选中项的数据(这里只保存Text,如果有子项也需要保存)  
+                string text = selectedItem.Text;
+                ListViewItem.ListViewSubItem[] subItems = selectedItem.SubItems.Cast<ListViewItem.ListViewSubItem>().ToArray(); // 如果有子项  
+
+                // 移除选中的项  
+                listView_select.Items.Remove(selectedItem);
+
+                // 在上一行的位置插入新的项(使用保存的数据)  
+                //int newIndex = selectedItem.Index - 1; // 上一行的索引  
+                ListViewItem newItem = new ListViewItem(text); // 创建新的项  
+                newItem.SubItems.AddRange(subItems); // 如果有子项,则添加它们  
+                listView_select.Items.Insert(newIndex, newItem); // 插入新的项  
+
+                // 重新选择移动后的项(可选)  
+                listView_select.Items[newIndex].Selected = true;
+            }
+        }
+
+        private void MoveSelectedItemDown()
+        {
+            // 确保ListView中有选中的项,并且不是最后一项  
+            if (listView_select.SelectedItems.Count > 0 && listView_select.SelectedIndices[0] < listView_select.Items.Count - 1)
+            {
+                // 获取选中的项  
+                ListViewItem selectedItem = listView_select.SelectedItems[0];
+                int selectedIndex = selectedItem.Index;
+                // 在下一行的位置插入新的项(使用保存的数据)  
+                int newIndex = selectedIndex + 1; // 下一行的索引  
+                // 保存选中项的数据(包括文本和任何子项)  
+                string text = selectedItem.Text;
+                ListViewItem.ListViewSubItem[] subItems = selectedItem.SubItems.Cast<ListViewItem.ListViewSubItem>().ToArray();
+
+                // 移除选中的项  
+                listView_select.Items.RemoveAt(selectedIndex);
+
+                // 在下一行的位置插入新的项(使用保存的数据)  
+                //int newIndex = selectedIndex + 1; // 下一行的索引  
+                ListViewItem newItem = new ListViewItem(text);
+                newItem.SubItems.AddRange(subItems); // 如果有子项,则添加它们  
+                listView_select.Items.Insert(newIndex, newItem);
+
+                // 重新选择移动后的项(可选)  
+                listView_select.Items[newIndex].Selected = true;
+
+                // 如果需要,滚动到新的位置  
+                listView_select.EnsureVisible(newIndex);
+            }
+        }
+
+        private void UpdateSelectedCategories()
+        {
+            OutElementList.Clear();
+
+            foreach (ListViewItem item in listView_select.Items)
+            {
+
+                string secondColumnData = item.SubItems[0].Text; // 索引1代表第二列  
+                OutElementList.Add(secondColumnData);
+
+            }
+
+        }
+
+        private void button_up_Click(object sender, EventArgs e)
+        {
+            MoveSelectedItemUp();
+        }
+
+        private void button_down_Click(object sender, EventArgs e)
+        {
+            MoveSelectedItemDown();
+        }
+
+        private void button3_Click(object sender, EventArgs e)
+        {
+            UpdateSelectedCategories();
+            this.Close();
+        }
+
+        private void button4_Click(object sender, EventArgs e)
+        {
+            OutElementList.Clear();
+            OutElementList = OriginalClassificationSet;
+            this.Close();
+        }
+    }
+}

+ 120 - 0
OTSIncAReportApp/1-UI/OTSReportExport/ClassificationOrderAdjuster.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 14 - 0
OTSIncAReportApp/1-UI/OTSReportExport/OTSReport_Template_INCA.Designer.cs

@@ -89,6 +89,7 @@
             this.groupBox5 = new System.Windows.Forms.GroupBox();
             this.textBox1 = new System.Windows.Forms.TextBox();
             this.groupBox6 = new System.Windows.Forms.GroupBox();
+            this.button8 = new System.Windows.Forms.Button();
             this.groupBox1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox7)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.numericMin)).BeginInit();
@@ -643,6 +644,7 @@
             // 
             // groupBox3
             // 
+            this.groupBox3.Controls.Add(this.button8);
             this.groupBox3.Controls.Add(this.label2);
             this.groupBox3.Controls.Add(this.groupBox_px);
             this.groupBox3.Controls.Add(this.lbv_syxt_mblb);
@@ -766,6 +768,17 @@
             this.groupBox6.TabStop = false;
             this.groupBox6.Text = "图标选择";
             // 
+            // button8
+            // 
+            this.button8.Location = new System.Drawing.Point(596, 119);
+            this.button8.Margin = new System.Windows.Forms.Padding(2);
+            this.button8.Name = "button8";
+            this.button8.Size = new System.Drawing.Size(72, 20);
+            this.button8.TabIndex = 68;
+            this.button8.Text = "顺序调整";
+            this.button8.UseVisualStyleBackColor = true;
+            this.button8.Click += new System.EventHandler(this.button8_Click);
+            // 
             // OTSReport_Template_INCA
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -877,5 +890,6 @@
         private System.Windows.Forms.GroupBox groupBox5;
         private System.Windows.Forms.TextBox textBox1;
         private System.Windows.Forms.GroupBox groupBox6;
+        private System.Windows.Forms.Button button8;
     }
 }

+ 29 - 0
OTSIncAReportApp/1-UI/OTSReportExport/OTSReport_Template_INCA.cs

@@ -869,5 +869,34 @@ namespace OTSIncAReportApp.OTSTemplateDesigner
         {
 
         }
+
+        private void button8_Click(object sender, EventArgs e)
+        {
+            List<string> vs = new List<string>();
+            string[] MainPriority = tb_ysfx_xsys.Text.Split(new char[] { ',' });
+            for (int i = 0; i < MainPriority.Length; i++)
+            {
+                if (tb_ysfx_xsys.Text.Split(',')[i] != "")
+                    vs.Add(MainPriority[i]);
+            }
+
+            ClassificationOrderAdjuster category = new ClassificationOrderAdjuster(vs);
+            category.ShowDialog();
+            List<string> ls = category.OutElementList;
+            string str = "";
+            for (int i = 0; i < ls.Count; i++)
+            {
+                if (i == ls.Count - 1)
+                {
+                    str = str + ls[i];
+                }
+                else
+                {
+                    str = str + ls[i] + ",";
+                }
+
+            }
+            tb_ysfx_xsys.Text = str;
+        }
     }
 }

+ 9 - 0
OTSIncAReportApp/OTSIncAReportApp.csproj

@@ -455,6 +455,12 @@
     <Compile Include="1-UI\frmReMeasure.Designer.cs">
       <DependentUpon>frmReMeasure.cs</DependentUpon>
     </Compile>
+    <Compile Include="1-UI\OTSReportExport\ClassificationOrderAdjuster.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="1-UI\OTSReportExport\ClassificationOrderAdjuster.Designer.cs">
+      <DependentUpon>ClassificationOrderAdjuster.cs</DependentUpon>
+    </Compile>
     <Compile Include="1-UI\Purity.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -834,6 +840,9 @@
     <EmbeddedResource Include="1-UI\frmReMeasure.resx">
       <DependentUpon>frmReMeasure.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="1-UI\OTSReportExport\ClassificationOrderAdjuster.resx">
+      <DependentUpon>ClassificationOrderAdjuster.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="1-UI\Purity.resx">
       <DependentUpon>Purity.cs</DependentUpon>
     </EmbeddedResource>