Hi! I have form in C# windows application. I want use it application in desktop and notebook or tablet. But its size different. How I can define device desktop for universal device?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RKeeper
{
public partial class User : Form
{
public static bool istxtLogActive = true;
public User()
{
InitializeComponent();
btnGroup();
}
private void User_Load(object sender, EventArgs e)
{
this.Size = Screen.PrimaryScreen.WorkingArea.Size;
}
private void btnClick(object sender, EventArgs e)
{
string number = (sender as Button).Text;
if (istxtLogActive)
{
txtLog.Text += number;
}
else
{
txtPas.Text += number;
}
}
private void TextBox_LostFocus(object sender, EventArgs e)
{
if ((sender as TextBox).Name == "txtLog")
{
istxtLogActive = true;
}
else
{
istxtLogActive = false;
}
}
public void btnGroup()
{
int w = (int)this.ClientSize.Width; // ширина окна
int h = (int)this.ClientSize.Height; // высота окна
//this.ClientSize = new System.Drawing.Size(w * h, h * w);
txtLog.LostFocus += new EventHandler(TextBox_LostFocus);
txtPas.LostFocus += new EventHandler(TextBox_LostFocus);
btn1.BackColor = Color.Green;
btn2.BackColor = Color.Green;
btn3.BackColor = Color.Green;
btn4.BackColor = Color.Green;
btn5.BackColor = Color.Green;
btn6.BackColor = Color.Green;
btn7.BackColor = Color.Green;
btn8.BackColor = Color.Green;
btn9.BackColor = Color.Green;
btn0.BackColor = Color.Green;
btn10.BackColor = Color.Green;
btn11.BackColor = Color.Green;
btn12.BackColor = Color.Red;
btn1.Click += new EventHandler(btnClick);
btn2.Click += new EventHandler(btnClick);
btn3.Click += new EventHandler(btnClick);
btn4.Click += new EventHandler(btnClick);
btn5.Click += new EventHandler(btnClick);
btn6.Click += new EventHandler(btnClick);
btn7.Click += new EventHandler(btnClick);
btn8.Click += new EventHandler(btnClick);
btn9.Click += new EventHandler(btnClick);
btn0.Click += new EventHandler(btnClick);
btn10.Click += new EventHandler(btnClick);
}
private void btn11_Click(object sender, EventArgs e)
{
string number = (sender as Button).Text;
if (istxtLogActive)
{
txtLog.Text = "";
}
else
{
txtPas.Text = "";
}
}
private void tmr_Tick(object sender, EventArgs e)
{
label2.Text = DateTime.Now.ToString("hh:mm:ss tt");
}
private void btn12_Click(object sender, EventArgs e)
{
if (txtLog.Text == "1" && txtPas.Text == "2")
{
mainForm mn = new mainForm();
mn.ShowDialog();
}
else
{
MessageBox.Show("Логин ё рамз нодуруст аст!");
txtLog.Focus();
}
txtLog.Text = "";
txtPas.Text = "";
}
private void txtLog_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
txtPas.Focus();
}
private void txtPas_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
btn12.Focus();
}
}
}