示例#1
0
 public void OnContainerShown()
 {
     for (int i = 0; i < _contentFormList.Count; i++)
     {
         Form form = _contentFormList[i];
         if (form != null)
         {
             //将窗口隐藏
             WindowAnimator.AnimateWindow(form.Handle, 1, WindowAnimator.AW_HIDE | WindowAnimator.AW_SLIDE | WindowAnimator.AW_HOR_POSITIVE);
         }
     }
     //for (int i = 0; i < _contentFormList.Count; i++)
     //{
     //    Form form = _contentFormList[i];
     //    if (form != null)
     //    {
     //        this.pnMain.Controls.Add(form);  //将窗口移动到主显示Panel中
     //    }
     //}
     for (int i = 0; i < _contentFormList.Count; i++)
     {
         Form form = _contentFormList[i];
         if (form != null)
         {
             form.Dock = DockStyle.Fill;      //设置窗口停靠模式为Fill
         }
     }
 }
示例#2
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);
        }