コード例 #1
0
 /// <summary>
 /// Sets the culture.
 /// </summary>
 /// <param name="culture">The culture.</param>
 internal static void SetCulture(string culture)
 {
     MultilanguageResource.currentResources = Hashtable.Synchronized(new Hashtable());
     MultilanguageResource.resourceManager  = null;
     MultilanguageResource.cultureInfo      = new CultureInfo(MultilanguageResource.cultureSuffix(culture));
     Thread.CurrentThread.CurrentUICulture  = MultilanguageResource.cultureInfo;
 }
コード例 #2
0
 /// <summary>
 /// Manages the resource.
 /// </summary>
 /// <param name="form">The form.</param>
 internal static void ManageResource(Form form, Control.ControlCollection cc)
 {
     form.Text = MultilanguageResource.GetString(form);
     foreach (Control c in cc)
     {
         string key   = String.Empty;
         string value = String.Empty;
         //Exceptions
         if (
             c.Name == "rbCSharp" ||
             c.Name == "rbVBNet"
             )
         {
             continue;
         }
         //
         if (c as Label != null)
         {
             key    = String.Format("{0}_{1}.Text", form.Name, ((Label)c).Name);
             c.Text = MultilanguageResource.GetString(key);
         }
         if (c as Button != null)
         {
             key    = String.Format("{0}_{1}.Text", form.Name, ((Button)c).Name);
             c.Text = MultilanguageResource.GetString(key);
         }
         if (c as RadioButton != null)
         {
             key    = String.Format("{0}_{1}.Text", form.Name, ((RadioButton)c).Name);
             c.Text = MultilanguageResource.GetString(key);
         }
         if (c as CheckBox != null)
         {
             key    = String.Format("{0}_{1}.Text", form.Name, ((CheckBox)c).Name);
             c.Text = MultilanguageResource.GetString(key);
         }
         if (c as GroupBox != null)
         {
             key    = String.Format("{0}_{1}.Text", form.Name, ((GroupBox)c).Name);
             c.Text = MultilanguageResource.GetString(key);
         }
         if (c as TabControl != null)
         {
             foreach (TabPage tb in ((TabControl)c).TabPages)
             {
                 key     = String.Format("{0}_{1}.Text", form.Name, tb.Name);
                 tb.Text = MultilanguageResource.GetString(key);
             }
         }
         if (c as ListView != null)
         {
             foreach (ColumnHeader ch in ((ListView)c).Columns)
             {
                 key     = String.Format("{0}_{1}_{2}.Text", form.Name, ((ListView)c).Name, ((ColumnHeader)ch).Index);
                 ch.Text = MultilanguageResource.GetString(key);
             }
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Gets the string.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        private static string GetStringInternal(string key)
        {
            if (MultilanguageResource.currentResources.ContainsKey(key))
            {
                return((String)MultilanguageResource.currentResources[key]);
            }

            string culture = MultilanguageResource.GetCurrentCulture();

            if (cultureInfo == null)
            {
                MultilanguageResource.SetCulture(culture);
            }
            if (resourceManager == null)
            {
                resourceManager = new ResourceManager(String.Format("NetSqlAzMan.SnapIn.Globalization.Resource_{0}", culture), Assembly.GetExecutingAssembly());
            }
            string result;

            try
            {
                result = MultilanguageResource.resourceManager.GetString(key);
                if (result != null)
                {
                    if (result.IndexOf("\\r\\n") != -1)
                    {
                        result = result.Replace("\\r\\n", "\r\n");
                    }
                }
                else
                {
                    result = String.Format("Globalization Error: Key '{0}' NOT FOUND in .resx file !!!", key);
                }
            }
            catch
            {
                result = String.Format("Globalization Error: Key '{0}' NOT FOUND in .resx file !!!", key);
            }
            lock (MultilanguageResource.currentResources.SyncRoot)
            {
                MultilanguageResource.currentResources.Add(key, result);
            }
            return(result);
        }
コード例 #4
0
 /// <summary>
 /// Gets the string.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <returns></returns>
 internal static string GetString(string key)
 {
     return(MultilanguageResource.GetStringInternal(key));
 }
コード例 #5
0
 /// <summary>
 /// Gets the string.
 /// </summary>
 /// <param name="className">Name of the class.</param>
 /// <param name="messageName">Name of the message.</param>
 /// <returns></returns>
 internal static string GetString(string className, string messageName)
 {
     return(MultilanguageResource.GetStringInternal(String.Format("{0}_{1}", className, messageName)));
 }
コード例 #6
0
 /// <summary>
 /// Gets the string.
 /// </summary>
 /// <param name="form">The form.</param>
 /// <returns></returns>
 internal static string GetString(Form form)
 {
     return(MultilanguageResource.GetStringInternal(String.Format("{0}.Text", form.Name)));
 }