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 }); } }
public void ToggleLibraryAsset(Project project, string[] paths) { foreach (string path in paths) { bool isResource = project.IsLibraryAsset(path); project.SetLibraryAsset(path, !isResource); } project.Save(); OnProjectModified(paths); }
public void ToggleShowHidden(Project project) { project.ShowHiddenPaths = !project.ShowHiddenPaths; project.Save(); OnProjectModified(null); }
public void ToggleHidden(Project project, string[] paths) { foreach (string path in paths) { bool isHidden = project.IsPathHidden(path); project.SetPathHidden(path, !isHidden); } project.Save(); OnProjectModified(null); }
public void ToggleDocumentClass(Project project, string[] paths) { foreach (string path in paths) { bool isMain = project.IsDocumentClass(path); project.SetDocumentClass(path, !isMain); } project.Save(); OnProjectModified(null); }
public void ToggleAlwaysCompile(Project project, string[] paths) { foreach (string path in paths) { bool isTarget = project.IsCompileTarget(path); project.SetCompileTarget(path, !isTarget); } if (project.MaxTargetsCount > 0) { while (project.CompileTargets.Count > project.MaxTargetsCount) { int len = project.CompileTargets.Count; string relPath = project.CompileTargets[0]; project.SetCompileTarget(relPath, false); if (project.CompileTargets.Count == len) // safety if path is not removed project.CompileTargets.RemoveAt(0); string path = project.GetAbsolutePath(relPath); OnProjectModified(new string[] { path }); } } project.Save(); OnProjectModified(paths); }
private void MoveRefactoredFiles() { MessageBar.Locked = true; AssociatedDocumentHelper.CloseTemporarilyOpenedDocuments(); foreach (var target in targets) { File.Delete(target.OldFilePath); if (target.OwnerPath == null) { OldPathToNewPath.Remove(target.OldFilePath); } // Casing changes, we cannot move directly here, there may be conflicts, better leave it to the next step if (target.TmpFilePath != null) { RefactoringHelper.Move(target.TmpFilePath, target.NewFilePath); } } // Move non-source files and whole folders foreach (KeyValuePair <string, string> item in OldPathToNewPath) { string oldPath = item.Key; string newPath = item.Value; if (File.Exists(oldPath)) { newPath = Path.Combine(newPath, Path.GetFileName(oldPath)); if (!Path.IsPathRooted(newPath)) { newPath = Path.Combine(Path.GetDirectoryName(oldPath), newPath); } RefactoringHelper.Move(oldPath, newPath, true); } else if (Directory.Exists(oldPath)) { newPath = renaming ? Path.Combine(Path.GetDirectoryName(oldPath), newPath) : Path.Combine(newPath, Path.GetFileName(oldPath)); // Look for document class changes // Do not use RefactoringHelper to avoid possible dialogs that we don't want ProjectManager.Projects.Project project = (ProjectManager.Projects.Project)PluginBase.CurrentProject; string newDocumentClass = null; string searchPattern = project.DefaultSearchFilter; foreach (string pattern in searchPattern.Split(';')) { foreach (string file in Directory.GetFiles(oldPath, pattern, SearchOption.AllDirectories)) { if (project.IsDocumentClass(file)) { newDocumentClass = file.Replace(oldPath, newPath); break; } } if (newDocumentClass != null) { break; } } // Check if this is a name casing change if (oldPath.Equals(newPath, StringComparison.OrdinalIgnoreCase)) { string tmpPath = oldPath + "$renaming$"; FileHelper.ForceMoveDirectory(oldPath, tmpPath); PluginCore.Managers.DocumentManager.MoveDocuments(oldPath, tmpPath); oldPath = tmpPath; } // Move directory contents to final location FileHelper.ForceMoveDirectory(oldPath, newPath); PluginCore.Managers.DocumentManager.MoveDocuments(oldPath, newPath); if (!string.IsNullOrEmpty(newDocumentClass)) { project.SetDocumentClass(newDocumentClass, true); project.Save(); } } } MessageBar.Locked = false; }
public void ToggleAlwaysCompile(Project project, string[] paths) { foreach (string path in paths) { bool isTarget = project.IsCompileTarget(path); project.SetCompileTarget(path, !isTarget); } if (project.MaxTargetsCount > 0) { while (project.CompileTargets.Count > project.MaxTargetsCount) { string relPath = project.CompileTargets[0]; string path = project.GetAbsolutePath(relPath); project.SetCompileTarget(path, false); OnProjectModified(new string[] { path }); } } project.Save(); OnProjectModified(paths); }