Exemplo n.º 1
0
        private void BGWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            button1.Enabled    = true;
            this.returnElement = AgilityParser.Parse(SourceCode);

            foreach (Label lbl in this.groupBox2.Controls.OfType <Label>())
            {
                lbl.Visible = true;
            }

            nameLabel.Text           = returnElement.Name;
            symbolLabel.Text         = returnElement.Symbol;
            ANumberLabel.Text        = returnElement.ANumber;
            AMassLabel.Text          = returnElement.AMass;
            MPLabel.Text             = returnElement.MP;
            BPLabel.Text             = returnElement.BP;
            NoPELabel.Text           = returnElement.NoPE;
            DensityLabel.Text        = returnElement.Density + "³";
            ColorLabel.Text          = returnElement.Color;
            CSLabel.Text             = returnElement.CrystalGeo;
            ClassificationLabel.Text = returnElement.Classification;
            groupBox2.Text           = AOS.Text = string.Format("{0} ({1})", returnElement.Name, returnElement.Symbol.Replace(" ", ""));

            this.IsotopesString         = returnElement.GetIsotopes();
            this.IsotopesButton.Enabled = true;



            pBox.SizeMode = PictureBoxSizeMode.Zoom;
            pBox.Load(returnElement.AtomicStructureImage);
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
0
 public Form1()
 {
     if (!AgilityParser.CheckInternetConnection())
     {
         if (MessageBox.Show("Could not detect any internet connection, you will not be able to use the program without Internet Connection, retry?", "No Connection", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Retry)
         {
             if (!AgilityParser.CheckInternetConnection())
             {
                 this.Close();
                 Application.Exit();
             }
         }
         else
         {
             this.Close();
             Application.Exit();
         }
     }
     InitializeComponent();
 }
Exemplo n.º 4
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();
            }
        }
Exemplo n.º 5
0
        private void BGWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.returnElement = AgilityParser.Parse(SourceCode);
            this.toolStripProgressBar1.Value = 100;
            this.toolStripStatusLabel1.Text  = "Ready";

            foreach (Label lbl in this.groupBox2.Controls.OfType <Label>())
            {
                lbl.Visible = true;
            }

            nameLabel.Text           = this.Text = returnElement.Name;
            symbolLabel.Text         = returnElement.Symbol;
            ANumberLabel.Text        = returnElement.ANumber;
            AMassLabel.Text          = returnElement.AMass;
            MPLabel.Text             = returnElement.MP;
            BPLabel.Text             = returnElement.BP;
            NoPELabel.Text           = returnElement.NoPE;
            DensityLabel.Text        = returnElement.Density + "³";
            ColorLabel.Text          = returnElement.Color;
            CSLabel.Text             = returnElement.CrystalGeo;
            ClassificationLabel.Text = returnElement.Classification;
            groupBox2.Text           = string.Format("{0} ({1})", returnElement.Name, returnElement.Symbol.Replace(" ", ""));
        }