Exemplo n.º 1
0
        /// <summary>
        ///     Gets the foreign version of the string.
        /// </summary>
        /// <param name="currentWindow">Name of the current WPF Windows or Global</param>
        /// <param name="resourceName">Resource Number</param>
        /// <returns></returns>
        public static string GetString(string currentWindow, int resourceName)
        {
            Lists.AddMessage(currentWindow + "-" + resourceName);
            var stringToFind       = currentWindow.Replace("frm", "Frm") + "-" + resourceName.ToString("D8");
            var stringGlobalToFind = "Global-" + resourceName.ToString("D8");

            if (Application.Current.TryFindResource(stringToFind) != null)
            {
                return((string)Application.Current.FindResource(stringToFind));
            }

            if (Application.Current.TryFindResource(stringGlobalToFind) != null)
            {
                return((string)Application.Current.FindResource(stringGlobalToFind));
            }

            //If a translation cannot be found, the default dictionary will be scanned.
            if (_defaultDictionary == null)
            {
                return("(null)");
            }

            if (_defaultDictionary.Contains(stringToFind))
            {
                return(_defaultDictionary[stringToFind].ToString());
            }

            if (_defaultDictionary.Contains(stringGlobalToFind))
            {
                return(_defaultDictionary[stringGlobalToFind].ToString());
            }

            //No translation was found.
            return("(null)");
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Updates the text of the label whilst taking multithreading
        ///     into consideration.
        /// </summary>
        /// <param name="control">The current label.</param>
        /// <param name="text">The new text.</param>
        public static void UpdateText(this ContentControl control, string text)
        {
            if (!control.Dispatcher.CheckAccess())
            {
                control.Dispatcher.Invoke(() => { control.UpdateText(text); });
                return;
            }

            Lists.AddMessage(text);
            control.Content = text;
        }