예제 #1
0
        private static T ObtainWindow <T>(MainWindowPackage package, string uniqueId) where T : ToolWindowPane
        {
            bool windowAlreadyOpened = false;
            int  windowId            = _windowCounter + 1;

            lock (Lock)
            {
                WindowInfo windowInfo;
                if (OpenedDetailWindows.TryGetValue(uniqueId, out windowInfo))
                {
                    windowAlreadyOpened = true;
                    windowId            = windowInfo.WindowId;
                }

                // open the existing window with the current windowId
                // if a window wasn't found, then a new one is created
                var toolWindow = (T)package.FindToolWindow(typeof(T), windowId, true);
                if (toolWindow?.Frame == null)
                {
                    throw new NotSupportedException("Cannot create tool window");
                }

                if (!windowAlreadyOpened)
                {
                    OpenedDetailWindows.Add(uniqueId, new WindowInfo(++_windowCounter, toolWindow));
                }

                IVsWindowFrame windowFrame = (IVsWindowFrame)toolWindow.Frame;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());

                return(toolWindow);
            }
        }
예제 #2
0
        /// <summary>
        /// Show the search window
        /// </summary>
        internal static void ShowSearchWindow(MainWindowPackage package, string searchFilter)
        {
            if (package == null || string.IsNullOrEmpty(searchFilter))
            {
                return;
            }

            var window = ObtainWindow <SearchToolWindow>(package, "SearchWindow");

            window?.Search(searchFilter);
        }
예제 #3
0
        /// <summary>
        /// Show the details window for the given entity
        /// </summary>
        internal static void ShowDetailsWindow(MainWindowPackage package, BaseEntity entity)
        {
            if (package == null || entity == null)
            {
                return;
            }

            var window = ObtainWindow <DetailsToolWindow>(package, GetUniqueIdentifier(entity));

            window?.LoadEntity(entity);
        }
 /// <inheritdoc/>>
 protected override void OnCreate()
 {
     base.OnCreate();
     PluginPackage = (MainWindowPackage)Package;
     _mainWindowControl.Initialize();
 }