Пример #1
0
 /// <summary>
 /// 设置是否自动换行
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static object isAutoLine(Dictionary <Type, object> data)
 {
     // 获取文本框
     if (data.ContainsKey(typeof(TextBox)) && data[typeof(TextBox)] is TextBox)
     {
         TextBox           t    = (TextBox)data[typeof(TextBox)];
         ToolStripMenuItem item = (ToolStripMenuItem)data[typeof(ToolStripMenuItem)];
         // 设置状态栏显示与隐藏
         bool check = item.Checked;
         t.WordWrap = check;
         MainTextBConfig.AUTO_WORDWRAP = check;
         // 获取tab容器中的全部的主文本框
         TextBox[] textAll = ControlCacheFactory.getSingletonChildCon <TextBox>(DefaultNameEnum.TAB_CONTENT);
         if (textAll != null)
         {
             foreach (TextBox textB in textAll)
             {
                 if (textB.Name.IndexOf(EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF)) >= 0)
                 {
                     // 设置自动换行
                     textB.WordWrap = check;
                 }
             }
         }
     }
     else
     {
         MessageBox.Show("无法获取文本框");
     }
     return(null);
 }
Пример #2
0
        /// <summary>
        /// 获取右键菜单
        /// </summary>
        /// <returns></returns>
        public static ContextMenuStrip getTextRightMenu()
        {
            DataGridViewRightMenu dataGridViewRightMenu = new DataGridViewRightMenu();

            ControlCacheFactory.addSingletonCache(dataGridViewRightMenu.table_rightStrip);
            return(dataGridViewRightMenu.table_rightStrip);
        }
 // 设置状态栏的编码
 private object setToolSatrtEcoding(Control con)
 {
     if (con == null)
     {
         MessageBox.Show("无法获取控件");
     }
     // 获取文本框
     if (con is TextBox)
     {
         TextBox t = (TextBox)con;
         // 开辟新线程执行方法
         ControlsUtils.AsynchronousMethod(t, 300, delegate {
             Dictionary <string, object> tag = TextBoxUtils.GetTextTagToMap(t);
             Encoding ecoding = TextBoxDataLibcs.TEXTBOX_ECODING_DEF;
             // 获取文本框中Tag中存的编码
             if (tag.ContainsKey(TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING))
             {
                 ecoding = (Encoding)TextBoxUtils.GetTextTagToMap(t)[TextBoxTagKey.TEXTBOX_TAG_KEY_ECODING];
             }
             // 全局单例控件工厂
             Dictionary <string, Control> single = ControlCacheFactory.getSingletonCache();
             if (single.ContainsKey(EnumUtils.GetDescription(DefaultNameEnum.TOOL_START)))
             {
                 // 状态栏
                 ToolStrip toolStrip = (ToolStrip)single[EnumUtils.GetDescription(DefaultNameEnum.TOOL_START)];
                 // 获取编码Item
                 ToolStripItem labEcoding = toolStrip.Items[StrutsStripDataLib.ItemName.编码];
                 labEcoding.Text          = ecoding.BodyName.ToUpper();
             }
         });
     }
     return(null);
 }
