Пример #1
0
        /// <summary>
        /// Reads the UI parameters into a RunParams object.
        /// </summary>
        private RunParams GetParamsFromUi()
        {
            RunParams parms = new RunParams();

            parms.GridSpec.SizeX = Convert.ToInt32(GridSizeX_NUD.Value);
            parms.GridSpec.SizeY = Convert.ToInt32(GridSizeY_NUD.Value);
            parms.GridSpec.SizeZ = Convert.ToInt32(GridSizeZ_NUD.Value);

            parms.LatticeSpacing = (float)LatticeSpacing_NUD.Value;
            parms.ParticleMass   = (float)Mass_NUD.Value;

            parms.InitialWavePacketSize     = new Vec3((float)InitialPacketSizeX_NUD.Value, (float)InitialPacketSizeY_NUD.Value, (float)InitialPacketSizeZ_NUD.Value);
            parms.InitialWavePacketCenter   = new Vec3((float)InitialPacketCenterX_NUD.Value, (float)InitialPacketCenterY_NUD.Value, (float)InitialPacketCenterZ_NUD.Value);
            parms.InitialWavePacketMomentum = new Vec3((float)InitialMomentumX_NUD.Value, (float)InitialMomentumY_NUD.Value, (float)InitialMomentumZ_NUD.Value);
            parms.DampingBorderWidth        = (int)DampingBorderWidth_NUD.Value;
            parms.DampingFactor             = (float)DampingFactor_NUD.Value;

            parms.TimeStep        = (float)TimeStep_NUD.Value;
            parms.TotalTime       = (float)TotalTime_NUD.Value;
            parms.NumFramesToSave = (int)NumFrames_NUD.Value;

            parms.MultiThread = MultiThread_CheckBox.Checked;

            parms.VCode = RunParams.FromString(Properties.Settings.Default.LastRunParams).VCode;

            return(parms);
        }
Пример #2
0
        /// <summary>
        /// Loads the last-saved code.
        /// </summary>
        private void LoadLastSavedCode()
        {
            string errorMessages = SetCode(RunParams.FromString(Properties.Settings.Default.LastRunParams).VCode);

            if (!string.IsNullOrEmpty(errorMessages))
            {
                SetCode(DefaultSnippet);
            }
        }
Пример #3
0
        // Constructor
        public SolverControl()
        {
            InitializeComponent();
            m_VBuilder = new VCodeBuilder(); // Also loads the last-used code snippet

            // Load the last-used params
            if (!string.IsNullOrEmpty(Properties.Settings.Default.LastRunParams))
            {
                try
                {
                    UpdateUiFromParams(RunParams.FromString(Properties.Settings.Default.LastRunParams));
                }
                catch {}
            }
        }
Пример #4
0
 /// <summary>
 /// Handler for drag-drop events
 /// </summary>
 private void OnDragDrop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
         if (files.Length > 0)
         {
             try
             {
                 string    fileContents = File.ReadAllText(files[0]);
                 RunParams parms        = RunParams.FromString(fileContents);
                 UpdateUiFromParams(parms);
             }
             catch
             {
                 MessageBox.Show("Invalid parameter file");
             }
         }
     }
 }
Пример #5
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("");
            }
        }