/// <summary> /// Draw 3D box according to style specification. There are four styles which our /// function know how to draw. /// </summary> /// <param name="graph">Graphics object used for drawing</param> /// <param name="rect">Box rectangle</param> /// <param name="style">Style of Box</param> public void Draw3DBox( Graphics graph, Rectangle rect, Canvas3DStyle style ) { Point pnt1 = Point.Empty, pnt2 = Point.Empty, pnt4 = Point.Empty; Point[] arrPoints = { pnt1, pnt2, pnt1, pnt4 }; switch( style ) { case Canvas3DStyle.Flat: graph.DrawRectangle( m_penDark, rect ); break; case Canvas3DStyle.Title: #region Canvas 3DStyle - Title graph.DrawRectangle( m_penDark, rect ); pnt1.X = rect.X+1; pnt1.Y = rect.Y+1; pnt2.X = rect.X+1; pnt2.Y = rect.Height-1; pnt4.X = rect.Width-1; pnt4.Y = rect.Y+1; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penLightLight, arrPoints ); #endregion break; case Canvas3DStyle.Raised: #region Canvas 3DStyle Raised // draw left upper corner pnt1.X = rect.X; pnt1.Y = rect.Y; pnt2.X = rect.X + rect.Width; pnt2.Y = rect.Y; pnt4.X = rect.X; pnt4.Y = rect.Y + rect.Height; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penDark, arrPoints ); pnt1.X++; pnt1.Y++; pnt2.X-=2; pnt2.Y++; pnt4.X++; pnt4.Y-=2; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penDarkDark, arrPoints ); pnt1.X = rect.X + rect.Width; pnt1.Y = rect.Y + rect.Height; pnt2.X = rect.X; pnt2.Y = rect.Y + rect.Height; pnt4.X = rect.X + rect.Width; pnt4.Y = rect.Y; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penLightLight, arrPoints ); pnt1.X--; pnt1.Y--; pnt2.X++; pnt2.Y--; pnt4.X--; pnt4.Y++; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penLight, arrPoints ); #endregion break; case Canvas3DStyle.Upped: #region Canvas 3D Style Upped // draw left upper corner pnt1.X = rect.X; pnt1.Y = rect.Y; pnt2.X = rect.X + rect.Width; pnt2.Y = rect.Y; pnt4.X = rect.X; pnt4.Y = rect.Y + rect.Height; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penLightLight, arrPoints ); pnt1.X++; pnt1.Y++; pnt2.X-=2; pnt2.Y++; pnt4.X++; pnt4.Y-=2; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penLight, arrPoints ); pnt1.X = rect.X + rect.Width; pnt1.Y = rect.Y + rect.Height; pnt2.X = rect.X; pnt2.Y = rect.Y + rect.Height; pnt4.X = rect.X + rect.Width; pnt4.Y = rect.Y; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penDarkDark, arrPoints ); pnt1.X--; pnt1.Y--; pnt2.X++; pnt2.Y--; pnt4.X--; pnt4.Y++; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penDark, arrPoints ); #endregion break; case Canvas3DStyle.Single: #region Canvas 3D Style Single // draw left upper corner pnt1.X = rect.X; pnt1.Y = rect.Y; pnt2.X = rect.Width; pnt2.Y = rect.Y; pnt4.X = rect.X; pnt4.Y = rect.Height; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penDark, arrPoints ); // draw right low corner pnt1.X = rect.Width; pnt1.Y = rect.Height; pnt2.X = rect.X; pnt2.Y = rect.Height; pnt4.X = rect.Width; pnt4.Y = rect.Y; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines( m_penLightLight, arrPoints ); #endregion break; } }
/// <summary> /// Draw 3D box according to style specification. There are four styles which our /// function know how to draw. /// </summary> /// <param name="graph">Graphics object used for drawing</param> /// <param name="rect">Box rectangle</param> /// <param name="style">Style of Box</param> public void Draw3DBox(Graphics graph, Rectangle rect, Canvas3DStyle style) { Point pnt1 = Point.Empty, pnt2 = Point.Empty, pnt4 = Point.Empty; Point[] arrPoints = { pnt1, pnt2, pnt1, pnt4 }; switch (style) { case Canvas3DStyle.Flat: graph.DrawRectangle(m_penDark, rect); break; case Canvas3DStyle.Title: #region Canvas 3DStyle - Title graph.DrawRectangle(m_penDark, rect); pnt1.X = rect.X + 1; pnt1.Y = rect.Y + 1; pnt2.X = rect.X + 1; pnt2.Y = rect.Height - 1; pnt4.X = rect.Width - 1; pnt4.Y = rect.Y + 1; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penLightLight, arrPoints); #endregion break; case Canvas3DStyle.Raised: #region Canvas 3DStyle Raised // draw left upper corner pnt1.X = rect.X; pnt1.Y = rect.Y; pnt2.X = rect.X + rect.Width; pnt2.Y = rect.Y; pnt4.X = rect.X; pnt4.Y = rect.Y + rect.Height; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penDark, arrPoints); pnt1.X++; pnt1.Y++; pnt2.X -= 2; pnt2.Y++; pnt4.X++; pnt4.Y -= 2; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penDarkDark, arrPoints); pnt1.X = rect.X + rect.Width; pnt1.Y = rect.Y + rect.Height; pnt2.X = rect.X; pnt2.Y = rect.Y + rect.Height; pnt4.X = rect.X + rect.Width; pnt4.Y = rect.Y; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penLightLight, arrPoints); pnt1.X--; pnt1.Y--; pnt2.X++; pnt2.Y--; pnt4.X--; pnt4.Y++; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penLight, arrPoints); #endregion break; case Canvas3DStyle.Upped: #region Canvas 3D Style Upped // draw left upper corner pnt1.X = rect.X; pnt1.Y = rect.Y; pnt2.X = rect.X + rect.Width; pnt2.Y = rect.Y; pnt4.X = rect.X; pnt4.Y = rect.Y + rect.Height; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penLightLight, arrPoints); pnt1.X++; pnt1.Y++; pnt2.X -= 2; pnt2.Y++; pnt4.X++; pnt4.Y -= 2; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penLight, arrPoints); pnt1.X = rect.X + rect.Width; pnt1.Y = rect.Y + rect.Height; pnt2.X = rect.X; pnt2.Y = rect.Y + rect.Height; pnt4.X = rect.X + rect.Width; pnt4.Y = rect.Y; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penDarkDark, arrPoints); pnt1.X--; pnt1.Y--; pnt2.X++; pnt2.Y--; pnt4.X--; pnt4.Y++; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penDark, arrPoints); #endregion break; case Canvas3DStyle.Single: #region Canvas 3D Style Single // draw left upper corner pnt1.X = rect.X; pnt1.Y = rect.Y; pnt2.X = rect.Width; pnt2.Y = rect.Y; pnt4.X = rect.X; pnt4.Y = rect.Height; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penDark, arrPoints); // draw right low corner pnt1.X = rect.Width; pnt1.Y = rect.Height; pnt2.X = rect.X; pnt2.Y = rect.Height; pnt4.X = rect.Width; pnt4.Y = rect.Y; // set new values to array of pointers arrPoints[0] = arrPoints[2] = pnt1; arrPoints[1] = pnt2; arrPoints[3] = pnt4; graph.DrawLines(m_penLightLight, arrPoints); #endregion break; } }