public static void SetUserControlLanguage(UserControl uc)
        {
            MainWindow theWnd = GetUserControlMainWindow(uc);

            if (theWnd != null)
            {
                WPFHelper.ApplyUILanguage(theWnd.lang, uc);
            }
        }
Exemplo n.º 2
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();
        }