Exemple #1
0
        public void SwitchToForm(string name, int switchFlags)
        {
            if (_currentShowFormName == name)
            {
                return;
            }

            Form toForm = null;

            if (_contentFormDict.ContainsKey(name))
            {
                toForm = _contentFormDict[name];
            }
            if (toForm == null)
            {
                throw new Exception("主内容区无法切换到名为" + name + "的Content窗口!");
            }

            //取消窗口WS_EX_COMPOSITED样式,以解决本控件切换内容窗口时图像卡顿的问题
            UnsetStyle(NativeConst.GWL_EXSTYLE, NativeConst.WS_EX_COMPOSITED);

            if (_currentShowForm != null)
            {
                //toForm.Dock = DockStyle.Fill;

                WindowAnimator.AnimateWindow(_currentShowForm.Handle, _switchMilliseconds,
                                             WindowAnimator.AW_HIDE | switchFlags);
                WindowAnimator.AnimateWindow(toForm.Handle, _switchMilliseconds,
                                             WindowAnimator.AW_ACTIVATE | switchFlags);

                //_currentShowForm.Dock = DockStyle.None;
                //_currentShowForm.Location = new Point(0, 0);
                //_currentShowForm.Size = new Size(1, 1);
            }
            else
            {
                //toForm.Dock = DockStyle.Fill;
                WindowAnimator.AnimateWindow(toForm.Handle, _switchMilliseconds,
                                             WindowAnimator.AW_ACTIVATE | switchFlags);
            }
            _currentShowForm     = toForm;
            _currentShowFormName = name;

            //子窗口含有Tab和MainContentHolder时,切换时调用该接口函数,
            //完成其中下一级子窗体的延迟加载
            ISubContentHolder subContentHolder = _currentShowForm as ISubContentHolder;

            if (subContentHolder != null)
            {
                //执行下一级子窗体延迟加载
                subContentHolder.OnFirstShow();
            }

            //设置窗口WS_EX_COMPOSITED样式,以解决本控件单独刷新时闪烁的问题
            SetStyle(NativeConst.GWL_EXSTYLE, NativeConst.WS_EX_COMPOSITED);
        }
Exemple #2
0
        /// <summary>
        /// 直接显示指定名称的窗口
        /// </summary>
        /// <param name="name"></param>
        public void ShowForm(string name)
        {
            if (_currentShowFormName == name)
            {
                return;
            }

            Form toForm = null;

            if (_contentFormDict.ContainsKey(name))
            {
                toForm = _contentFormDict[name];
            }
            if (toForm == null)
            {
                throw new Exception("主内容区无法切换到名为" + name + "的Content窗口!");
            }

            //取消窗口WS_EX_COMPOSITED样式,以解决本控件切换内容窗口时图像卡顿的问题
            UnsetStyle(NativeConst.GWL_EXSTYLE, NativeConst.WS_EX_COMPOSITED);

            if (_currentShowForm != null)
            {
                NativeMethods.ShowWindow(_currentShowForm.Handle, NativeConst.SW_HIDE);
                NativeMethods.ShowWindow(toForm.Handle, NativeConst.SW_SHOW);
            }
            else
            {
                NativeMethods.ShowWindow(toForm.Handle, NativeConst.SW_SHOW);
            }
            _currentShowForm     = toForm;
            _currentShowFormName = name;

            //子窗口含有Tab和MainContentHolder时,切换时调用该接口函数,
            //完成其中下一级子窗体的延迟加载
            ISubContentHolder subContentHolder = _currentShowForm as ISubContentHolder;

            if (subContentHolder != null)
            {
                //执行下一级子窗体延迟加载
                subContentHolder.OnFirstShow();
            }

            //设置窗口WS_EX_COMPOSITED样式,以解决本控件单独刷新时闪烁的问题
            SetStyle(NativeConst.GWL_EXSTYLE, NativeConst.WS_EX_COMPOSITED);
        }