diff --git a/FrmCsvViewer.Designer.cs b/FrmCsvViewer.Designer.cs index 2bea46c..fff2f13 100644 --- a/FrmCsvViewer.Designer.cs +++ b/FrmCsvViewer.Designer.cs @@ -30,106 +30,114 @@ { this.txtPath = new System.Windows.Forms.TextBox(); this.btnLoad = new System.Windows.Forms.Button(); - this.btnFirstReg = new System.Windows.Forms.Button(); + this.grpFile = new System.Windows.Forms.GroupBox(); + this.pnlScrollData = new CsvView.DoubleBufferPanel(); + this.pnlData = new CsvView.DoubleBufferPanel(); + this.pnlReg = new CsvView.DoubleBufferPanel(); this.btnPrevReg = new System.Windows.Forms.Button(); - this.btnNextReg = new System.Windows.Forms.Button(); - this.btnLastReg = new System.Windows.Forms.Button(); + this.tblRegNumbers = new System.Windows.Forms.TableLayoutPanel(); this.txtCurrentReg = new System.Windows.Forms.TextBox(); this.txtTotalRegs = new System.Windows.Forms.TextBox(); - this.tblRegNumbers = new System.Windows.Forms.TableLayoutPanel(); - this.pnlReg = new CsvView.DoubleBufferPanel(); - this.pnlData = new CsvView.DoubleBufferPanel(); - this.tblRegNumbers.SuspendLayout(); + this.btnFirstReg = new System.Windows.Forms.Button(); + this.btnLastReg = new System.Windows.Forms.Button(); + this.btnNextReg = new System.Windows.Forms.Button(); + this.grpFile.SuspendLayout(); + this.pnlScrollData.SuspendLayout(); this.pnlReg.SuspendLayout(); + this.tblRegNumbers.SuspendLayout(); this.SuspendLayout(); // // txtPath // this.txtPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.txtPath.Location = new System.Drawing.Point(12, 14); + this.txtPath.Location = new System.Drawing.Point(7, 27); + this.txtPath.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.txtPath.Name = "txtPath"; - this.txtPath.Size = new System.Drawing.Size(457, 20); + this.txtPath.Size = new System.Drawing.Size(676, 26); this.txtPath.TabIndex = 0; this.txtPath.DoubleClick += new System.EventHandler(this.txtPath_DoubleClick); // // btnLoad // this.btnLoad.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnLoad.Location = new System.Drawing.Point(475, 11); + this.btnLoad.Location = new System.Drawing.Point(691, 27); + this.btnLoad.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.btnLoad.Name = "btnLoad"; - this.btnLoad.Size = new System.Drawing.Size(45, 23); + this.btnLoad.Size = new System.Drawing.Size(68, 26); this.btnLoad.TabIndex = 3; this.btnLoad.Text = "Load"; this.btnLoad.UseVisualStyleBackColor = true; this.btnLoad.Click += new System.EventHandler(this.btnLoad_Click); // - // btnFirstReg + // grpFile // - this.btnFirstReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnFirstReg.Location = new System.Drawing.Point(0, 0); - this.btnFirstReg.Name = "btnFirstReg"; - this.btnFirstReg.Size = new System.Drawing.Size(36, 30); - this.btnFirstReg.TabIndex = 4; - this.btnFirstReg.Text = "|<"; - this.btnFirstReg.UseVisualStyleBackColor = true; - this.btnFirstReg.Click += new System.EventHandler(this.btnFirstReg_Click); + this.grpFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.grpFile.Controls.Add(this.btnLoad); + this.grpFile.Controls.Add(this.txtPath); + this.grpFile.Location = new System.Drawing.Point(20, 12); + this.grpFile.Name = "grpFile"; + this.grpFile.Size = new System.Drawing.Size(766, 67); + this.grpFile.TabIndex = 12; + this.grpFile.TabStop = false; + this.grpFile.Text = "File"; + // + // pnlScrollData + // + this.pnlScrollData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlScrollData.AutoScroll = true; + this.pnlScrollData.Controls.Add(this.pnlData); + this.pnlScrollData.DisableAutoScroll = true; + this.pnlScrollData.Location = new System.Drawing.Point(20, 126); + this.pnlScrollData.Name = "pnlScrollData"; + this.pnlScrollData.Size = new System.Drawing.Size(766, 664); + this.pnlScrollData.TabIndex = 12; + // + // pnlData + // + this.pnlData.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlData.BackColor = System.Drawing.SystemColors.Control; + this.pnlData.DisableAutoScroll = true; + this.pnlData.Location = new System.Drawing.Point(0, 0); + this.pnlData.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.pnlData.Name = "pnlData"; + this.pnlData.Size = new System.Drawing.Size(766, 80); + this.pnlData.TabIndex = 11; + // + // pnlReg + // + this.pnlReg.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.pnlReg.BackColor = System.Drawing.SystemColors.Control; + this.pnlReg.Controls.Add(this.btnPrevReg); + this.pnlReg.Controls.Add(this.tblRegNumbers); + this.pnlReg.Controls.Add(this.btnFirstReg); + this.pnlReg.Controls.Add(this.btnLastReg); + this.pnlReg.Controls.Add(this.btnNextReg); + this.pnlReg.Enabled = false; + this.pnlReg.Location = new System.Drawing.Point(21, 87); + this.pnlReg.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.pnlReg.Name = "pnlReg"; + this.pnlReg.Size = new System.Drawing.Size(765, 701); + this.pnlReg.TabIndex = 11; // // btnPrevReg // this.btnPrevReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnPrevReg.Location = new System.Drawing.Point(42, 0); + this.btnPrevReg.Location = new System.Drawing.Point(62, 0); + this.btnPrevReg.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.btnPrevReg.Name = "btnPrevReg"; - this.btnPrevReg.Size = new System.Drawing.Size(36, 30); + this.btnPrevReg.Size = new System.Drawing.Size(54, 31); this.btnPrevReg.TabIndex = 5; this.btnPrevReg.Text = "<"; this.btnPrevReg.UseVisualStyleBackColor = true; this.btnPrevReg.Click += new System.EventHandler(this.btnPrevReg_Click); // - // btnNextReg - // - this.btnNextReg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnNextReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnNextReg.Location = new System.Drawing.Point(430, 0); - this.btnNextReg.Name = "btnNextReg"; - this.btnNextReg.Size = new System.Drawing.Size(36, 30); - this.btnNextReg.TabIndex = 6; - this.btnNextReg.Text = ">"; - this.btnNextReg.UseVisualStyleBackColor = true; - this.btnNextReg.Click += new System.EventHandler(this.btnNextReg_Click); - // - // btnLastReg - // - this.btnLastReg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnLastReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnLastReg.Location = new System.Drawing.Point(472, 0); - this.btnLastReg.Name = "btnLastReg"; - this.btnLastReg.Size = new System.Drawing.Size(36, 30); - this.btnLastReg.TabIndex = 7; - this.btnLastReg.Text = ">|"; - this.btnLastReg.UseVisualStyleBackColor = true; - this.btnLastReg.Click += new System.EventHandler(this.btnLastReg_Click); - // - // txtCurrentReg - // - this.txtCurrentReg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtCurrentReg.Location = new System.Drawing.Point(3, 3); - this.txtCurrentReg.Name = "txtCurrentReg"; - this.txtCurrentReg.Size = new System.Drawing.Size(164, 20); - this.txtCurrentReg.TabIndex = 8; - this.txtCurrentReg.TextChanged += new System.EventHandler(this.txtCurrentReg_TextChanged); - // - // txtTotalRegs - // - this.txtTotalRegs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtTotalRegs.Location = new System.Drawing.Point(173, 3); - this.txtTotalRegs.Name = "txtTotalRegs"; - this.txtTotalRegs.ReadOnly = true; - this.txtTotalRegs.Size = new System.Drawing.Size(164, 20); - this.txtTotalRegs.TabIndex = 9; - // // tblRegNumbers // this.tblRegNumbers.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) @@ -137,59 +145,94 @@ this.tblRegNumbers.ColumnCount = 2; this.tblRegNumbers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tblRegNumbers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tblRegNumbers.Controls.Add(this.txtTotalRegs, 1, 0); this.tblRegNumbers.Controls.Add(this.txtCurrentReg, 0, 0); - this.tblRegNumbers.Location = new System.Drawing.Point(84, 0); + this.tblRegNumbers.Controls.Add(this.txtTotalRegs, 1, 0); + this.tblRegNumbers.Location = new System.Drawing.Point(124, 0); + this.tblRegNumbers.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.tblRegNumbers.Name = "tblRegNumbers"; this.tblRegNumbers.RowCount = 1; this.tblRegNumbers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tblRegNumbers.Size = new System.Drawing.Size(340, 30); + this.tblRegNumbers.Size = new System.Drawing.Size(517, 31); this.tblRegNumbers.TabIndex = 10; // - // pnlReg + // txtCurrentReg // - this.pnlReg.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.txtCurrentReg.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pnlReg.Controls.Add(this.pnlData); - this.pnlReg.Controls.Add(this.btnPrevReg); - this.pnlReg.Controls.Add(this.tblRegNumbers); - this.pnlReg.Controls.Add(this.btnFirstReg); - this.pnlReg.Controls.Add(this.btnLastReg); - this.pnlReg.Controls.Add(this.btnNextReg); - this.pnlReg.Enabled = false; - this.pnlReg.Location = new System.Drawing.Point(12, 40); - this.pnlReg.Name = "pnlReg"; - this.pnlReg.Size = new System.Drawing.Size(508, 469); - this.pnlReg.TabIndex = 11; + this.txtCurrentReg.Location = new System.Drawing.Point(4, 5); + this.txtCurrentReg.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtCurrentReg.Name = "txtCurrentReg"; + this.txtCurrentReg.Size = new System.Drawing.Size(250, 26); + this.txtCurrentReg.TabIndex = 8; + this.txtCurrentReg.TextChanged += new System.EventHandler(this.txtCurrentReg_TextChanged); // - // pnlData + // txtTotalRegs // - this.pnlData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.txtTotalRegs.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pnlData.AutoScroll = true; - this.pnlData.Location = new System.Drawing.Point(0, 37); - this.pnlData.DisableAutoScroll = true; - this.pnlData.Name = "pnlData"; - this.pnlData.Size = new System.Drawing.Size(508, 432); - this.pnlData.TabIndex = 11; + this.txtTotalRegs.Location = new System.Drawing.Point(262, 5); + this.txtTotalRegs.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.txtTotalRegs.Name = "txtTotalRegs"; + this.txtTotalRegs.ReadOnly = true; + this.txtTotalRegs.Size = new System.Drawing.Size(251, 26); + this.txtTotalRegs.TabIndex = 9; + // + // btnFirstReg + // + this.btnFirstReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnFirstReg.Location = new System.Drawing.Point(0, 0); + this.btnFirstReg.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.btnFirstReg.Name = "btnFirstReg"; + this.btnFirstReg.Size = new System.Drawing.Size(54, 31); + this.btnFirstReg.TabIndex = 4; + this.btnFirstReg.Text = "|<"; + this.btnFirstReg.UseVisualStyleBackColor = true; + this.btnFirstReg.Click += new System.EventHandler(this.btnFirstReg_Click); + // + // btnLastReg + // + this.btnLastReg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnLastReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnLastReg.Location = new System.Drawing.Point(711, 0); + this.btnLastReg.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.btnLastReg.Name = "btnLastReg"; + this.btnLastReg.Size = new System.Drawing.Size(54, 31); + this.btnLastReg.TabIndex = 7; + this.btnLastReg.Text = ">|"; + this.btnLastReg.UseVisualStyleBackColor = true; + this.btnLastReg.Click += new System.EventHandler(this.btnLastReg_Click); + // + // btnNextReg + // + this.btnNextReg.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnNextReg.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnNextReg.Location = new System.Drawing.Point(649, 0); + this.btnNextReg.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.btnNextReg.Name = "btnNextReg"; + this.btnNextReg.Size = new System.Drawing.Size(54, 31); + this.btnNextReg.TabIndex = 6; + this.btnNextReg.Text = ">"; + this.btnNextReg.UseVisualStyleBackColor = true; + this.btnNextReg.Click += new System.EventHandler(this.btnNextReg_Click); // // FrmCsvViewer // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(532, 521); + this.ClientSize = new System.Drawing.Size(798, 802); + this.Controls.Add(this.pnlScrollData); + this.Controls.Add(this.grpFile); this.Controls.Add(this.pnlReg); - this.Controls.Add(this.btnLoad); - this.Controls.Add(this.txtPath); + this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.Name = "FrmCsvViewer"; this.Text = "CsvViewer"; + this.grpFile.ResumeLayout(false); + this.grpFile.PerformLayout(); + this.pnlScrollData.ResumeLayout(false); + this.pnlReg.ResumeLayout(false); this.tblRegNumbers.ResumeLayout(false); this.tblRegNumbers.PerformLayout(); - this.pnlReg.ResumeLayout(false); this.ResumeLayout(false); - this.PerformLayout(); } @@ -206,6 +249,8 @@ private System.Windows.Forms.TableLayoutPanel tblRegNumbers; private CsvView.DoubleBufferPanel pnlReg; private CsvView.DoubleBufferPanel pnlData; + private System.Windows.Forms.GroupBox grpFile; + private DoubleBufferPanel pnlScrollData; } } diff --git a/FrmCsvViewer.cs b/FrmCsvViewer.cs index 04f6e9f..5c95b7f 100644 --- a/FrmCsvViewer.cs +++ b/FrmCsvViewer.cs @@ -147,9 +147,10 @@ namespace CsvView last = true; } - pnlData.SuspendDrawing(); - - pnlData.VerticalScroll.Value = 0; + pnlScrollData.SuspendDrawing(); + pnlScrollData.VerticalScroll.Value = 0; + pnlData.Height = 10; + pnlData.Controls.Clear(); _currentReg = currentReg; txtCurrentReg.Text = Convert.ToString(currentReg); @@ -161,33 +162,36 @@ namespace CsvView btnNextReg.Enabled = (last == false); List currentData = Index_LoadReg((int)currentReg); - + int y = 0; const int TexboxPadding = 5; - const int Padding = 9; + const int PaddingLeft = 0; + const int PaddingRight = 0; + const int PaddingBetween = 10; const int LineHeight = 15; for (int i = 0; i < currentData.Count; i++) { - TextBox txtValue = RenderValue(currentData[i], y, TexboxPadding, Padding, LineHeight); + TextBox txtValue = RenderValue(currentData[i], y, TexboxPadding, PaddingLeft, PaddingRight, LineHeight); pnlData.Controls.Add(txtValue); - y += txtValue.Height + Padding; + y += txtValue.Height + PaddingBetween; } + pnlData.Height = y; - pnlData.ResumeDrawing(); + pnlScrollData.ResumeDrawing(); _rendering = false; } - private TextBox RenderValue(string value, int y, int TexboxPadding, int Padding, int LineHeight) + private TextBox RenderValue(string value, int y, int TexboxPadding, int PaddingLeft, int PaddingRight, int LineHeight) { string[] valueLines = value.Split('\n'); CTextBox txtValue = new CTextBox() { Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right), - Width = pnlData.Width - Padding, + Width = pnlData.Width - (PaddingLeft + PaddingRight), Height = (valueLines.Length * LineHeight) + TexboxPadding, Multiline = (valueLines.Length > 1), Top = y, - Left = 0, + Left = PaddingLeft, ReadOnly = true, }; for (int j = 0; j < valueLines.Length; j++) @@ -206,15 +210,16 @@ namespace CsvView if (_rendering) { return; } _rendering = true; - pnlData.SuspendDrawing(); - - pnlData.VerticalScroll.Value = 0; + pnlScrollData.SuspendDrawing(); + pnlScrollData.VerticalScroll.Value = 0; + pnlData.Height = 10; + pnlData.Controls.Clear(); pnlReg.Enabled = false; txtCurrentReg.Text = string.Empty; txtTotalRegs.Text = string.Empty; - pnlData.ResumeDrawing(); + pnlScrollData.ResumeDrawing(); _rendering = false; }