Beispiel #1
0
        private void AddSymbolFiles(bool fromPlatform)
        {
            OpenFileDialog fileDlg = new OpenFileDialog()
            {
                Filter           = PlatformSymbols.FILENAME_FILTER,
                Multiselect      = true,
                InitialDirectory = fromPlatform ? RuntimeDataAccess.GetDirectory() : mProjectDir,
                RestoreDirectory = true     // doesn't seem to work?
            };

            if (fileDlg.ShowDialog() != true)
            {
                return;
            }

            foreach (string pathName in fileDlg.FileNames)
            {
                // I'm assuming the full names got the Path.GetFullPath() canonicalization and
                // don't need further processing.  Also, I'm assuming that all files live in
                // the same directory, so if one is in an invalid location then they all are.
                ExternalFile ef = ExternalFile.CreateFromPath(pathName, mProjectDir);
                if (ef == null)
                {
                    // Files not found in runtime or project directory.
                    string projDir = mProjectDir;
                    if (string.IsNullOrEmpty(projDir))
                    {
                        projDir = Res.Strings.UNSET;
                    }
                    string msg = string.Format(Res.Strings.EXTERNAL_FILE_BAD_DIR_FMT,
                                               RuntimeDataAccess.GetDirectory(), projDir, pathName);
                    MessageBox.Show(msg, Res.Strings.EXTERNAL_FILE_BAD_DIR_CAPTION,
                                    MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                string ident = ef.Identifier;

                if (mWorkProps.PlatformSymbolFileIdentifiers.Contains(ident))
                {
                    Debug.WriteLine("Already present: " + ident);
                    continue;
                }

                Debug.WriteLine("Adding symbol file: " + ident);
                mWorkProps.PlatformSymbolFileIdentifiers.Add(ident);
                IsDirty = true;
            }

            if (IsDirty)
            {
                LoadPlatformSymbolFiles();
                UpdateControls();
            }
        }
        private void addExtensionScriptsButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDlg = new OpenFileDialog()
            {
                Filter           = Sandbox.ScriptManager.FILENAME_FILTER,
                Multiselect      = true,
                InitialDirectory = RuntimeDataAccess.GetDirectory(),
                RestoreDirectory = true     // doesn't seem to work?
            };

            if (fileDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            foreach (string pathName in fileDlg.FileNames)
            {
                // I'm assuming the full names got the Path.GetFullPath() canonicalization and
                // don't need further processing.  Also, I'm assuming that all files live in
                // the same directory, so if one is in an invalid location then they all are.
                ExternalFile ef = ExternalFile.CreateFromPath(pathName, mProjectDir);
                if (ef == null)
                {
                    // Files not found in runtime or project directory.
                    string projDir = mProjectDir;
                    if (string.IsNullOrEmpty(projDir))
                    {
                        projDir = Properties.Resources.UNSET;
                    }
                    string msg = string.Format(Properties.Resources.EXTERNAL_FILE_BAD_DIR,
                                               RuntimeDataAccess.GetDirectory(), projDir, pathName);
                    MessageBox.Show(this, msg, Properties.Resources.EXTERNAL_FILE_BAD_DIR_CAPTION,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                string ident = ef.Identifier;

                if (mWorkProps.ExtensionScriptFileIdentifiers.Contains(ident))
                {
                    Debug.WriteLine("Already present: " + ident);
                    continue;
                }

                Debug.WriteLine("Adding extension script: " + ident);
                mWorkProps.ExtensionScriptFileIdentifiers.Add(ident);
                mDirty = true;
            }

            if (mDirty)
            {
                LoadExtensionScriptNames();
                UpdateControls();
            }
        }