예제 #1
0
        private void MakeED()
        {
            //Fill Rho array
            try
            {
                RhoCalc.IsOneSigma      = Holdsigma.Checked;
                RhoCalc.ZOffset         = Zoffset.ToDouble();
                RhoCalc.GetSubRoughness = SubRough.ToDouble();
                RhoCalc.BoxCount        = BoxCount.ToInt();
                RhoCalc.SubphaseSLD     = SubphaseSLD.ToDouble();
                RhoCalc.SuperphaseSLD   = SupSLDTB.ToDouble();

                //Blank our Rho data from the previous iteration
                RhoCalc.RhoArray.Clear();
                RhoCalc.LengthArray.Clear();
                RhoCalc.SigmaArray.Clear();

                BoxRhoArray.ForEach(p => RhoCalc.RhoArray.Add(p.ToDouble()));
                BoxLengthArray.ForEach(p => RhoCalc.LengthArray.Add(p.ToDouble()));
                BoxSigmaArray.ForEach(p => RhoCalc.SigmaArray.Add(p.ToDouble()));

                if (Holdsigma.Checked)
                {
                    ChangeRoughnessArray();
                }

                GreyFields();

                RhoCalc.UpdateProfile();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
예제 #2
0
        /// <summary>
        /// This routine updates our frontend. All updates are performed in a threadsafe manner, as the
        /// stochastic methods can take place on a separate thread
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ReflCalc_Update(object sender, EventArgs e)
        {
            //Necessary due to the possibility of updating from a separate thread (such as stochastic fitting). Otherwise, events are fired which reset some of the values
            //below. A lock isn't necessary this isn't necessarilly a race condition
            m_isupdating = true;

            SubRough.ThreadSafeSetText(ReflCalc.GetSubRoughness.ToString());

            if (ReflCalc.ImpNormCB)
            {
                NormCorrectTB.ThreadSafeSetText(ReflCalc.NormalizationFactor.ToString());
            }

            Holdsigma.ThreadSafeChecked(ReflCalc.IsOneSigma);
            BoxCount.ThreadSafeSetText(ReflCalc.BoxCount.ToString());
            ImpNormCB.ThreadSafeChecked(ReflCalc.ImpNormCB);

            //Blank our Rho data from the previous iteration
            for (int i = 0; i < RhoArray.Count; i++)
            {
                if (!m_bUseSLD)
                {
                    RhoArray[i].ThreadSafeSetText(ReflCalc.RhoArray[i].ToString());
                }
                else
                {
                    RhoArray[i].ThreadSafeSetText((ReflCalc.RhoArray[i] / ReflCalc.SubphaseSLD).ToString());
                }

                LengthArray[i].ThreadSafeSetText(ReflCalc.LengthArray[i].ToString());
                SigmaArray[i].ThreadSafeSetText(ReflCalc.SigmaArray[i].ToString());
            }

            if (Holdsigma.Checked)
            {
                ChangeRoughnessArray();
            }

            if (m_bmodelreset)
            {
                ReflGraphing.Clear();
                ReflGraphing.LoadDatawithErrorstoGraph("Reflectivity Data", Color.Black, SymbolType.Circle, 5, ReflData.Instance.GetQData, ReflData.Instance.GetReflData);
                m_bmodelreset = false;
            }

            GreyFields();
            //Update graphs
            RhoGraphing.Pane.XAxis.Scale.Min = 0;
            RhoGraphing.Pane.XAxis.Scale.Max = ReflCalc.Z[ReflCalc.Z.Length - 1];

            ReflGraphing.LoadfromArray("modelrefl", ReflData.Instance.GetQData, ReflCalc.ReflectivityMap, System.Drawing.Color.Black, SymbolType.XCross, 4, true, string.Empty);
            RhoGraphing.LoadfromArray("Model Dependent Fit", ReflCalc.Z, ReflCalc.ElectronDensityArray, System.Drawing.Color.Turquoise, SymbolType.None, 0, true, string.Empty);
            RhoGraphing.LoadfromArray("Model Dependent Box Fit", ReflCalc.Z, ReflCalc.BoxElectronDensityArray, System.Drawing.Color.Red, SymbolType.None, 0, false, string.Empty);

            chisquaretb.ThreadSafeSetText(ReflCalc.MakeChiSquare().ToString());
            FitnessScoreTB.ThreadSafeSetText(ReflCalc.MakeFitnessScore().ToString());

            m_isupdating = false;
        }
예제 #3
0
        private void BtnStart_Click(object sender, RoutedEventArgs e)
        {
            Random r = new Random();

            compNum            = r.Next(1, 101);
            BtnTry.IsEnabled   = true;
            BtnStart.IsEnabled = false;
            cnt = 0;
            BoxNumber.Clear();
            BoxAnswer.Clear();
            BoxCount.Clear();
            BoxNumber.Focus();
        }
예제 #4
0
 private void GreyFields()
 {
     for (int i = 0; i < 6; i++)
     {
         if (i < BoxCount.ToInt())
         {
             BoxRhoArray[i].Enabled   = BoxLengthArray[i].Enabled = true;
             BoxSigmaArray[i].Enabled = !Holdsigma.Checked;
         }
         else
         {
             BoxRhoArray[i].Enabled   = BoxLengthArray[i].Enabled = false;
             BoxSigmaArray[i].Enabled = false;
         }
     }
 }
예제 #5
0
        /// <summary>
        /// Checks to verify that the Textbox has valid numerical input. This check respects cultural variations
        /// in number entry.
        /// </summary>
        /// <param name="sender">A textbox is expected as input</param>
        /// <param name="e">return true if the number can be cast to an integer or false if not</param>
        protected void ValidateIntegerInput(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                base.OnValidating(e);

                HelperFunctions.ValidateIntegerInput(sender, e);

                if (((TextBox)sender).Name == "BoxCount")
                {
                    if (BoxCount.ToInt() > 6)
                    {
                        MessageBox.Show("Six is the maximum number of boxes");
                        e.Cancel = true;
                    }
                }
            }
            catch { }
        }
예제 #6
0
        private void MakeReflectivity()
        {
            //Fill Rho array
            try
            {
                ReflCalc.IsOneSigma          = Holdsigma.Checked;
                ReflCalc.ZOffset             = 25;
                ReflCalc.GetSubRoughness     = SubRough.ToDouble();
                ReflCalc.BoxCount            = BoxCount.ToInt();
                ReflCalc.SubphaseSLD         = SubphaseSLD.ToDouble();
                ReflCalc.SuperphaseSLD       = SupSLDTB.ToDouble();
                ReflCalc.HighQOffset         = Rightoffset.ToInt();
                ReflCalc.LowQOffset          = CritOffset.ToInt();
                ReflCalc.NormalizationFactor = NormCorrectTB.ToDouble();
                ReflCalc.ImpNormCB           = ImpNormCB.Checked;
                ReflCalc.QSpreadTB           = QSpreadTB.ToDouble();
                //Blank our Rho data from the previous iteration
                ReflCalc.RhoArray.Clear();
                ReflCalc.LengthArray.Clear();
                ReflCalc.SigmaArray.Clear();

                RhoArray.ForEach(p => ReflCalc.RhoArray.Add(p.ToDouble()));
                LengthArray.ForEach(p => ReflCalc.LengthArray.Add(p.ToDouble()));
                SigmaArray.ForEach(p => ReflCalc.SigmaArray.Add(p.ToDouble()));

                if (Holdsigma.Checked)
                {
                    ChangeRoughnessArray();
                }

                ReflCalc.UpdateProfile();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }