Exemple #1
0
        /// <summary>
        /// 获取控件的名称
        /// </summary>
        /// <param name="form"></param>
        public static void getNames(Form form)
        {
            LanguageItemModel        lm     = new LanguageItemModel();
            List <LanguageItemModel> lmList = getLanguageItem(form.Name.ToString());


            Control.ControlCollection controlNames = form.Controls;

            try
            {
                foreach (Control control in controlNames)
                {
                    if (control.GetType() == typeof(System.Windows.Forms.Panel))
                    {
                        GetSubControls(control.Controls, lmList);
                    }

                    if (control.GetType() == typeof(System.Windows.Forms.GroupBox))
                    {
                        GetSubControls(control.Controls, lmList);
                    }

                    if (control.GetType() == typeof(System.Windows.Forms.SplitContainer))
                    {
                        GetSubControls(control.Controls, lmList);
                    }

                    if (control.GetType() == typeof(System.Windows.Forms.SplitterPanel))
                    {
                        GetSubControls(control.Controls, lmList);
                    }

                    if (control.GetType() == typeof(System.Windows.Forms.DataGridView))
                    {
                        GetDataGridView(control, lmList);
                    }


                    lm = lmList.Where(p => p.CONTROLS_NAME == control.Name).FirstOrDefault();
                    if (lm != null)
                    {
                        control.Text = Language == "EN" ? lm.LANGUAGE_EN : lm.LANGUAGE_CH;
                    }
                }

                //窗体的名称
                lm = lmList.Where(p => p.CONTROLS_NAME == form.Name.ToString()).FirstOrDefault();
                if (lm != null)
                {
                    form.Text = Language == "EN" ? lm.LANGUAGE_EN : lm.LANGUAGE_CH;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemple #2
0
        private static void GetDataGridView(Control control, List <LanguageItemModel> lmList)
        {
            LanguageItemModel lm  = new LanguageItemModel();
            DataGridView      dgv = (DataGridView)control;

            for (int i = 0; i < dgv.Columns.Count; i++)
            {
                lm = lmList.Where(p => p.ITEM_FOR == control.Name && p.CONTROLS_NAME == dgv.Columns[i].Name).FirstOrDefault();
                if (lm != null)
                {
                    dgv.Columns[i].HeaderText = Language == "EN" ? lm.LANGUAGE_EN : lm.LANGUAGE_CH;
                }
            }
        }
        /// <summary>
        /// 获取控件的名称
        /// </summary>
        /// <param name="form"></param>
        public static void getNames(Form form)
        {
            LanguageItemModel lm = new LanguageItemModel();
            List<LanguageItemModel> lmList = getLanguageItem(form.Name.ToString());

            Control.ControlCollection controlNames = form.Controls;

            try
            {
                foreach (Control control in controlNames)
                {

                    if (control.GetType() == typeof(System.Windows.Forms.Panel))
                        GetSubControls(control.Controls, lmList);

                    if (control.GetType() == typeof(System.Windows.Forms.GroupBox))
                        GetSubControls(control.Controls, lmList);

                    if (control.GetType() == typeof(System.Windows.Forms.SplitContainer))
                        GetSubControls(control.Controls, lmList);

                    if (control.GetType() == typeof(System.Windows.Forms.SplitterPanel))
                        GetSubControls(control.Controls, lmList);

                    if (control.GetType() == typeof(System.Windows.Forms.DataGridView))
                        GetDataGridView(control, lmList);

                    lm = lmList.Where(p => p.CONTROLS_NAME == control.Name).FirstOrDefault();
                    if (lm != null)
                    {
                        control.Text = Language == "EN" ? lm.LANGUAGE_EN : lm.LANGUAGE_CH;
                    }

                }

                //窗体的名称
                lm = lmList.Where(p => p.CONTROLS_NAME == form.Name.ToString()).FirstOrDefault();
                if (lm != null)
                {
                    form.Text = Language == "EN" ? lm.LANGUAGE_EN : lm.LANGUAGE_CH;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemple #4
0
        /// <summary>
        /// 获得子控件的显示名
        /// </summary>
        /// <param name="controls"></param>
        /// <param name="table"></param>
        private static void GetSubControls(Control.ControlCollection controls, List <LanguageItemModel> lmList)
        {
            LanguageItemModel lm = new LanguageItemModel();

            foreach (Control control in controls)
            {
                if (control.GetType() == typeof(System.Windows.Forms.Panel))
                {
                    GetSubControls(control.Controls, lmList);
                }

                if (control.GetType() == typeof(System.Windows.Forms.GroupBox))
                {
                    GetSubControls(control.Controls, lmList);
                }

                if (control.GetType() == typeof(System.Windows.Forms.SplitContainer))
                {
                    GetSubControls(control.Controls, lmList);
                }

                if (control.GetType() == typeof(System.Windows.Forms.SplitterPanel))
                {
                    GetSubControls(control.Controls, lmList);
                }

                if (control.GetType() == typeof(System.Windows.Forms.DataGridView))
                {
                    GetDataGridView(control, lmList);
                }

                lm = lmList.Where(p => p.CONTROLS_NAME == control.Name).FirstOrDefault();
                if (lm != null)
                {
                    control.Text = Language == "EN" ? lm.LANGUAGE_EN : lm.LANGUAGE_CH;
                }
            }
        }
 private static void GetDataGridView(Control control, List<LanguageItemModel> lmList)
 {
     LanguageItemModel lm = new LanguageItemModel();
     DataGridView dgv=(DataGridView)control;
     for (int i = 0; i < dgv.Columns.Count; i++)
     {
         lm = lmList.Where(p => p.ITEM_FOR == control.Name && p.CONTROLS_NAME == dgv.Columns[i].Name).FirstOrDefault();
         if (lm != null)
         {
             dgv.Columns[i].HeaderText = Language == "EN" ? lm.LANGUAGE_EN : lm.LANGUAGE_CH;
         }
     }
 }
        /// <summary>
        /// 获得子控件的显示名
        /// </summary>
        /// <param name="controls"></param>
        /// <param name="table"></param>
        private static void GetSubControls(Control.ControlCollection controls, List<LanguageItemModel> lmList)
        {
            LanguageItemModel lm = new LanguageItemModel();
            foreach (Control control in controls)
            {

                if (control.GetType() == typeof(System.Windows.Forms.Panel))
                    GetSubControls(control.Controls, lmList);

                if (control.GetType() == typeof(System.Windows.Forms.GroupBox))
                    GetSubControls(control.Controls, lmList);

                if (control.GetType() == typeof(System.Windows.Forms.SplitContainer))
                    GetSubControls(control.Controls, lmList);

                if (control.GetType() == typeof(System.Windows.Forms.SplitterPanel))
                    GetSubControls(control.Controls, lmList);

                if (control.GetType() == typeof(System.Windows.Forms.DataGridView))
                    GetDataGridView(control, lmList);

                lm = lmList.Where(p => p.CONTROLS_NAME == control.Name).FirstOrDefault();
                if (lm != null)
                {
                    control.Text = Language == "EN" ? lm.LANGUAGE_EN : lm.LANGUAGE_CH;
                }
            }
        }