Ejemplo n.º 1
0
        public void AddLibraryAsset(Project project, string inDirectory)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Title = TextHelper.GetString("Label.AddLibraryAsset");
            dialog.Filter = TextHelper.GetString("Info.FileFilter");
            dialog.Multiselect = false;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string filePath = CopyFile(dialog.FileName, inDirectory);

                // null means the user cancelled
                if (filePath == null) return;

                // add as an asset
                project.SetLibraryAsset(filePath, true);

                if (!FileInspector.IsSwc(filePath))
                {
                    // ask if you want to keep this file updated
                    string caption = TextHelper.GetString("FlashDevelop.Title.ConfirmDialog");
                    string message = TextHelper.GetString("Info.ConfirmFileUpdate");

                    DialogResult result = MessageBox.Show(mainForm, message, caption,
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (result == DialogResult.Yes)
                    {
                        LibraryAsset asset = project.GetAsset(filePath);
                        asset.UpdatePath = project.GetRelativePath(dialog.FileName);
                    }
                }

                project.Save();
                OnProjectModified(new string[] { filePath });
            }
        }