机房UI优化

机房重构已经进行了半个月了,刚开始的时候是很期待的,因为这次是C#语言的重构,很想看看面向对象技术在机房重构的应用。
这次机房一边实现功能,一边进行优化。
1.对主窗体的优化
这里写图片描述
1.首先主窗体没有采用之前的敲VB的时候用的MDI窗体,因为MDI窗体优化起来比较死板。所以这次用的就是普通窗体。
2.首先是整个窗体的圆角化,相比于之前的窗体边角进行圆角化之后,感觉更加美观。

using System.Drawing.Drawing2D;
public void SetWindowRegion()
        {
            System.Drawing.Drawing2D.GraphicsPath FormPath;
            FormPath = new System.Drawing.Drawing2D.GraphicsPath();
            Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
            FormPath = GetRoundedRectPath(rect, 10);
            this.Region = new Region(FormPath);

        }
        private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
        {
            int diameter = radius;
            Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
            GraphicsPath path = new GraphicsPath();

            // 左上角
            path.AddArc(arcRect, 180, 90);

            // 右上角
            arcRect.X = rect.Right - diameter;
            path.AddArc(arcRect, 270, 90);

            // 右下角
            arcRect.Y = rect.Bottom - diameter;
            path.AddArc(arcRect, 0, 90);

            // 左下角
            arcRect.X = rect.Left;
            path.AddArc(arcRect, 90, 90);
            path.CloseFigure();//闭合曲线
            return path;
        }
        //这个代码写在需要进行圆角化的窗体的Resize事件中
        private void frmStudentUI_Resize(object sender, EventArgs e)
        {
            SetWindowRegion();
        }

2、菜单栏
菜单栏采用工具ToolStrip。这个工具栏非常灵活,在里面可以添加标签框,还有下拉菜单,还有按钮。
3、容器
容器主要用了GroupBox,还有panel。
panel容器的主要作用是将其他窗体状态里面。这样普通窗体也就有了父窗体类似的功能。

            frmStudentInfo frmstudentinfo = new frmStudentInfo();//实例化窗体
            frmstudentinfo.TopLevel = false;
            frmstudentinfo.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;//将窗体设置为无边框
            frmstudentinfo.WindowState = FormWindowState.Maximized;//窗体打开后默认最大化
            frmpanel.Controls.Add(frmstudentinfo);//将要打开的窗体放进容器中
            frmstudentinfo.BackColor = this.BackColor;
            frmstudentinfo.Show();//打开窗体

未完待续……

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 31
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 31
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LLLDa_&

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值