SidebarLibrary.WinControls.OutlookBar.DrawArrowButton C# (CSharp) Method

DrawArrowButton() private method

private DrawArrowButton ( Rectangle buttonRect, ButtonState state ) : void
buttonRect System.Drawing.Rectangle
state ButtonState
return void
		void DrawArrowButton(Rectangle buttonRect, ButtonState state)
		{
			if (HasChild())
			{
				// No drawing buttons if there is a child control in the current band
				return;
			}

			// Directly draw the arrow button
			using (Graphics g = Graphics.FromHwnd(Handle))
			{
				bool up = true;
				ScrollButton buttonType = ScrollButton.Up;
				if (buttonRect.Equals(downArrowRect))
				{
					buttonType = ScrollButton.Down;
					up = false;
				}

				if (flatArrowButtons && !HasChild())
				{
					int first;
					int last;
					GetVisibleRange(g, out first, out last);

					if (up && first == 0)
					{
						// up arrow is not visible no need to pain it
						return;
					}
					else if (up == false && last == bands[currentBandIndex].Items.Count - 1)
					{
						// down arrow is not visible no need to pain it
						return;
					}

					// If using flat button and the mouse is still over the button
					// then don't allow drawing it without the hightlight
					Point pos = Control.MousePosition;
					pos = PointToClient(pos);
					if (buttonRect.Contains(pos))
					{
						if (up)
							UpFlatArrowState = DrawState.Hot;
						else
							DownFlatArrowState = DrawState.Hot;

						DrawFlatArrowButton(g, buttonRect, up, DrawState.Hot);
					}
					else
					{
						if (up)
							UpFlatArrowState = DrawState.Normal;
						else
							DownFlatArrowState = DrawState.Normal;

					DrawFlatArrowButton(g, buttonRect, up, DrawState.Normal);
					}
				}
				else
					ControlPaint.DrawScrollButton(g, buttonRect, buttonType, state);
			}
		}