/// <summary>
        /// Initializes a new instance of the <see cref="CalculatorAndFktEditor"/> class.
        /// </summary>
        /// <param name="modus">
        /// The modus.
        /// </param>
        public CalculatorAndFktEditor(TRechnerArt modus)
        {
            int k;

            this.InitializeComponent();
            this.textBox1.Text             = string.Empty;
            this.Ergebnis                  = string.Empty;
            this.art                       = modus;
            this.buttonTakeKonst.IsEnabled = true;
            this.usesDecimalkomma          = (15 == Convert.ToDouble("1.5"));
            if (modus == TRechnerArt.rechner)
            {
                this.Title = Labels.CalculatorDialogTitleCalc;
                this.buttonX.Visibility   = Visibility.Hidden;
                this.buttonFertig.Content = Labels.CalculatorDialogButtonDoneCalc;
            }
            else
            {
                this.Title = Labels.CalculatorDialogTitleFunctionEditor;
                this.buttonX.Visibility   = Visibility.Visible;
                this.buttonFertig.Content = Labels.CalculatorDialogButtonDoneFktEdit;
            }

            for (k = 0; k < Constants.konstante.Length; k++)
            {
                string uiString;
                var    locExtension = new LocExtension("VianaNET:Labels:" + Constants.konstante[k].titel);
                locExtension.ResolveLocalizedValue(out uiString);
                this.comboBox1.Items.Add(uiString);
            }

            this.buttonKomma.Content = this.usesDecimalkomma ? "," : ".";
            this.textBox1.Focus();
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter == null)
            {
                return(values);
            }

            var bindingParams = (object[])values.Clone();

            // Remove the {DependancyProperty.UnsetValue} from unbound datasources.
            for (var i = 0; i < bindingParams.Length; i++)
            {
                if (bindingParams[i] != null && bindingParams[i] == DependencyProperty.UnsetValue)
                {
                    bindingParams[i] = null;
                }
            }

            var keyStr = (string)parameter;

#pragma warning disable 618
            // It needs to identify the Assembly and Dictionary, as the Converter doesn't know squat about what is defined on the Window.
            var ext = new LocExtension(keyStr)
            {
                Assembly = "SEToolbox", Dict = "Resources"
            };
#pragma warning restore 618

            string localizedValue;
            return(ext.ResolveLocalizedValue(out localizedValue) ? string.Format(localizedValue, bindingParams) : null);
        }
 public static string GetUIString(string key)
 {
     string uiString;
     LocExtension locExtension = new LocExtension(String.Format("FreeDriverScout:Resources:{0}", key));
     locExtension.ResolveLocalizedValue(out uiString);
     return uiString;
 }
Example #4
0
 public string Localize(string key)
 {
     string str;
     LocExtension loc = new LocExtension("LunchViewer:Strings:" + key);
     loc.ResolveLocalizedValue(out str);
     return str;
 }
 /// <summary>
 /// Get localized string from resource dictionary
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public string GetLocalizedString(string key)
 {
     string uiString;
     LocExtension locExtension = new LocExtension(key);
     locExtension.ResolveLocalizedValue(out uiString);
     return uiString;
 }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter == null) return values;

            var bindingParams = (object[])values.Clone();

            // Remove the {DependancyProperty.UnsetValue} from unbound datasources.
            for (var i = 0; i < bindingParams.Length; i++)
            {
                if (bindingParams[i] != null && bindingParams[i] == DependencyProperty.UnsetValue)
                {
                    bindingParams[i] = null;
                }
            }

            var keyStr = (string)parameter;

#pragma warning disable 618
            // It needs to identify the Assembly and Dictionary, as the Converter doesn't know squat about what is defined on the Window.
            var ext = new LocExtension(keyStr) { Assembly = "SEToolbox", Dict = "Resources" };
#pragma warning restore 618

            string localizedValue;
            return ext.ResolveLocalizedValue(out localizedValue) ? string.Format(localizedValue, bindingParams) : null;
        }
 public static string GetUIString(string key)
 {
     string uiString;
     LocExtension locExtension = new LocExtension(String.Format("DriversGalaxy.Infrastructure:Resources:{0}", key));
     locExtension.ResolveLocalizedValue(out uiString);
     return uiString;
 }
Example #8
0
        /// <summary>
        /// assemblyName + ":" + resourceName + ":" + key
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resourceKey"></param>
        /// <returns></returns>
        static public T Get <T>(string resourceKey)
        {
            T   uiString;
            var locExtension = new LocExtension(resourceKey);

            locExtension.ResolveLocalizedValue <T>(out uiString);
            return(uiString);
        }
        public static string GetUIString(string key)
        {
            string       uiString;
            LocExtension locExtension = new LocExtension(String.Format("FreeDriverScout:Resources:{0}", key));

            locExtension.ResolveLocalizedValue(out uiString);
            return(uiString);
        }