Пример #4
0
 /// <summary>
 /// 设置状态栏的显示与隐藏
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public static object isStartBarDisplay(Dictionary <Type, object> data)
 {
     // 获取文本框
     if (data.ContainsKey(typeof(TextBox)) && data[typeof(TextBox)] is TextBox)
     {
         ToolStripMenuItem item = (ToolStripMenuItem)data[typeof(ToolStripMenuItem)];
         // 全局单例控件工厂
         Dictionary <string, Control> single = ControlCacheFactory.getSingletonCache();
         if (single.ContainsKey(EnumUtils.GetDescription(DefaultNameEnum.TOOL_START)) && single.ContainsKey(EnumUtils.GetDescription(DefaultNameEnum.TAB_CONTENT)))
         {
             // 状态栏
             Control toolStrip = single[EnumUtils.GetDescription(DefaultNameEnum.TOOL_START)];
             // 标签容器的父容器
             Control tabParent = single[EnumUtils.GetDescription(DefaultNameEnum.MAIN_CONTAINER)];
             // 设置状态栏显示与隐藏
             bool check = item.Checked;
             toolStrip.Visible = check;
             // 调整标签容器的位置
             if (check)
             {
                 tabParent.Height = tabParent.Height - toolStrip.Height;
             }
             else
             {
                 tabParent.Height = tabParent.Height + toolStrip.Height;
             }
         }
     }
     else
     {
         MessageBox.Show("无法获取文本框");
     }
     return(null);
 }
        // 关联状态栏
        public void statusBarAssociation()
        {
            TabPage pp = this;

            if (pp.Controls.Count > 0)
            {
                setSourceControl(pp);
                void setSourceControl(Control con)
                {
                    foreach (Control c in con.Controls)
                    {
                        if (c is TextBox || c is DataGridView)
                        {
                            ControlsUtils.TimersMethod(20, 2000, this, (object sender, ElapsedEventArgs e) => {
                                Control ccc = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TOOL_START);
                                if (ccc != null && ccc is RedrawStatusBar)
                                {
                                    RedrawStatusBar bar = (RedrawStatusBar)ccc;
                                    bar.SetSourceControl(c);
                                    ((System.Timers.Timer)sender).Dispose();
                                }
                            });
                        }
                        else if (c.Controls.Count > 0)
                        {
                            setSourceControl(c);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 打开多例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initPrototypeExample(bool isShowTop)
        {
            RedrawDataTable conThis = this;

            conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.DATA_GRID_VIEW_REDRAW) + DateTime.Now.Ticks.ToString();;
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            // 加入到多例工厂
            ControlCacheFactory.addPrototypeCache(DefaultNameEnum.DATA_GRID_VIEW_REDRAW, conThis);
            return(conThis);
        }
        /// <summary>
        /// 打开多例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initPrototypeExample(bool isShowTop)
        {
            RedrawMainContainer conThis = this;

            conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.MAIN_CONTAINER) + DateTime.Now.Ticks.ToString();;
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            // 加入到多例工厂
            ControlCacheFactory.addPrototypeCache(DefaultNameEnum.MAIN_CONTAINER, conThis);
            return(conThis);
        }
Пример #8
0
        /// <summary>
        /// 打开多例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initPrototypeExample(bool isShowTop)
        {
            RedrawPromptMessBut conThis = this;

            conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.PROMPT_MESSAGE) + DateTime.Now.Ticks.ToString();
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            // 加入到多例工厂
            ControlCacheFactory.addPrototypeCache(DefaultNameEnum.PROMPT_MESSAGE, conThis);
            return(conThis);
        }
Пример #9
0
        /// <summary>
        /// 打开多例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initPrototypeExample(bool isShowTop)
        {
            ContextMenuStrip conThis = table_rightStrip;

            conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.DATA_VIEW_RIGHT_MENU) + DateTime.Now.Ticks.ToString();;
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            // 加入到多例工厂
            ControlCacheFactory.addPrototypeCache(DefaultNameEnum.DATA_VIEW_RIGHT_MENU, conThis);
            return(conThis);
        }
        /// <summary>
        /// 打开多例模式下的添加字符窗口
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initPrototypeExample(bool isShowTop)
        {
            RedrawAddPageBut conThis = this;

            conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.ADD_CHARS_FORM) + DateTime.Now.Ticks.ToString();
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            // 加入到多例工厂
            ControlCacheFactory.addPrototypeCache(DefaultNameEnum.ADD_CHARS_FORM, conThis);
            return(conThis);
        }
        /// <summary>
        /// 打开多例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initPrototypeExample(bool isShowTop)
        {
            RedrawStatusBar conThis = this;

            conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.TOOL_START) + DateTime.Now.Ticks.ToString();;
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            // 加入到多例工厂
            ControlCacheFactory.addPrototypeCache(DefaultNameEnum.TOOL_START, conThis);
            return(conThis);
        }
