コード例 #1
0
        public MainForm(CyPhy2Modelica_v2Settings settings, string projectDir)
        {
            InitializeComponent();
            this.ProjectDir = projectDir;
            this.ModelicaSettings = settings;
            libData = ((System.Windows.Forms.BindingSource)dataGridView1.DataSource).List;
            var libraries = ModelicaLibrary.GetLibrariesFromSettings(this.ModelicaSettings, this.ProjectDir);
            foreach (var lib in libraries)
            {
                var selectedPath = lib.GetCurrentLibraryPath();
                if (Path.IsPathRooted(selectedPath) == false)
                {
                    selectedPath = Path.Combine(this.ProjectDir, selectedPath);
                }

                if (File.Exists(selectedPath) || Directory.Exists(selectedPath))
                {
                    libData.Add(lib);
                }
            }

            if (string.IsNullOrEmpty(DymolaExe))
            {
                chbCheckWithDymola.Enabled = false;
            }
            else
            {
                chbCheckWithDymola.Enabled = true;
            }

            chbCheckWithDymola.Checked = this.ModelicaSettings.CheckWithDymola;

            if (string.IsNullOrEmpty(OMCExe))
            {
                chbCheckWithOM.Enabled = false;
            }
            else
            {
                chbCheckWithOM.Enabled = true;
            }

            chbCheckWithOM.Checked = this.ModelicaSettings.CheckWithOpenModelica;

        }
コード例 #2
0
        public MainForm(CyPhy2Modelica_v2Settings settings, string projectDir)
        {
            InitializeComponent();
            this.ProjectDir       = projectDir;
            this.ModelicaSettings = settings;
            libData = ((System.Windows.Forms.BindingSource)dataGridView1.DataSource).List;
            var libraries = ModelicaLibrary.GetLibrariesFromSettings(this.ModelicaSettings, this.ProjectDir);

            foreach (var lib in libraries)
            {
                var selectedPath = lib.GetCurrentLibraryPath();
                if (Path.IsPathRooted(selectedPath) == false)
                {
                    selectedPath = Path.Combine(this.ProjectDir, selectedPath);
                }

                if (File.Exists(selectedPath) || Directory.Exists(selectedPath))
                {
                    libData.Add(lib);
                }
            }

            if (string.IsNullOrEmpty(DymolaExe))
            {
                chbCheckWithDymola.Enabled = false;
                chbCheckWithDymola.Checked = false;
            }
            else
            {
                chbCheckWithDymola.Enabled = true;
                chbCheckWithDymola.Checked = this.ModelicaSettings.CheckWithDymola;
            }

            if (string.IsNullOrEmpty(OMCExe))
            {
                chbCheckWithOM.Enabled = false;
                chbCheckWithOM.Checked = false;
            }
            else
            {
                chbCheckWithOM.Enabled = true;
                chbCheckWithOM.Checked = this.ModelicaSettings.CheckWithOpenModelica;
            }
        }
コード例 #3
0
ファイル: ModelicaLibrary.cs プロジェクト: landunin/meta-core
        public static List <ModelicaLibrary> GetLibrariesFromSettings(CyPhy2Modelica_v2Settings settings, string projectDir)
        {
            var libraries = new List <ModelicaLibrary>();

            // If directory name was saved append package.mo
            // support all formats
            foreach (var dirPath in settings.IncludeDirectoryPath)
            {
                if (LibraryExists(dirPath, projectDir) == false)
                {
                    continue;
                }
                var newLib = ModelicaLibrary.GetLibraryFromPath(dirPath);
                var found  = libraries.FirstOrDefault(x => x.Name == newLib.Name);
                if (found == null)
                {
                    libraries.Add(newLib);
                }
            }

            foreach (var dirPath in settings.NonCheckedIncludeDirPaths)
            {
                if (LibraryExists(dirPath, projectDir) == false)
                {
                    continue;
                }
                var newLib = ModelicaLibrary.GetLibraryFromPath(dirPath);
                var found  = libraries.FirstOrDefault(x => x.Name == newLib.Name);
                if (found == null)
                {
                    newLib.IsSelected = false;
                    libraries.Add(newLib);
                }
                else
                {
                    found.Versions.Add(newLib.Versions.FirstOrDefault());
                }
            }

            return(libraries);
        }
