Added new logic to find next cell in a table
Added Button for Curent Cell or Paragraph
This commit is contained in:
parent
b43f4c711e
commit
b766f9c868
@ -43,7 +43,6 @@
|
||||
this.ofd = new System.Windows.Forms.OpenFileDialog();
|
||||
this.btnNextIns = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnNextRpl = new DevComponents.DotNetBar.ButtonX();
|
||||
// C2019-021 New Buttons
|
||||
this.btnReplaceNext = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnInsertNext = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnAfter = new DevComponents.DotNetBar.ButtonX();
|
||||
@ -55,6 +54,9 @@
|
||||
this.btnPaste = new DevComponents.DotNetBar.ButtonX();
|
||||
this.tbxNumber = new DevComponents.DotNetBar.Controls.TextBoxX();
|
||||
this.labelX4 = new DevComponents.DotNetBar.LabelX();
|
||||
this.lblTable = new DevComponents.DotNetBar.LabelX();
|
||||
this.btnCurrent = new DevComponents.DotNetBar.ButtonX();
|
||||
this.btnTest = new DevComponents.DotNetBar.ButtonX();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txbWordFile
|
||||
@ -67,7 +69,7 @@
|
||||
this.txbWordFile.Location = new System.Drawing.Point(3, 29);
|
||||
this.txbWordFile.Name = "txbWordFile";
|
||||
this.txbWordFile.PreventEnterBeep = true;
|
||||
this.txbWordFile.Size = new System.Drawing.Size(452, 20);
|
||||
this.txbWordFile.Size = new System.Drawing.Size(626, 20);
|
||||
this.txbWordFile.TabIndex = 0;
|
||||
this.txbWordFile.TextChanged += new System.EventHandler(this.txbWordFile_TextChanged);
|
||||
//
|
||||
@ -87,7 +89,7 @@
|
||||
//
|
||||
this.btnBrowse.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnBrowse.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnBrowse.Location = new System.Drawing.Point(470, 12);
|
||||
this.btnBrowse.Location = new System.Drawing.Point(644, 12);
|
||||
this.btnBrowse.Name = "btnBrowse";
|
||||
this.btnBrowse.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnBrowse.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
@ -119,7 +121,7 @@
|
||||
this.txvStyle.Name = "txvStyle";
|
||||
this.txvStyle.PreventEnterBeep = true;
|
||||
this.txvStyle.ReadOnly = true;
|
||||
this.txvStyle.Size = new System.Drawing.Size(201, 20);
|
||||
this.txvStyle.Size = new System.Drawing.Size(282, 20);
|
||||
this.txvStyle.TabIndex = 4;
|
||||
//
|
||||
// txbLevel
|
||||
@ -129,7 +131,7 @@
|
||||
//
|
||||
this.txbLevel.Border.Class = "TextBoxBorder";
|
||||
this.txbLevel.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.txbLevel.Location = new System.Drawing.Point(301, 58);
|
||||
this.txbLevel.Location = new System.Drawing.Point(383, 58);
|
||||
this.txbLevel.Name = "txbLevel";
|
||||
this.txbLevel.PreventEnterBeep = true;
|
||||
this.txbLevel.ReadOnly = true;
|
||||
@ -142,7 +144,7 @@
|
||||
//
|
||||
//
|
||||
this.labelX3.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.labelX3.Location = new System.Drawing.Point(260, 58);
|
||||
this.labelX3.Location = new System.Drawing.Point(342, 58);
|
||||
this.labelX3.Name = "labelX3";
|
||||
this.labelX3.Size = new System.Drawing.Size(35, 23);
|
||||
this.labelX3.TabIndex = 5;
|
||||
@ -155,18 +157,19 @@
|
||||
//
|
||||
this.txbWrdText.Border.Class = "TextBoxBorder";
|
||||
this.txbWrdText.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.txbWrdText.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txbWrdText.Location = new System.Drawing.Point(13, 84);
|
||||
this.txbWrdText.Multiline = true;
|
||||
this.txbWrdText.Name = "txbWrdText";
|
||||
this.txbWrdText.PreventEnterBeep = true;
|
||||
this.txbWrdText.Size = new System.Drawing.Size(442, 84);
|
||||
this.txbWrdText.Size = new System.Drawing.Size(611, 110);
|
||||
this.txbWrdText.TabIndex = 7;
|
||||
//
|
||||
// btnOpen
|
||||
//
|
||||
this.btnOpen.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnOpen.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnOpen.Location = new System.Drawing.Point(470, 41);
|
||||
this.btnOpen.Location = new System.Drawing.Point(644, 41);
|
||||
this.btnOpen.Name = "btnOpen";
|
||||
this.btnOpen.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnOpen.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
@ -178,7 +181,7 @@
|
||||
//
|
||||
this.btnPage.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnPage.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnPage.Location = new System.Drawing.Point(461, 84);
|
||||
this.btnPage.Location = new System.Drawing.Point(635, 84);
|
||||
this.btnPage.Name = "btnPage";
|
||||
this.btnPage.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F10);
|
||||
this.btnPage.Size = new System.Drawing.Size(84, 23);
|
||||
@ -191,7 +194,7 @@
|
||||
//
|
||||
this.btnPrev.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnPrev.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnPrev.Location = new System.Drawing.Point(462, 113);
|
||||
this.btnPrev.Location = new System.Drawing.Point(636, 113);
|
||||
this.btnPrev.Name = "btnPrev";
|
||||
this.btnPrev.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F11);
|
||||
this.btnPrev.Size = new System.Drawing.Size(84, 23);
|
||||
@ -204,7 +207,7 @@
|
||||
//
|
||||
this.btnNext.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnNext.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnNext.Location = new System.Drawing.Point(462, 142);
|
||||
this.btnNext.Location = new System.Drawing.Point(636, 142);
|
||||
this.btnNext.Name = "btnNext";
|
||||
this.btnNext.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F12);
|
||||
this.btnNext.Size = new System.Drawing.Size(84, 23);
|
||||
@ -230,7 +233,6 @@
|
||||
this.btnNextIns.TabIndex = 12;
|
||||
this.btnNextIns.Text = "Insert After (F4)";
|
||||
this.btnNextIns.Visible = false;
|
||||
//this.btnNextIns.Click += new System.EventHandler(this.btnNextIns_Click);
|
||||
//
|
||||
// btnNextRpl
|
||||
//
|
||||
@ -244,13 +246,12 @@
|
||||
this.btnNextRpl.TabIndex = 13;
|
||||
this.btnNextRpl.Text = "Replace After (F3)";
|
||||
this.btnNextRpl.Visible = false;
|
||||
//this.btnNextRpl.Click += new System.EventHandler(this.btnNextRpl_Click);
|
||||
//
|
||||
// btnReplaceNext
|
||||
//
|
||||
this.btnReplaceNext.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnReplaceNext.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnReplaceNext.Location = new System.Drawing.Point(462, 174);
|
||||
this.btnReplaceNext.Location = new System.Drawing.Point(637, 200);
|
||||
this.btnReplaceNext.Name = "btnReplaceNext";
|
||||
this.btnReplaceNext.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnReplaceNext.Size = new System.Drawing.Size(82, 20);
|
||||
@ -263,7 +264,7 @@
|
||||
//
|
||||
this.btnInsertNext.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnInsertNext.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnInsertNext.Location = new System.Drawing.Point(462, 200);
|
||||
this.btnInsertNext.Location = new System.Drawing.Point(637, 226);
|
||||
this.btnInsertNext.Name = "btnInsertNext";
|
||||
this.btnInsertNext.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F4);
|
||||
this.btnInsertNext.Size = new System.Drawing.Size(82, 20);
|
||||
@ -276,7 +277,7 @@
|
||||
//
|
||||
this.btnAfter.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnAfter.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnAfter.Location = new System.Drawing.Point(425, 174);
|
||||
this.btnAfter.Location = new System.Drawing.Point(600, 200);
|
||||
this.btnAfter.Name = "btnAfter";
|
||||
this.btnAfter.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnAfter.Size = new System.Drawing.Size(31, 20);
|
||||
@ -289,7 +290,7 @@
|
||||
//
|
||||
this.btnSect.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnSect.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnSect.Location = new System.Drawing.Point(230, 174);
|
||||
this.btnSect.Location = new System.Drawing.Point(405, 200);
|
||||
this.btnSect.Name = "btnSect";
|
||||
this.btnSect.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnSect.Size = new System.Drawing.Size(31, 20);
|
||||
@ -302,7 +303,7 @@
|
||||
//
|
||||
this.btnHigh.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnHigh.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnHigh.Location = new System.Drawing.Point(351, 174);
|
||||
this.btnHigh.Location = new System.Drawing.Point(526, 200);
|
||||
this.btnHigh.Name = "btnHigh";
|
||||
this.btnHigh.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnHigh.Size = new System.Drawing.Size(31, 20);
|
||||
@ -315,7 +316,7 @@
|
||||
//
|
||||
this.btnSEQ.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnSEQ.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnSEQ.Location = new System.Drawing.Point(388, 174);
|
||||
this.btnSEQ.Location = new System.Drawing.Point(563, 200);
|
||||
this.btnSEQ.Name = "btnSEQ";
|
||||
this.btnSEQ.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnSEQ.Size = new System.Drawing.Size(31, 20);
|
||||
@ -328,7 +329,7 @@
|
||||
//
|
||||
this.btnParentAfter.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnParentAfter.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnParentAfter.Location = new System.Drawing.Point(388, 200);
|
||||
this.btnParentAfter.Location = new System.Drawing.Point(563, 226);
|
||||
this.btnParentAfter.Name = "btnParentAfter";
|
||||
this.btnParentAfter.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnParentAfter.Size = new System.Drawing.Size(68, 20);
|
||||
@ -341,7 +342,7 @@
|
||||
//
|
||||
this.btnSplit.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnSplit.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnSplit.Location = new System.Drawing.Point(351, 200);
|
||||
this.btnSplit.Location = new System.Drawing.Point(526, 226);
|
||||
this.btnSplit.Name = "btnSplit";
|
||||
this.btnSplit.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnSplit.Size = new System.Drawing.Size(31, 20);
|
||||
@ -354,7 +355,7 @@
|
||||
//
|
||||
this.btnPaste.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnPaste.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnPaste.Location = new System.Drawing.Point(461, 226);
|
||||
this.btnPaste.Location = new System.Drawing.Point(636, 252);
|
||||
this.btnPaste.Name = "btnPaste";
|
||||
this.btnPaste.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnPaste.Size = new System.Drawing.Size(83, 20);
|
||||
@ -370,7 +371,7 @@
|
||||
//
|
||||
this.tbxNumber.Border.Class = "TextBoxBorder";
|
||||
this.tbxNumber.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.tbxNumber.Location = new System.Drawing.Point(388, 58);
|
||||
this.tbxNumber.Location = new System.Drawing.Point(494, 58);
|
||||
this.tbxNumber.Name = "tbxNumber";
|
||||
this.tbxNumber.PreventEnterBeep = true;
|
||||
this.tbxNumber.Size = new System.Drawing.Size(56, 20);
|
||||
@ -382,17 +383,58 @@
|
||||
//
|
||||
//
|
||||
this.labelX4.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.labelX4.Location = new System.Drawing.Point(343, 58);
|
||||
this.labelX4.Location = new System.Drawing.Point(437, 58);
|
||||
this.labelX4.Name = "labelX4";
|
||||
this.labelX4.Size = new System.Drawing.Size(51, 23);
|
||||
this.labelX4.TabIndex = 24;
|
||||
this.labelX4.Text = "Number:";
|
||||
//
|
||||
// lblTable
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.lblTable.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
|
||||
this.lblTable.Location = new System.Drawing.Point(556, 58);
|
||||
this.lblTable.Name = "lblTable";
|
||||
this.lblTable.Size = new System.Drawing.Size(52, 23);
|
||||
this.lblTable.TabIndex = 26;
|
||||
this.lblTable.Text = "Not Table";
|
||||
//
|
||||
// btnCurrent
|
||||
//
|
||||
this.btnCurrent.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnCurrent.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnCurrent.Location = new System.Drawing.Point(637, 171);
|
||||
this.btnCurrent.Name = "btnCurrent";
|
||||
this.btnCurrent.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F12);
|
||||
this.btnCurrent.Size = new System.Drawing.Size(84, 23);
|
||||
this.btnCurrent.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnCurrent.TabIndex = 27;
|
||||
this.btnCurrent.Text = "Current";
|
||||
this.btnCurrent.Click += new System.EventHandler(this.btnCurrent_Click);
|
||||
//
|
||||
// btnTest
|
||||
//
|
||||
this.btnTest.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
|
||||
this.btnTest.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
|
||||
this.btnTest.Location = new System.Drawing.Point(122, 3);
|
||||
this.btnTest.Name = "btnTest";
|
||||
this.btnTest.Shortcuts.Add(DevComponents.DotNetBar.eShortcut.F3);
|
||||
this.btnTest.Size = new System.Drawing.Size(31, 20);
|
||||
this.btnTest.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
|
||||
this.btnTest.TabIndex = 28;
|
||||
this.btnTest.Text = "Test";
|
||||
this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
|
||||
//
|
||||
// frmImportWordContents
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(556, 272);
|
||||
this.ClientSize = new System.Drawing.Size(731, 272);
|
||||
this.Controls.Add(this.btnTest);
|
||||
this.Controls.Add(this.btnCurrent);
|
||||
this.Controls.Add(this.lblTable);
|
||||
this.Controls.Add(this.tbxNumber);
|
||||
this.Controls.Add(this.labelX4);
|
||||
this.Controls.Add(this.btnPaste);
|
||||
@ -456,5 +498,8 @@
|
||||
private DevComponents.DotNetBar.ButtonX btnPaste;
|
||||
private DevComponents.DotNetBar.Controls.TextBoxX tbxNumber;
|
||||
private DevComponents.DotNetBar.LabelX labelX4;
|
||||
private DevComponents.DotNetBar.LabelX lblTable;
|
||||
private DevComponents.DotNetBar.ButtonX btnCurrent;
|
||||
private DevComponents.DotNetBar.ButtonX btnTest;
|
||||
}
|
||||
}
|
@ -92,8 +92,10 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void btnPrev_Click(object sender, EventArgs e)
|
||||
{
|
||||
_WordApp.Selection.MoveUp(LBWdUnits.wdParagraph, 1, 0);
|
||||
_WordApp.Selection.MoveUp(LBWdUnits.wdParagraph, 1, 1);
|
||||
// C2019-021 RHM 5/15/2019 Added new methods and properties for Import Word Content
|
||||
_WordApp.Selection.MoveUp(LBWdUnits.wdParagraph, 1, 0); // Move to previous paragraph
|
||||
_WordApp.Selection.MoveUp(LBWdUnits.wdParagraph, 1, 1); // Select paragraph
|
||||
//_WordApp.Selection.MoveEnd(LBWdUnits.wdCharacter, -1); // Move 1 Character Back
|
||||
try
|
||||
{
|
||||
// C2019-021 Use generic function CopyWordText
|
||||
@ -106,19 +108,79 @@ namespace Volian.Controls.Library
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
// C2019-021 RHM 5/15/2019 Added new methods and properties for Import Word Content
|
||||
/// <summary>
|
||||
/// MoveToNextCell
|
||||
/// Find the next Cell including merged cells
|
||||
/// Loop through columns then rows
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// Yes - if Processed as a cell
|
||||
/// No - Not Processed
|
||||
/// </returns>
|
||||
private bool MoveToNextCell()
|
||||
{
|
||||
// Get the row and column for the current selection within the table.
|
||||
int rowIndex = _WordApp.Selection.Cells[1].RowIndex;
|
||||
int columnIndex = _WordApp.Selection.Cells[1].ColumnIndex;
|
||||
// Only do this for tables
|
||||
if (_WordApp.Selection.Tables != null && _WordApp.Selection.Tables.Count > 0)
|
||||
{
|
||||
LBTable tbl = _WordApp.Selection.Tables[1];
|
||||
if (tbl.Range.Cells != null && tbl.Range.Cells.Count > 0)
|
||||
{
|
||||
// Make sure the entire cell is selected
|
||||
_WordApp.Selection.SelectCell();
|
||||
// Loop through the cells of the table
|
||||
for (int i = 1; i < tbl.Range.Cells.Count; i++)
|
||||
{
|
||||
LBCell myCell = tbl.Range.Cells[i];
|
||||
// if this cell has matching indices, then move to the next cell
|
||||
if (myCell.RowIndex == rowIndex && myCell.ColumnIndex == columnIndex)
|
||||
{
|
||||
// Move the Start to the start of the next cell
|
||||
_WordApp.Selection.Start = tbl.Range.Cells[i + 1].Range.Start;
|
||||
// Select the entire cell
|
||||
_WordApp.Selection.SelectCell();
|
||||
return true; // Cell Found and moved
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false; // Cell not found
|
||||
}
|
||||
private void btnNext_Click(object sender, EventArgs e)
|
||||
{
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 0);
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 1);
|
||||
// C2019-021 Either move by cells or paragraphs
|
||||
if (_WordApp.Selection.Cells != null && _WordApp.Selection.Cells.Count > 0)
|
||||
{
|
||||
if (!MoveToNextCell())
|
||||
{
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 2, 0);// Move beyond the table
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 1);// Select a Paragraph
|
||||
}
|
||||
}
|
||||
else // not a table
|
||||
{
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 0); // Move to the next paragraph
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 1); // Select a Paragraph
|
||||
}
|
||||
try
|
||||
{
|
||||
// C2019-021 Use Generic CopyWordText
|
||||
CopyWordText();
|
||||
// C2019-021If the word text only contains whitespace skip to next
|
||||
if (txbWrdText.Text.TrimEnd("\f\r\n".ToCharArray()) == "")
|
||||
btnNext_Click(sender, e);
|
||||
else
|
||||
if (_WordApp.Selection.Cells != null && _WordApp.Selection.Cells.Count > 0)
|
||||
{
|
||||
Clipboard.SetText(txbWrdText.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
// C2019-021 If the word text only contains whitespace skip to next
|
||||
if (txbWrdText.Text.TrimEnd("\f\r\n".ToCharArray()) == "")
|
||||
btnNext_Click(sender, e);
|
||||
else
|
||||
Clipboard.SetText(txbWrdText.Text);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@ -129,17 +191,33 @@ namespace Volian.Controls.Library
|
||||
txvStyle.Text = _WordApp.Selection.Style.NameLocal;
|
||||
txbLevel.Text = _WordApp.Selection.Style.ListLevelNumber.ToString();
|
||||
tbxNumber.Text = _WordApp.Selection.Range.ListFormat.ListString;
|
||||
int idx = -1;
|
||||
if (_WordApp.Selection.Text.EndsWith("\t(\r") || _WordApp.Selection.Text.EndsWith("\t___\r"))
|
||||
idx = _WordApp.Selection.Text.LastIndexOf("\t");
|
||||
if (idx > 0)
|
||||
txbWrdText.Text = _WordApp.Selection.Text.Substring(0, idx);
|
||||
else
|
||||
txbWrdText.Text = _WordApp.Selection.Text;
|
||||
txbWrdText.Text = txbWrdText.Text.Replace('\xA0', ' '); // replace hard space with regular space
|
||||
txbWrdText.Text = txbWrdText.Text.Replace('\x0B', ' '); // replace hard return with regular space
|
||||
// C2019-021 Don't replace tabs
|
||||
//txbWrdText.Text = txbWrdText.Text.Replace("\t", " "); // replace tabs with 5 regular spaces
|
||||
// C2019-021 RHM 5/15/2019 Added new methods and properties for Import Word Content
|
||||
try
|
||||
{
|
||||
//Console.WriteLine("Cell Count = {0}", _WordApp.Selection.Cells.Count);
|
||||
lblTable.Text = "Table";
|
||||
lblTable.FontBold = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
lblTable.Text = "Not Table";
|
||||
lblTable.FontBold = false;
|
||||
}
|
||||
txbWrdText.Text = ShowText(_WordApp.Selection.Text.TrimEnd("\r\a".ToCharArray()));
|
||||
_WordApp.Activate();
|
||||
}
|
||||
// C2019-021 RHM 5/15/2019 Added newe methods and properties for Import Word Content
|
||||
private string ShowText(string txt)
|
||||
{
|
||||
// This was for debugging
|
||||
//StringBuilder sb = new StringBuilder();
|
||||
//foreach (char c in txt)
|
||||
// if (((int)c) >= ' ' && ((int)c) < '\x7F')
|
||||
// sb.Append(c);
|
||||
// else
|
||||
// sb.Append(string.Format("\\u{0:X4} ", ((int)c)));
|
||||
//return sb.ToString();
|
||||
return txt;
|
||||
}
|
||||
private void txbWordFile_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
@ -185,12 +263,20 @@ namespace Volian.Controls.Library
|
||||
// }
|
||||
// this.Focus(); // set focus back to this form
|
||||
//}
|
||||
// C2019-021 New function to replace the PROMS text with the word text and move to the next paragraph in word.
|
||||
// C2019-021 New function to replace the PROMS text with the word text and move to the next paragraph in word.
|
||||
private void btnReplaceNext_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MyStepRTB != null)
|
||||
{
|
||||
if (MyStepRTB.MyItemInfo.IsSection && tbxNumber.Text != "")
|
||||
if (MyStepRTB.Parent is VlnFlexGrid)//Replace text in a Grid (Table cell)
|
||||
{
|
||||
VlnFlexGrid vg = MyStepRTB.Parent as VlnFlexGrid;
|
||||
vg.StartEditing();
|
||||
MyStepRTB.Text = txbWrdText.Text;
|
||||
vg[vg.Row, vg.Col] = MyStepRTB.Rtf;
|
||||
vg.FinishEditing(false);
|
||||
}
|
||||
else if (MyStepRTB.MyItemInfo.IsSection && tbxNumber.Text != "")
|
||||
{
|
||||
using (VEPROMS.CSLA.Library.Item ii = MyStepRTB.MyItemInfo.Get())
|
||||
{
|
||||
@ -227,10 +313,19 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (MyStepRTB != null)
|
||||
{
|
||||
EditItem ei = MyStepRTB.Parent as EditItem;
|
||||
if (ei != null)
|
||||
if (MyStepRTB.Parent is VlnFlexGrid)
|
||||
{
|
||||
ei.AddSiblingAfter();
|
||||
VlnFlexGrid vg = MyStepRTB.Parent as VlnFlexGrid;
|
||||
//vg.FinishEditing(false);
|
||||
vg.SelectNextCell();
|
||||
}
|
||||
else
|
||||
{
|
||||
EditItem ei = MyStepRTB.Parent as EditItem;
|
||||
if (ei != null)
|
||||
{
|
||||
ei.AddSiblingAfter();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -247,10 +342,10 @@ namespace Volian.Controls.Library
|
||||
return;
|
||||
}
|
||||
while (ei != null && !ei.MyItemInfo.IsSection)
|
||||
if(ei.MyParentEditItem != null)
|
||||
if (ei.MyParentEditItem != null)
|
||||
ei = ei.MyParentEditItem;
|
||||
else
|
||||
ei=ei.MyPreviousEditItem;
|
||||
ei = ei.MyPreviousEditItem;
|
||||
if (ei != null)
|
||||
{
|
||||
ei.AddSiblingAfter();
|
||||
@ -324,5 +419,34 @@ namespace Volian.Controls.Library
|
||||
MyStepRTB.SelectedText = Clipboard.GetText();
|
||||
}
|
||||
}
|
||||
// C2019-021 RHM 5/15/2019 Added new methods and properties for Import Word Content
|
||||
private void btnCurrent_Click(object sender, EventArgs e)
|
||||
{
|
||||
_WordApp.Selection.MoveUp(LBWdUnits.wdParagraph, 1, 0); // Select paragraph
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 1); // Select paragraph
|
||||
_WordApp.Selection.MoveEnd(LBWdUnits.wdCharacter, -1); // Exclude the last character
|
||||
try
|
||||
{
|
||||
// C2019-021 Use Generic CopyWordText
|
||||
CopyWordText();
|
||||
// C2019-021If the word text only contains whitespace skip to next
|
||||
//if (txbWrdText.Text.TrimEnd("\f\r\n\a".ToCharArray()) == "")
|
||||
// btnNext_Click(sender, e);
|
||||
//else
|
||||
Clipboard.SetText(txbWrdText.Text);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
private void btnTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!MoveToNextCell())
|
||||
{
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 2, 0);
|
||||
_WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 1);
|
||||
}
|
||||
_WordApp.Activate();
|
||||
//int cols = _WordApp.Selection.Tables[1].Columns.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user