private void WindowsList_Paint(object sender, PaintEventArgs e) { try { if (DesignMode == true) { Graphics g = e.Graphics; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; if (1 == 1) { Pen p = new Pen(Color.Gray); p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; g.DrawLine(p, 0, this.headerHeight, this.Width, this.headerHeight); // Rectangle r = new Rectangle(0, 0, this.Width, this.headerHeight); g.DrawString("导航条", this.headerFont, new SolidBrush(this.ForeColor), r, sf); } if (1 == 1) { Rectangle r = new Rectangle(0, this.headerHeight, this.Width, this.Height - this.headerHeight); g.DrawString("窗体容器", this.Font, new SolidBrush(this.ForeColor), r, sf); } } else { List <CellObject> lstobj = new List <CellObject>(); Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; // LinearGradientBrush bru = new LinearGradientBrush(new Rectangle(0, 0, this.Width, this.Height), GlobalData.top_main_nav1, GlobalData.top_main_nav2, LinearGradientMode.Vertical); g.DrawImage(ResourcesHelper.GetImage("导航条"), new Rectangle(0, 0, this.Width, this.headerHeight)); // StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; int x = 120; int y = 0; int w = 0; int h = this.headerHeight; //画主页按钮 if (1 == 1) { if (lst.Count < 1) { return; } var form = lst[0]; string header = form.Text; Image home_img = ResourcesHelper.GetImage("工具栏_首页按钮"); Rectangle home = new Rectangle( 0, (h - 5 - home_img.Height), x, home_img.Height ); g.DrawImage(home_img, new Rectangle((x - home_img.Width) / 2, home.Y, home_img.Width, home_img.Height)); CellObject obj1 = new CellObject(); obj1.r = home; obj1.type = 1; obj1.data = form; lstobj.Add(obj1); } Rectangle move_r_all = new Rectangle(-100, -100, -100, -100); for (int i = 1; i < lst.Count; i++) { var form = lst[i]; string header = form.Text; w = (int)g.MeasureString(header, this.headerFont).Width + 2; Rectangle r_all = new Rectangle(x, y + 5, w + 5 + 20, h + 2); CellObject obj1 = new CellObject(); obj1.r = r_all; obj1.type = 1; obj1.data = form; Rectangle r = new Rectangle(x + (r_all.Width - w) / 2, y + 5, w, h + 2); if (move_form != null && form == (Form)move_form.data) { move_r_all = r_all; r_all = new Rectangle(r_all.X + (this.e_x - this.x), r_all.Y, r_all.Width, r_all.Height); r = new Rectangle(r.X + (this.e_x - this.x), r.Y, r.Width, r.Height); } if (move_form == null || form != (Form)move_form.data) { if (form == this.Controls[0]) { g.DrawImage(ResourcesHelper.GetImage("导航栏选中"), r_all); g.DrawString(header, this.headerFont, new SolidBrush(Color.Black), r, sf); } else { g.DrawImage(ResourcesHelper.GetImage("导航栏未选中"), r_all); g.DrawString(header, this.headerFont, new SolidBrush(Color.White), r, sf); } } x += w; // Image dhl_close = ResourcesHelper.GetImage("导航栏关闭"); r = new Rectangle(r_all.X + r_all.Width - 8, r_all.Y - 5, dhl_close.Width + 1, dhl_close.Height + 1); x += 40; // CellObject obj2 = new CellObject(); obj2.r = r; obj2.type = 2; obj2.data = form; if (move_form == null || form != (Form)move_form.data) { g.DrawImage(DrawHelper.WaySOne((Bitmap)dhl_close), r); } // if (i > 0) { lstobj.Add(obj2); } lstobj.Add(obj1); } //画正在移动的矩形 if (isMove == 1 && move_form != null) { var form = (Form)move_form.data; string header = form.Text; w = (int)g.MeasureString(header, this.headerFont).Width + 2; Rectangle r_all = move_r_all; Rectangle r = new Rectangle(r_all.X + (r_all.Width - w) / 2, y + 5, w, h + 2); r_all = new Rectangle(r_all.X + (this.e_x - this.x), r_all.Y, r_all.Width, r_all.Height); r = new Rectangle(r.X + (this.e_x - this.x), r.Y, r.Width, r.Height); if (form == this.Controls[0]) { g.DrawImage(ResourcesHelper.GetImage("导航栏选中"), r_all); g.DrawString(header, this.headerFont, new SolidBrush(Color.Black), r, sf); } else { g.DrawImage(ResourcesHelper.GetImage("导航栏未选中"), r_all); g.DrawString(header, this.headerFont, new SolidBrush(Color.White), r, sf); } Image dhl_close = ResourcesHelper.GetImage("导航栏关闭"); r = new Rectangle(r_all.X + r_all.Width - 8, r_all.Y - 5, dhl_close.Width + 1, dhl_close.Height + 1); g.DrawImage(DrawHelper.WaySOne((Bitmap)dhl_close), r); } // bru = new LinearGradientBrush(new Rectangle(0, headerHeight - 3, this.Width, 5), Color.White, Color.White, LinearGradientMode.Horizontal); e.Graphics.FillRectangle(bru, new Rectangle(0, headerHeight, this.Width, 2)); this.lstobj = lstobj; } } catch (Exception ex) { e.Graphics.DrawString(ex.ToString(), this.Font, Brushes.Black, 0, 0); } }
private void ModuleList_Paint(object sender, PaintEventArgs e) { try { if (DesignMode == true) { Graphics g = e.Graphics; /* * if (headerBackImage != null) * { * g.DrawImage(headerBackImage, 0, 0, headerWidth, this.Height); * }*/ // StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; if (1 == 1) { Pen p = new Pen(Color.Gray); p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; g.DrawLine(p, headerWidth, 0, headerWidth, this.Height); // Rectangle r = new Rectangle(0, 0, headerWidth, this.Height); g.DrawString("标题", this.headerFont, new SolidBrush(this.ForeColor), r, sf); } if (1 == 1) { Rectangle r = new Rectangle(headerWidth, 0, this.Width - headerWidth, this.Height); g.DrawString("容器", this.Font, new SolidBrush(this.ForeColor), r, sf); } } else { List <CellObject> lstobj = new List <CellObject>(); Graphics g = e.Graphics; // LinearGradientBrush bru = new LinearGradientBrush(new Rectangle(0, 0, headerWidth + 50, this.Height + 2), GlobalData.left_nav1, GlobalData.left_nav2, LinearGradientMode.Horizontal); // g.FillRectangle(bru, new Rectangle(0, -1, headerWidth + 50, this.Height + 2)); g.DrawImage(ResourcesHelper.GetImage("菜单栏"), new Rectangle(0, -1, ResourcesHelper.GetImage("菜单栏").Width, this.Height + 1)); g.DrawImage(ResourcesHelper.GetImage("左侧底部公众号"), new Rectangle(0, this.Height - ResourcesHelper.GetImage("左侧底部公众号").Height, ResourcesHelper.GetImage("左侧底部公众号").Width, ResourcesHelper.GetImage("左侧底部公众号").Height)); // g.SmoothingMode = SmoothingMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; // FillRoundRectangle(g, new SolidBrush(this.BackColor), new Rectangle(headerWidth, -1, 100, this.Height + 50), 20); // StringFormat sf = new StringFormat(); int w = 150; int h = 0; int x = (this.headerWidth - w) / 2; int y = 10; if (headerBackImage != null) { g.DrawImage(headerBackImage, 0, 0, headerWidth, this.Height); } // for (int i = 0; i < lst.Count; i++) { var form = lst[i]; string header = form.Text; h = 60; Rectangle r = new Rectangle(x, y + 20, w, h); CellObject obj1 = new CellObject(); obj1.r = new Rectangle(0, y, this.headerWidth, h); obj1.data = form; lstobj.Add(obj1); Image icon = null; dicIcon.TryGetValue(form, out icon); var p = this.PointToClient((System.Windows.Forms.Cursor.Position)); if (form == this.Controls[0]) { if (icon == null) { Helper.DrawHelper.FillRoundRectangle(g, Brushes.Blue, r, 5); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; g.DrawString(header, this.headerFont, new SolidBrush(Color.White), r, sf); } else { h = icon.Height + 5; dicSelectIcon.TryGetValue(form, out icon); g.DrawImage(icon, new Rectangle(r.X, r.Y, icon.Width, icon.Height)); } } else if (r.Contains(p) == true) { if (icon == null) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; g.DrawString(header, this.headerFont, new SolidBrush(Color.White), r, sf); } else { h = icon.Height + 5; g.DrawImage(icon, new Rectangle(r.X, r.Y, icon.Width, icon.Height)); } } else { if (icon == null) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; g.DrawString(header, this.headerFont, new SolidBrush(Color.White), r, sf); } else { h = icon.Height + 5; g.DrawImage(icon, new Rectangle(r.X, r.Y, icon.Width, icon.Height)); } } // // y += h; } this.lstobj = lstobj; // } } catch (Exception ex) { e.Graphics.DrawString(ex.ToString(), this.Font, Brushes.Black, 0, 0); } }