diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index c1903b11..4698e9ea 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -2449,11 +2449,11 @@ namespace Volian.Controls.Library IsControlChar = false; } } - private void RtbSendKeys(string keys) + public void RtbSendKeys(string keys) { Focus(); - SendKeys.Send(keys); // With .Net Framework 3.0 this can be replaced with EditingCommands - // http://msdn.microsoft.com/en-us/library/ms771634.aspx + SendKeys.Send(keys); // list of keys https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send%28v=vs.80%29.aspx + // With .Net Framework 3.0 this can be replaced with EditingCommands http://msdn.microsoft.com/en-us/library/ms771634.aspx } public bool PasteRtfAsText(bool PasteNoReturnsSetting) { diff --git a/PROMS/Volian.Controls.Library/StepTabRibbon.cs b/PROMS/Volian.Controls.Library/StepTabRibbon.cs index bd272db8..3a1a67b2 100644 --- a/PROMS/Volian.Controls.Library/StepTabRibbon.cs +++ b/PROMS/Volian.Controls.Library/StepTabRibbon.cs @@ -62,6 +62,7 @@ namespace Volian.Controls.Library MyStepRTB = null; //if (rtabChgId.Visible) // txtBxChgId.Text = (this.Parent as StepTabPanel).MyDisplayTabControl.ChgId; + } } public void SetChangeId(string chgid, ItemInfo ii) @@ -431,6 +432,7 @@ namespace Volian.Controls.Library set { _MyStepRTB = value; + if (fiwc != null) fiwc.MyStepRTB = value; if (value != null) { //Console.WriteLine(string.Format("StepTabRibbon: In set of MyStepRTB, Selected Text = {0}", MyStepRTB.SelectedText)); @@ -3279,10 +3281,12 @@ namespace Volian.Controls.Library (this.Parent as StepTabPanel).MyDisplayTabControl.ItemsChangeIds.Add(_MyEditItem.MyStepRTB.MyItemInfo.MyProcedure.ItemID, txtBxChgId.Text); } + private frmImportWordContents fiwc = null; // open the Import Word Text dialog private void rbnImpWrd_ItemClick(object sender, EventArgs e) { - frmImportWordContents fiwc = new frmImportWordContents(); + if (fiwc == null) fiwc = new frmImportWordContents(); + fiwc.MyStepRTB = this.MyStepRTB; fiwc.Show(); } } diff --git a/PROMS/Volian.Controls.Library/frmImportWordContents.Designer.cs b/PROMS/Volian.Controls.Library/frmImportWordContents.Designer.cs index d1788283..e29811d5 100644 --- a/PROMS/Volian.Controls.Library/frmImportWordContents.Designer.cs +++ b/PROMS/Volian.Controls.Library/frmImportWordContents.Designer.cs @@ -41,6 +41,8 @@ this.btnPrev = new DevComponents.DotNetBar.ButtonX(); this.btnNext = new DevComponents.DotNetBar.ButtonX(); this.ofd = new System.Windows.Forms.OpenFileDialog(); + this.btnNextIns = new DevComponents.DotNetBar.ButtonX(); + this.btnNextRpl = new DevComponents.DotNetBar.ButtonX(); this.SuspendLayout(); // // txbWordFile @@ -136,13 +138,12 @@ // // txbWrdText // - this.txbWrdText.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); // // // this.txbWrdText.Border.Class = "TextBoxBorder"; this.txbWrdText.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.txbWrdText.Location = new System.Drawing.Point(13, 87); + this.txbWrdText.Location = new System.Drawing.Point(13, 84); this.txbWrdText.Multiline = true; this.txbWrdText.Name = "txbWrdText"; this.txbWrdText.PreventEnterBeep = true; @@ -165,12 +166,12 @@ // this.btnPage.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnPage.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnPage.Location = new System.Drawing.Point(470, 87); + this.btnPage.Location = new System.Drawing.Point(470, 84); this.btnPage.Name = "btnPage"; this.btnPage.Size = new System.Drawing.Size(75, 23); this.btnPage.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnPage.TabIndex = 9; - this.btnPage.Text = "Page"; + this.btnPage.Text = "Pa&ge"; this.btnPage.Click += new System.EventHandler(this.btnPage_Click); // // btnPrev @@ -182,7 +183,7 @@ this.btnPrev.Size = new System.Drawing.Size(75, 23); this.btnPrev.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnPrev.TabIndex = 10; - this.btnPrev.Text = "Previous"; + this.btnPrev.Text = "&Previous"; this.btnPrev.Click += new System.EventHandler(this.btnPrev_Click); // // btnNext @@ -194,7 +195,7 @@ this.btnNext.Size = new System.Drawing.Size(75, 23); this.btnNext.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnNext.TabIndex = 11; - this.btnNext.Text = "Next"; + this.btnNext.Text = "&Next"; this.btnNext.Click += new System.EventHandler(this.btnNext_Click); // // ofd @@ -202,11 +203,37 @@ this.ofd.Filter = "Docx Files|*.docx|Doc Files|*.doc|All Files|*.*"; this.ofd.FileOk += new System.ComponentModel.CancelEventHandler(this.ofd_FileOk); // + // btnNextIns + // + this.btnNextIns.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnNextIns.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnNextIns.Location = new System.Drawing.Point(380, 200); + this.btnNextIns.Name = "btnNextIns"; + this.btnNextIns.Size = new System.Drawing.Size(75, 20); + this.btnNextIns.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.btnNextIns.TabIndex = 12; + this.btnNextIns.Text = "Insert "; + this.btnNextIns.Click += new System.EventHandler(this.btnNextIns_Click); + // + // btnNextRpl + // + this.btnNextRpl.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; + this.btnNextRpl.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; + this.btnNextRpl.Location = new System.Drawing.Point(380, 174); + this.btnNextRpl.Name = "btnNextRpl"; + this.btnNextRpl.Size = new System.Drawing.Size(75, 20); + this.btnNextRpl.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; + this.btnNextRpl.TabIndex = 13; + this.btnNextRpl.Text = "Replace"; + this.btnNextRpl.Click += new System.EventHandler(this.btnNextRpl_Click); + // // frmImportWordContents // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(557, 183); + this.ClientSize = new System.Drawing.Size(556, 226); + this.Controls.Add(this.btnNextRpl); + this.Controls.Add(this.btnNextIns); this.Controls.Add(this.btnNext); this.Controls.Add(this.btnPrev); this.Controls.Add(this.btnPage); @@ -244,5 +271,7 @@ private DevComponents.DotNetBar.ButtonX btnPrev; private DevComponents.DotNetBar.ButtonX btnNext; private System.Windows.Forms.OpenFileDialog ofd; + private DevComponents.DotNetBar.ButtonX btnNextIns; + private DevComponents.DotNetBar.ButtonX btnNextRpl; } } \ No newline at end of file diff --git a/PROMS/Volian.Controls.Library/frmImportWordContents.cs b/PROMS/Volian.Controls.Library/frmImportWordContents.cs index 8155165c..ac1392ea 100644 --- a/PROMS/Volian.Controls.Library/frmImportWordContents.cs +++ b/PROMS/Volian.Controls.Library/frmImportWordContents.cs @@ -14,6 +14,13 @@ namespace Volian.Controls.Library { LBApplicationClass _WordApp; bool _initializing = false; + private StepRTB _MyStepRTB = null; + + public StepRTB MyStepRTB + { + get { return _MyStepRTB; } + set { _MyStepRTB = value; } + } public frmImportWordContents() { _initializing = true; @@ -91,7 +98,10 @@ namespace Volian.Controls.Library _WordApp.Selection.MoveUp(LBWdUnits.wdParagraph, 1, 1); try { - int idx = _WordApp.Selection.Text.IndexOfAny("\t".ToCharArray()); + //int idx = _WordApp.Selection.Text.IndexOfAny("\t".ToCharArray()); + 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 @@ -113,13 +123,17 @@ namespace Volian.Controls.Library _WordApp.Selection.MoveDown(LBWdUnits.wdParagraph, 1, 1); try { - int idx = _WordApp.Selection.Text.IndexOfAny("\t".ToCharArray()); + //int idx = _WordApp.Selection.Text.IndexOfAny("\t".ToCharArray()); + 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 + txbWrdText.Text = txbWrdText.Text.Replace("\t", " "); // replace tabs with 5 regular spaces txvStyle.Text = _WordApp.Selection.Style.NameLocal; txbLevel.Text = _WordApp.Selection.Style.ListLevelNumber.ToString(); @@ -128,13 +142,12 @@ namespace Volian.Controls.Library } catch { } - //_WordApp.Selection.Copy(); //string tmp = Clipboard.GetText(TextDataFormat.Html); - //EditItem ei = MyDisplayTabItem.MyStepTabPanel.SelectedEditItem; - //while (ei.Enabled == false) - // ei = ei.MyParentEditItem ?? ei.MyPreviousEditItem; - //ei.MyStepRTB.Focus(); - + //if (MyStepRTB != null) + //{ + // MyStepRTB.RtbSendKeys("^+i"); + // MyStepRTB.RtbSendKeys("^v"); + //} } private void txbWordFile_TextChanged(object sender, EventArgs e) @@ -154,5 +167,31 @@ namespace Volian.Controls.Library // incase user manually closed word } } + + private void btnNextIns_Click(object sender, EventArgs e) + { + //btnNext_Click(sender, e); + if (MyStepRTB != null) + { + if (MyStepRTB.MyItemInfo.IsSection) + { + MyStepRTB.RtbSendKeys("^{DOWN}"); // down arrow + MyStepRTB.RtbSendKeys("^+b"); // insert previous + } + else + MyStepRTB.RtbSendKeys("^+i"); // insert next (same type and level) + MyStepRTB.RtbSendKeys("^v"); // clipboard paste + } + } + + private void btnNextRpl_Click(object sender, EventArgs e) + { + if (MyStepRTB != null) + { + MyStepRTB.RtbSendKeys("^{DOWN}"); // move to next edit window + MyStepRTB.RtbSendKeys("^a"); // select all + MyStepRTB.RtbSendKeys("^v"); // clipboard paste + } + } } }