Интернет-журнал "Домашняя лаборатория", 2007 №9 - Журнал «Домашняя лаборатория»
Шрифт:
Интервал:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentMode1;
using System.Windows.Forms;
using System.Data;
using Shapes;
namespace Final
{
/// <summary>
/// Эта форма обеспечивает интерфейс для создания,
/// рисования, показа, перемещения, сохранения в списке
/// и выполнения других операций над объектами семейства
/// геометрических фигур. Форма имеет меню и
/// инструментальные панели.
/// </summary>
public class Form1 System.Windows.Forms.Form
{
//fields
Graphics graphic;
Brush brush, clearBrush;
Pen pen, clearPen;
Color color;
Figure current;
TwoWayList listFigure;
private System.Windows.Forms.MainMenu mainMenu1
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolBar tooiBar1
private System.Windows.Forms.MenuItem menuItem1
// аналогичные определения для других элементов меню
private System.Windows.Forms.MenuItem menuItem35;
private System.Windows.Forms.ToolBarButton toolBarButton1;
// аналогичные определения для других командных кнопок
private System.Windows.Forms.ToolBarButton toolBarButton18;
private System.ComponentMode1.IContainer components;
public Form1()
{
InitializeComponent ();
InitFields();
}
void InitFields()
{
graphic = CreateGraphics ();
color = SystemColors.ControlText;
brush = new SolidBrush(color);
clearBrush = new SolidBrush(SystemColors.Control);
pen = new Pen (color);
clearPen = new Pen(SystemColors.Control);
listFigure = new TwoWayList();
current = new Person (20, 50, 50);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool disposing)
{
if(disposing)
{
if (components!= null)
{
components.Dispose ();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support — do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent ()
{
// Код, инициализирующий компоненты и построенный
// дизайнером, опущен
}
#endregion
/// <summary>
/// Точка входа в приложение — процедура Main,
/// запускающая форму
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void menuItem7_Click(object sender, System.EventArgs e)
{
createEllipse ();
}
void createEllipse ()
{
//clear old figure
if (current!= null) current.Show(graphic, clearPen, clearBrush);
//create ellipse
current = new Ellipse (50, 30, 180,180);
}
private void menuItem8_Click(object sender, System.EventArgs e)
{
createCircle ();
}
void createCircle ()
{
//clear old figure
if (current!= null) current.Show(graphic, clearPen, clearBrush);
//create circle
current = new Circle (30, 180, 180);
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
createLittleCircle ();
}
void createLittleCircle ()
{
//clear old figure
if (current!= null) current.Show(graphic, clearPen, clearBrush);
//create littlecircle
current = new Littlecircle (180, 180);
}
private void menuItem10_Click(object sender, System.EventArgs e)
{
createRectangle ();
}
void createRectangle ()
{
//clear old figure
if (current!= null) current.Show(graphic, clearPen, clearBrush);
//create rectangle current = new Rect(50, 30, 180,180);
}
private void menuItem11_Click(object sender, System.EventArgs e)
{
createSquare();
}
void createSquare()
{
//clear old figure
if (current!= null) current.Show(graphic, clearPen, clearBrush);
//create square
current = new Square(30, 180,180);
}
private void menuItem12_Click (object sender, System.EventArgs e)
{
createPerson ();
}
void createPerson ()
}
//clear old figure
if (current!= null) current.Show(graphic, clearPen, clearBrush);
//create person
current = new Person (20, 180, 180);
}
private void menuItem13_Click(object sender, System.EventArgs e)
{
showCurrent ();
}
void showCurrent()
{
//Show current
current.Show(graphic, pen, brush);
}
private void menuItem14_Click(object sender, System.EventArgs e)
{
clearCurrent ();
}
void clearCurrent()
{
//Clear current
current.Show(graphic, clearPen, clearBrush)
}
private void menuItem17_Click(object sender, System.EventArgs e)
{
incScale ();
}
void incScale ()
{
//Increase scale
current.Show(graphic, clearPen, clearBrush)
current.Scale (1.5);
current.Show(graphic, pen, brush);
}
private void menuItem18_Click(object sender, System.EventArgs e)
{
decScale ();
}
void decScale()
{
//Decrease scale
current.Show(graphic, clearPen, clearBrush)
current.Scale(2.0/3);
current.Show(graphic, pen, brush);
}
private void menuItem19_Click(object sender, System.EventArgs e)
{
moveLeft ();
}
void moveLeft()
{
//Move left
current.Show(graphic, clearPen, clearBrush)
current.Move(-20,0);
current.Show(graphic, pen, brush);
}
private void menuItem20_Click(object sender, System.EventArgs e)
{
moveRight ();
}
void moveRight()
{
//Move right
current.Show(graphic, clearPen, clearBrush)
current.Move(20,0);
current.Show(graphic, pen, brush);
}
private void menuItem21_Click(object sender, System.EventArgs e)
{
moveTop ();
Поделиться книгой в соц сетях:
Обратите внимание, что комментарий должен быть не короче 20 символов. Покажите уважение к себе и другим пользователям!