Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

windows Forms

natalja muzq4enko Ученик (124), на голосовании 11 лет назад
using System;
using System.Windows.Forms;
using System.Drawing;

using MyButtonClass;

namespace Calc
{
class MyForm : Form
{
bool detectaoperacion = true;
string operacion;
double result;
double number1;
double number2;
const int x_begin = 10, y_begin = 45;
char separ =
System.Globalization.NumberFormatInfo.
CurrentInfo.NumberDecimalSeparator[0];
Label text;
bool flag_text = false;//flag novoj cepo4ki

public MyForm()
{
this.Text = "Calculator";
this.MaximizeBox = false;//ubratj knopku razvernutj
this.FormBorderStyle = FormBorderStyle.FixedSingle;
//klientskaja oblastj
this.ClientSize = new Size(140, 150);//razmer formy
//kartinka kaljkuljatora (ikonka)
this.Icon = new Icon(this.GetType(), "calc.ico");
//4toby ne vyskakivala ikonka try
InitLable();
InitButton();

Scale(new SizeF(Font.Height / 8f, Font.Height / 8f));//formatiruet vnutrennie elementy po otnoweniju k forme
}//end konstruktor

void InitLable()
{
text = new Label();
text.Parent = this;
text.Location = new Point(x_begin, y_begin / 2);
text.ForeColor = Color.Black;
text.BackColor = Color.White;

//stilj
text.BorderStyle = BorderStyle.FixedSingle;
text.Size = new Size(ClientSize.Width - 2 * x_begin, Font.Height);
text.TextAlign = ContentAlignment.TopRight;//nolj budet s prava

//text dolzen pojavljatsja s pravo
text.Font = new Font("Arial", 10);
text.TabStop = false;
//text.Text = "0"+separ;
text.Text = null;
}

void InitButton()
{
int x, y, dx, dy;//dx, dy smewenie
int cx = 20, cy = 20;
int col, row;//col, row wirina vysota
dx = cx + cx / 4;//rastojanie mezdu knopkami
dy = cy + cy / 4;

string[,] textBtn ={
{"7","8","9", "/","<-"},
{"4","5","6", "*","C"},
{"1","2","3", "-","="},
{"0"," +/-",separ.ToString(), "+",""}};

MyButton btn;
Color color = Color.Blue;
//Color color = this.ForeColor;

for (row = 0, y = y_begin;
row <= textBtn.GetUpperBound(0);
row++, y += dy)
{
for (col = 0, x = x_begin;
col <= textBtn.GetUpperBound(1);
col++, x += dx)
{
if (row == 3 && col == 4)
break;//continuo esli v centre
cy = 20;
if (col == 4 && row == 2)// 4toby sdelatj knopku "=" v 2 raza boljwe
{
cy += dy;
}
color = Color.Blue;
if (col == 3 || col == 4)
{
color = Color.Red;
}
btn = new MyButton(this, textBtn[row, col],
color, x, y, cx, cy);

//obrabot4ik sobytija
btn.Click += new EventHandler(btn_Click);

}
}

}

void btn_Click(object sender, EventArgs e)
{
MyButton btn = (MyButton)sender;
char chOperation = btn.Text[0];
if (chOperation >= '0' && chOperation <= '9')//esli eto cifra to
{
text.Text += btn.Text;// sozdajotsja cepo4ka zna4enij
}

}

Незнаю как сделать с операциями и равно очистить и так далее помогите
Дополнен 11 лет назад
c#
Голосование за лучший ответ
ГРИБ. Мастер (1732) 11 лет назад
Если не срочно, в почту все скиньте с полным описанием что нужно, вечером посмотрю.
Похожие вопросы