/// <summary>
        /// Read configuration file
        /// </summary>
        public void ReadConfig()
        {
            // get configuration with default values
            // images and language
            wpLandscape = ReadOneSettingSafe("wpLandscape", "");
            wpPortrait = ReadOneSettingSafe("wpPortrait", "");
            lcLandscape = ReadOneSettingSafe("lcLandscape", "");
            lcPortrait = ReadOneSettingSafe("lcPortrait", "");
            language = ReadOneSettingSafe("language", "");

            // reverse
            string revstr = "";
            revstr = ReadOneSettingSafe("reverse", null);
            if (revstr != null && revstr == true.ToString())
            {
                reverse = true;
            }
            else
            {
                reverse = false;
            }

            // picture position
            string poswpl = "";
            string poswpp = "";
            poswpl = ReadOneSettingSafe("posWpLandscape", "Fill");
            poswpp = ReadOneSettingSafe("posWpPortrait", "Fill");
            wpPosLandscape = PicPos.Fill;
            wpPosPortrait = PicPos.Fill;
            foreach (string pos in Enum.GetNames(typeof(PicPos)))
            {
                if (string.Compare(poswpl, pos, ignoreCase: true) == 0) Enum.TryParse<PicPos>(pos, true, out wpPosLandscape);
                if (string.Compare(poswpp, pos, ignoreCase: true) == 0) Enum.TryParse<PicPos>(pos, true, out wpPosPortrait);
            }

            // last size
            string rWidth = ReadOneSettingSafe("lastWidth", "800");
            string rHeight = ReadOneSettingSafe("lastHeight", "600");
            int.TryParse(rWidth, out lastWidth);
            int.TryParse(rHeight, out lastHeight);
            if (lastWidth <= 0) lastWidth = 800;
            if (lastHeight <= 0) lastHeight = 600;

            // last version
            string rver = ReadOneSettingSafe("ver", WPFHelper.GetCurrentVer().ToString());
            int.TryParse(rver, out ver);

            SaveConfig();
        }
 /// <summary>
 /// Set the picture position of Windows (by setting registry)
 /// </summary>
 /// <param name="p">target picture position</param>
 /// <returns>true if succeed, false otherwise</returns>
 public static bool SetDesktopPicPos(PicPos p)
 {
     try
     {
         RegistryKey reg = Registry.CurrentUser;
         reg = reg.OpenSubKey("Control Panel\\desktop", true);
         reg.SetValue("WallpaperStyle", ((int)p).ToString());
         reg.Close();
         return true;
     }
     catch (Exception ex)
     {
         if (GeneralLogger.IsInitialized()) GeneralLogger.WriteLog("Set desktop picpos failed. error:" + ex.Message, LogType.ERROR);
         return false;
     }
 }
 public static void SetPicPosConfig(PicMode picMode, Orientation orientation, MainWindow wnd, PicPos value)
 {
     switch (picMode)
     {
         case PicMode.Wallpaper:
             switch (orientation)
             {
                 case Orientation.Landscape:
                     wnd.config.wpPosLandscape = value;
                     break;
                 case Orientation.Portrait:
                     wnd.config.wpPosPortrait = value;
                     break;
             }
             break;
     }
 }
Beispiel #4
0
 /// <summary>
 /// Set the picture position of Windows (by setting registry)
 /// </summary>
 /// <param name="p">target picture position</param>
 /// <returns>true if succeed, false otherwise</returns>
 public static bool SetDesktopPicPos(PicPos p)
 {
     try
     {
         RegistryKey reg = Registry.CurrentUser;
         reg = reg.OpenSubKey("Control Panel\\desktop", true);
         reg.SetValue("WallpaperStyle", ((int)p).ToString());
         reg.Close();
         return(true);
     }
     catch (Exception ex)
     {
         if (GeneralLogger.IsInitialized())
         {
             GeneralLogger.WriteLog("Set desktop picpos failed. error:" + ex.Message, LogType.ERROR);
         }
         return(false);
     }
 }
