示例#1
0
        /// <summary>
        /// 初始化主窗口显示
        /// </summary>
        void InitFrameContainer()
        {
            this.ShowInTaskbar = true;

            FrameContainerConfig cfg = Env.ClientConfig.FrameContainerConfig;

            //还原状态
            if (cfg.WindowSize.Width > 0)
            {
                this.Size = cfg.WindowSize;
            }
            if (cfg.WindowState != -1)
            {
                this.WindowState = (FormWindowState)cfg.WindowState;
            }
            if (!cfg.Location.IsEmpty)
            {
                this.StartPosition = FormStartPosition.Manual;
                this.Location      = cfg.Location;
            }
            if (cfg.HostListWidth > 0)
            {
                this.mainContainer.SplitterDistance = cfg.HostListWidth;
            }
            //if (cfg.ChatAreaWidth > 0) this.bodyContainer.SplitterDistance = cfg.ChatAreaWidth;

            //绑定属性,以便于记录状态
            this.LocationChanged += (s, e) => { if (this.WindowState != FormWindowState.Minimized)
                                                {
                                                    cfg.Location = this.Location;
                                                }
            };
            this.SizeChanged += (s, e) =>
            {
                cfg.WindowState = (int)this.WindowState;
                if (this.WindowState == FormWindowState.Normal)
                {
                    cfg.WindowSize = this.Size;
                }
            };
            this.mainContainer.SplitterMoved += (s, e) => { cfg.HostListWidth = this.mainContainer.SplitterDistance; };
            //this.bodyContainer.SplitterMoved += (s, e) => { cfg.ChatAreaWidth = this.bodyContainer.SplitterDistance; };
            this.smSystem_Exit.Click    += (s, e) => ShutdownIPM();
            this.sm_System_Config.Click += (s, e) =>
            {
                new UI.Forms.SysConfig().ShowDialog();
            };


            //关闭到托盘
            this.FormClosing += (s, e) =>
            {
                if (Env.ClientConfig.FrameContainerConfig.MinimizeToTray && !isSystemOpClose)
                {
                    e.Cancel     = true;
                    this.Visible = false;
                }
            };
        }
示例#2
0
        /// <summary>
        /// 切换到浮动模式
        /// </summary>
        void HostView_SwitchToFloat()
        {
            if (hostContainer == null)
            {
                hostContainer = new ControlContainer()
                {
                    TopMost       = Env.ClientConfig.FrameContainerConfig.HostListContainerTopMost,
                    StartPosition = FormStartPosition.Manual,
                    ShowInTaskbar = true
                };
                FrameContainerConfig cfg = Env.ClientConfig.FrameContainerConfig;

                //还原状态
                if (cfg.HostListContainerSize.Width > 0)
                {
                    hostContainer.Size = cfg.HostListContainerSize;
                }
                if (cfg.HostListContainerWindowState != -1)
                {
                    hostContainer.WindowState = (FormWindowState)cfg.HostListContainerWindowState;
                }
                if (!cfg.HostListContainerLocation.IsEmpty)
                {
                    hostContainer.Location = cfg.HostListContainerLocation;
                }

                //绑定属性,以便于记录状态
                hostContainer.LocationChanged += (s, e) => { if (hostContainer.WindowState != FormWindowState.Minimized)
                                                             {
                                                                 cfg.HostListContainerLocation = hostContainer.Location;
                                                             }
                };
                hostContainer.SizeChanged += (s, e) =>
                {
                    cfg.HostListContainerWindowState = (int)hostContainer.WindowState;
                    if (hostContainer.WindowState != FormWindowState.Minimized)
                    {
                        cfg.HostListContainerSize = hostContainer.Size;
                    }
                };
                hostContainer.TopMostChanged += (s, e) => { Env.ClientConfig.FrameContainerConfig.HostListContainerTopMost = hostContainer.TopMost; };
                hostContainer.FormClosing    += (s, e) =>
                {
                    if (!isSystemOpClose)
                    {
                        if (Env.ClientConfig.FrameContainerConfig.MinimizeToTray)
                        {
                            e.Cancel = true; hostContainer.Visible = false;
                        }
                        else
                        {
                            ShutdownIPM();
                        }
                    }
                    else
                    {
                        hostContainer.ClearControl();
                    }
                };
            }
            hostContainer.EmbedControl(hostView);
            hostContainer.Show();
            this.mainContainer.Panel1Collapsed = true;
            Env.ClientConfig.FrameContainerConfig.HostListFloat = true;

            this.Visible = chat.SessionCount > 0;
        }