Example #10
0
        public string Localize(string key)
        {
            string       str;
            LocExtension loc = new LocExtension("LunchViewer:Strings:" + key);

            loc.ResolveLocalizedValue(out str);
            return(str);
        }
        public static string GetUIString(string key)
        {
            string       uiString;
            LocExtension locExtension = new LocExtension(String.Format("DriversGalaxy.Infrastructure:Resources:{0}", key));

            locExtension.ResolveLocalizedValue(out uiString);
            return(uiString);
        }
Example #12
0
        public static string Convert(string key)
        {
            string       uiString     = (key).Replace(" ", "");
            LocExtension locExtension = new LocExtension(key);

            locExtension.ResolveLocalizedValue(out uiString);
            return(uiString);
        }
Example #13
0
        /// <summary>
        /// Get localized string from resource dictionary
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetLocalizedString(string key)
        {
            string       uiString;
            LocExtension locExtension = new LocExtension(key);

            locExtension.ResolveLocalizedValue(out uiString);
            return(uiString);
        }
Example #14
0
        private void UpdateStrings()
        {
            string       str;
            LocExtension loc = new LocExtension("WpfLocalizationTest:Strings:code_property");

            loc.ResolveLocalizedValue(out str);
            Text = str;
        }
Example #15
0
 public static string Localize(this string key)
 {
     string localized;
     
     var locExtension = new LocExtension(key);
     locExtension.ResolveLocalizedValue(out localized);
     return localized;
 }
Example #16
0
        public static string GetUIString(string key)
        {
            string       uiString;
            LocExtension locExtension = new LocExtension("Software:Strings:" + key);

            locExtension.ResolveLocalizedValue(out uiString);
            return(uiString);
        }
Example #17
0
        static public T Get <T>(string assemblyName, string resourceName, string key)
        {
            T   uiString;
            var locExtension = new LocExtension(assemblyName + ":" + resourceName + ":" + key);

            locExtension.ResolveLocalizedValue <T>(out uiString);
            return(uiString);
        }
Example #18
0
        public string Localize(string key, string culture)
        {
            var culture_info = CultureInfo.CreateSpecificCulture(culture);

            string str;
            LocExtension loc = new LocExtension("LunchViewer:Strings:" + key);
            loc.ResolveLocalizedValue(out str, culture_info);
            return str;
        }
Example #19
0
        public string Localize(string key, string culture)
        {
            var culture_info = CultureInfo.CreateSpecificCulture(culture);

            string       str;
            LocExtension loc = new LocExtension("LunchViewer:Strings:" + key);

            loc.ResolveLocalizedValue(out str, culture_info);
            return(str);
        }
        public static string Translate(Assembly assembly, string key)
        {
            string returnValue;

            m_loc.Key = assembly + ":Translate:" + key;
            m_loc.ResolveLocalizedValue(out returnValue);
            if (returnValue == null)
            {
                return("Key:" + key);
            }
            return(returnValue);
        }
        public string GetLocalizedString(string key, string assembly, string dictionary)
        {
            string value;

            string prefix = string.Format("{0}:{1}:", assembly, dictionary);

            LocExtension locExtension = new LocExtension(prefix + key);

            locExtension.ResolveLocalizedValue(out value);

            return(value);
        }
Example #22
0
        /// <summary>
        /// 获取本地化的字符串
        /// </summary>
        /// <param name="key">欲获取资源的Key</param>
        /// <param name="resourceFileName">资源文件名称</param>
        /// <param name="addSpaceAfter"></param>
        /// <returns></returns>
        public static string GetLocalizedString(string key, string resourceFileName)
        {
            var localizedString = String.Empty;

            // Build up the fully-qualified name of the key
            var assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            var fullKey      = assemblyName + ":" + resourceFileName + ":" + key;
            var locExtension = new LocExtension(fullKey);

            locExtension.ResolveLocalizedValue(out localizedString);

            return(localizedString);
        }
Example #23
0
        /// <summary>
        /// Programmatic method for retrieving a localized string via key from a resource file.
        /// </summary>
        /// <param name="key">The key for the string.</param>
        /// <param name="resourceFileName">(Optional) The name of the Resource file. Default: Strings.</param>
        /// <param name="addSpaceAfter">A System.Boolean indicating if a whitespace character should be appended to the end of the localized string.</param>
        /// <returns></returns>
        public static string GetLocalizedString(string key, string resourceFileName = "Strings", bool addSpaceAfter = false)
        {
            var localizedString = String.Empty;

            // Build up the fully-qualified name of the key
            var assemblyName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            var fullKey      = assemblyName + ":" + resourceFileName + ":" + key;
            var locExtension = new LocExtension(fullKey);

            locExtension.ResolveLocalizedValue(out localizedString);

            // Add a space to the end, if requested
            if (addSpaceAfter)
            {
                localizedString += " ";
            }

            return(localizedString);
        }