Beispiel #5
0
        public void UpdateWallpaper()
        {
            string path   = lastOrientation == Orientation.Landscape ? config.wpLandscape : config.wpPortrait;
            PicPos picpos = lastOrientation == Orientation.Landscape ? config.wpPosLandscape : config.wpPosPortrait;

            if (File.Exists(path))
            {
                if (!DWAS2Interop.SetDesktopPicPos(picpos))
                {
                    notifyIcon.ShowBalloonTip(1000, "DWAS2", "DWAS2 failed to set your picture position.".t(lang), WinForms.ToolTipIcon.Error);
                }
                if (!DWAS2Interop.SetWallpaper(path))
                {
                    notifyIcon.ShowBalloonTip(1000, "DWAS2", "DWAS2 failed to set your wallpaper.".t(lang), WinForms.ToolTipIcon.Error);
                    return;
                }
            }
            else
            {
                notifyIcon.ShowBalloonTip(1000, "DWAS2", "DWAS2 wallpaper for current orientation does not exist.".t(lang), WinForms.ToolTipIcon.Error);
            }
        }
 public PicPosChangedEventArgs(PicPos picPos)
 {
     newPicPos = picPos;
 }
        public static void SetPicPosConfig(PicMode picMode, Orientation orientation, MainWindow wnd, PicPos value)
        {
            switch (picMode)
            {
            case PicMode.Wallpaper:
                switch (orientation)
                {
                case Orientation.Landscape:
                    wnd.config.wpPosLandscape = value;
                    break;

                case Orientation.Portrait:
                    wnd.config.wpPosPortrait = value;
                    break;
                }
                break;
            }
        }
Beispiel #8
0
        /// <summary>
        /// Read configuration file
        /// </summary>
        public void ReadConfig()
        {
            // get configuration with default values
            // images and language
            wpLandscape = ReadOneSettingSafe("wpLandscape", "");
            wpPortrait  = ReadOneSettingSafe("wpPortrait", "");
            lcLandscape = ReadOneSettingSafe("lcLandscape", "");
            lcPortrait  = ReadOneSettingSafe("lcPortrait", "");
            language    = ReadOneSettingSafe("language", "");

            // reverse
            string revstr = "";

            revstr = ReadOneSettingSafe("reverse", null);
            if (revstr != null && revstr == true.ToString())
            {
                reverse = true;
            }
            else
            {
                reverse = false;
            }

            // picture position
            string poswpl = "";
            string poswpp = "";

            poswpl         = ReadOneSettingSafe("posWpLandscape", "Fill");
            poswpp         = ReadOneSettingSafe("posWpPortrait", "Fill");
            wpPosLandscape = PicPos.Fill;
            wpPosPortrait  = PicPos.Fill;
            foreach (string pos in Enum.GetNames(typeof(PicPos)))
            {
                if (string.Compare(poswpl, pos, ignoreCase: true) == 0)
                {
                    Enum.TryParse <PicPos>(pos, true, out wpPosLandscape);
                }
                if (string.Compare(poswpp, pos, ignoreCase: true) == 0)
                {
                    Enum.TryParse <PicPos>(pos, true, out wpPosPortrait);
                }
            }

            // last size
            string rWidth  = ReadOneSettingSafe("lastWidth", "800");
            string rHeight = ReadOneSettingSafe("lastHeight", "600");

            int.TryParse(rWidth, out lastWidth);
            int.TryParse(rHeight, out lastHeight);
            if (lastWidth <= 0)
            {
                lastWidth = 800;
            }
            if (lastHeight <= 0)
            {
                lastHeight = 600;
            }

            // last version
            string rver = ReadOneSettingSafe("ver", WPFHelper.GetCurrentVer().ToString());

            int.TryParse(rver, out ver);

            SaveConfig();
        }
 private void changePicPosButton_Click(object sender, RoutedEventArgs e)
 {
     SelectedPicPos = WPFHelper.GetNextEnum<PicPos>(SelectedPicPos);
     SetPicPosButtonText();
     PicPosChangedEvent(new PicPosChangedEventArgs(SelectedPicPos));
 }
 private void changePicPosButton_Click(object sender, RoutedEventArgs e)
 {
     SelectedPicPos = WPFHelper.GetNextEnum <PicPos>(SelectedPicPos);
     SetPicPosButtonText();
     PicPosChangedEvent(new PicPosChangedEventArgs(SelectedPicPos));
 }
 public PicPosChangedEventArgs(PicPos picPos)
 {
     newPicPos = picPos;
 }