Posted 2 years ago by SPF - Appeon
Version: 22.1.1
Avatar

Inheriting the "rangeoutliningsourcebase" class and using the "addnode()" method to dynamically modify the "defaultcollapsedcontent" attribute did not achieve the desired effect.

Demo in this path

https://github.com/spf-oss/deno

Comments (4)

Posted 2 years ago by SPF - Appeon
Avatar

If I have a problem, please tell me the correct way to use it.

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If you want to dynamically change the collapsed content, you need to override the OutliningNodeDefinition.GetCollapsedContent method instead: 

private class MyOutliningNodeDefinition : OutliningNodeDefinition
{
    public MyOutliningNodeDefinition(string key) : base(key) { }

    public override object GetCollapsedContent(IOutliningNode node)
    {
        return "show" + node.SnapshotRange.Length;
    }
}

Then use an instance of that node definition class instead of creating a regular OutliningNodeDefinition and setting its DefaultCollapsedContent property.


Actipro Software Support

Posted 2 years ago by SPF - Appeon
Avatar

Thank you for solving my problem!

But I have the following doubts.

Can you explain the function of the "key" attribute? (when the same key value is added, the nodes added later will not take effect)

Is my method of dynamically changing and folding correct, or do I need to use other methods?

The instance program has been sent to you by email.

[Modified 2 years ago]

Posted 2 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

The "IOutliningNodeDefinition.Key" property is used to group related outlining nodes. It is primarily used as an optimization when outlining is updated after a change. After each change, the automatic outlining logic will attempt to merge the new OutliningSource with the existing nodes. When a node shares the same key and offsets, it can update the existing node instead of creating a new one. If a node is found at the same offset with different keys, it knows not to update that node.

So in general, nodes which apply to the same logical concept should share the same key. All nodes could have the same key, but those nodes would not be able to have overlapping start/end offsets in that scenario.

Otherwise, what I see in your sample appears to be a valid implementation of how to dynamically define outlining.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.