Пример #12
0
        /// <summary>
        /// 打开多例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initPrototypeExample(bool isShowTop)
        {
            RedrawTextBox conThis = this;

            conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF) + DateTime.Now.Ticks.ToString();;
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            // 加入到多例工厂
            ControlCacheFactory.addPrototypeCache(DefaultNameEnum.TEXTBOX_NAME_DEF, conThis);
            return(conThis);
        }
Пример #13
0
        /// <summary>
        /// 菜单子选项的总绑定类,执行选项name对应的绑定类
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_Click(object sender, EventArgs e)
        {
            try {
                ToolStripMenuItem tool = (ToolStripMenuItem)sender;
                //获取当前主Tab容器中的文本框
                TextBox t       = null;
                Control control = null;
                // 获得主tab容器
                Control tabCon = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TAB_CONTENT);
                if (tabCon != null && tabCon is TabControl)
                {
                    TabControl tab = (TabControl)tabCon;
                    if (t == null)
                    {
                        control = ControlsUtils.GetControlByName(tab.SelectedTab.Controls, EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF), true);
                        if (control != null && control is TextBox)
                        {
                            t = (TextBox)control;
                        }
                    }
                    if (t == null)
                    {
                        control = ControlsUtils.GetFocueControlByType(tab.SelectedTab.Controls);
                        if (control != null && control is TextBox)
                        {
                            t = (TextBox)control;
                        }
                    }
                }
                // 遍历对应关系字典
                foreach (KeyValuePair <string, Delegate> kvp in eventBinding())
                {
                    // 判断当前点击的选项名是否与关系字典中的选项名对应,对应则执行关系字典中的对应方法
                    if (kvp.Key.Equals(tool.Name))
                    {
                        // 判断当前控件是否有与其关联的句柄
                        if (topMenuStrip.IsHandleCreated)
                        {
                            Dictionary <Type, object> data = new Dictionary <Type, object>();
                            data.Add(typeof(TextBox), t);
                            data.Add(typeof(ToolStripMenuItem), tool);

                            topMenuStrip.Invoke(kvp.Value, new object[] { data });
                        }
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #14
0
        /// <summary>
        /// 获取单例模式下的控件
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层控件</param>
        /// <returns></returns>
        public static Control getSingleControl(DefaultNameEnum name, bool isShowTop)
        {
            Control con = ControlCacheFactory.getSingletonCache(name);

            if (con == null || con.IsDisposed)
            {
                IComponentInitMode <Control> mode = getInitControlRelation(name);
                if (mode != null)
                {
                    con = mode.initSingleExample(isShowTop);
                }
            }
            return(con);
        }
Пример #15
0
        /// <summary>
        /// 获取单例的右键菜单
        /// </summary>
        /// <returns></returns>
        public static ContextMenuStrip getSingleTextRightMenu()
        {
            Control con = ControlCacheFactory.getSingletonCache(DefaultNameEnum.DATA_VIEW_RIGHT_MENU);

            if (con == null)
            {
                DataGridViewRightMenu dataGridViewRightMenu = new DataGridViewRightMenu();
                ControlCacheFactory.addSingletonCache(dataGridViewRightMenu.table_rightStrip);
                return(dataGridViewRightMenu.table_rightStrip);
            }
            else
            {
                return((ContextMenuStrip)con);
            }
        }
Пример #16
0
        /// <summary>
        /// 获取右键菜单
        /// </summary>
        /// <returns></returns>
        public static MenuStrip getTopMenuStrip()
        {
            Control con = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TOP_MENU);

            if (con == null)
            {
                TopMenuContainer topMenuContainer = new TopMenuContainer();
                ControlCacheFactory.addSingletonCache(topMenuContainer.topMenuStrip);
                return(topMenuContainer.topMenuStrip);
            }
            else
            {
                return((MenuStrip)con);
            }
        }
        /// 状态栏的鼠标点击公用事件
        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");
            }
        }
Пример #18
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];
             }
         }
     }
 }
Пример #19
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);
        }
