hide arbitary lines in a document

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Ken Howe
Version: 4.0.0284
Avatar
hi,

I want to hide some line in a document I am displaying (not based around brackets or parsing but effectively arbitary). I have tried switching outlining into manual and creating my own outlines and then making them not visible but I dont seem to be able to get the manual outlines working.

Is there a better approach I could take ro do you have an example of creating manual outlines?

Code I tried:

private void btnLoad_Click( object sender, EventArgs e )
        {
            StringBuilder sb = new StringBuilder();

            syntaxEditor1.Document.Outlining.Mode = ActiproSoftware.SyntaxEditor.OutliningMode.Automatic;

            sb.AppendLine( "using {" );

            for( int i = 0 ; i < 9 ; i++ )
            {
                sb.AppendLine( "Testing Line " + i.ToString() );
            }

            sb.AppendLine( "}" );

            syntaxEditor1.Document.Text = sb.ToString();
        }

        private void btnOutline_Click( object sender, EventArgs e )
        {
            syntaxEditor1.Document.Outlining.Mode = ActiproSoftware.SyntaxEditor.OutliningMode.Manual;

            syntaxEditor1.Document.Outlining.Add( null, 10, 100 );
        }
Thanks
-- Ken

Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ken,

In the WinForms version that is the only way to do this, via manual outlining. If you look at how we handle the various outlining menu items in our MainForm.cs code, you should see how to manually create hidden ranges.

In the newer WPF version's design, we have a way where you can specify arbitrary ranges to hide, which is probably exactly what you want. But that is only in the WPF version.


Actipro Software Support

Posted 15 years ago by Ken Howe
Avatar
Hi,

I think the manual outline will give me what I want, and I can create an outline using the create from a selection:

        private void btnSelOutline_Click( object sender, EventArgs e )
        {
            syntaxEditor1.Document.Outlining.Mode = ActiproSoftware.SyntaxEditor.OutliningMode.Manual;

            OutliningNode node = syntaxEditor1.SelectedView.CreateOutliningNodeFromSelection( null );
            if( node != null )
            {
                syntaxEditor1.SelectedView.Selection.StartOffset = node.EndOffset;
                node.Expanded = false;
            }
        }
I saw how to do that in the MainForm example, however I dont seem to be able to create the outlines programmatically, ie I want to loop through my document and create the outline.

IE something like:

        private void btnOutline_Click( object sender, EventArgs e )
        {
            syntaxEditor1.Document.Outlining.Mode = ActiproSoftware.SyntaxEditor.OutliningMode.Manual;

            syntaxEditor1.Document.Outlining.Add( null, 10, 100 );
        }
Can you show me an example of how to do that please as the above code does not create an outline node.

Thanks,

-- Ken
Posted 15 years ago by Ken Howe
Avatar
I have it sussed out:

            OutliningNode node = syntaxEditor1.Document.Outlining.Add( null,
                syntaxEditor1.Document.Lines[ 1 ].StartOffset,
                syntaxEditor1.Document.Lines[ 2 ].EndOffset );
            node.Expanded = false;
Looks like until you say the node.Expanded = false the little + next to your outline never appears so you dont know its there, now I set it to false the + is there and I can open/close at will.

Feels like it could be a bug to me?

-- Ken
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Ken,

CreateOutliningNodeFromSelection does the same Add method call you are doing. But I don't believe we trigger a repaint when adding nodes, you need to do that yourself to get them to show up. We do this so you can batch update the outlining tree. The node.Expanded = false does trigger a repaint though since it's affecting the UI.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.