///---------------------------------------------------------------------------------------- /// <summary> /// Update the current graph with the new values. /// </summary> /// <returns>True, if the update was successful, otherwise false</returns> ///---------------------------------------------------------------------------------------- public bool UpdateGraph(int[] full_downlines, int[] full_uplines) { try { Bitmap bm = new Bitmap(this.Width, this.Height, PixelFormat.Format16bppRgb555); Graphics g = Graphics.FromImage((Image)bm); g.FillRegion(new LinearGradientBrush( new PointF(bm.Width / 2, 0), new PointF(bm.Width / 2, bm.Height) , Color.Gray, Color.Black) , new Region(new Rectangle(0, 0, bm.Width, bm.Height))); //draw each line in the graph DrawNetworkGraph.DrawGraph(g, full_downlines, full_uplines, Height, Width, false); IntPtr oBm = bm.GetHbitmap(); this.Image = Image.FromHbitmap(oBm); DeleteObject(oBm); bm.Dispose(); g.Dispose(); } catch (Exception) { return(false); } return(true); }
private void DrawIconRepresentation() { Bitmap b = new Bitmap(16, 16, PixelFormat.Format16bppRgb555); Graphics g = Graphics.FromImage((Image)b); g.FillRegion(new LinearGradientBrush(new PointF(b.Width / 2, 0), new PointF(b.Width / 2, b.Height ), Color.Gray, Color.Black), new Region(new Rectangle(0, 0, 16, 16))); if (!icon_representation) { //draw each line in the graph DrawNetworkGraph.DrawGraph(g, downlines, uplines,16,16 ,true); } else { //draw cool icon DrawCoolIcon(g); b.MakeTransparent(Color.FromArgb(255, 0, 255)); } IntPtr oIcon = b.GetHicon(); m_notifyicon.Icon = Icon.FromHandle(oIcon); g.Dispose(); b.Dispose(); DestroyIcon(oIcon); }