Пример #20
0
        /// <summary>
        /// 获取当前标签的文本框
        /// </summary>
        /// <returns></returns>
        public static TextBox GetSelectPageTextBox()
        {
            Control con = null;

            con = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TAB_CONTENT);
            if (con is TabControl)
            {
                TabControl redrawTab = (TabControl)con;
                // 获取标签容器中当前标签的文本框
                con = ControlsUtils.GetControlByName(redrawTab.SelectedTab.Controls, EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF), true);
            }
            // 转化为文本框
            TextBox textBox = con != null && con is TextBox?(TextBox)con : null;

            return(textBox);
        }
        /// <summary>
        /// 导出数据到新标签
        /// </summary>
        public static void ExportNewPage(string s)
        {
            // 获取当前程序的标签容器
            Control con = null;

            con = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TAB_CONTENT);
            if (con is RedrawTabControl)
            {
                RedrawTabControl redrawTab = (RedrawTabControl)con;
                redrawTab.TransferDddPageInvoke();
                // 获取标签容器中当前标签的文本框
                con = ControlsUtils.GetControlByName(redrawTab.SelectedTab.Controls, EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF), true);
            }
            // 转化为文本框
            TextBox textBox = con != null && con is TextBox?(TextBox)con : null;

            ControlsUtils.ExportTextBox(textBox, s);
        }
Пример #22
0
 /// <summary>
 /// 实例化字体对话框
 /// </summary>
 /// <returns></returns>
 public static object fontDialogMethod(Dictionary <Type, object> data)
 {
     // 判断是否存在文本框
     if (data.ContainsKey(typeof(TextBox)) && data[typeof(TextBox)] is TextBox)
     {
         TextBox t   = (TextBox)data[typeof(TextBox)];
         object  obj = PublicEventMet.fontDialogMethod(t);
         if (obj != null && obj is Dictionary <string, object> )
         {
             Dictionary <string, object> dic = (Dictionary <string, object>)obj;
             // 获取字体设置对话框
             FontDialog fontD = dic.ContainsKey("1") && dic["1"] is FontDialog? (FontDialog)dic["1"] : null;
             // 是否点击了确定
             DialogResult ok = dic.ContainsKey("2") && dic["2"] is DialogResult? (DialogResult)dic["2"] : DialogResult.None;
             if (DialogResult.OK.Equals(ok) && fontD != null)
             {
                 // 询问是否将该字体应用到全部的文本框
                 ControlsUtils.ShowAskMessBox("是否将该字体应用到全部的文本框中", "设置字体",
                                              delegate {
                     MainTextBConfig.TEXTBOX_FONT = fontD.Font;
                     // 获取tab容器中的全部的主文本框
                     TextBox[] textAll = ControlCacheFactory.getSingletonChildCon <TextBox>(DefaultNameEnum.TAB_CONTENT);
                     if (textAll != null)
                     {
                         foreach (TextBox textB in textAll)
                         {
                             if (textB.Name.IndexOf(EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF)) >= 0)
                             {
                                 // 设置字体
                                 textB.Font = fontD.Font;
                             }
                         }
                     }
                 }, null);
             }
         }
     }
     else
     {
         MessageBox.Show("无法获取文本框");
     }
     return(null);
 }
Пример #23
0
 /// <summary>
 /// 恢复文本框默认字体
 /// </summary>
 /// <returns></returns>
 public static object textBoxFontReset(Dictionary <Type, object> data)
 {
     ControlsUtils.ShowAskMessBox("是否恢复全部文本框的默认字体", "恢复默认字体",
                                  delegate {
         MainTextBConfig.TEXTBOX_FONT = TextBoxDataLibcs.TEXTBOX_FONT_DEF;
         // 获取tab容器中的全部的主文本框
         TextBox[] textAll = ControlCacheFactory.getSingletonChildCon <TextBox>(DefaultNameEnum.TAB_CONTENT);
         if (textAll != null)
         {
             foreach (TextBox textB in textAll)
             {
                 if (textB.Name.IndexOf(EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF)) >= 0)
                 {
                     // 设置字体
                     textB.Font = TextBoxDataLibcs.TEXTBOX_FONT_DEF;
                 }
             }
         }
     }, null);
     return(null);
 }
        /// <summary>
        /// 打开单例模式下的添加字符窗口
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initSingleExample(bool isShowTop)
        {
            RedrawAddPageBut conThis = null;
            Control          con     = ControlCacheFactory.getSingletonCache(DefaultNameEnum.ADD_PAGE_BUTTON);

            if (con == null || !(con is RedrawAddPageBut))
            {
                conThis      = this;
                conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.ADD_CHARS_FORM);
                ControlCacheFactory.addSingletonCache(conThis);
            }
            else
            {
                conThis = (RedrawAddPageBut)con;
            }
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            return(conThis);
        }
