Exemplo n.º 1
0
        /// <summary>
        /// Handles click events from the Run/Stop button.
        /// </summary>
        private void RunStop_Btn_Click(object sender, EventArgs e)
        {
            // Sanity check the inputs
            if (2 * DampingBorderWidth_NUD.Value > Math.Min(GridSizeX_NUD.Value, GridSizeY_NUD.Value))
            {
                MessageBox.Show("Damping border must be less than half the minimum grid dimension.");
                return;
            }

            if (RunStop_Btn.Text == "Stop")
            {
                RunStop_Btn.Enabled     = false;
                PauseResume_Btn.Enabled = false;

                m_evolver.Cancel();
            }
            else
            {
                RunStop_Btn.Text        = "Stop";
                PauseResume_Btn.Enabled = true;
                Main_ProgressBar.Value  = 0;
                EnableInputs(false);

                m_params = GetParamsFromUi();
                Properties.Settings.Default.LastRunParams = m_params.ToString();
                Properties.Settings.Default.Save();
                CreateAnimationFrames();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Evolves the wavefunction and saves keyframes to disk.
        /// </summary>
        private void CreateAnimationFrames()
        {
            // Get a fresh output directory
            m_outputDir = CreateOutputDir();

            // Write the run parameters to a file
            string paramsFile = Path.Combine(m_outputDir, "Params.txt");

            File.WriteAllText(paramsFile, m_params.ToString().Replace("\n", "\r\n"));

            // Create an Evolver and run it in the background
            Evolver.VDelegate V = (x, y, m, sx, sy) => { return(m_VBuilder.V(x, y, m, sx, sy)); };

            m_evolver = new Evolver(m_params, V, m_outputDir);
            m_evolver.ProgressEvent   += Evolver_ProgressEvent;
            m_evolver.CompletionEvent += Evolver_CompletionEvent;

            m_evolver.RunInBackground();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets and saves the V-code.
        /// </summary>
        public string SetCode(string code)
        {
            // Try to compile the given code
            string   errorMessages;
            Assembly assembly = CompileCode(AddBoilerplateCode(code), out errorMessages);

            // Check for compilation errors
            if (assembly == null)
            {
                return(string.IsNullOrEmpty(errorMessages) ? "Unknown compilation error." : errorMessages);
            }
            else
            {
                // Accept the given code
                Code_TextBox.Text = code;
                m_vCalcMethodInfo = assembly.GetTypes()[0].GetMethod("V", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

                RunParams parms = RunParams.FromString(Properties.Settings.Default.LastRunParams);
                parms.VCode = code;
                Properties.Settings.Default.LastRunParams = parms.ToString();
                Properties.Settings.Default.Save();
                return("");
            }
        }