Example #24
0
        public static string GetLocalizedString(string key, bool addSpaceAfter = false, string resourceFileName = "MarkdownPadStrings")
        {
            string text = string.Empty;
            string name = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            string key2 = string.Concat(new string[]
            {
                name,
                ":",
                resourceFileName,
                ":",
                key
            });
            LocExtension locExtension = new LocExtension(key2);

            locExtension.ResolveLocalizedValue <string>(out text);
            if (addSpaceAfter)
            {
                text += " ";
            }
            return(text);
        }
Example #25
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (parameter == null)
            {
                return(values);
            }

            var bindingParams = (object[])values.Clone();

            // Remove the {DependancyProperty.UnsetValue} from unbound datasources.
            for (var i = 0; i < bindingParams.Length; i++)
            {
                if (bindingParams[i] != null && bindingParams[i] == DependencyProperty.UnsetValue)
                {
                    bindingParams[i] = null;
                }
            }

            var    keyStr = (string)parameter;
            var    ext    = new LocExtension(keyStr);
            string localizedValue;

            return(ext.ResolveLocalizedValue(out localizedValue) ? string.Format(localizedValue, bindingParams) : null);
        }
Example #26
0
        public bool TryGetLocalizedString(string key, out string result)
        {
            LocExtension locExtension = new LocExtension(key);

            return(locExtension.ResolveLocalizedValue(out result));
        }
Example #27
0
        /// <summary>
        /// Evaluates a property using the StringParser. Equivalent to StringParser.Parse("${" + propertyName + "}");
        /// </summary>
        public static string GetValue(string propertyName, params StringTagPair[] customTags)
        {
            if(propertyName == null)
                throw new ArgumentNullException("propertyName");
            if(propertyName == "$")
                return "$";

            if(customTags != null){
                foreach(StringTagPair pair in customTags){
                    if(propertyName.Equals(pair.Tag, StringComparison.OrdinalIgnoreCase))
                        return pair.Value;
                }
            }

            int k = propertyName.IndexOf(':');
            if(k <= 0){
                // it's property without prefix

                if(propertyName.Equals("DATE", StringComparison.OrdinalIgnoreCase))
                    return DateTime.Today.ToShortDateString();
                if(propertyName.Equals("TIME", StringComparison.OrdinalIgnoreCase))
                    return DateTime.Now.ToShortTimeString();
                if(propertyName.Equals("ProductName", StringComparison.OrdinalIgnoreCase))
                    return IoC.Get<IMessageService>().ProductName;
                if(propertyName.Equals("GUID", StringComparison.OrdinalIgnoreCase))
                    return Guid.NewGuid().ToString().ToUpperInvariant();
                if(propertyName.Equals("USER", StringComparison.OrdinalIgnoreCase))
                    return Environment.UserName;
                if(propertyName.Equals("Version", StringComparison.OrdinalIgnoreCase))
                    return "1.00";
                if(propertyName.Equals("CONFIGDIRECTORY", StringComparison.OrdinalIgnoreCase))
                    return IoC.Get<IPropertyService>().ConfigDirectory;

                foreach(IStringTagProvider provider in string_tag_providers){
                    string result = provider.ProvideString(propertyName, customTags);
                    if(result != null)
                        return result;
                }

                return null;
            }else{
                // it's a prefixed property

                // res: properties are quite common, so optimize by testing for them first
                // before allocaing the prefix/propertyName strings
                // All other prefixed properties {prefix:Key} shoulg get handled in the switch below.
                if(propertyName.StartsWith("res:", StringComparison.OrdinalIgnoreCase)){
                    string str_resource;
                    var loc_extension = new LocExtension(ValidateIdentifier(propertyName.Substring(4)));
                    if(!loc_extension.ResolveLocalizedValue(out str_resource))
                        return null;

                    return Parse(str_resource, customTags);
                }

                string prefix = propertyName.Substring(0, k);
                propertyName = propertyName.Substring(k + 1);
                switch(prefix.ToUpperInvariant()){
                case "SDKTOOLPATH":
                    return FileUtility.GetSdkPath(propertyName);

                case "ADDINPATH":
                    foreach(var add_in in IoC.Get<IAddInTree>().AddIns){
                        if(add_in.Manifest.Identities.ContainsKey(propertyName))
                            return System.IO.Path.GetDirectoryName(add_in.FileName);
                    }
                    return null;

                case "DATE":
                    try{
                        return DateTime.Now.ToString(propertyName, CultureInfo.CurrentCulture);
                    }catch(Exception ex){
                        return ex.Message;
                    }

                case "ENV":
                    return Environment.GetEnvironmentVariable(propertyName);

                case "PROPERTY":
                    return GetProperty(propertyName);

                default:
                    IStringTagProvider provider;
                    if(prefixed_string_tag_providers.TryGetValue(prefix, out provider))
                        return provider.ProvideString(propertyName, customTags);
                    else
                        return null;
                }
            }
        }
Example #28
0
 private void UpdateStrings()
 {
     string str;
     LocExtension loc = new LocExtension("WpfLocalizationTest:Strings:code_property");
     loc.ResolveLocalizedValue(out str);
     Text = str;
 }