啊鑫
2024-07-09 0552fcc8cb73fc3021e2915129f55a42ed3f20e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#region
 
using System.Windows.Forms;
using CSFrameworkV5.Business;
using CSFrameworkV5.Core;
using CSFrameworkV5.Language;
using DevExpress.LookAndFeel;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
 
#endregion
 
namespace CSFrameworkV5.Library
{
    /// <summary>
    ///     所有窗体基类,继承XtraForm用于设置皮肤
    /// </summary>
    public partial class frmBase : XtraForm, IFormBase, ILanguageSupport
    {
        /// <summary>
        ///     按回车键自动将焦点移到下一输入框
        /// </summary>
        protected bool _EnterFocusNextControl = true;
 
        public frmBase()
        {
            InitializeComponent();
        }
 
        #region ILanguageSupport 成员
 
        /// <summary>
        ///     接口的方法,设置当前窗体的语言
        /// </summary>
        public virtual void SetLanguage()
        {
            Text = LanLib.Get(LanLib.Current, GetType().FullName, Text);
            LanTool.SetLanguage(this);
        }
 
        #endregion
 
        /// <summary>
        ///     处理热键
        /// </summary>
        /// <param name="key"></param>
        protected virtual void DoHotkey(char key)
        {
            //
        }
 
        /// <summary>
        ///     处理回车键或系统热键
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmBase_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter && _EnterFocusNextControl)
            {
                if (ActiveControl is Form) return;
 
                if (ActiveControl != null && ActiveControl is MemoEdit) return;
 
                if (ActiveControl != null && ActiveControl is TextBox &&
                    ((TextBox)ActiveControl).Multiline) return;
 
                if (ActiveControl != null && ActiveControl is UserControl)
                    return;
 
                if (ActiveControl != null && ActiveControl is GridControl)
                    return; //注意:不处理表格的按键,在派生类处理,如明细表
 
                SendKeys.Send("{Tab}"); //发送Tab键
            }
            else //其它键,作为系统热键处理
            {
                DoHotkey(e.KeyChar);
            }
        }
 
        #region IFormBase 成員
 
        /// <summary>
        ///     加载皮肤
        /// </summary>
        public void LoadSkin()
        {
            UserLookAndFeel.Default.SetSkinStyle(UserConfig.Current
                .SkinName); //设置主题样式
        }
 
        /// <summary>
        ///     设置窗体皮肤
        /// </summary>
        /// <param name="skinName">名称</param>
        public void SetSkin(string skinName)
        {
            UserLookAndFeel.Default.SetSkinStyle(skinName); //设置主题样式
        }
 
        #endregion
    }
}