Пример #1
0
        private void IniSystemButtons()
        {
            bool isShowMaxButton = _owner.MaximizeBox;
            bool isShowMinButton = _owner.MinimizeBox;

            //Colse
            SystemButton closeBtn = new SystemButton();

            SystemButtonArray[0]  = closeBtn;
            closeBtn.ToolTip      = "关闭";
            closeBtn.NormalImg    = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.close_normal.png");
            closeBtn.HighLightImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.close_highlight.png");
            closeBtn.DownImg      = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.close_down.png");
            closeBtn.LocationRect = new Rectangle(
                _owner.Width - closeBtn.NormalImg.Width,
                -1,
                closeBtn.NormalImg.Width,
                closeBtn.NormalImg.Height);
            //注册事件
            closeBtn.OnMouseDownEvent += new MouseDownEventHandler(this.CloseButtonEvent);


            //Max
            SystemButton MaxBtn = new SystemButton();

            SystemButtonArray[1] = MaxBtn;
            MaxBtn.ToolTip       = "最大化";
            if (isShowMaxButton)
            {
                MaxBtn.NormalImg         = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.max_normal.png");
                MaxBtn.HighLightImg      = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.max_highlight.png");
                MaxBtn.DownImg           = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.max_down.png");
                MaxBtn.OnMouseDownEvent += new MouseDownEventHandler(this.MaxButtonEvent);
                MaxBtn.LocationRect      = new Rectangle(
                    closeBtn.LocationRect.X - MaxBtn.NormalImg.Width,
                    -1,
                    MaxBtn.NormalImg.Width,
                    MaxBtn.NormalImg.Height);
            }
            else
            {
                MaxBtn.LocationRect = Rectangle.Empty;
            }

            //Min
            SystemButton minBtn = new SystemButton();

            SystemButtonArray[2] = minBtn;
            minBtn.ToolTip       = "最小化";
            if (!isShowMinButton)
            {
                minBtn.LocationRect = Rectangle.Empty;
                return;
            }

            minBtn.NormalImg         = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.min_normal.png");
            minBtn.HighLightImg      = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.min_highlight.png");
            minBtn.DownImg           = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.min_down.png");
            minBtn.OnMouseDownEvent += new MouseDownEventHandler(this.MinButtonEvent);
            if (isShowMaxButton)
            {
                minBtn.LocationRect = new Rectangle(
                    MaxBtn.LocationRect.X - minBtn.NormalImg.Width,
                    -1,
                    minBtn.NormalImg.Width,
                    minBtn.NormalImg.Height);
            }
            else
            {
                minBtn.LocationRect = new Rectangle(
                    closeBtn.LocationRect.X - minBtn.NormalImg.Width,
                    -1,
                    minBtn.NormalImg.Width,
                    minBtn.NormalImg.Height);
            }
        }
Пример #2
0
        private void IniSystemButtons()
        {
            bool isShowMaxButton = _owner.MaximizeBox;
            bool isShowMinButton = _owner.MinimizeBox;

            //Colse
            SystemButton closeBtn = new SystemButton();
            SystemButtonArray[0] = closeBtn;
            closeBtn.ToolTip = "关闭";
            closeBtn.NormalImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.close_normal.png");
            closeBtn.HighLightImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.close_highlight.png");
            closeBtn.DownImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.close_down.png");
            closeBtn.LocationRect = new Rectangle(
                _owner.Width - closeBtn.NormalImg.Width,
                -1,
                closeBtn.NormalImg.Width,
                closeBtn.NormalImg.Height);
            //注册事件
            closeBtn.OnMouseDownEvent += new MouseDownEventHandler(this.CloseButtonEvent);

            //Max
            SystemButton MaxBtn = new SystemButton();
            SystemButtonArray[1] = MaxBtn;
            MaxBtn.ToolTip = "最大化";
            if (isShowMaxButton)
            {
                MaxBtn.NormalImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.max_normal.png");
                MaxBtn.HighLightImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.max_highlight.png");
                MaxBtn.DownImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.max_down.png");
                MaxBtn.OnMouseDownEvent += new MouseDownEventHandler(this.MaxButtonEvent);
                MaxBtn.LocationRect = new Rectangle(
                    closeBtn.LocationRect.X - MaxBtn.NormalImg.Width,
                    -1,
                    MaxBtn.NormalImg.Width,
                    MaxBtn.NormalImg.Height);
            }
            else
            {
                MaxBtn.LocationRect = Rectangle.Empty;
            }

            //Min
            SystemButton minBtn = new SystemButton();
            SystemButtonArray[2] = minBtn;
            minBtn.ToolTip = "最小化";
            if (!isShowMinButton)
            {
                minBtn.LocationRect = Rectangle.Empty;
                return;
            }

            minBtn.NormalImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.min_normal.png");
            minBtn.HighLightImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.min_highlight.png");
            minBtn.DownImg = RenderHelper.GetImageFormResourceStream("ControlExs.FormEx.Res.SystemButtons.min_down.png");
            minBtn.OnMouseDownEvent += new MouseDownEventHandler(this.MinButtonEvent);
            if (isShowMaxButton)
            {
                minBtn.LocationRect = new Rectangle(
                    MaxBtn.LocationRect.X - minBtn.NormalImg.Width,
                    -1,
                    minBtn.NormalImg.Width,
                    minBtn.NormalImg.Height);
            }
            else
            {
                minBtn.LocationRect = new Rectangle(
                   closeBtn.LocationRect.X - minBtn.NormalImg.Width,
                   -1,
                   minBtn.NormalImg.Width,
                   minBtn.NormalImg.Height);
            }
        }