コード例 #1
0
ファイル: SolverControl.cs プロジェクト: aarongrisez/TDSE
        /// <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.Mass1          = (float)Mass1_NUD.Value;
            parms.Mass2          = (float)Mass2_NUD.Value;

            parms.InitialWavePacketSize      = new Vec3((float)InitialPacketSizeX_NUD.Value, (float)InitialPacketSizeY_NUD.Value, (float)InitialPacketSizeZ_NUD.Value);
            parms.InitialWavePacketCenter1   = new Vec3((float)InitialPacketCenter1x_NUD.Value, (float)InitialPacketCenter1y_NUD.Value, (float)InitialPacketCenter1z_NUD.Value);
            parms.InitialWavePacketCenter2   = new Vec3((float)InitialPacketCenter2x_NUD.Value, (float)InitialPacketCenter2y_NUD.Value, (float)InitialPacketCenter2z_NUD.Value);
            parms.InitialWavePacketMomentum1 = new Vec3((float)P1x_NUD.Value, (float)P1y_NUD.Value, (float)P1z_NUD.Value);
            parms.InitialWavePacketMomentum2 = new Vec3((float)P2x_NUD.Value, (float)P2y_NUD.Value, (float)P2z_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
ファイル: SolverControl.cs プロジェクト: aarongrisez/TDSE
        // 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
ファイル: SolverControl.cs プロジェクト: aarongrisez/TDSE
 /// <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("");
            }
        }