示例#1
0
        /// <summary>
        /// Set the provided image as the background
        /// </summary>
        /// <param name="entry">the image entry</param>
        private void SetBackgroundImage(WallpaperEntry entry)
        {
            try
            {
                // try to download image to cache
                string localFile = this.GetLocalCopyOfImage(entry, false);
                if (localFile == null)
                {
                    throw new Exception("Could not get local copy of the image");
                }

                // set the new file as the desktop wallpaper
                BackgroundSetter.SetBackgroundImage(localFile, Settings.Instance.DisplayMode, Settings.Instance.GetBackgroundColor());
            }
            catch (Exception e)
            {
                throw new Exception("Setting image did not complete fully", e);
            }

            Settings.Instance.SelectedImage = entry.FilePath;
            this.trayIcon.SetToolText(entry.FilePath);
        }
示例#2
0
        /// <summary>
        /// Switch to/from the presentation mode
        /// </summary>
        /// <param name="enable">whether to enable or disable the presentation mode</param>
        /// <exception cref="Exception">Can throw exception</exception>
        public void SwitchPresentationMode(bool enable)
        {
            if (string.IsNullOrEmpty(Settings.Instance.PresentationImage) ||
                Settings.Instance.InPresentationMode == enable)
            {
                // nothing to do if it is already set appropriately
                return;
            }

            try
            {
                string imageFile = enable ? Settings.Instance.PresentationImage : Settings.Instance.SelectedImage;
                if (string.IsNullOrEmpty(imageFile))
                {
                    throw new Exception("No image file found");
                }

                // download image to cache
                string localFile = this.GetLocalCopyOfImage(imageFile, false);
                if (localFile == null)
                {
                    throw new Exception("Could not get local copy of the image");
                }

                //set the new file as the desktop wallpaper
                BackgroundSetter.SetBackgroundImage(localFile, Settings.Instance.DisplayMode, Settings.Instance.GetBackgroundColor());
                this.trayIcon.SetToolText(imageFile);

                // update the UI elements
                this.UpdatePresentationMode(enable);
            }
            catch (Exception e)
            {
                ErrorLog.Log("Failed to switch presentation mode.", e);
            }
        }