예제 #1
0
        /// <summary>
        /// Displays the Settings form when requested by the Control Panel.
        /// </summary>
        static void ShowSettings(IntPtr hWnd)
        {
            Logging.LogLineIf(fDebugTrace, "ShowSettings(): Entered.");

            if (NativeMethods.IsWindow(hWnd))
            {
                Form settings = new Settings(hWnd);

                // use Win32 API's to get the window handles we need for ShowModal

                // Get the root owner window of the passed hWnd
                int error = 0;
                Logging.LogLineIf(fDebugTrace, "  ShowSettings(): Getting Root Ancestor: calling GetAncestor(hWnd, GetRoot)...");
                NativeMethods.SetLastErrorEx(0, 0);
                IntPtr passedWndRoot = NativeMethods.GetAncestor(hWnd, NativeMethods.GetAncestorFlags.GetRoot);
                error = System.Runtime.InteropServices.Marshal.GetLastWin32Error();
                Logging.LogLineIf(fDebugTrace, "  ShowSettings(): GetAncestor() returned IntPtr: " + Logging.DecNHex(passedWndRoot));
                Logging.LogLineIf(fDebugTrace, "      GetLastError() returned: " + error.ToString());
                Logging.LogLineIf(fDebugTrace, " ");

                // and then show ourselves modal to that window
                JoeKCo.Utilities.WinFormSupport.WindowWrapper ww = new JoeKCo.Utilities.WinFormSupport.WindowWrapper(passedWndRoot);
                Logging.LogLineIf(fDebugTrace, "  ShowSettings(): calling ShowDialog().");
                settings.ShowDialog(ww);

                // and run it
                Logging.LogLineIf(fDebugTrace, "  ShowSettings(): calling Application.Run(settings)).");
                Application.Run(settings);
            }
            else
            {
                Logging.LogLineIf(fDebugOutput, "  ShowSettings(): Invalid hWnd passed: " + hWnd.ToString());
                throw new ArgumentException("Invalid hWnd passed to ShowMiniPreview(): " + hWnd.ToString());
            }

            Logging.LogLineIf(fDebugTrace, "ShowSettings(): Exiting.");
        }
예제 #2
0
        // -------------------- Lifecycle Stuff -------------------- //
        private void DoSettingsDialog()
        {
            bool fDebugOutput = true;
            bool fDebugOutputTraceLevel = true;
            bool fDebugTrace = fDebugOutput && fDebugOutputTraceLevel;

            Logging.LogLineIf(fDebugTrace, "DoSettingsDialog(): Entered.");

            // pause became redundant with our activation/deactivation code;
            // restore this code if we remove the activation/deactivation logic

            //// Pause the slideshow if necessary
            //bool fWasSlideshowMode = false;
            //if (fSlideshowMode)
            //{
            //    fWasSlideshowMode = true;
            //    ExitSlideshowMode();
            //}

            // Create the settings form and show it as a modal dialog.
            // Doing it all in one statement like this causes the Settings form to be created, used,
            // disposed of, and all references to it nulled, all in one line.

            settingsForm = new Settings(true, this);
            settingsForm.Owner = this;
            fShowingDialog = true;

            //if ((new Settings(true, this)).ShowDialog(this.Owner) == System.Windows.Forms.DialogResult.Retry)
            if (settingsForm.ShowDialog(this) == System.Windows.Forms.DialogResult.Retry)
            {
                fShowingDialog = false;

                // User changed something that requires a rebuild of the file list.
                MainFiles.Rebuild((List<DirectoryInfo>)SettingsInfo.GetListOfDirectoryInfo(), GraphicFileExtensions, SettingsInfo.GetBlacklistedFullFilenames(), SettingsInfo.UseRecursion, SettingsInfo.ShuffleMode);

                // Don't go back to an old stale pic. Force ourselves to get a new one.
                DoPreviousOrNext(false);
            }
            else
            {
                fShowingDialog = false;
            }

            // dispose of the form, since we create a new one every time
            settingsForm.Dispose();

            // update the slideshow data, just in case
            ourSlideshow.IntervalInMilliSeconds = SettingsInfo.SlideshowIntervalInSecs * 1000;
            ourSlideshow.DeferralTimeWindowInMilliseconds = 1500;
            ourSlideshow.DeferralIntervalInMilliseconds = ourSlideshow.IntervalInMilliSeconds;

            // pause became redundant with our activation/deactivation code;
            // restore this code if we remove the activation/deactivation logic

            //// Resume the slideshow if necessary
            //if (fWasSlideshowMode)
            //{
            //    EnterSlideshowMode();
            //}

            Logging.LogLineIf(fDebugTrace, "DoSettingsDialog(): Exiting.");
        }
예제 #3
0
 /// <summary>
 /// Displays the Settings form; used when command line has no args, or when args = /c.
 /// </summary>
 static void ShowSettings()
 {
     Form settings = new Settings();
     settings.Show();
     Application.Run(settings);
 }