How can i resize IntelliPromptMemberListBox in runtime.

SyntaxEditor .NET Languages Add-on for Windows Forms Forum

Posted 14 years ago by Marina
Version: 4.0.0285
Avatar
Hello,

I have a child of CSharpSyntaxLanguage in my project. I'd like to add one item additionally to the intelliprompt list if some conditions execute. I also would like to display this item first in list.
To achive this I override ShowIntelliPromptMemberList.

public override bool ShowIntelliPromptMemberList(SyntaxEditor syntaxEditor)
        {

            bool word = base.ShowIntelliPromptMemberList(syntaxEditor);
           

            IntelliPromptMemberList list = syntaxEditor.IntelliPrompt.MemberList;
            IntelliPromptMemberListItem[] items = new IntelliPromptMemberListItem[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                items[i] = list[i];
            }

            list.Clear();
            list.Sorted = false;
            IntelliPromptMemberListItem itemi = new IntelliPromptMemberListItem("very long label", (int)ActiproSoftware.Products.SyntaxEditor.IconResource.Warning, "", "", "");
            
            list.Add(itemi);

            foreach (IntelliPromptMemberListItem item in items)
            {
                list.Add(item);
            }
            

            return word;
        }

Everything is displayed correctly except that my new item has long label and if other items in MemberList are shorter than this label, MemberList preserves its width before my item addition.
How can i prompt IntelliPrompt list to resize the list to my item's width?

Thanks in advance,
Marina

Comments (5)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Marina,

You are altering the list after it is displayed, which is bad. We have a feature for doing this type of thing that works better. Please read this documenation topic for details:
"SyntaxEditor .NET Languages Add-on Guide / Member List Pre-Filtering"


Actipro Software Support

Posted 14 years ago by Marina
Avatar
Thanks, I'll try to investigate the topic.
Posted 14 years ago by Marina
Avatar
Hello again.
I have overloaded IntelliPromptMemberListPreFilter and resizing works fine.
My problem stays though: i would like to display my item first in the list, but there is no method Insert in e.Items(HashTable). Moreover, if I set e.SyntaxEditor.IntelliPrompt.MemberList.Sorted = false;, my item is displayed first indeed, but all the other items are unsorted.
Is there any way to put my new item on the top of the list WITH other items being sorted the way they were?

Thanks
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Marina,

Unfortunately probably not, and the other thing is that the list must remain sorted one way or another. If it isn't sorted them item matching functionality won't work correctly as the end user types. So when Sorted=false, the list of items passed in must be pre-sorted.

I believe we worked around that issue in the WPF/Silverlight versions where we have a completely new designer for member lists and how they do item matching. So there, you are able to have items that aren't sorted and it should still work, although we always recommend keeping them sorted.


Actipro Software Support

Posted 14 years ago by Marina
Avatar
Hello,

Unfortunately, i cannot change my syntaxEditor version to wpf one, i have managed to find a solution though.

Here is the code:
 public override bool IntelliPromptCompleteWord(SyntaxEditor syntaxEditor)
        {
            bool word = base.IntelliPromptCompleteWord(syntaxEditor);
            
            if (flag_)
            {
                AddInfo(syntaxEditor);
                flag_ = false;
            }
            else
            {
                syntaxEditor.IntelliPrompt.MemberList.Sorted = true;
            }

            return word;
        }

        protected override void OnSyntaxEditorIntelliPromptMemberListPreFilter(SyntaxEditor syntaxEditor, IntelliPromptMemberListPreFilterEventArgs e)
        {
            base.OnSyntaxEditorIntelliPromptMemberListPreFilter(syntaxEditor, e);

            syntaxEditor.IntelliPrompt.MemberList.Sorted = true;

            if (((DotNetContext)e.Context).Type != DotNetContextType.None && !condition())
            {
                flag_ = true;

                const string Description = "Very long string               ";
                //add item here (later will be discarded) , so that we get correct resizing
                e.Items.Add(Description, new IntelliPromptMemberListItem(
                    Description,
                    (int)ActiproSoftware.Products.SyntaxEditor.IconResource.Warning,
                    Description,
                    string.Empty,
                    string.Empty));
            }
        }
        
        private static void AddInfo(SyntaxEditor syntaxEditor)
        {
            IntelliPromptMemberList list = syntaxEditor.IntelliPrompt.MemberList;
            IntelliPromptMemberListItem[] items = new IntelliPromptMemberListItem[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                items[i] = list[i];
            }

            list.Clear();
            list.Sorted = false;

            const string Description = "Very long string               ";
            syntaxEditor.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem(
                Description,
                (int)ActiproSoftware.Products.SyntaxEditor.IconResource.Warning, 
                Description, 
                string.Empty, 
                string.Empty));

            foreach (IntelliPromptMemberListItem item in items)
            {
                //skip item that was added on OnSyntaxEditorIntelliPromptMemberListPreFilter step
                if (item.Text != Description)
                    list.Add(item);
            }
        }
The latest build of this product (v24.1.1) was released 29 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.