private void OnLoad(object sender, EventArgs e) { #if !DEBUG if (!this.IsPreview) { Cursor.Hide(); this.TopMost = true; this.Focus(); } #endif this._Saver = ScreenSaverManager.GetScreenSaver("lightning"); if (this._Saver == null) { return; } var screenSaverControl = new ScreenSaverControl { Parent = this, Model = this._Saver, Dock = DockStyle.Fill }; #if !DEBUG if (!this.IsPreview) { screenSaverControl.MouseClick += this.OnMouseClick; screenSaverControl.MouseMove += this.OnMouseMove; screenSaverControl.KeyPress += this.OnKeyPress; } #endif screenSaverControl.Start(); }
public static void Inhibit() { try { IScreenSaver ss = Bus.Session.GetObject <IScreenSaver>("org.gnome.ScreenSaver", new ObjectPath("/org/gnome/ScreenSaver")); if (ss != null) { ss.Inhibit("test-runner", "Running the Moonlight tests"); } } catch { } }
public void DelayedInitialize() { if (Application.CommandLine.Contains("disable-dbus")) { return; } if (!Bus.Session.NameHasOwner(BusName)) { throw new ApplicationException(String.Format("Name {0} has no owner", BusName)); } m_screenSaver = Bus.Session.GetObject <IScreenSaver> (BusName, new ObjectPath(ObjectPath)); /* connect to the active changed event and forward it */ m_screenSaver.ActiveChanged += delegate(bool isActive) { ActiveChangedHandler handler = ActiveChanged; if (handler != null) { handler(isActive); } }; /* connect to the session idle event and forward it */ m_screenSaver.SessionIdleChanged += delegate(bool isSessionIdle) { SessionIdleChangedHandler handler = SessionIdleChanged; if (handler != null) { handler(isSessionIdle); } }; /* connect to the begin auth and forward it */ m_screenSaver.AuthenticationRequestBegin += delegate() { EventHandler handler = AuthenticationRequestBegin; if (handler != null) { handler(this, EventArgs.Empty); } }; /* connect to the end auth and forward it */ m_screenSaver.AuthenticationRequestEnd += delegate() { EventHandler handler = AuthenticationRequestEnd; if (handler != null) { handler(this, EventArgs.Empty); } }; }
public static IScreenSaver GetScreensaver() { const string name = "org.gnome.ScreenSaver"; if (!Bus.Session.NameHasOwner(name)) { return(null); } IScreenSaver sv = null; try { sv = Bus.Session.GetObject <IScreenSaver> (name, ObjectPath.Root); } catch { } return(sv); }
public void DelayedInitialize() { if (Application.CommandLine.Contains("disable-dbus")) return; if (!Bus.Session.NameHasOwner (BusName)) throw new ApplicationException(String.Format("Name {0} has no owner", BusName)); m_screenSaver = Bus.Session.GetObject<IScreenSaver> (BusName, new ObjectPath (ObjectPath)); /* connect to the active changed event and forward it */ m_screenSaver.ActiveChanged += delegate (bool isActive) { ActiveChangedHandler handler = ActiveChanged; if (handler != null) handler (isActive); }; /* connect to the session idle event and forward it */ m_screenSaver.SessionIdleChanged += delegate (bool isSessionIdle) { SessionIdleChangedHandler handler = SessionIdleChanged; if (handler != null) handler (isSessionIdle); }; /* connect to the begin auth and forward it */ m_screenSaver.AuthenticationRequestBegin += delegate () { EventHandler handler = AuthenticationRequestBegin; if (handler != null) handler (this, EventArgs.Empty); }; /* connect to the end auth and forward it */ m_screenSaver.AuthenticationRequestEnd += delegate () { EventHandler handler = AuthenticationRequestEnd; if (handler != null) handler (this, EventArgs.Empty); }; }