stevencohn / OneMore

A OneNote add-in with simple, yet powerful and useful features
Mozilla Public License 2.0
2.6k stars 219 forks source link

The add-in window won't pop-up as expected #1042

Closed valuex closed 1 year ago

valuex commented 1 year ago

Problem to Solve

I added one feature based on the great foundation of OneMore. It's function is very simple, that is to do incremental search for the pages or sections while typing into the text box.
The shortcut for this feature is F5 But the window won't behavior as expected. The 1st problem is that everytime when OneNote is reopened, the window can NOT pop-up when pressing F5 or click the menu item for the first time.
The 2nd problem is that sometimes when the window pop-ups, it get stuck. No content was loaded into the TreeView.
The 2nd problem can be reproduced when doing the debug with VS.
Could you help to review the code and point-out where needs to be revised? Thanks.

OS:

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected Behavior

A clear and concise description of what you expected to happen.

Screenshots

image

Environment (if applicable)

Additional Context

Add any other context about the problem here. Attach page XML file or the app log file as appropriate. You can find the log file here: %localappdata%\temp\OneMore.log

THE FINE PRINT This is a hobby project that I started for myself. I'm happy to take requests and will promise to consider each one carefully but offer no guarantees that I will ultimately agree to their usefulness or have time to implement any of them. If OneNote offers a "close enough" work-around then I will probably reject the request - you've been warned!

stevencohn commented 1 year ago

Do you have a github branch that I can look at? Otherwise, there's nothing here for me to reproduce or debug.

valuex commented 1 year ago

OneMore1.zip

valuex commented 1 year ago

I uploaded the source file here.

valuex commented 1 year ago

Do you have a github branch that I can look at? Otherwise, there's nothing here for me to reproduce or debug.

https://github.com/stevencohn/OneMore/compare/main...valuex:OneMore:master I added one branche here. Any comments will be highly appreciated.😃

stevencohn commented 1 year ago

F5 is still bound to both your new command and AddFormulaCmd; unassign it from AddFormulaCmd. Also, you should not declare the one variable at the class-scope; instead, declare it inline with a using statement since it is disposable and should be short-lived.

But the main issue is that you're attempting to interact with the UI from the constructor which is prior to Application.Run within RunModeless so you don't yet have an applicable UI thread. Move that logic to an OnLoad handler. I've attached a zip of the NaviPages.cs file

NaviPages.zip

valuex commented 1 year ago

Thank you very much for pointing-out the problem and showing the code on how to fix it. That's really helpful.