示例#1
0
        private void RSearch_Click(object sender, EventArgs e)
        {
            this.elementString = AgilityParser.GetElement(new Random().Next(1, 118));
            this.TBSearch.Text = elementString.Replace(elementString[0].ToString(), elementString[0].ToString().ToUpper());

            this.NameCB.Checked   = true;
            this.numberCB.Checked = false;

            if (!BGWorker.IsBusy)
            {
                BGWorker.RunWorkerAsync();
            }
        }
示例#2
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            string[]      Elements = "h,he,li,be,b,c,n,o,f,ne,na,mg,al,si,p,s,cl,ar,k,ca,sc,ti,v,cr,mn,fe,co,ni,cu,zn,ga,ge,as,se,br,kr,rb,sr,y,zr,nb,mo,tc,ru,rh,pd,ag,cd,in,sn,sb,te,i,xe,cs,ba,la,ce,pr,nd,pm,sm,eu,gd,tb,dy,ho,er,tm,yb,lu,hf,ta,w,re,os,ir,pt,au,hg,ti,pb,bi,po,at,rn,fr,ra,ac,th,pa,u,np,pu,am,cm,bk,cf,es,fm,md,no,lr,rf,db,sg,bh,mt,ds,rg,uub,uut,uuq,uup,uuh,uus,uuo".Split(new char[] { ',' });
            List <string> el       = Elements.ToList <string>();

            if (!SearchByName)
            {
                int n;
                if (Int32.TryParse(this.TBSearch.Text, out n))
                {
                    if (n <= 0 || n > 118)
                    {
                        MessageBox.Show("The element number must be a number between 1 and 118.", "Out of Range", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button3);
                    }
                    else
                    {
                        this.elementString = AgilityParser.GetElement(n - 1);
                    }
                }
            }
            else
            {
                if (elementString.Length > 3)
                {
                    MessageBox.Show("The element symbol must be 3 digits long by maximum.", "Out of Range", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button3);
                }
                else if (!el.Contains(this.TBSearch.Text.ToLower()))
                {
                    MessageBox.Show("Unknown element.", "Unknown Element;", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button3);
                }
                else
                {
                    this.elementString = this.TBSearch.Text.ToLower();
                }
            }

            if (!BGWorker.IsBusy)
            {
                BGWorker.RunWorkerAsync();
            }
        }