Welcome Guest Search | Active Topics | Members | Log In | Register

Add code to existing region Options · View
Paw
Posted: Thursday, April 03, 2008 1:26:30 AM
Rank: Newbie
Groups: Member

Joined: 4/3/2008
Posts: 1
Points: 3
Location: Denmark
Hi

A thing I would really love to see, is if a selected region could be added to an existing region, if that region has been created previously.
This is especially usefull when autogenerating properties or event methods from the gui.

Regards
Paw
Alvaro
Posted: Tuesday, April 08, 2008 3:16:26 PM
Rank: Administration
Groups: Administration

Joined: 3/16/2008
Posts: 22
Points: 72
Location: Spain
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
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008