示例#1
0
        /// <summary>
        /// Logs the specified message. Will include the Shell Extension name and page name if available.
        /// </summary>
        /// <param name="message">The message.</param>
        protected void Log(string message)
        {
            var level1 = Parent != null ? Parent.DisplayName : "Unknown";
            var level2 = Target != null ? Target.PageTitle : "Unknown";

            Logging.Log($"{level1} (Proxy {HostWindowHandle.ToString("x8")} for '{level2}' Page): {message}");
        }
示例#2
0
        /// <summary>
        /// Logs the specified message as an error.  Will include the Shell Extension name and page name if available.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="exception">Optional exception details.</param>
        protected void LogError(string message, Exception exception = null)
        {
            var level1 = Parent != null ? Parent.DisplayName : "Unknown";
            var level2 = Target != null ? Target.PageTitle : "Unknown";

            Logging.Error($"{level1} (Proxy {HostWindowHandle.ToString("x8")} for {level2}): {message}", exception);
        }
        /// <summary>
        /// Creates the property page handle.
        /// </summary>
        public void CreatePropertyPageHandle(NativeBridge.NativeBridge nativeBridge)
        {
            Logging.Log("Creating property page handle via bridge.");

            //  Create a prop sheet page structure.
            var psp = new PROPSHEETPAGE();

            //  Set the key properties.
            psp.dwSize = (uint)Marshal.SizeOf(psp);
            //psp.dwFlags = PSP.USETITLE | PSP.USECALLBACK/* | PSP.DEFAULT |*/| PSP.DLGINDIRECT;
            //psp.dwFlags = PSP.DEFAULT | PSP.USETITLE | PSP.DLGINDIRECT;
            //psp.hInstance = nativeBridge.GetInstanceHandle();

            psp.hInstance = nativeBridge.GetInstanceHandle();
            psp.dwFlags   = PSP.PSP_DEFAULT | PSP.PSP_USETITLE | PSP.PSP_USECALLBACK;
            Logging.Log("Getting proxy host...");
            psp.pTemplate   = nativeBridge.GetProxyHostTemplate();
            psp.pfnDlgProc  = dialogProc;
            psp.pcRefParent = 0;
            psp.pfnCallback = callbackProc;
            psp.lParam      = IntPtr.Zero;

            //  If we have a title, set it.
            if (!string.IsNullOrEmpty(Target.PageTitle))
            {
                psp.dwFlags |= PSP.PSP_USETITLE;
                psp.pszTitle = Target.PageTitle;
            }

            //  If we have an icon, set it.
            if (Target.PageIcon != null && Target.PageIcon.Handle != IntPtr.Zero)
            {
                psp.dwFlags |= PSP.PSP_USEHICON;
                psp.hIcon    = Target.PageIcon.Handle;
            }

            //  Create a the property sheet page.
            HostWindowHandle = Comctl32.CreatePropertySheetPage(ref psp);

            //  Log the host window handle.
            Logging.Log("Created Proxy Host: " + HostWindowHandle.ToString("X8"));
        }