using System;
using System .Collections .Generic;
using System .ComponentModel;
using System .Drawing;
using System .Windows .Forms;
using MoveGraphLibrary;
namespace UserDrivenApplications
{
public partial class Form_About : Form
{
Mover mover;
string strAbout = "This program is designed especially to accompany\n" +
"the article \"User-Driven Applications\".\n" +
"All codes of this program are available.\n" +
"Other related programs and documents can be found at\n" +
" www.sourceforge.net \n" +
" in the project MoveableGraphics";
string [] strAuthor = new string [] {"By Sergey Andreyev",
"( andreyev_sergey@yahoo.com )"};
string strDate = "April 2010";
Font fontAuthor;
TextM infoAbout, infoDate;
LinkedRectangles lrAuthor;
TextMR citation;
// -------------------------------------------------
public Form_About ()
{
InitializeComponent ();
mover = new Mover (this);
int cxL = 20;
int cyT = 20;
infoAbout = new TextM (this, new Point (cxL, cyT), strAbout);
infoAbout .BackColor = Color .LightYellow;
Rectangle rcAbout = infoAbout .RectAround;
fontAuthor = new Font (Font .Name, (float) (Font .SizeInPoints * 1.1), FontStyle .Bold);
Size [] sizes = Auxi_Geometry .RoundMeasureStrings (this, strAuthor, fontAuthor);
Rectangle [] rcs = new Rectangle [2];
rcs [0] = new Rectangle (rcAbout .Left, rcAbout .Bottom + 12, sizes [0] .Width, sizes [0] .Height);
rcs [1] = new Rectangle (rcs [0] .Left + rcs [0] .Width * 2 / 3, rcs [0] .Bottom, sizes [1] .Width, sizes [1] .Height);
lrAuthor = new LinkedRectangles (rcs);
citation = new TextMR (this, new Point (Auxi_Geometry .Middle (rcAbout) .X, rcs [1] .Bottom + 2 * rcs [1] .Height),
"\"... for the joy of the working ...\"",
new Font ("Times New Roman", (float) (Font .SizeInPoints * 1.8)), 12, Color .Blue, false, BackColor);
citation .Location = new Point (citation .Location .X, rcs [1] .Bottom + citation .RectAround .Height / 2);
infoDate = new TextM (this, new Point (rcAbout .Left, citation .RectAround .Bottom), strDate);
infoDate .ShowFrame = false;
infoDate .BackColor = Color .Transparent;
infoDate .Move (infoAbout .Width - infoDate .Width, - infoDate .Height);
ClientSize = new Size (infoDate .RectAround .Right + cxL, infoDate .RectAround .Bottom + cyT);
mover .Add (infoDate);
mover .Add (citation);
mover .Add (lrAuthor);
mover .Add (infoAbout);
}
// ------------------------------------------------- OnPaint
private void OnPaint (object sender, PaintEventArgs e)
{
Graphics grfx = e .Graphics;
infoAbout .Draw (grfx);
for (int i = 0; i < strAuthor .Length; i++)
{
Auxi_Drawing .DrawText (grfx, strAuthor [i], fontAuthor, 0, ForeColor, lrAuthor .Rectangle (i) .Location, TextBasis .NW);
}
citation .Draw (grfx);
infoDate .Draw (grfx);
}
// ------------------------------------------------- OnMouseDown
private void OnMouseDown (object sender, MouseEventArgs mea)
{
mover .Catch (mea .Location, mea .Button);
}
// ------------------------------------------------- OnMouseUp
private void OnMouseUp (object sender, MouseEventArgs e)
{
mover .Release ();
}
// ------------------------------------------------- OnMouseMove
private void OnMouseMove (object sender, MouseEventArgs mea)
{
if (mover .Move (mea .Location))
{
Invalidate ();
}
}
}
}