PageRenderTime 4ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/CmsCheckin/AdminLogin.cs

https://bitbucket.org/mahalowe/bvcms
C# | 151 lines | 135 code | 16 blank | 0 comment | 11 complexity | a19a116ca734ab26d1d056bcbca94b78 MD5 | raw file
  1using System;
  2using System.Collections.Generic;
  3using System.ComponentModel;
  4using System.Data;
  5using System.Drawing;
  6using System.Linq;
  7using System.Text;
  8using System.Windows.Forms;
  9using System.Net;
 10using System.Xml.Linq;
 11using System.Drawing.Printing;
 12using System.Xml.Serialization;
 13using System.IO;
 14
 15namespace CmsCheckin
 16{
 17    public partial class AdminLogin : Form
 18    {
 19        public AdminLogin()
 20        {
 21            InitializeComponent();
 22
 23            b1.Click += new EventHandler(buttonclick);
 24            b2.Click += new EventHandler(buttonclick);
 25            b3.Click += new EventHandler(buttonclick);
 26            b4.Click += new EventHandler(buttonclick);
 27            b5.Click += new EventHandler(buttonclick);
 28            b6.Click += new EventHandler(buttonclick);
 29            b7.Click += new EventHandler(buttonclick);
 30            b8.Click += new EventHandler(buttonclick);
 31            b9.Click += new EventHandler(buttonclick);
 32            b0.Click += new EventHandler(buttonclick);
 33
 34            bq.Click += new EventHandler(buttonclick);
 35            bw.Click += new EventHandler(buttonclick);
 36            be.Click += new EventHandler(buttonclick);
 37            br.Click += new EventHandler(buttonclick);
 38            bt.Click += new EventHandler(buttonclick);
 39            by.Click += new EventHandler(buttonclick);
 40            bu.Click += new EventHandler(buttonclick);
 41            bi.Click += new EventHandler(buttonclick);
 42            bo.Click += new EventHandler(buttonclick);
 43            bp.Click += new EventHandler(buttonclick);
 44
 45            ba.Click += new EventHandler(buttonclick);
 46            bs.Click += new EventHandler(buttonclick);
 47            bd.Click += new EventHandler(buttonclick);
 48            bf.Click += new EventHandler(buttonclick);
 49            bg.Click += new EventHandler(buttonclick);
 50            bh.Click += new EventHandler(buttonclick);
 51            bj.Click += new EventHandler(buttonclick);
 52            bk.Click += new EventHandler(buttonclick);
 53            bl.Click += new EventHandler(buttonclick);
 54
 55            bz.Click += new EventHandler(buttonclick);
 56            bx.Click += new EventHandler(buttonclick);
 57            bc.Click += new EventHandler(buttonclick);
 58            bv.Click += new EventHandler(buttonclick);
 59            bb.Click += new EventHandler(buttonclick);
 60            bn.Click += new EventHandler(buttonclick);
 61            bm.Click += new EventHandler(buttonclick);
 62
 63            password.KeyPress += textBox_KeyPress;
 64
 65            password.Enter += textbox_Enter;
 66            password.Focus();
 67        }
 68
 69        private void button1_Click(object sender, EventArgs e)
 70        {
 71        }
 72
 73        TextBox current = null;
 74        private void Login_Load(object sender, EventArgs e)
 75        {
 76            password.Focus();
 77        }
 78        void buttonclick(object sender, EventArgs e)
 79        {
 80            var b = sender as Button;
 81            var d = b.Name[1];
 82            KeyStroke(d);
 83        }
 84        private void textBox_KeyPress(object sender, KeyPressEventArgs e)
 85        {
 86            if (current == null)
 87                return;
 88            if (e.KeyChar == '\b')
 89                BackSpace();
 90            else
 91                KeyStroke(e.KeyChar);
 92            e.Handled = true;
 93        }
 94        private void KeyStroke(char d)
 95        {
 96            if (current == null)
 97                return;
 98            current.Text += d;
 99            current.Focus();
100            current.Select(current.Text.Length, 0);
101        }
102        private void BackSpace()
103        {
104            if (current == null)
105                return;
106            var t = current.Text;
107            var len = t.Length - 1;
108            if (len < 0)
109                len = 0;
110            current.Text = t.Substring(0, len);
111            current.Focus();
112            current.Select(current.Text.Length, 0);
113        }
114
115        private void bdot_Click(object sender, EventArgs e)
116        {
117            KeyStroke('.');
118        }
119
120        private void textbox_Enter(object sender, EventArgs e)
121        {
122            current = (TextBox)sender;
123        }
124
125        private void bbs_Click(object sender, EventArgs e)
126        {
127            BackSpace();
128        }
129
130        private void bang_Click(object sender, EventArgs e)
131        {
132            KeyStroke('!');
133        }
134
135        private void bslash_Click(object sender, EventArgs e)
136        {
137            KeyStroke('/');
138        }
139
140        private void bcolon_Click(object sender, EventArgs e)
141        {
142            KeyStroke(':');
143        }
144
145        private void AdminLogin_FormClosing(object sender, FormClosingEventArgs e)
146        {
147            if (password.Text != Program.AdminPassword)
148                e.Cancel = true;
149        }
150   }
151}