Using system; using system.componentmodel; using system.data; using system.windows.form; using system.text;
Namespace pzcontrol {///
///
// Todo: Add any initialization pens.bluepen = new pen (color.blue, 1); pens.redpen = new pen (color.red, 1); pens.yellowpen = new pen (color.bisque, 1); this.money = 0m; this.Width = W; this.height = h; this.currentnum = this.nums [12]; this.upindex = 12;} ///
public void StartSet (Color SelectedColor, Color UselectedColor, decimal MoneyP) {if (SelectedColor == UselectedColor) {MessageBox.Show ( "time when selecting the color is not selected and is not provided to the same!"); return;} this.selectedColor = SELECTEDCOLOR; this.unselectedColor = uselectedColor; this.moneyzf = Moneyp; this.moneyup = MONEYP; this.Modified = false;} ///
Public Bool Zf {Get {Return this.zf;} set {this.zf = value; this.drawMoney (); this.modified = true;}}
///
i ; w = i * segment; dc.drawline (Pens.bluepen, new point (w, 0), new point (w, h)); i ; w = i * segment; dc.drawline (Pens.yellowpen, New Point (w, 0), new point (w, h)); i ; w = i * segment; dc.drawline (Pens.yellowpen, new point (w, 0), new point (w, h)); i W = i * segment; dc.drawline (Pens.bluepen, New Point (w, 0), New Point (w, h)); i ; w = i * segment; dc.drawline (Pens.yellowpen, New Point (w, 0), New Point (w, h)); i ; w = i * segment; dc.drawline (Pens.yellowpen, New Point (w, 0), New Point (W, H));
i ; w = i * segment; dc.drawline (Pens.bluepen, new point (w, 0), new point (w, h)); i ; w = i * segment; dc.drawline (Pens.yellowpen, New Point (w, 0), new point (w, h)); i ; w = i * segment; dc.drawline (Pens.yellowpen, new point (w, 0), new point (w, h));
i ; w = i * segment; dc.drawline (pens.redpen, new point (w, 0), new point (w, h)); i ; w = i * segment; dc.drawline (Pens.Yellowpen, New Point (w, 0), new point (w, h)); i ; w = i * segment; dc.drawline (Pens.yellowpen, new point (w, 0), new point (w, h)); if (DrawRAM) DC.DrawRectangle (New Pen (Brushes.black, 2), 0, 0, W, H);} ///
#REGION component designer generated code ///
Private void MoneyControl_load (Object sender, system.eventargs e) {this.width = W; this.height = h; this.upindex = 12;}
private void MoneyControl_BackColorChanged (object sender, System.EventArgs e) {if (this.BackColor == this.unSelectedColor) timer1.Enabled = false; else timer1.Enabled = true;} private void timer1_Tick (object sender, System.EventArgs e) {This.show =! (This.show); graphics dc = this.creategraphics (); if (this.show) Dc.drawline (New Pen (Brushes.black, 1), New Point (Currentnum.Point.x 2, currentnum.point.y 12), new point (Currentnum.Point.x 6, currentnum.point.y 12); else dc.drawline (New Pen (this.backcolor, 1), New Point Currentnum.Point.x 2, currentnum.point.y 12), new point (currentnum.point.x 6, currentnum.point.y 12);} private void MoneyControl_enter (Object Sender, System.EventArgs e ) {THIS.BACKCOLORCHANGED = New EventHandler (MoneyControl_backcolorchange; this.backcolor = this.selectedColor; if (this.moneyp == 0m) {NUMS [12] .num = '0'; NUMS [13] .num = ' 0 '; NUMS [14] .Num =' 0 ';} this.currentnum = this.nums [12];
private void MoneyControl_Leave (object sender, System.EventArgs e) {this.BackColorChanged = new EventHandler (MoneyControl_BackColorChanged); this.BackColor = this.unSelectedColor; if (this.moneyP == 0m) {numS [12] .num = ' '; NUMS [13] .num ='; NUMS [14] .Num = ';}}
private void MoneyControl_KeyDown (object sender, System.Windows.Forms.KeyEventArgs e) {Graphics dc = this.CreateGraphics (); int code = e.KeyValue; int index = 0; upIndex = this.CurrentNum.index; dc.DrawLine ( New Pen (Brushes.Black, 1), New Point (NUMS [UPINDEX] .Point.x 2, NUMS [UPINDEX] .Point.y 12), New Point (NUMS [UPINDEX] .point.x 6, Nums [upindex] .point.y 12)); Num Temnum = new num (); temnum = NUMS [UPINDEX]; switch (code) {case 33: // Mobile cursor case 36: index = this.currentnum .index -1; IF (index <0) {index = 0; this.Parent.selectnextControl (this, false, false, false, true);} this.currentnum = this.nums [index]; dc.drawline (New Pen (THIS.BACKCOLOR, 1), New Point (Temnum.Point.x 2, Temnum.Point.y 12), New Point (Temnum.Point.x 6, Temnum.Point.y 12); Dc.drawline (New Pen (Brushes.Black, 1), New Point (Currentnum.Point.x 2, Currentnum.Point.y 12), New Point (Currentnum.Point.x 6, Currentnum.Point.y 12)); Break; Case 34: // Move the cursor Case 35: index = this.c Urrentnum.index 1; if (index> 14) {index = 14; this.parent.selectnextControl (this, true, false, false, true);} this.currentnum = this.nums [index]; dc.drawline New Pen (this.backcolor, 1), New Point (Temnum.Point.x 2, Temnum.Point.y 12), New Point (Temnum.Point.x 6, Temnum.Point.y 12))) Dc.drawline (New Pen (Brushes.black, 1), New Point (currentnum.point.x 2, currentnum.point.y 12), New Point (Currentnum.Point.x 6, Currentnum.Point. Y 12)); Break; Case 13: // Press the Enter key Keyenter (); break; case 8: // 退格 // case 46: if (this.readonly) return; backbutton (false, -1 );
Break; Case 48: // 0-- Digital Key Case 49: Case 50: Case 51: Case 52: Case 53: Case 54: Case 55: Case 56: Case 57: Case 96: Case 97: Case 98: CASE 99: Case 100: Case 101: Case 102: Case 103: Case 104: Case 105: {IF (this.readonly) Return; if (this.currentnum.index == 0) Return; int Num = 0; if (Code > = 48 && code <= 57) NUM = CODE-48; IF (CODE> = 96 && code <= 105) Num = Code-96; this.BackButton (True, Num);} Break; Case 110: // Decuog Case 190: DC.Drawline (New Pen (this.backcolor, 1), New Point (this.currentnum.point.x 2, this.currentnum.point.y 12), New Point (this.currentnum.point .X 6, this.currentnum.point.y 12); this.currentnum = this.nums [13]; break; case 109: // Negase Case 189: if (this.readonly) return; if (this.Readonly) return; THIS.ZF) this.zf = false; Break; Case 107: // Positive Case 187: if (this.readOnly) Return; if (! this.zf) this.zf = true; Break;}} public Virtual Void KE yEnter () {this.Parent.SelectNextControl (this, true, false, false, true);} private void backButton (bool numORback, int num) {string temMoneyStr = this.moneyP.ToString (); StringBuilder Zstr = new StringBuilder ( ""); Stringbuilder lstr = new stringbuilder (""); int S = 0; s = TemmoneyStr.indexof ("."); If (s == - 1) {if (this.moneyp == 0M && Numorback = = false; else zstr.Append (TemmoneyStr);} else {zstr.Append (TemmoneyStr.Substring (0, s)); lstr.Append (TemmoneyStr.Substring (S 1, TemmoneyStr.Length-S-1) } IF (lstr.tostring () ==
"") Lstr.append ("00"); int b = 0; string numstr = Num.toString (); if (this.currentnum.index> 12) // Extra number {b = 14-this.currentnum.index 1; lstr.remove (lstr.length -b, 1); if (numorback) {if (this.currentnum.index == 13) {this.currentnum = this.nums [14]; this.upindex = 13; Lstr.insert (0, Num.Tostring ()); graphics dc = this.creategraphics (); dc.drawline (new Pen (this.backcolor, 1), new point (NUMS [13] .point.x 2, Nums [13] .point.y 12), New Point (NUMS [13] .point.x 6, NUMS [13] .point.y 12));} else {lstr.Append (Num.Tostring )));}} String m = lstr.tostring (); m = m.padright (2, '0'); lstr.replace (lstr.tostring (), m);} else // integer part {b = 12 -THIS.CURRENTNUM.INDEX 1; if (! Numorback) {if (b> zstr.length) {this.upindex = this.currentnum.index; this.currentnum = this.nums [13-zstr.length]; graphics DC = this.creategraphics (); dc.drawline (New Pen (this.backcolor, 1), new point (nums [this.upindex] .point.x 2 Nums [this.upindex] .point.y 12), new point (NUMS [this.upindex] .point.x 6, NUMS [this.upindex] .point.y 12)); Return;} zstr .Remove (zstr.length -b, 1);} else {if (zstr.length> = 12) {MessageBox.show ("The maximum or minimum of the input is only 999, 999, 999, 999.99!" "/ N" "The current number is:" this.moneyzf.tostring ()); return;}}} (b> zstr.length) {numstr = Numstr.padright (b-zstr.length, '0'); Numstr = Numstr ZSTR .Tostring (); zstr.replace (zstr.tostring (), numstr);} else {b = zstr.length-b 1;
ZStr.insert (b, num.tostring ());}}} f (zstr.tostring () == "") zstr.append ("0"); decimal money = this.moneyp; try {money = Decimal. Parse (ZSTR.TOString () "." Lstr.tostring ());} catch {messagebox.show ("The number of inputs is too large, no processing! Current number" this.moneyP.toString ()); } This.money = Money; if (this.moneyp == 0m) {NUMS [12] .num = '0'; NUMS [13] .Num = '0'; NUMS [14] .Num = '0'; } this.UnDisplayMoney (); this.drawMoney ();} private void MoneyControl_MouseDown (object sender, System.Windows.Forms.MouseEventArgs e) {if (e.Button == MouseButtons.Left) {this.upIndex = this.CurrentNum .index; int = (int) Math.floor (ex / 8); this.currentnum = this.nums [i]; graphics dc = this.creategraphics (); dc.drawline (new Pen (this.backcolor, 1 ), new point (NUMS [this.upindex] .point.x 2, NUMS [this.upindex] .point.y 12), new point (NUMS [this.upindex] .point.x 6, NUMS [ This.upindex] .point.y 12)); dc.drawline (new pen (brushes.black, 1), new point (currentnum.point.x 2, currentnum.point.y 12), new Point (CurrentNum.point.X 6, CurrentNum.point.Y 12));}} private void UnDisplayMoney () {Graphics dc = this.CreateGraphics (); Brush solidBrush = new SolidBrush (this.BackColor); for (INT i = 0; i <15; i ) {dc.FillRectangle (Solidbrush, NUMS [i] .point.x 1, NUMS [i] .point.y, 7, 12);}} /// < Summary> /// Show amount /// summary> public void displaymoney () {this.undisplayMoney (); this.drawmoney ();} // ************************ ************************************************************* Public String Moneywz () {RETURN MONEYTOWZ this.moneyzf);
PUBLIC STATIC STRING MONEYTOWZ (DECIMAL MONEYT) {Decimal Tem = Math.Abs (Moneyt); String FH = ""; IF (Moneyt <0) FH = "Negative"; String TemstR = Tem.toString (); int s = Temstr.indexof ("."); string zstr = ""; string lstr = ""; if (s == - 1) {zstr = temstr;} else {zstr = Temstr.SUBSTRING (0, s); lstr = Temstr.substring (S 1, Temstr.length-S-S-1);} String [] Quan = {"", "10,000", "100 million", "mega"}; string [] wzp = {"," Pick up "," "," "}; string [] MoneyNum = new string [zstr.length]; if (zstr.length> 12) {MessageBox.show (" Number is too big, unable to handle! "); Return "";} For (int i = 0; i
For (int J = 0; j 1 && obj.tostring.substring (obj.tostring.length -1, 1) == "zero") obj.tostring = obj.tostring.remove (obj.tostring.Length-1, 1); if (obj.tostring == ") Obj.toString =" zero ";
IF (lstr! = "&&lstr! =" 00 ") {obj.tostring =" point "; OPERSTR TEMV = New OPERSTR (); for (int i = 0; i SOHU.com Address: East to County | East to Huayuan Textile Company Control Name: MoneyControl Name Space: PZControl Use: Digital (similar money) is displayed in the control, you can enter the output and convert the number into a text! "; Return Temstr;}} }