Пример #1
0
        /// <summary>
        /// 根据传入的页面模式初始化窗口的基本要素
        /// </summary>
        /// <param name="pageMode">页面的模式(新增/编辑/查看)</param>
        protected BaseWindow(PageMode pageMode)
        {
            //保存页面模式
            _pageMode = pageMode;

            //从Properties中获得主窗口的VM
            var tmpVM = (MainVM) Application.Current.Properties["MainVM"];

            //从Properties中获得模块-权限列表
            if (_modulePermPairs == null)
            {
                _modulePermPairs = Application.Current.Properties["ModulePermPairs"] as List<ModulePermPair>;
            }

            //从主窗口的VM中获得当前用户对象和主窗口的对象
            _currentUser = tmpVM.CurrentUser;
            _mainWindow = tmpVM.Main;

            //设置当前窗口的Parent
            Owner = _mainWindow;

            //将Parent窗口Disable
            Owner.IsEnabled = false;

            //设置弹出窗的初始位置
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            //Loaded事件handlor
            Loaded += BaseWindowLoaded;

            //Closing事件的handlor
            Closing += BaseWindowClosing;

            //IsEnabledChanged事件handlor
            IsEnabledChanged += BaseWindowIsEnabledChanged;

            //KeyDown事件的Handlor
            KeyDown += OnKeyDown;
        }
Пример #2
0
        /// <summary>
        /// 根据传入的页面模式初始化页面的基本要素
        /// </summary>
        /// <param name="pageMode">页面的模式(新增/编辑/查看)</param>
        protected BasePage(PageMode pageMode)
        {
            //保存页面模式
            _pageMode = pageMode;

            //从Properties中获得主窗口的VM
            var tmpVM = (MainVM) Application.Current.Properties["MainVM"];

            //从Properties中获得模块-权限列表
            if (_modulePermPairs == null)
            {
                _modulePermPairs = Application.Current.Properties["ModulePermPairs"] as List<ModulePermPair>;
            }

            //从主窗口的VM中获得当前用户对象和主窗口的对象
            _currentUser = tmpVM.CurrentUser;
            _mainWindow = tmpVM.Main;

            //Loaded事件handlor
            Loaded += BasePageLoaded;

            //IsEnabledChanged事件handlor
            IsEnabledChanged += BasePageIsEnabledChanged;
        }
Пример #3
0
        private void LoginWindow()
        {
            VM.Password = tbPassword.Password;
            try
            {
                User user = VM.Login();

                Application.Current.Properties["CurrentUser"] = user;

                var main = new Main();
                Close();
                main.Show();

                main.Activate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ErrorMsgManager.GetClientErrMsg(ex, CultureManager.UICulture));
            }
        }