コード例 #4
0
ファイル: ModelicaLibrary.cs プロジェクト: neemask/meta-core
        public static List<ModelicaLibrary> GetLibrariesFromSettings(CyPhy2Modelica_v2Settings settings, string projectDir)
        {
            var libraries = new List<ModelicaLibrary>();

            // If directory name was saved append package.mo
            // support all formats
            foreach (var dirPath in settings.IncludeDirectoryPath)
            {
                if (LibraryExists(dirPath, projectDir) == false)
                {
                    continue;
                }
                var newLib = ModelicaLibrary.GetLibraryFromPath(dirPath);
                var found = libraries.FirstOrDefault(x => x.Name == newLib.Name);
                if (found == null)
                {
                    libraries.Add(newLib);
                }
            }

            foreach (var dirPath in settings.NonCheckedIncludeDirPaths)
            {
                if (LibraryExists(dirPath, projectDir) == false)
                {
                    continue;
                }
                var newLib = ModelicaLibrary.GetLibraryFromPath(dirPath);
                var found = libraries.FirstOrDefault(x => x.Name == newLib.Name);
                if (found == null)
                {
                    newLib.IsSelected = false;
                    libraries.Add(newLib);
                }
                else
                {
                    found.Versions.Add(newLib.Versions.FirstOrDefault());
                }
            }

            return libraries;
        }
コード例 #5
0
ファイル: ModelicaLibrary.cs プロジェクト: landunin/meta-core
        public static CyPhy2Modelica_v2Settings UpdateSettingsFromModelicaLibraries(CyPhy2Modelica_v2Settings currentSettings, List <ModelicaLibrary> libraries)
        {
            currentSettings.IncludeDirectoryPath      = new List <string>();
            currentSettings.NonCheckedIncludeDirPaths = new List <string>();

            foreach (var library in libraries)
            {
                if (library.IsSelected)
                {
                    currentSettings.IncludeDirectoryPath.Add(library.GetCurrentLibraryPath());
                    currentSettings.NonCheckedIncludeDirPaths.AddRange(library.GetNonSelectedLibraryPaths());
                }
                else
                {
                    currentSettings.NonCheckedIncludeDirPaths.Add(library.GetCurrentLibraryPath());
                    currentSettings.NonCheckedIncludeDirPaths.AddRange(library.GetNonSelectedLibraryPaths());
                }
            }

            return(currentSettings);
        }
コード例 #6
0
        /// <summary>
        /// Shows a form for the user to select/change settings through a GUI. All interactive 
        /// GUI operations MUST happen within this function scope.
        /// </summary>
        /// <param name="preConfig">Result of PreConfig</param>
        /// <param name="previousConfig">Previous configuration to initialize the GUI.</param>
        /// <returns>Null if operation is cancelled by the user. Otherwise returns with a new
        /// configuration object.</returns>
        public IInterpreterConfiguration DoGUIConfiguration(
            IInterpreterPreConfiguration preConfig,
            IInterpreterConfiguration previousConfig)
        {
            DialogResult ok = DialogResult.Cancel;

            var settings = previousConfig as CyPhy2Modelica_v2Settings;

            if (settings == null)
            {
                settings = new CyPhy2Modelica_v2Settings();
            }

            using (MainForm mf = new MainForm(settings, (preConfig as CyPhy2Modelica_v2PreConfiguration).ProjectDirectory))
            {
                // show main form
                ok = mf.ShowDialog();
            }

            if (ok == DialogResult.OK)
            {
                return settings;
            }

            return null;
        }
コード例 #7
0
ファイル: ModelicaLibrary.cs プロジェクト: neemask/meta-core
        public static CyPhy2Modelica_v2Settings UpdateSettingsFromModelicaLibraries(CyPhy2Modelica_v2Settings currentSettings, List<ModelicaLibrary> libraries)
        {
            currentSettings.IncludeDirectoryPath = new List<string>();
            currentSettings.NonCheckedIncludeDirPaths = new List<string>();

            foreach (var library in libraries)
            {
                if (library.IsSelected)
                {
                    currentSettings.IncludeDirectoryPath.Add(library.GetCurrentLibraryPath());
                    currentSettings.NonCheckedIncludeDirPaths.AddRange(library.GetNonSelectedLibraryPaths());
                }
                else
                {
                    currentSettings.NonCheckedIncludeDirPaths.Add(library.GetCurrentLibraryPath());
                    currentSettings.NonCheckedIncludeDirPaths.AddRange(library.GetNonSelectedLibraryPaths());
                }
            }

            return currentSettings;
        }