码迷,mamicode.com
首页 > Windows程序 > 详细

Metro UI 菜单(Winform)

时间:2015-11-18 12:17:58      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:

我有个项目需要要到菜单导航,就自己动作做了一个,感觉还可以,分享给大家。下载地址:http://files.cnblogs.com/files/dyj057/MetroUIMenu.zip

主要代码:

 private void SetElements()
        {
            if (Elements == null) return;
            int eWidth = BorderWidth + ElementWidth;
            int eHeight = BorderWidth + ElementHeight;
            int count = Elements.Count;
            int col = this.Size.Width / eWidth;
            if (col == 0) return;
            int row = (int)Math.Ceiling((double)count / col);
            Console.WriteLine("{0}x{1}",row,col);
            var k = 0;
            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < col; j++)
                {
                    if (k >= count) break;
                    var child = Elements[k];
                    child.Location = new Point(j * eWidth  + BorderWidth, eHeight * i + BorderWidth);
                    child.Size = new Size(ElementWidth, ElementHeight);
                    Console.WriteLine("X:{0} Y:{1} W:{2} H:{3}", child.Location.X, child.Location.Y, child.Size.Width,child.Size.Height);
                    if (!this.Controls.Contains(child))
                    {
                        child.SelectedChanged += Child_SelectedChanged;
                        this.Controls.Add(child);
                    }
                    k++;
                }
            }
        }

  

技术分享

技术分享

技术分享

 

Metro UI 菜单(Winform)

标签:

原文地址:http://www.cnblogs.com/dyj057/p/4973984.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!