From 5d479070a9fd2557ea037ff7d8b42ce04972d80b Mon Sep 17 00:00:00 2001 From: dahall Date: Sat, 14 Nov 2020 13:34:50 -0700 Subject: [PATCH] Added compiler directives for .NET 5 --- Windows.Shell/Registration/ShellRegistrar.cs | 2 +- Windows.Shell/ShellObjects/ShellBrowser.cs | 4 ++-- Windows.Shell/ShellObjects/ShellContextMenu.cs | 14 ++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Windows.Shell/Registration/ShellRegistrar.cs b/Windows.Shell/Registration/ShellRegistrar.cs index ec5ef452..d5b177e0 100644 --- a/Windows.Shell/Registration/ShellRegistrar.cs +++ b/Windows.Shell/Registration/ShellRegistrar.cs @@ -58,7 +58,7 @@ namespace Vanara.Windows.Shell return true; } -#if !(NETCOREAPP3_0 || NETCOREAPP3_1) +#if !(NETCOREAPP3_0 || NETCOREAPP3_1 || NET5_0) /// Registers the specified type as a COM Local Server. /// The type of the COM object. diff --git a/Windows.Shell/ShellObjects/ShellBrowser.cs b/Windows.Shell/ShellObjects/ShellBrowser.cs index fd5302cc..b07354e1 100644 --- a/Windows.Shell/ShellObjects/ShellBrowser.cs +++ b/Windows.Shell/ShellObjects/ShellBrowser.cs @@ -38,11 +38,11 @@ namespace Vanara.Windows.Shell /// The progress bar. public ProgressBar ProgressBar { get; set; } +#if NETFRAMEWORK || NETCOREAPP3_0 /// Gets or sets the status bar associated with the view. /// The status bar. public StatusBar StatusBar { get; set; } -#if NETFRAMEWORK || NETCOREAPP3_0 /// Gets or sets the tool bar associated with the view. /// The tool bar. public ToolBar ToolBar { get; set; } @@ -92,8 +92,8 @@ namespace Vanara.Windows.Shell phwnd = id switch { FCW.FCW_PROGRESS => CheckAndLoad(ProgressBar), - FCW.FCW_STATUS => CheckAndLoad(StatusBar), #if NETFRAMEWORK || NETCOREAPP3_0 + FCW.FCW_STATUS => CheckAndLoad(StatusBar), FCW.FCW_TOOLBAR => CheckAndLoad(ToolBar), #endif FCW.FCW_TREE => CheckAndLoad(TreeView), diff --git a/Windows.Shell/ShellObjects/ShellContextMenu.cs b/Windows.Shell/ShellObjects/ShellContextMenu.cs index 08138d31..3b6eb34a 100644 --- a/Windows.Shell/ShellObjects/ShellContextMenu.cs +++ b/Windows.Shell/ShellObjects/ShellContextMenu.cs @@ -178,6 +178,13 @@ namespace Vanara.Windows.Shell ComInterface.InvokeCommand(invoke); } + private void InvokeCommand(int index) + { + var invoke = new CMINVOKECOMMANDINFOEX(index) { nShow = ShowWindowCommand.SW_SHOWNORMAL }; + m_ComInterface2.InvokeCommand(invoke); + } + +#if !NET5_0 /// Populates a with the context menu items for a shell item. /// /// If this method is being used to populate a Form's main menu then you need to call in the Form's @@ -204,12 +211,6 @@ namespace Vanara.Windows.Shell } } - private void InvokeCommand(int index) - { - var invoke = new CMINVOKECOMMANDINFOEX(index) { nShow = ShowWindowCommand.SW_SHOWNORMAL }; - m_ComInterface2.InvokeCommand(invoke); - } - private void RemoveShellMenuItems(Menu menu) { const int tag = 0xAB; @@ -263,6 +264,7 @@ namespace Vanara.Windows.Shell SetMenuInfo(item.Handle, info); } } +#endif private class MessageWindow : Control {