<?xml version="1.0" encoding="utf-8"?>
<ScriptCommand version="3" xmlns="http://www.waterproof.fr/PHPEdit/ScriptCommand">
	<Description>Paste the selected clipboard history item in the editor.</Description>
	<Category>Clipboard History</Category>
	<Prototypes>
    <Prototype />
  </Prototypes>
  <scr:Script version="3" language="C#" xmlns:scr="http://www.waterproof.fr/PHPEdit/Script">
    <scr:ValidationRules>
			<scr:Rule name="Parameters.Count" possibleCounts="0" />
      <scr:Rule name="Documents.HasActiveProjectFile" />
      <scr:Not>
        <scr:Rule name="Documents.ActiveProjectFile.CodeEditor.IsReadOnly" />
      </scr:Not>
    </scr:ValidationRules>
    <scr:GetEnabled>
      <![CDATA[
IClipboardHistory clipboardHistory;
if (Program.Services.GetService<IClipboardHistory>(out clipboardHistory))
{
    return clipboardHistory.HasSelectedItem;
}
return false;
]]>
      </scr:GetEnabled>
    <scr:Execute>
      <![CDATA[
IClipboardHistory clipboardHistory;
if (!Program.Services.GetService<IClipboardHistory>(out clipboardHistory))
{
    return;
}

IProjectFileViewCodeEdition codeEditionView;
if (CodeEditionView.GetActiveCodeEditionView(out codeEditionView))
{
    codeEditionView.Editor.ActiveView.SelText = clipboardHistory.SelectedItem;
    codeEditionView.BringToFront();
}
]]>
    </scr:Execute>
  </scr:Script>
</ScriptCommand>
