96 lines
3.0 KiB
C#

//
// Copyright ?2006-2010, Intel Corporation. All rights reserved.
//
// File: AdvancedPlatformSearch.cs
//
// Contents: Defintion of logic of inner pane (GUI componet)
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace AMT_SW_GUI
{
public partial class InnerPane : Panel
{
public InnerPane()
{
InitializeComponent();
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
Color fillColor = Color.FromArgb(255, 250, 249, 249);
public Color FillColor
{
get { return fillColor; }
set { fillColor = value; }
}
Color borderColor = Color.FromArgb(255, 164, 192, 223);
public Color BorderColor
{
get { return borderColor; }
set { borderColor = value; }
}
int roundCorners = 5;
public int RoundCorners
{
get { return roundCorners; }
set
{
if (value > 25)
{
roundCorners = 25;
}
else
{
if (value < 1) { roundCorners = 1; }
else { roundCorners = value; }
}
this.Refresh();
}
}
protected override void OnPaint(PaintEventArgs e)
{
int cornerSize = this.roundCorners * 2;
const float sweepAngle = 90.0f;
Rectangle panelRect = new Rectangle(this.Padding.Left, this.Padding.Top, this.Width - this.Padding.Right - this.Padding.Left, this.Height - this.Padding.Bottom - this.Padding.Top);
Rectangle tl = new Rectangle(this.Padding.Left, this.Padding.Top, cornerSize, cornerSize);
Rectangle bl = new Rectangle(this.Padding.Left, this.Padding.Top+ panelRect.Height - cornerSize - 1 , cornerSize, cornerSize);
Rectangle br = new Rectangle(panelRect.Width - cornerSize - 1 + this.Padding.Left, this.Padding.Top + panelRect.Height - cornerSize - 1, cornerSize, cornerSize);
Rectangle tr = new Rectangle(panelRect.Width - cornerSize - 1 + this.Padding.Left, this.Padding.Top, cornerSize, cornerSize);
GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddArc(tr, 270, sweepAngle);
path.AddArc(br, 360, sweepAngle);
path.AddArc(bl, 90, sweepAngle);
path.AddArc(tl, 180, sweepAngle);
path.CloseAllFigures();
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
SolidBrush fillBrush = new SolidBrush(fillColor);
e.Graphics.FillPath(fillBrush, path);
Pen borderPen = new Pen(borderColor, 1);
e.Graphics.DrawPath(borderPen, path);
path.Dispose();
fillBrush.Dispose();
borderPen.Dispose();
}
}
}