/// <summary>
 /// 获取指定单例控件中的某种类型的全部子控件
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="singConName"></param>
 /// <returns></returns>
 public static T[] getSingletonChildCon <T>(DefaultNameEnum singConName) where T : Control
 {
     T[] retAll = null;
     // 全局单例控件工厂
     if (singletonCache.ContainsKey(EnumUtils.GetDescription(singConName)))
     {
         // 全局单例控件工厂
         Dictionary <string, Control> single = ControlCacheFactory.getSingletonCache();
         if (single.ContainsKey(EnumUtils.GetDescription(DefaultNameEnum.TOOL_START)) && single.ContainsKey(EnumUtils.GetDescription(DefaultNameEnum.TAB_CONTENT)))
         {
             // 获取指定姓名的控件
             Control tabParent = single[EnumUtils.GetDescription(singConName)];
             if (tabParent != null)
             {
                 List <T> conList = new List <T>();
                 ControlsUtils.GetAllControlByType(ref conList, tabParent.Controls);
                 if (conList != null && conList.Count > 0)
                 {
                     retAll = conList.ToArray();
                 }
             }
         }
     }
     return(retAll);
 }
        /// 状态栏的鼠标点击公用事件
        private void toolLabelMouseDown(object sender, MouseEventArgs e)
        {
            ToolStripStatusLabel lable    = (ToolStripStatusLabel)sender;
            List <Control>       textList = new List <Control>();

            ControlsUtils.GetAllControlByType(ref textList, ControlCacheFactory.getSingletonCache(DefaultNameEnum.TAB_CONTENT).Controls);
            TextBox textBox = textList[0] is TextBox? (TextBox)textList[0] : new TextBox();

            //判断当前控件是否有与其关联的句柄并且按下的是左键
            if (this.IsHandleCreated && e.Button.Equals(MouseButtons.Left))
            {
                // 改变背景色
                lable.BackColor = ColorTranslator.FromHtml("#6CB8F4");
            }
        }
Esempio n. 3
0
        private static TextBox getPageTextBox()
        {
            Control        conTab   = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TAB_CONTENT);
            List <TextBox> controls = null;
            TextBox        t        = null;

            if (conTab != null && conTab is TabControl && t == null)
            {
                ControlsUtils.GetAllControlByType(ref controls, ((TabControl)conTab).SelectedTab.Controls);
                if (controls.Count > 0 && controls[0] is TextBox)
                {
                    return(controls[0]);
                }
            }
            return(null);
        }
Esempio n. 4
0
 /// <summary>
 /// 初始化源数据控件 这里是文本框
 /// </summary>
 private void initSourceDataCon()
 {
     if (textBox == null)
     {
         Control        conTab   = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TAB_CONTENT);
         List <TextBox> controls = null;
         if (conTab != null && conTab is TabControl)
         {
             ControlsUtils.GetAllControlByType(ref controls, ((TabControl)conTab).SelectedTab.Controls);
             if (controls.Count > 0 && controls[0] is TextBox)
             {
                 textBox = controls[0];
             }
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 初始化数据
 /// </summary>
 private bool initData()
 {
     // 获取当前标签中的文本框
     if (textBox == null)
     {
         Control        conTab   = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TAB_CONTENT);
         List <TextBox> controls = null;
         TextBox        t        = null;
         if (conTab != null && conTab is TabControl && t == null)
         {
             ControlsUtils.GetAllControlByType(ref controls, ((TabControl)conTab).SelectedTab.Controls);
             if (controls.Count > 0 && controls[0] is TextBox)
             {
                 textBox = controls[0];
             }
         }
     }
     if (textBox != null && textBox is TextBox)
     {
         if (textBox != null)
         {
             // 重置搜索
             isResetFindMet = true;
         }
         // 赋值启动主窗体
         rootDisplayForm = textBox.FindForm();
         // 赋值要操作的文本框的右键菜单
         textRightMenu = textBox.ContextMenuStrip;
         // 赋值要操作的文本
         text = textBox.Text;
         return(true);
     }
     else
     {
         MessageBox.Show("无法获取文本框");
         return(false);
     }
 }