public void SetPreferredDeviceForDisplay(Display display, string deviceName)
        {
            if (display != null && !String.IsNullOrEmpty(deviceName))
            {
                display.SetPreferredDevice(deviceName);

                if (this.displaySettings.ContainsKey(display.Name))
                {
                    this.displaySettings[display.Name].DeviceName = deviceName;
                }
                else
                {
                    DisplaySetting ds = new DisplaySetting();
                    ds.DeviceName = deviceName;
                    this.displaySettings.Add(display.Name, ds);
                }

                this.dpSettingSaver.Save(this.displaySettings);
            }
        }
        internal void SendSystemNotification(string title, string text, Display display)
        {
            Growl.Connector.RequestInfo requestInfo = new Growl.Connector.RequestInfo();  // this is not used, but needed as a placeholder

            DisplayStyle.Notification n = new Growl.DisplayStyle.Notification();
            n.UUID = requestInfo.RequestID;
            n.ApplicationName = Properties.Resources.SystemNotification_ApplicationName;
            n.Description = text;
            n.Name = "Growl System Message";
            n.Priority = (int)Growl.Connector.Priority.Normal;
            n.Sticky = false;   // system notifications are never sticky
            n.Title = title;
            n.Image = Growl.FormResources.growl;

            ShowNotification(n, display, null, false, requestInfo);
        }
        private void ShowNotification(Growl.DisplayStyle.Notification notification, Display display, Growl.Daemon.CallbackInfo cbInfo, bool recordInMissedNotifications, Growl.Connector.RequestInfo requestInfo)
        {
            // could be cross-thread, so check for invokerequired
            if (this.synchronizingObject != null && this.synchronizingObject.InvokeRequired)
            {
                MethodInvoker invoker = new MethodInvoker(delegate()
                {
                    ShowNotification(notification, display, cbInfo, recordInMissedNotifications, requestInfo);
                });

                this.synchronizingObject.Invoke(invoker, null);
            }
            else
            {
                if (display == null) display = this.growlDefaultDisplay;

                // if not a system notification and we are paused, dont show
                if (recordInMissedNotifications && paused)
                {
                    display = Display.None;
                    requestInfo.SaveHandlingInfo(String.Format("Not shown - {0}", (paused ? "Paused" : "Idle")));
                }
                else
                {
                    requestInfo.SaveHandlingInfo(String.Format("Displayed using '{0}' {1}", display.Name, (display.IsDefault ? "(" + display.ActualName + ")" : "")));
                }

                display.ProcessNotification(notification, cbInfo, requestInfo);
                this.lastUsedDisplay = display;
            }
        }
 public string GetPreferredDeviceForDisplay(Display display)
 {
     string deviceName = null;
     if (this.displaySettings.ContainsKey(display.Name))
     {
         deviceName = this.displaySettings[display.Name].DeviceName;
     }
     return deviceName;
 }
        private void LoadDisplays()
        {
            this.missedNotificationsDisplay = new MissedNotificationsDisplay();

            TimeSpan ts = DateTime.Now - ApplicationMain.st;
            Utility.WriteDebugInfo("TIMESTAMP - Before DisplayStyleManager.Load(): " + ts.TotalSeconds.ToString());

            DisplayStyleManager.Load();

            ts = DateTime.Now - ApplicationMain.st;
            Utility.WriteDebugInfo("TIMESTAMP - After DisplayStyleManager.Load(): " + ts.TotalSeconds.ToString());

            try
            {
                this.defaultDisplayName = Properties.Settings.Default.DefaultDisplay;
                this.growlDefaultDisplay = DisplayStyleManager.AvailableDisplayStyles[this.defaultDisplayName];
            }
            catch
            {
                // the default display was not found. that is bad
                Utility.WriteDebugInfo("The default display '{0}' was not found.", this.defaultDisplayName);
                // fall back to Standard
                this.growlDefaultDisplay = DisplayStyleManager.AvailableDisplayStyles["Standard"];
            }

            try
            {
                this.displaySettings = (Dictionary<string, DisplaySetting>)dpSettingSaver.Load();
                if (this.displaySettings == null) this.displaySettings = new Dictionary<string, DisplaySetting>();
                foreach (KeyValuePair<string, DisplaySetting> setting in this.displaySettings)
                {
                    string name = setting.Key;
                    if (!String.IsNullOrEmpty(name) && DisplayStyleManager.AvailableDisplayStyles.ContainsKey(name))
                    {
                        Display d = DisplayStyleManager.AvailableDisplayStyles[name];
                        Utility.WriteDebugInfo("Setting preferred device for '{0}' display to: {1}", d.Name, setting.Value.DeviceName);
                        d.SetPreferredDevice(setting.Value.DeviceName);
                    }
                }
            }
            catch
            {
                Utility.WriteDebugInfo("EXCEPTION: failed to load common display settings");
            }

            Display.Default.Update(this.growlDefaultDisplay);
        }
 void DisplayStyleManager_DisplayLoaded(Display display)
 {
     display.NotificationCallback += new Display.NotificationCallbackEventHandler(display_NotificationCallback);
 }
Exemple #7
0
 internal void SendSystemNotification(string title, string text, Display display)
 {
     if (this.controller != null)
     {
         this.controller.SendSystemNotification(title, text, display);
     }
 }
        private void ShowNotification(Growl.DisplayStyle.Notification notification, Display display, Growl.Daemon.CallbackInfo cbInfo, bool recordInMissedNotifications, Growl.Connector.RequestInfo requestInfo)
        {
            // could be cross-thread, so check for invokerequired
            if (this.synchronizingObject != null && this.synchronizingObject.InvokeRequired)
            {
                MethodInvoker invoker = new MethodInvoker(delegate()
                {
                    ShowNotification(notification, display, cbInfo, recordInMissedNotifications, requestInfo);
                });

                this.synchronizingObject.Invoke(invoker, null);
            }
            else
            {
                if (display == null) display = this.growlDefaultDisplay;

                // check for fullscreen handling
                if (!paused && (this.AutoPauseFullscreen && this.fullscreenHelper.IsFullScreenAppActive()))
                {
                    Utility.WriteDebugInfo("Fullscreen app detected - automatically pausing Growl");
                    ApplicationMain.Program.Pause(true);
                    this.fullscreenHelper.StartChecking();
                }

                // if not a system notification and we are paused, dont show
                if (recordInMissedNotifications && paused)
                {
                    display = Display.None;
                    requestInfo.SaveHandlingInfo(String.Format("Not shown - {0}", (paused ? "Paused" : "Idle")));
                }
                else
                {
                    requestInfo.SaveHandlingInfo(String.Format("Displayed using '{0}' {1}", display.Name, (display.IsDefault ? "(" + display.ActualName + ")" : "")));
                }

                display.ProcessNotification(notification, cbInfo, requestInfo);
                this.lastUsedDisplay = display;
            }
        }
 public void Update(Display display)
 {
     this.realDisplay = display;
 }