Пример #25
0
        /// <summary>
        /// 打开单例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initSingleExample(bool isShowTop)
        {
            RedrawTextBox conThis = null;
            Control       con     = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TEXTBOX_NAME_DEF);

            if (con == null || !(con is RedrawTextBox))
            {
                conThis      = this;
                conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.TEXTBOX_NAME_DEF);
                ControlCacheFactory.addSingletonCache(conThis);
            }
            else
            {
                conThis = (RedrawTextBox)con;
            }
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            return(conThis);
        }
        /// <summary>
        /// 打开单例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initSingleExample(bool isShowTop)
        {
            RedrawStatusBar conThis = null;
            Control         con     = ControlCacheFactory.getSingletonCache(DefaultNameEnum.TOOL_START);

            if (con == null || !(con is RedrawStatusBar))
            {
                conThis      = this;
                conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.TOOL_START);
                ControlCacheFactory.addSingletonCache(conThis);
            }
            else
            {
                conThis = (RedrawStatusBar)con;
            }
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            return(conThis);
        }
Пример #27
0
        /// <summary>
        /// 打开单例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initSingleExample(bool isShowTop)
        {
            ContextMenuStrip conThis = null;
            Control          con     = ControlCacheFactory.getSingletonCache(DefaultNameEnum.DATA_VIEW_RIGHT_MENU);

            if (con == null || !(con is ContextMenuStrip))
            {
                conThis      = table_rightStrip;
                conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.DATA_VIEW_RIGHT_MENU);
                ControlCacheFactory.addSingletonCache(conThis);
            }
            else
            {
                conThis = (ContextMenuStrip)con;
            }
            if (isShowTop)
            {
                conThis.BringToFront();
            }
            return(conThis);
        }
Пример #28
0
        /// <summary>
        /// 打开单例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initSingleExample(bool isShowTop)
        {
            RedrawPromptMessBut conThis = null;
            Control             con     = ControlCacheFactory.getSingletonCache(DefaultNameEnum.PROMPT_MESSAGE);

            if (con == null || !(con is RedrawPromptMessBut))
            {
                conThis      = this;
                conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.PROMPT_MESSAGE);
                ControlCacheFactory.addSingletonCache(conThis);
            }
            else
            {
                conThis = (RedrawPromptMessBut)con;
            }

            if (isShowTop)
            {
                conThis.BringToFront();
            }
            return(conThis);
        }
        /// <summary>
        /// 打开单例模式下的对象
        /// </summary>
        /// <param name="isShowTop">是否显示为顶层窗体</param>
        /// <returns></returns>
        public Control initSingleExample(bool isShowTop)
        {
            DataGridView conThis = null;
            Control      con     = ControlCacheFactory.getSingletonCache(DefaultNameEnum.DATA_GRID_VIEW_REDRAW);

            if (con == null || !(con is DataGridView))
            {
                conThis      = this;
                conThis.Name = EnumUtils.GetDescription(DefaultNameEnum.DATA_GRID_VIEW_REDRAW);
                ControlCacheFactory.addSingletonCache(conThis);
            }
            else
            {
                conThis = (DataGridView)con;
            }

            if (isShowTop)
            {
                conThis.BringToFront();
            }
            return(conThis);
        }
Пример #30
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);
     }
 }