static public void PopupDialog() { if (singleton && Instance != null) { Win32.SetForegroundWindow(Instance.Handle); Instance.SetExpression(Utils.GetStatementAtCaret()); return; } var document = Npp.GetCurrentDocument(); if (ownedByNpp) { var dialog = new QuickWatchPanel(); Instance = dialog; //string expression = Utils.GetStatementAtCaret(); string expression = document.GetSelectedText(); dialog.SetExpression(expression) .SetAutoRefreshAvailable(Config.Instance.QuickViewAutoRefreshAvailable); var nativeWindow = new NativeWindow(); nativeWindow.AssignHandle(Npp.Editor.Handle); dialog.Show(nativeWindow); } else { if (singleton && Instance != null) { Win32.SetForegroundWindow(Instance.Handle); return; } else { var t = new Thread(() => { using (QuickWatchPanel dialog = new QuickWatchPanel()) { Instance = dialog; string expression = document.GetSelectedText(); if (string.IsNullOrWhiteSpace(expression)) { expression = Npp.GetCurrentDocument().GetStatementAtPosition(); } dialog.SetExpression(expression); dialog.ShowModal(); } Instance = null; }); t.SetApartmentState(ApartmentState.STA); t.Start(); } } }