Example #1
0
        /// <summary>
        /// Fixes a bug in Mono MWF support for localized forms and multiline textboxes:
        /// https://bugzilla.novell.com/show_bug.cgi?id=440191
        /// </summary>
        /// <param name="owner">The toplevel control to run the procedure on</param>
        public static void FixTextBoxes(Control owner, System.ComponentModel.ComponentResourceManager resources)
        {
            try
            {
                if (!Duplicati.Library.Utility.Utility.IsClientLinux)
                    return;

                Dictionary<Control, Control> visited = new Dictionary<Control, Control>();
                Queue<Control> work = new Queue<Control>();
                work.Enqueue(owner);

                while (work.Count > 0)
                {
                    Control c = work.Dequeue();
                    visited[c] = null;

                    if (c.HasChildren)
                        foreach (Control cc in c.Controls)
                            if (!visited.ContainsKey(cc))
                            {
                                work.Enqueue(cc);
                                visited[cc] = null;
                            }

                    if (c is TextBox && ((TextBox)c).Multiline)
                        resources.ApplyResources(c, c.Name);
                }
            }
            finally
            {
                if (resources != null)
                    resources.ReleaseAllResources();
            }
        }
 //This is a Hack, there should be a better way to do this,like getting the form's private fields.
 public void ApplyResources(Control form, System.ComponentModel.ComponentResourceManager resources)
 {
     foreach (Control item in form.Controls)
     {
         if (item is MenuStrip)
         {
             resources.ApplyResources(item, item.Name);
             ApplyResourcesToMenu(resources, ((MenuStrip)item).Items);
         }
         else
         {
             if(item is TextBox || item is Label)
                 resources.ApplyResources(item, item.Name);
         }
     }
 }
Example #3
0
 /// <summary>
 /// 遍历菜单
 /// </summary>
 /// <param name="item"></param>
 /// <param name="resources"></param>
 private static void AppLang(ToolStripMenuItem item, System.ComponentModel.ComponentResourceManager resources)
 {
     if (item is ToolStripMenuItem)
     {
         resources.ApplyResources(item, item.Name);
         ToolStripMenuItem tsmi = (ToolStripMenuItem)item;
         if (tsmi.DropDownItems.Count > 0)
         {
             foreach (ToolStripMenuItem c in tsmi.DropDownItems)
             {
                 //if (tsmi != ToolStripSeparator)
                 //{ }
                 AppLang(c, resources);
             }
         }
     }
 }
 private void ApplyRes(System.Windows.Forms.Control control, System.ComponentModel.ComponentResourceManager mgr)
 {
     mgr.ApplyResources(control, control.Name);
     foreach (System.Windows.Forms.Control item in control.Controls)
     {
         ApplyRes(item, mgr);
     }
     if(control is System.Windows.Forms.ComboBox)
     {
         System.Windows.Forms.ComboBox item = control as System.Windows.Forms.ComboBox;
         for (int i = 0; i < item.Items.Count; i++ )
         {
             string appendix = i.ToString();
             if (i == 0)
                 appendix = "";
             try
             {
                 item.Items[i] = mgr.GetString(item.Name + ".Items" + appendix);
             }
             catch (System.ArgumentNullException)
             {
             }
         }
     }
     if(control is System.Windows.Forms.ListBox)
     {
         System.Windows.Forms.ListBox item = control as System.Windows.Forms.ListBox;
         for (int i = 0; i < item.Items.Count; i++)
         {
             string appendix = i.ToString();
             if (i == 0)
                 appendix = "";
             try
             {
                 item.Items[i] = mgr.GetString(item.Name + ".Items" + appendix);
             }
             catch (System.ArgumentNullException)
             {
             }
         }
     }
 }
 private void loadIPList(System.ComponentModel.ComponentResourceManager resources)
 {
     if (screenList != null)
     {
         reloadIPList();
        
         
     }
     resources.ApplyResources(this.listViewScrn, "listView1");
 }
        private static void ApplyResourcesToMenu(System.ComponentModel.ComponentResourceManager resources, IEnumerable item)
        {
            foreach (object menuItem in item)
            {
                if (menuItem is ToolStripMenuItem)
                {
                    resources.ApplyResources(menuItem, ((ToolStripMenuItem)menuItem).Name);
                    ApplyResourcesToMenu(resources, ((ToolStripMenuItem)menuItem).DropDownItems);
                }

            }
        }