added Plain Text paste option
This commit is contained in:
@@ -461,7 +461,8 @@ namespace Volian.Controls.Library
|
||||
btnCMCut.Enabled = btnCut.Enabled = setting;
|
||||
btnCMUndo.Enabled = btnUndo.Enabled = setting;
|
||||
btnCMRedo.Enabled = btnRedo.Enabled = setting;
|
||||
btnCMPaste.Enabled = btnPaste.Enabled = setting;
|
||||
//btnEdit3CMPaste.Enabled = btnPasteText.Enabled = btnCMPasteText.Enabled = btnCMPaste.Enabled = btnPaste.Enabled = setting;
|
||||
btnCMPaste.Enabled = btnCMPasteText.Enabled = btnPasteText.Enabled = btnPasteStepText.Enabled = btnPaste.Enabled = setting;
|
||||
btnCMCopy.Enabled = btnCopy.Enabled = setting;
|
||||
btnPasteAfter.Enabled = btnPasteBefore.Enabled = btnStepPaste.Enabled = btnPasteReplace.Enabled = setting;
|
||||
btnCMGrid.Enabled = setting;
|
||||
@@ -514,7 +515,11 @@ namespace Volian.Controls.Library
|
||||
|
||||
// for paste, see if there is clipboard data, & if so, of a type we can use.
|
||||
IDataObject iData = Clipboard.GetDataObject();
|
||||
btnCMPaste.Enabled = btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
|
||||
//btnEdit3CMPaste.Enabled = btnPasteText.Enabled = btnCMPasteText.Enabled = btnCMPaste.Enabled = btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
|
||||
//btnPasteText.Enabled = btnPasteStepText.Enabled = btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
|
||||
btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf));
|
||||
btnCMPasteText.Enabled = btnPasteText.Enabled = iData.GetDataPresent(DataFormats.Text);
|
||||
btnCMPaste.Enabled = btnPasteStepText.Enabled = iData.GetDataPresent(DataFormats.Rtf);
|
||||
}
|
||||
// all selected copy while in either Edit or View mode
|
||||
btnCMCopy.Enabled = btnCopy.Enabled = _MyStepRTB.SelectionLength > 0;
|
||||
@@ -886,12 +891,13 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion
|
||||
#region Home Tab
|
||||
private bool _PastePlainText = false;
|
||||
private void btnPaste_Click(object sender, EventArgs e)
|
||||
{
|
||||
IDataObject myDO = Clipboard.GetDataObject();
|
||||
RichTextBox myRtb = _MyStepRTB;
|
||||
Control ctrl = FindActiveControl();
|
||||
Console.WriteLine("Paste myRTB == ctrl {0}", myRtb.Equals(ctrl));
|
||||
//Console.WriteLine("Paste myRTB == ctrl {0}", myRtb.Equals(ctrl));
|
||||
if (!_MyStepRTB.Focused)
|
||||
{
|
||||
if (ctrl is RichTextBox)
|
||||
@@ -903,15 +909,18 @@ namespace Volian.Controls.Library
|
||||
ComboBox cmb = ctrl as ComboBox;
|
||||
if (myDO.GetDataPresent(DataFormats.Text))
|
||||
cmb.SelectedText = myDO.GetData(DataFormats.Text).ToString();
|
||||
_PastePlainText = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveErrorInLogProblemWithType(ctrl);
|
||||
_PastePlainText = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (myDO.GetDataPresent(DataFormats.Rtf))
|
||||
|
||||
if (myDO.GetDataPresent(DataFormats.Rtf) && !_PastePlainText)
|
||||
{
|
||||
string tmpForLink = myDO.GetData(DataFormats.Rtf).ToString();
|
||||
tmpForLink = Regex.Replace(tmpForLink, @"#Link:ReferencedObject:[0-9]+ ", @"#Link:ReferencedObject:<NewID> ");
|
||||
@@ -920,9 +929,15 @@ namespace Volian.Controls.Library
|
||||
myRtb.SelectedRtf = tmpForLink;
|
||||
}
|
||||
else if (myDO.GetDataPresent(DataFormats.Text))
|
||||
myRtb.SelectedText = myDO.GetData(DataFormats.Text).ToString();
|
||||
{
|
||||
string ptext = myDO.GetData(DataFormats.Text).ToString();
|
||||
myRtb.SelectedText = ptext;
|
||||
//myRtb.SelectedText = myDO.GetData(DataFormats.Text).ToString();
|
||||
}
|
||||
if (myRtb.SelectionLength == 0 && myRtb is StepRTB) myRtb.SelectionFont = (myRtb as StepRTB).MyStyleFont.WindowsFont;
|
||||
_PastePlainText = false;
|
||||
}
|
||||
|
||||
private void SaveErrorInLogProblemWithType(Control ctrl)
|
||||
{
|
||||
StringBuilder errormsg = new StringBuilder(string.Format("Failed clipboard action with control {0} a {1} ", ctrl.Name, ctrl.GetType().Name));
|
||||
@@ -958,21 +973,32 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
Control ctrl = FindActiveControl();
|
||||
Clipboard.Clear();
|
||||
DataObject myDO;
|
||||
DataObject myDO = new DataObject(); ;
|
||||
if (ctrl is RichTextBox)
|
||||
{
|
||||
myDO = new DataObject("Rich Text Format", (ctrl as RichTextBox).SelectedRtf);
|
||||
myDO.SetText(_MyStepRTB.SelectedText);
|
||||
if(isCut) (ctrl as RichTextBox).SelectedText = "";
|
||||
//myDO = new DataObject("Rich Text Format", (ctrl as RichTextBox).SelectedRtf);
|
||||
string tmp2 = _MyStepRTB.SelectedText;
|
||||
string tmp = _MyStepRTB.GetSelectionForClipBoard();
|
||||
tmp2 = Regex.Replace(tmp2, @"#Link:ReferencedObject:[0-9]+ +[0-9a-zA-Z]+ [0-9]+", @"");
|
||||
tmp2 = Regex.Replace(tmp2, @"#Link:Transition:([0-9]+) [0-9]+ [1-9]+", @"");
|
||||
tmp2 = Regex.Replace(tmp2, @"#Link:TransitionRange:([0-9]+) [0-9]+ [0-9]+ [0-9]+", "");
|
||||
tmp2 = tmp2.Replace("<START]", "");
|
||||
tmp2 = tmp2.Replace("[END>", "");
|
||||
myDO.SetText(tmp2, TextDataFormat.Text);
|
||||
//myDO.SetText(_MyStepRTB.SelectedRtf, TextDataFormat.Rtf);
|
||||
myDO.SetText(tmp, TextDataFormat.Rtf);
|
||||
if (isCut) (ctrl as RichTextBox).SelectedText = "";
|
||||
}
|
||||
else if (ctrl is ComboBox)
|
||||
{
|
||||
myDO = new DataObject("Text Format", (ctrl as ComboBox).SelectedText);
|
||||
//myDO = new DataObject("Text Format", (ctrl as ComboBox).SelectedText);
|
||||
myDO.SetText((ctrl as ComboBox).SelectedText, TextDataFormat.Text);
|
||||
if (isCut) (ctrl as ComboBox).SelectedText = "";
|
||||
}
|
||||
else if (ctrl is TextBox)
|
||||
{
|
||||
myDO = new DataObject("Text Format", (ctrl as TextBox).SelectedText);
|
||||
//myDO = new DataObject("Text Format", (ctrl as TextBox).SelectedText);
|
||||
myDO.SetText((ctrl as TextBox).SelectedText, TextDataFormat.Text);
|
||||
if (isCut) (ctrl as TextBox).SelectedText = "";
|
||||
}
|
||||
else
|
||||
@@ -980,6 +1006,28 @@ namespace Volian.Controls.Library
|
||||
SaveErrorInLogProblemWithType(ctrl);
|
||||
return;
|
||||
}
|
||||
//DataObject myDO;
|
||||
//if (ctrl is RichTextBox)
|
||||
//{
|
||||
// myDO = new DataObject("Rich Text Format", (ctrl as RichTextBox).SelectedRtf);
|
||||
// myDO.SetText(_MyStepRTB.SelectedText);
|
||||
// if(isCut) (ctrl as RichTextBox).SelectedText = "";
|
||||
//}
|
||||
//else if (ctrl is ComboBox)
|
||||
//{
|
||||
// myDO = new DataObject("Text Format", (ctrl as ComboBox).SelectedText);
|
||||
// if (isCut) (ctrl as ComboBox).SelectedText = "";
|
||||
//}
|
||||
//else if (ctrl is TextBox)
|
||||
//{
|
||||
// myDO = new DataObject("Text Format", (ctrl as TextBox).SelectedText);
|
||||
// if (isCut) (ctrl as TextBox).SelectedText = "";
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SaveErrorInLogProblemWithType(ctrl);
|
||||
// return;
|
||||
//}
|
||||
Clipboard.SetDataObject(myDO);
|
||||
}
|
||||
private void btnCopy_Click(object sender, EventArgs e)
|
||||
@@ -1969,9 +2017,14 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
public void SetRibbonForGrid()
|
||||
{
|
||||
// for paste, see if there is clipboard data, & if so, of a type we can use.
|
||||
IDataObject iData = Clipboard.GetDataObject();
|
||||
// set to true if editing cell, otherwise false for grids
|
||||
bool enable = (MyFlexGrid != null && MyFlexGrid.Editor != null);
|
||||
btnPaste.Enabled = enable;
|
||||
//btnPasteText.Enabled = btnPasteStepText.Enabled = btnPaste.Enabled = enable;
|
||||
btnPaste.Enabled = (iData.GetDataPresent(DataFormats.Text) || iData.GetDataPresent(DataFormats.Rtf)) && enable;
|
||||
btnCMPasteText.Enabled = btnPasteText.Enabled = iData.GetDataPresent(DataFormats.Text) && enable;
|
||||
btnCMPaste.Enabled = btnPasteStepText.Enabled = iData.GetDataPresent(DataFormats.Rtf ) && enable;
|
||||
btnCopy.Enabled = enable;
|
||||
btnCut.Enabled = enable;
|
||||
btnBold.Enabled = enable;
|
||||
@@ -2154,6 +2207,12 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
#endregion // Expand/Collapse Ribbon
|
||||
|
||||
private void btnPasteText_Click(object sender, EventArgs e)
|
||||
{
|
||||
_PastePlainText = true;
|
||||
btnPaste_Click(sender, e);
|
||||
}
|
||||
|
||||
}
|
||||
public enum E_FieldToEdit { StepText, Text, Number, PSI };
|
||||
public class StepTabRibbonEventArgs : EventArgs
|
||||
|
Reference in New Issue
Block a user