/// <summary> /// Paint the header with a Gradient Background /// </summary> private void OnHeaderPaint(object sender, PaintEventArgs e) { Bitmap buffer = new Bitmap(this.Width, this.Height, e.Graphics); Graphics g = Graphics.FromImage(buffer); //draw the header Rectangle headerR = new Rectangle(0, 0, this.Width, headerHeight); Brush l = new LinearGradientBrush(headerR, IrcColor.colors[_parent.IceChatColors.PanelHeaderBG1], IrcColor.colors[_parent.IceChatColors.PanelHeaderBG2], 300); g.FillRectangle(l, headerR); // http://www.scip.be/index.php?Page=ArticlesNET01&Lang=EN //System.Diagnostics.Debug.WriteLine("p:" + this.Parent.GetType()); //System.Diagnostics.Debug.WriteLine("pp:" + this.Parent.Parent.GetType()); if (this.Parent.Parent.GetType() != typeof(FormFloat)) { if (Application.RenderWithVisualStyles) { if (System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(System.Windows.Forms.VisualStyles.VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal)) { System.Windows.Forms.VisualStyles.VisualStyleRenderer renderer = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal); //which side are we docked on Rectangle rect = Rectangle.Empty; if (((IceDockPanel)this.Parent.Parent.Parent.Parent).Dock == DockStyle.Right) { rect = new Rectangle(0, 0, 22, 22); } else { rect = new Rectangle(this.Width - 22, 0, 22, 22); } renderer.DrawBackground(g, rect); } } } StringFormat sf = new StringFormat { Alignment = StringAlignment.Center }; Font headerFont = new Font("Verdana", 10); Rectangle centered = headerR; centered.Offset(0, (int)(headerR.Height - g.MeasureString(headerCaption, headerFont).Height) / 2); g.DrawString(headerCaption, headerFont, new SolidBrush(IrcColor.colors[_parent.IceChatColors.PanelHeaderForeColor]), centered, sf); e.Graphics.DrawImageUnscaled(buffer, 0, 0); buffer.Dispose(); g.Dispose(); l.Dispose(); headerFont.Dispose(); }
private void OnPaint(object sender, PaintEventArgs e) { try { //make the buffer we draw this all to Bitmap buffer = new Bitmap(this.Width, this.Height, e.Graphics); Graphics g = Graphics.FromImage(buffer); //draw the header g.Clear(IrcColor.colors[FormMain.Instance.IceChatColors.ServerListBackColor]); g.InterpolationMode = InterpolationMode.Low; g.SmoothingMode = SmoothingMode.HighSpeed; g.PixelOffsetMode = PixelOffsetMode.None; g.CompositingQuality = CompositingQuality.HighSpeed; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; Font headerFont = new Font("Verdana", 10); Rectangle headerR = new Rectangle(0, 0, this.Width, headerHeight); Brush l = new LinearGradientBrush(headerR, IrcColor.colors[FormMain.Instance.IceChatColors.PanelHeaderBG1], IrcColor.colors[FormMain.Instance.IceChatColors.PanelHeaderBG2], 300); g.FillRectangle(l, headerR); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; Rectangle centered = headerR; centered.Offset(0, (int)(headerR.Height - e.Graphics.MeasureString(headerCaption, headerFont).Height) / 2); g.DrawString(headerCaption, headerFont, new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.PanelHeaderForeColor]), centered, sf); if (this.Parent.Parent.GetType() != typeof(FormFloat)) { if (Application.RenderWithVisualStyles) { if (System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(System.Windows.Forms.VisualStyles.VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal)) { System.Windows.Forms.VisualStyles.VisualStyleRenderer renderer = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal); //which side are we docked on Rectangle rect = Rectangle.Empty; if (((IceDockPanel)this.Parent.Parent.Parent.Parent).Dock == DockStyle.Right) rect = new Rectangle(0, 0, 22, 22); else rect = new Rectangle(this.Width - 22, 0, 22, 22); renderer.DrawBackground(g, rect); } } } //draw each individual server Rectangle listR; if (this.panelButtons.Visible == true) listR = new Rectangle(0, headerHeight, this.Width, this.Height - headerHeight - panelButtons.Height); else listR = new Rectangle(0, headerHeight, this.Width, this.Height - headerHeight); int currentY = listR.Y; int _lineSize = Convert.ToInt32(this.Font.GetHeight(g)); BuildServerNodes(); int nodeCount = 0; bool flashTabs = false; //check if we have any flashing tabs for (int i = 0; i < FormMain.Instance.TabMain.TabPages.Count ; i++) { if (FormMain.Instance.TabMain.TabPages[i].FlashTab == true) { flashTabs = true; break; } } if (flashTabs == true) { //enable the flash tab timer flashTabTimer.Enabled = true; flashTabTimer.Start(); } else { //disable the flash tab timer flashTabTimer.Stop(); flashTabTimer.Enabled = false; } foreach (KeyValuePair<string, object> de in serverNodes) { //get the object type for this node string node = (string)de.Key; string[] nodes = node.Split(':'); object value = de.Value; int x = 16; Brush b; Pen p = new Pen(IrcColor.colors[FormMain.Instance.IceChatColors.TabBarCurrent]); nodeCount++; if (nodeCount <= topIndex) continue; if (nodeCount == selectedNodeIndex) { g.FillRectangle(new SolidBrush(SystemColors.Highlight), 0, currentY, this.Width, _lineSize); b = new SolidBrush(SystemColors.HighlightText); } else { b = new SolidBrush(IrcColor.colors[Convert.ToInt32(nodes[2])]); } if (value.GetType() == typeof(ServerSetting)) { if (nodeCount == selectedNodeIndex) { selectedServerID = ((ServerSetting)value).ID; } //TreeCollapse -- 0 - no items :: 1- show + sign (not collapsed) :: 2- show - sign (collapsed) if (((ServerSetting)value).TreeCollapse > 0) g.DrawRectangle(p, x - 12, currentY + 2, 8, 8); //now draw the + or - if it is collapsed or not if (((ServerSetting)value).TreeCollapse == 1) { //the plus sign g.DrawLine(p, x - 12, currentY + 6, x - 4, currentY + 6); g.DrawLine(p, x - 8, currentY + 2, x - 8, currentY + 10); } else if (((ServerSetting)value).TreeCollapse == 2) { //the minus sign g.DrawLine(p, x - 12, currentY + 6, x - 4, currentY + 6); } x = 16; } if (value.GetType() == typeof(IceTabPage)) { x = 32; if (((IceTabPage)value).WindowStyle == IceTabPage.WindowType.Channel || ((IceTabPage)value).WindowStyle == IceTabPage.WindowType.Query || ((IceTabPage)value).WindowStyle == IceTabPage.WindowType.DCCChat) { if (nodeCount == selectedNodeIndex) { selectedServerID = ((IceTabPage)value).Connection.ServerSetting.ID; ((IceTabPage)value).FlashTab = false; } } else if (((IceTabPage)value).WindowStyle == IceTabPage.WindowType.Window) { if (((IceTabPage)value).Connection == null) x = 16; } } switch (nodes[1]) { case "0": //disconnected g.DrawImage(StaticMethods.LoadResourceImage("disconnect-icon.png"), x, currentY, 16, 16); break; case "1": //connected g.DrawImage(StaticMethods.LoadResourceImage("connect-icon.png"), x, currentY, 16, 16); break; case "2": //connecting g.DrawImage(StaticMethods.LoadResourceImage("refresh-icon.png"), x, currentY, 16, 16); break; case "3": //channel //check if we are flashing or not if (((IceTabPage)value).FlashTab == true) { if (((IceTabPage)value).FlashValue == 1) g.DrawImage(StaticMethods.LoadResourceImage("channel.png"), x, currentY, 16, 16); } else g.DrawImage(StaticMethods.LoadResourceImage("channel.png"), x, currentY, 16, 16); break; case "4": //query case "5": //dcc chat if (((IceTabPage)value).FlashTab == true) { if (((IceTabPage)value).FlashValue == 1) g.DrawImage(StaticMethods.LoadResourceImage("new-query.ico"), x, currentY, 16, 16); } else g.DrawImage(StaticMethods.LoadResourceImage("new-query.ico"), x, currentY, 16, 16); break; case "6": //channel list g.DrawImage(StaticMethods.LoadResourceImage("channellist.png"), x, currentY, 16, 16); break; case "7": g.DrawImage(StaticMethods.LoadResourceImage("window-icon.ico"), x, currentY, 16, 16); break; } g.DrawString(nodes[4], this.Font, b, x + 16, currentY); b.Dispose(); if (currentY >= (listR.Height + listR.Y)) { vScrollBar.Maximum = serverNodes.Count - 2; vScrollBar.LargeChange = ((listR.Height - _lineSize) / _lineSize); break; } currentY += _lineSize; } if (currentY > listR.Height || vScrollBar.Value > 0) vScrollBar.Visible = true; else vScrollBar.Visible = false; l.Dispose(); sf.Dispose(); //paint the buffer onto the usercontrol e.Graphics.DrawImageUnscaled(buffer, 0, 0); buffer.Dispose(); headerFont.Dispose(); g.Dispose(); } catch (Exception ee) { FormMain.Instance.WriteErrorFile(FormMain.Instance.InputPanel.CurrentConnection,"ServerTree OnPaint", ee); } }
public override void Paint(GridColumnHandler column, sd.Graphics graphics, sd.Rectangle clipBounds, sd.Rectangle cellBounds, int rowIndex, swf.DataGridViewElementStates cellState, object value, object formattedValue, string errorText, swf.DataGridViewCellStyle cellStyle, swf.DataGridViewAdvancedBorderStyle advancedBorderStyle, ref swf.DataGridViewPaintParts paintParts) { if (object.ReferenceEquals(column.Widget, this.Widget.Columns[0])) { // paint the background if (paintParts.HasFlag(swf.DataGridViewPaintParts.Background)) { sd.Brush brush; if (cellState.HasFlag(swf.DataGridViewElementStates.Selected)) { brush = new sd.SolidBrush(cellStyle.SelectionBackColor); } else { brush = new sd.SolidBrush(cellStyle.BackColor); } graphics.FillRectangle(brush, cellBounds); paintParts &= ~swf.DataGridViewPaintParts.Background; } var node = controller.GetNodeAtRow(rowIndex); var treeRect = cellBounds; treeRect.X += node.Level * INDENT_WIDTH; treeRect.Width = 16; if (ClassicStyle && ClassicGridLines) { // Draw grid lines - for classic style using (var linePen = new sd.Pen(sd.SystemBrushes.ControlDark, 1.0f)) { var lineRect = treeRect; lineRect.X += 7; lineRect.Width = 10; linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; var isFirstSibling = node.IsFirstNode; var isLastSibling = node.IsLastNode; if (node.Level == 0) { // the Root nodes display their lines differently if (isFirstSibling && isLastSibling) { // only node, both first and last. Just draw horizontal line graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2); } else if (isLastSibling) { // last sibling doesn't draw the line extended below. Paint horizontal then vertical graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Top + cellBounds.Height / 2); } else if (isFirstSibling) { // first sibling doesn't draw the line extended above. Paint horizontal then vertical graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.X, cellBounds.Bottom); } else { // normal drawing draws extended from top to bottom. Paint horizontal then vertical graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Bottom); } } else { if (isLastSibling) { // last sibling doesn't draw the line extended below. Paint horizontal then vertical graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Top + cellBounds.Height / 2); } else { // normal drawing draws extended from top to bottom. Paint horizontal then vertical graphics.DrawLine(linePen, lineRect.X, cellBounds.Top + cellBounds.Height / 2, lineRect.Right, cellBounds.Top + cellBounds.Height / 2); graphics.DrawLine(linePen, lineRect.X, cellBounds.Top, lineRect.X, cellBounds.Bottom); } // paint lines of previous levels to the root int horizontalStop = lineRect.X - INDENT_WIDTH; var previousNode = node.Parent; while (previousNode != null) { if (!previousNode.IsLastNode) { // paint vertical line graphics.DrawLine(linePen, horizontalStop, lineRect.Top, horizontalStop, lineRect.Bottom); } previousNode = previousNode.Parent; horizontalStop = horizontalStop - INDENT_WIDTH; } } } } if (node.Item.Expandable) { // draw open/close glyphs if (swf.Application.RenderWithVisualStyles) { EnsureGlyphRenderers(); if (controller.IsExpanded(rowIndex)) { openRenderer.DrawBackground(graphics, new sd.Rectangle(treeRect.X, treeRect.Y + (treeRect.Height / 2) - 8, 16, 16)); } else { closedRenderer.DrawBackground(graphics, new sd.Rectangle(treeRect.X, treeRect.Y + (treeRect.Height / 2) - 8, 16, 16)); } } else { // todo: draw +/- manually var glyphRect = treeRect; glyphRect.Width = glyphRect.Height = 8; glyphRect.X += 3; glyphRect.Y += (treeRect.Height - glyphRect.Height) / 2; graphics.FillRectangle(sd.SystemBrushes.Window, glyphRect); graphics.DrawRectangle(sd.SystemPens.ControlDark, glyphRect); glyphRect.Inflate(-2, -2); if (!controller.IsExpanded(rowIndex)) { var midx = glyphRect.X + glyphRect.Width / 2; graphics.DrawLine(sd.SystemPens.ControlDarkDark, midx, glyphRect.Top, midx, glyphRect.Bottom); } var midy = glyphRect.Y + glyphRect.Height / 2; graphics.DrawLine(sd.SystemPens.ControlDarkDark, glyphRect.Left, midy, glyphRect.Right, midy); } } } }
private void OnPaint(object sender, PaintEventArgs e) { try { //make the buffer we draw this all to Bitmap buffer = new Bitmap(this.Width, this.Height, e.Graphics); Graphics g = Graphics.FromImage(buffer); //draw the header g.Clear(IrcColor.colors[FormMain.Instance.IceChatColors.NickListBackColor]); g.InterpolationMode = InterpolationMode.Low; g.SmoothingMode = SmoothingMode.HighSpeed; g.PixelOffsetMode = PixelOffsetMode.None; g.CompositingQuality = CompositingQuality.HighSpeed; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault; Font headerFont = new Font("Verdana", 10); Rectangle headerR = new Rectangle(0, 0, this.Width, headerHeight); //get the header colors here Brush l = new LinearGradientBrush(headerR, IrcColor.colors[FormMain.Instance.IceChatColors.PanelHeaderBG1], IrcColor.colors[FormMain.Instance.IceChatColors.PanelHeaderBG2], 300); g.FillRectangle(l, headerR); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; Rectangle centered = headerR; centered.Offset(0, (int)(headerR.Height - e.Graphics.MeasureString(headerCaption, headerFont).Height) / 2); g.DrawString(headerCaption, headerFont, new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.PanelHeaderForeColor]), centered, sf); if (this.Parent.Parent.GetType() != typeof(FormFloat)) { if (Application.RenderWithVisualStyles) { if (System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(System.Windows.Forms.VisualStyles.VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal)) { System.Windows.Forms.VisualStyles.VisualStyleRenderer renderer = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal); //which side are we docked on Rectangle rect = Rectangle.Empty; if (((IceDockPanel)this.Parent.Parent.Parent.Parent).Dock == DockStyle.Right) rect = new Rectangle(0, 0, 22, 22); else rect = new Rectangle(this.Width - 22, 0, 22, 22); renderer.DrawBackground(g, rect); } } } //draw the nicks Rectangle listR; if (this.panelButtons.Visible) listR = new Rectangle(0, headerHeight, this.Width, this.Height - headerHeight - panelButtons.Height); else listR = new Rectangle(0, headerHeight, this.Width, this.Height - headerHeight); if (currentWindow != null && currentWindow.WindowStyle == IceTabPage.WindowType.Channel) { PopulateNicks(); int currentY = listR.Y; int _lineSize = Convert.ToInt32(this.Font.GetHeight(g)); int randColor = -1; for (int i = topIndex; i < sortedNickNames.Count; i++) { Brush b = null; User u = currentWindow.GetNick(sortedNickNames[i].nick); if (FormMain.Instance.IceChatColors.RandomizeNickColors) { randColor++; if (randColor > (IrcColor.colors.Length-1)) randColor = 0; //make sure its not the same color as the background if (randColor == FormMain.Instance.IceChatColors.NickListBackColor) { randColor++; if (randColor > (IrcColor.colors.Length-1)) randColor = 0; } b = new SolidBrush(IrcColor.colors[randColor]); u.nickColor = randColor; } else { //get the correct nickname color for channel status for (int y = 0; y < u.Level.Length; y++) { if (u.Level[y]) { switch (currentWindow.Connection.ServerSetting.StatusModes[0][y]) { case 'q': b = new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.ChannelOwnerColor]); break; case 'a': b = new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.ChannelAdminColor]); break; case 'o': b = new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.ChannelOpColor]); break; case 'h': b = new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.ChannelHalfOpColor]); break; case 'v': b = new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.ChannelVoiceColor]); break; default: b = new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.ChannelRegularColor]); break; } break; } } if (b == null) b = new SolidBrush(IrcColor.colors[FormMain.Instance.IceChatColors.ChannelRegularColor]); } //check if selected, if so, draw the selector bar if (sortedNickNames[i].selected) { g.FillRectangle(new SolidBrush(SystemColors.Highlight), 0, currentY, this.Width, _lineSize); b = null; b = new SolidBrush(SystemColors.HighlightText); } //draw the nickname g.DrawString(sortedNickNames[i].nick, this.Font, b, 2, currentY); //draw the host if (FormMain.Instance.IceChatOptions.ShowNickHost) { if (currentWindow.Connection.ServerSetting.IAL.ContainsKey(u.NickName)) { string host = sortedNickNames[i].host; if (sortedNickNames[i].host.Length > 0) g.DrawString(sortedNickNames[i].host, this.Font, b, (this.Font.SizeInPoints * 14), currentY); } } currentY += _lineSize; if (currentY >= (listR.Height + listR.Y)) { vScrollBar.Maximum = sortedNickNames.Count - 2; vScrollBar.LargeChange = ((listR.Height - _lineSize) / _lineSize); break; } } if (currentY >= listR.Height || vScrollBar.Value > 0) vScrollBar.Visible = true; else { vScrollBar.Visible = false; } } l.Dispose(); sf.Dispose(); //paint the buffer onto the usercontrol e.Graphics.DrawImageUnscaled(buffer, 0, 0); buffer.Dispose(); g.Dispose(); headerFont.Dispose(); } catch (Exception ee) { FormMain.Instance.WriteErrorFile(currentWindow.Connection, "NickList OnPaint:" + currentWindow.Nicks.Values.Count, ee); } }
/// <summary> /// Paint the header with a Gradient Background /// </summary> private void OnHeaderPaint(object sender, PaintEventArgs e) { Bitmap buffer = new Bitmap(this.Width, this.Height, e.Graphics); Graphics g = Graphics.FromImage(buffer); //draw the header Rectangle headerR = new Rectangle(0, 0, this.Width, headerHeight); Brush l = new LinearGradientBrush(headerR, IrcColor.colors[_parent.IceChatColors.PanelHeaderBG1], IrcColor.colors[_parent.IceChatColors.PanelHeaderBG2], 300); g.FillRectangle(l, headerR); if (this.Parent.Parent.GetType() != typeof(FormFloat)) { if (Application.RenderWithVisualStyles) { if (System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(System.Windows.Forms.VisualStyles.VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal)) { System.Windows.Forms.VisualStyles.VisualStyleRenderer renderer = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(System.Windows.Forms.VisualStyles.VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal); //which side are we docked on Rectangle rect = Rectangle.Empty; if (((IceDockPanel)this.Parent.Parent.Parent.Parent).Dock == DockStyle.Right) rect = new Rectangle(0, 0, 22, 22); else rect = new Rectangle(this.Width - 22, 0, 22, 22); renderer.DrawBackground(g, rect); } } } StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; Font headerFont = new Font("Verdana", 10); Rectangle centered = headerR; centered.Offset(0, (int)(headerR.Height - g.MeasureString(headerCaption, headerFont).Height) / 2); g.DrawString(headerCaption, headerFont, new SolidBrush(IrcColor.colors[_parent.IceChatColors.PanelHeaderForeColor]), centered, sf); e.Graphics.DrawImageUnscaled(buffer, 0, 0); buffer.Dispose(); g.Dispose(); l.Dispose(); headerFont.Dispose(); }