Hi Paw,
Do you mean moving a selected code inside an existing region?
Here is a command that, after selecting a piece of code, it moves it to a specify region.
To test this command:
1. Create a region named “Properties”
2. Set the cursor out of the region
3. Write a property (“‘string name p” Ctrl+Enter)
4. Select the code of the property already created
5. Press Ctrl+Enter and write in the AutoCode input box “Properties move”. Press enter.
After that, the selected property will be moved inside the “Properties” region.
Here is the complete “Move” command.
Code:
<?xml version="1.0"?>
<Commands xmlns="http://schemas.devprojects.net/AutoCode/v3.0">
<Command name="Move" priority="50">
<CommandBehavior>
<CommandLine shortcut="move" />
<ActiveDocument extensions=".cs"/>
</CommandBehavior>
<CommandCode language="csharp">
<Render>
EditPoint ep1;
EditPoint ep2 = null;
TextRanges tr = null;
// create an EditPoint, move to the start of the document and search for "#region <name>"
ep1 = Selection.ActivePoint.CreateEditPoint();
ep1.StartOfDocument();
if (ep1.FindPattern("#region " + Arguments[0], (int)(vsFindOptions.vsFindOptionsMatchInHiddenText | vsFindOptions.vsFindOptionsMatchCase), ref ep2, ref tr))
{
// move the EditPoint returned by FindPattern to the beginning of the next line
ep2.StartOfLine();
ep2.LineDown(1);
// write a copy of the selected text
ep2.Insert(Selection.Text);
// clear the selected text
Selection.Text = "";
}
</Render>
</CommandCode>
</Command>
</Commands>
Hope this helps,
Alvaro