protected void CheckScreenSaver()
        {
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            if (workflowManager.IsStateContainedInNavigationStack(Consts.WF_STATE_ID_PARTY_MUSIC_PLAYER))
            {
                if (DisableScreenSaver)
                {
                    if (_screenSaverController == null)
                    {
                        IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();
                        _screenSaverController = screenControl.GetScreenSaverController();
                    }
                    if (_screenSaverController != null)
                    {
                        _screenSaverController.IsScreenSaverDisabled = true;
                    }
                }
            }
            else
            {
                if (_screenSaverController != null)
                {
                    _screenSaverController.Dispose();
                    _screenSaverController = null;
                }
            }
        }
Example #2
0
 public ScreenSaverController GetScreenSaverController()
 {
     if (_screenSaverController != null)
     {
         ServiceRegistration.Get <ILogger>().Warn("SkinEngine MainForm: ScreenSaverControl is already registered, prevent creation of another ScreenSaverControl");
         return(null);
     }
     return(_screenSaverController = new ScreenSaverController(() => { _screenSaverController = null; }));
 }
Example #3
0
        static void Main(string[] args)
        {
            // Don't scan the image directory all too often.
            // In true screensaver mode, this will be set to -1 (infinity).
            SWA.Utilities.Directory.ResultValidForSeconds = 30;

            #region Check if we have been started by the Linux xscreensaver(1)
            // The protocol is like this:
            // * A fullscreen screensaver is called without parameters
            // * A preview screensaver is called with "-window-id 0xXXXX" arguments
            //   see: xscreensaver-5.44/driver/demo-Gtk.c : launch_preview_subproc()

            string windowHandleStr = Environment.GetEnvironmentVariable("XSCREENSAVER_WINDOW");
            if (!String.IsNullOrEmpty(windowHandleStr))
            {
                // Convert "0xXXXX" (hex) to "NNNN" (decimal)
                windowHandleStr = UInt32.Parse(windowHandleStr.Substring(2),
                                               System.Globalization.NumberStyles.AllowHexSpecifier).ToString();

                // https://github.com/mono/mono/blob/master/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIX11.cs
                // When the MONO_XEXCEPTIONS environment variable is set,
                // an Exception will be thrown when a X11 error is encountered;
                // by default a message is displayed but execution continues.
                //
                // We prefer the Exception. Otherwise the app would continue running
                // even when the connection to the XSCREENSAVER_WINDOW has been lost.
                //
                Environment.SetEnvironmentVariable("MONO_XEXCEPTIONS", "1");

                if (args.Length > 0 && args[0] == "-window-id")
                {
                    ScreenSaverPreviewController.Run(windowHandleStr);
                }
                else
                {
                    ScreenSaverController.Run(windowHandleStr);
                }
            }
            #endregion
            else
            #region Evaluate the command line options
            if (args.Length > 0)
            {
                // Get the 2 character command line argument.
                string arg = args[0].ToLowerInvariant().Trim().Substring(0, 2);

                // Convert Linux style argument to Windows style.
                if (arg == "-o")
                {
                    arg = "/c";
                }                                // options
                if (arg == "-f")
                {
                    arg = "/s";
                }                                // fullscreen

                switch (arg)
                {
                case "/c":
                    // Show the options dialog
                    Application.Run(new OptionsDialog());
                    break;

                case "/p":
                    // Show a preview window within the Display settings panel.
                    ScreenSaverPreviewController.Run(args[1]);
                    break;

                case "/s":
                    // Show screensaver form
                    SWA.Utilities.Display.EnableDpiAwareness();
                    SWA.Utilities.Directory.ResultValidForSeconds = -1;
                    // Create the ImageLoader as early as possible.
                    ImageLoader imageLoader = ImageLoader.GetScreenSaverImageLoader(Screen.PrimaryScreen.Bounds);
                    BlankSecondaryScreens();
                    Application.Run(new ScreenSaverForm(true, imageLoader));
                    break;

                default:
                    MessageBox.Show("Invalid command line argument: " + args[0],
                                    "Invalid Command Line Argument",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
            #endregion
            else
            #region Run as a regular, standalone application
            {
                SWA.Utilities.Display.EnableDpiAwareness();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Form form = new MazeForm();
                form.Icon = Properties.Resources.AriadneIcon_32x32;
                Application.Run(form);
            }
            #endregion
        }
Example #4
0
 /// <summary>
 /// Starts a ScreenSaverController that behaves like in screen saver mode
 /// on a Linux platform under control of xscreensaver(1).
 /// </summary>
 private void OnOpenScreenSaverHack(object sender, EventArgs e)
 {
     ScreenSaverController.Run();
 }