C# How to extract text from floating themes with the help of "foreach"?

  • 1
  • Question
  • Updated 9 months ago
  • (Edited)
Used 
C #
MindManager v. 2017 for Windows

Made a cycle
Mindjet.MindManager.Interop.Application app;
            app = new Mindjet.MindManager.Interop.Application();

            currentMap = app.ActiveDocument;
            string floatTopText;
            
            foreach (var flTopic in currentMap.FloatingTopics)
            {
                
                floatTopText = Convert.ToString(flTopic);               
               
            }

How to make it extract text from Floating Topix?

Analog to VBA
 For Each tpcWorking In ActiveDocument.FloatingTopics(True)
    ' For Each tpcWorking In ActiveDocument.Range(mmRangeAllFloatingTopics,False) ' ошибка
' tpcWorking.Text
tpcWorkingTxt = tpcWorking.Text
MsgBox "Текст топика - '" & tpcWorkingTxt & "'" ' !!! работает 
Next
Photo of Ivan

Ivan

  • 41 Posts
  • 0 Reply Likes

Posted 9 months ago

  • 1
Photo of Nick Duffill

Nick Duffill, Champion

  • 508 Posts
  • 169 Reply Likes
flTopic.Text should return the text
Photo of Ivan

Ivan

  • 41 Posts
  • 0 Reply Likes
There is no "* .Text".
Or am I doing something wrong?
Photo of Nick Duffill

Nick Duffill, Champion

  • 508 Posts
  • 169 Reply Likes
Have you created a link to the MindManager type library in your project references? Without it, COM will work "late-bound" and you will not get any Intellisense tips in the development environment. Add a COM reference to the version of MindManager that you are using. In VS 2015 this is normally at Project > {} Properties... > References > Add.  
Photo of Ivan

Ivan

  • 41 Posts
  • 0 Reply Likes
When I asked the question a link to the MindManager type library in the project references was created.

The solution of "Mathieu van der Wal (aHa! Coaching)"

Thank you for responding.
Photo of aHa!Coaching

aHa!Coaching, Champion

  • 1192 Posts
  • 116 Reply Likes
Isn't this related to not specifying the type of each variable? For example, here's your code with types specified (just from the top of my mind, so might not compile), this wil also help the IntelliSense to figure at what you're trying to achieve:

using MindManager = Mindjet.MindManager.Interop;
MindManager.Application app = new MindManager.Application();
Mindmanager.Document currentMap = app.ActiveDocument; string floatTopText;
            
foreach (MindManager.Topic flTopic in currentMap.FloatingTopics)
{
                floatTopText = flTopic.Text;                }

You might need to cast the elements in the FloatingTopics collection to MindManager.Topic.
Photo of Ivan

Ivan

  • 41 Posts
  • 0 Reply Likes
You're right.
Works.

Thank you very much.
Photo of Nick Duffill

Nick Duffill, Champion

  • 508 Posts
  • 169 Reply Likes
Good point Mathieu