⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appendenttable.cs

📁 PDF文件格式解析库源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
	rowA.{1}.rawValue = rowB.{2}.rawValue;
	rowB.{3}.rawValue = temp;", 4);
            script += @"
}
";
            script = script.Replace("table2", Name);
            btnMoveUp.Event.Click = new JavaScript(script);
            return btnMoveUp;
        }

        private Button CreateMoveDownButton()
        {
            Button btnMoveDown = CreateButton("↓", 12, 12);
            string script = @"
var rowIndex = table2.index*10+inputRow.index;
var rowCount = (table2.all.length-1)*10+table2.all.item(table2.all.length-1).inputRow.all.length;
if(rowIndex < rowCount-1)
{
	currentRow = table2.all.item(Math.floor(rowIndex/10)).inputRow.all.item(rowIndex%10);
	nextRow = table2.all.item(Math.floor((rowIndex+1)/10)).inputRow.all.item((rowIndex+1)%10);
	swapValue( currentRow, nextRow );
}

function swapValue( rowA, rowB)
{
    var temp;";
            script += SetFieldValueScript(@"
	temp = rowA.{0}.rawValue;
	rowA.{1}.rawValue = rowB.{2}.rawValue;
	rowB.{3}.rawValue = temp;", 4);
            script += @"
}
";
            script = script.Replace("table2", Name);
            btnMoveDown.Event.Click = new JavaScript(script);
            return btnMoveDown;
        }


        protected string SetFieldValueScript(string format, int times)
        {
            StringBuilder script = new StringBuilder();
            foreach (string fieldname in FieldNames)
            {
                string[] items = fieldname.Split(':');
                string name = items[1];
                List<string> param = new List<string>(times);
                for (int i = 0; i < times; i++)
                {
                    param.Add(name);
                }
                script.AppendFormat(format, param.ToArray());
            }
            return script.ToString();
        }

        protected string ClearFieldValueScript(string format)
        {
            StringBuilder script = new StringBuilder();
            foreach (string fieldname in FieldNames)
            {
                string[] items = fieldname.Split(':');
                string name = items[1];
                script.AppendFormat(format, name);
            }
            return script.ToString();
        }

        public abstract Table[] BuildTable();
        public virtual Form[] BuildSubform() { return null; }

        protected Table CreateTableHeader(string[][] columnHeaders)
        {
            int rows = columnHeaders.Length;
            int cols = columnHeaders[0].Length;
            Table tablehead = new Table(rows, cols);
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < cols; j++)
                {
                    string text = columnHeaders[i][j];
                    tablehead.Cells[i][j] = CreateLabel(text);
                }
            }
            return tablehead;
        }

        protected Table CreateInputRow(string[] fieldnames, List<float> widths, out float paddingLeft, out float paddingRight)
        {
            int rows = 1;
            int cols = fieldnames.Length;
            Table tableinput = new Table(rows, cols + 2);
            //Table tableinput = new Table(rows, cols);
            Table btnCellLeft = CreateButtonCell(CreateInsertRowButton(), CreateDeleteRowButton());
            tableinput.Cells[0][0] = btnCellLeft;
            btnCellLeft.CalculateSize();
            paddingLeft = btnCellLeft.Width;
            for (int j = 0; j < cols; j++)
            {
                Control cell = CreateCellControl(fieldnames[j]);
                cell.Width = widths[j];
                tableinput.Cells[0][j + 1] = cell;
                //tableinput.Cells[0][j] = cell;
                tableinput[cell.Name] = cell;
            }
            Table btnCellRight = CreateButtonCell(CreateMoveUpButton(), CreateMoveDownButton());
            tableinput.Cells[0][cols + 1] = btnCellRight;
            btnCellRight.CalculateSize();
            paddingRight = btnCellRight.Width;
            tableinput.Occurance.Inintial = InitialRows;
            tableinput.Occurance.Maximum = 10;
            return tableinput;
        }

        private Control CreateCellControl(string fieldname)
        {
            string[] items = fieldname.Split(':');
            string type = items[0];
            string name = items[1];
            switch (type)
            {
                case "T":
                    return CreateTextBox(name);
                    break;
                case "N":
                    return CreateNumerictBox(name);
                    break;
                default:
                    return CreateTextBox(name);
                    break;
            }
        }

        protected Table CreateButtonCell(Button upperbtn, Button lowerbtn)
        {
            Table btnCell = new Table(2, 1);
            btnCell.Cells[0][0] = upperbtn;
            btnCell.Cells[1][0] = lowerbtn;
            return btnCell;
        }

        protected Table CreateFootRow(int sumcolspan, string[] fieldnames, List<float> widths)
        {
            int rows = 1;
            int cols = fieldnames.Length + 1;
            Table tablefoot = new Table(rows, cols);
            Label sumlabel = CreateLabel("累计");
            float sumwidth = 0;
            for (int i = 0; i < sumcolspan; i++)
            {
                sumwidth += widths[i];
            }
            sumlabel.Width = sumwidth;
            tablefoot.Cells[0][0] = sumlabel;
            for (int j = 1; j < cols; j++)
            {
                string name = fieldnames[j - 1];
                if (name == "")
                {
                    Label label = CreateLabel("");
                    label.Width = widths[sumcolspan + j - 1];
                    tablefoot.Cells[0][j] = label;
                }
                else
                {
                    NumerictBox txtBox = CreateNumerictBox(name);
                    txtBox.Width = widths[sumcolspan + j - 1];
                    tablefoot.Cells[0][j] = txtBox;
                    tablefoot[txtBox.Name] = txtBox;
                }
            }
            return tablefoot;
        }

        protected Form CreateRemarks()
        {
            string[] lines = Remarks.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            Form remarks = new Form();
            remarks.Name = "remarks";
            remarks.Padding.Top = 10;
            Label zhu = new Label();
            zhu.Text = "注:";
            zhu.Font = new Font("仿宋_GB2312", 12);
            remarks.ApplyAlignment(Alignment.Top, zhu);
            remarks.Controls.Add(zhu);
            float labeltop = zhu.Top;
            float lablewidth = 0;
            foreach (string line in lines)
            {
                Label label = new Label();
                label.Padding.Bottom = 5;
                label.Text = line;
                label.Font = new Font("仿宋_GB2312", 12);
                label.TextAlign = Alignment.MiddleLeft;
                label.Left = zhu.Right;
                label.Top = labeltop;
                labeltop += label.Height;
                lablewidth = Math.Max(lablewidth, label.Width);
                remarks.Controls.Add(label);
            }
            remarks.Width = zhu.Right + lablewidth;
            remarks.Height = labeltop;
            return remarks;
        }

        protected virtual Label CreateLabel(string text)
        {
            Label label = new Label();
            label.Padding.Top = 3;
            label.Padding.Bottom = 3;
            label.Padding.Left = 3;
            label.Padding.Right = 3;
            label.Border.Width = 0.5F;
            label.Text = text;
            label.Font = new Font("仿宋_GB2312", 12);
            label.TextAlign = Alignment.MiddleCenter;
            return label;
        }

        protected virtual TextBox CreateTextBox(string name)
        {
            TextBox txtBox = new TextBox();
            txtBox.Name = name;
            txtBox.Width = 100;
            txtBox.Height = 24;
            txtBox.Border.Style = BorderStyle.Solid;
            txtBox.TextAlign = Alignment.MiddleCenter;
            return txtBox;
        }

        protected virtual NumerictBox CreateNumerictBox(string name)
        {
            NumerictBox txtBox = new NumerictBox();
            txtBox.Name = name;
            txtBox.Width = 100;
            txtBox.Height = 24;
            txtBox.Border.Style = BorderStyle.Solid;
            txtBox.TextAlign = Alignment.MiddleCenter;
            return txtBox;
        }

        protected static Button CreateButton(string text, float width, float height)
        {
            Button btn = new Button();
            btn.Padding.Left = 2;
            btn.Padding.Right = 2;
            btn.Padding.Top = 2;
            btn.Padding.Bottom = 1;
            btn.Width = width;
            btn.Height = height;
            btn.Text = text;
            return btn;
        }

        protected static void SetCalculateScript(TextBox textBox, Script script)
        {
            textBox.ReadOnly = true;
            textBox.Event.Calculate = script;
        }

        protected static void SetCalculateScript(NumerictBox textBox, Script script)
        {
            textBox.ReadOnly = true;
            textBox.Event.Calculate = script;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -