Skip to content

Instantly share code, notes, and snippets.

@vitek999
Created February 21, 2016 16:20
Show Gist options
  • Save vitek999/df6f6a7d6be8380b77c5 to your computer and use it in GitHub Desktop.
Save vitek999/df6f6a7d6be8380b77c5 to your computer and use it in GitHub Desktop.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test_Alpha_govnokod_
{
public partial class Form1 : Form
{
//Переменные
string UserName;
int QuestionNumber = 1;
int TrueAns;
Form2 logger = new Form2();
public Form1()
{
InitializeComponent();
logger.Show();
LoadAllQuestion(QuestionNumber);
}
//Авторизация
private void button1_Click(object sender, EventArgs e)
{
if (UserNameBox.Text == "")
{
logger.ButLog("Error:[Bad User Name!];");
}
else
{
UserName = UserNameBox.Text;
string logmess = ("I: User: " + UserName + " was logged in successfully! ");
//вызов метода со второй формы для вывода лога (временный метод)
logger.ButLog(logmess);
tabControl1.SelectTab(1);
UserNameLabel1.Text = UserName;
UserNameLabel2.Text = UserName;
}
}
private void button2_Click(object sender, EventArgs e)
{
tabControl1.SelectTab(2);
string logmess = ("I: Frame was loaded in successfuly");
logger.ButLog(logmess);
}
public void LoadAllQuestion(int QuestionNumber)
{
if (QuestionNumber == 1)
{
labelQuest.Text = "Who are you?";
TrueAns = 1;
} else if (QuestionNumber == 2)
{
labelQuest.Text = "What is you name?";
TrueAns = 2;
}
/*
TODO:
More question!
*/
}
private void NextQuestion_Click(object sender, EventArgs e)
{
int ButAns;
if (checkBox1.Checked)
{
ButAns = 1;
} else if (checkBox2.Checked)
{
ButAns = 2;
} else if (checkBox3.Checked)
{
ButAns = 3;
} else
{
ButAns = 4;
}
if (ButAns == TrueAns)
{
MessageBox.Show("true");
}
else
{
MessageBox.Show("false");
}
QuestionNumber++;
LoadAllQuestion(QuestionNumber);
checkBox1.Checked = false;
checkBox2.Checked = false;
checkBox3.Checked = false;
checkBox4.Checked = false;
}
}
}
Form2. cs:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test_Alpha_govnokod_
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
string curTimeLong = DateTime.Now.ToLongTimeString();
richTextBox1.Text = ("[" + curTimeLong + "]: Program has been started!" + Environment.NewLine);
}
//Временный метод логирования происходящего(сделан для координат)
public void ButLog(string text)
{
string curTimeLong = DateTime.Now.ToLongTimeString();
richTextBox1.Text += ("[" + curTimeLong + "]: " + text + Environment.NewLine);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment