// Copy a list of files and/or directories from a drag-drop operation to the user's local working directory public static void CopyFiles(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; List <object> args = e.Argument as List <object>; string[] filenames = args[0] as string[]; string classification = args[1] as string; if (filenames != null && filenames.Length > 0) { try { // Sort files and dirs ArrayList fileList = new ArrayList(); ArrayList dirList = new ArrayList(); foreach (string filename in filenames) { if (Directory.Exists(filename)) { dirList.Add(filename); } else if (File.Exists(filename)) { fileList.Add(filename); } } string targetPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(classification); // Simply copy the files foreach (string dirname in dirList) { string target = Path.Combine(targetPath, Path.GetFileName(dirname)); MOG_ControllerSystem.DirectoryCopyEx(dirname, target, worker); } // Simply copy the files foreach (string filename in fileList) { string target = Path.Combine(targetPath, Path.GetFileName(filename)); MOG_ControllerSystem.FileCopyEx(filename, target, true, true, worker); } } catch { } } }
public void MogControl_LibraryListView_DragDrop(object sender, DragEventArgs args) { // Extract the filenames string[] filenames = (string[])args.Data.GetData("FileDrop", false); if (filenames != null && filenames.Length > 0) { bool bCopyFiles = true; bool bAutoAddFiles = false; bool bPromptUser = false; bool bCancel = false; // Check if thes files are coming from the same spot? string classification = this.CurrentClassification; string classificationPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(classification); // Get the common directory scope of the items ArrayList items = new ArrayList(filenames); string rootPath = MOG_ControllerAsset.GetCommonDirectoryPath("", items); if (rootPath.StartsWith(classificationPath)) { bCopyFiles = false; } // Check if auto import is checked? if (this.LibraryExplorer.IsAutoImportChecked()) { // Automatically add the file on the server bAutoAddFiles = true; bPromptUser = true; // Check if these files are already within the library? if (MOG_ControllerLibrary.IsPathWithinLibrary(rootPath)) { // Ignore what the user specified and rely on the classification generated from the filenames classification = ""; bPromptUser = false; bCopyFiles = false; } } // Promt the user for confirmation before we import these files if (bPromptUser) { // Prompt the user and allow them to cancel if (LibraryFileImporter.PromptUserForConfirmation(filenames, classification) == false) { bCancel = true; } } // Make sure we haven't canceled if (!bCancel) { if (bCopyFiles) { // Import the files List <object> arguments = new List <object>(); arguments.Add(filenames); arguments.Add(classification); ProgressDialog progress = new ProgressDialog("Copying Files", "Please wait while the files are copied", LibraryFileImporter.CopyFiles, arguments, true); progress.ShowDialog(); } } // Make sure we haven't canceled if (!bCancel) { if (bAutoAddFiles) { // Import the files List <object> arguments = new List <object>(); arguments.Add(filenames); arguments.Add(classification); ProgressDialog progress = new ProgressDialog("Copying Files", "Please wait while the files are copied", LibraryFileImporter.ImportFiles, arguments, true); progress.ShowDialog(); } } // Refresh view this.LibraryExplorer.Refresh(); } }
private void LocateNonMogAssets_Worker(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; string path = e.Argument as string; // Determin our workspaceDirectory and platformName string workspaceDirectory = ""; string relativePath = ""; string platformName = ""; // Check if this is a library path? if (MOG_ControllerLibrary.GetWorkingDirectory().Length > 0 && path.StartsWith(MOG_ControllerLibrary.GetWorkingDirectory(), StringComparison.CurrentCultureIgnoreCase)) { // Determin proper settings for the library workspaceDirectory = MOG_ControllerLibrary.GetWorkingDirectory(); relativePath = path.Substring(workspaceDirectory.Length).Trim("\\".ToCharArray()); platformName = "All"; // Get the list of known MOG files within the workspace string classification = MOG_ControllerLibrary.ConstructLibraryClassificationFromPath(path); ArrayList containedAssets = MOG_DBAssetAPI.GetAllAssetsByParentClassification(classification); foreach (MOG_Filename thisAsset in containedAssets) { string thisPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(thisAsset.GetAssetClassification()); string thisFilename = Path.Combine(thisPath, thisAsset.GetAssetLabel()); mKnownSyncFiles.Add(thisFilename, thisFilename); mKnownSyncFiles_ArrayList.Add(thisFilename); } } // Check if this is a workspace path? else { workspaceDirectory = MOG_ControllerSyncData.DetectWorkspaceRoot(path); if (workspaceDirectory.Length > 0) { relativePath = path.Substring(workspaceDirectory.Length).Trim("\\".ToCharArray()); MOG_ControllerSyncData sync = MOG_ControllerProject.GetCurrentSyncDataController(); if (sync != null) { platformName = sync.GetPlatformName(); // Get the list of known MOG files within the workspace ArrayList allFiles = MOG_DBAssetAPI.GetAllProjectSyncTargetFilesForPlatform(platformName); foreach (string thisFile in allFiles) { // Trim thisFile just in case it has an extra '\' at the beginning (Needed for BioWare's formulaic sync target booboo) string tempFile = thisFile.Trim("\\".ToCharArray()); // Check if this relative directory matches? if (tempFile.StartsWith(relativePath, StringComparison.CurrentCultureIgnoreCase)) { string filename = Path.Combine(workspaceDirectory, tempFile); mKnownSyncFiles[filename] = filename; mKnownSyncFiles_ArrayList.Add(filename); } } } } } // Continue as long as we got at least one asset from the database ArrayList rogueFiles = new ArrayList(); LocateNonMogAssetsScanFiles(worker, path, rogueFiles, mKnownSyncFiles, path, null); e.Result = rogueFiles; }
public void MogControl_LibraryTreeView_DragDrop(object sender, DragEventArgs args) { if (this.dragOverNode != null) { // Restore node's original colors this.dragOverNode.BackColor = SystemColors.Window; this.dragOverNode.ForeColor = SystemColors.ControlText; } // Get node we want to drop at TreeNode targetNode = this.GetNodeAt(this.PointToClient(new Point(args.X, args.Y))); // and select it so it'll show up in the ListView this.SelectedNode = targetNode; if (args.Data.GetDataPresent("FileDrop")) { // Extract the filenames and import string[] filenames = (string[])args.Data.GetData("FileDrop", false); if (filenames != null && filenames.Length > 0) { bool bCopyFiles = true; bool bAutoAddFiles = false; bool bPromptUser = false; bool bCancel = false; // Check if thes files are coming from the same spot? string classification = targetNode.FullPath; string classificationPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(classification); // Get the common directory scope of the items ArrayList items = new ArrayList(filenames); string rootPath = MOG_ControllerAsset.GetCommonDirectoryPath("", items); if (rootPath.StartsWith(classificationPath)) { bCopyFiles = false; } // Check if auto import is checked? if (this.LibraryExplorer.IsAutoImportChecked()) { // Automatically add the file on the server bAutoAddFiles = true; bPromptUser = true; // Check if these files are already within the library? if (MOG_ControllerLibrary.IsPathWithinLibrary(rootPath)) { // Ignore what the user specified and rely on the classification generated from the filenames classification = ""; bPromptUser = false; bCopyFiles = false; } } // Promt the user for confirmation before we import these files if (bPromptUser) { // Prompt the user and allow them to cancel if (LibraryFileImporter.PromptUserForConfirmation(filenames, classification) == false) { bCancel = true; } } // Make sure we haven't canceled if (!bCancel) { if (bCopyFiles) { // Import the files List <object> arguments = new List <object>(); arguments.Add(filenames); arguments.Add(classification); ProgressDialog progress = new ProgressDialog("Copying Files", "Please wait while the files are copied", LibraryFileImporter.CopyFiles, arguments, true); progress.ShowDialog(); } } // Make sure we haven't canceled if (!bCancel) { if (bAutoAddFiles) { // Import the files List <object> arguments = new List <object>(); arguments.Add(filenames); arguments.Add(classification); ProgressDialog progress = new ProgressDialog("Copying Files", "Please wait while the files are copied", LibraryFileImporter.ImportFiles, arguments, true); progress.ShowDialog(); } } // Refresh view DeInitialize(); Initialize(); } } else if (args.Data.GetDataPresent("LibraryListItems")) { ArrayList items = args.Data.GetData("LibraryListItems") as ArrayList; foreach (string item in items) { // Move library asset here MOG_Filename assetName = new MOG_Filename(item); // Check if this was an asset? if (assetName.GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { bool success = MOG_ControllerProject.GetProject().AssetRename(assetName.GetAssetFullName(), SelectedNode.FullPath + assetName.GetAssetName()); // Make sure we unsync this asset just in case it had already been synced MOG_ControllerLibrary.Unsync(assetName); } // Check if this was a file? else if (DosUtils.FileExistFast(item)) { string dstPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(SelectedNode.FullPath); string dstTarget = Path.Combine(dstPath, Path.GetFileName(item)); DosUtils.FileMoveFast(item, dstTarget, true); } } } else if (args.Data.GetDataPresent("LibraryTreeNode")) { string classification = args.Data.GetData("LibraryTreeNode") as string; if (classification != null && classification.Length > 0) { //Move classification here string[] parts = classification.Split("~".ToCharArray()); if (parts.Length > 0) { string lastPart = parts[parts.Length - 1]; bool success = MOG_ControllerProject.GetProject().ClassificationRename(classification, SelectedNode.FullPath + "~" + lastPart); } else { MOG_Prompt.PromptResponse("Cannot move classification", "MOG was unable to move the classification", Environment.StackTrace, MOGPromptButtons.OK); } } } }
/// <summary> /// Shows Assets based on MOG_Property(s) assigned to PropertyList /// </summary> private void ExpandPropertyTreeDown(TreeNode node) { BeginUpdate(); List <string> classificationsToAdd = GetSubClassifications(node); string thisClassification = node.FullPath; string thisClassificationPath = MOG_ControllerLibrary.ConstructPathFromLibraryClassification(thisClassification); // Check for any local directories if (thisClassificationPath.Length > 0) { DirectoryInfo[] directories = DosUtils.DirectoryGetList(thisClassificationPath, "*.*"); if (directories != null && directories.Length > 0) { foreach (DirectoryInfo directory in directories) { // If we don't already have this classification, add it. if (!classificationsToAdd.Contains(directory.Name)) { classificationsToAdd.Add(directory.Name); } } } } // Sort our classifications alphabetically classificationsToAdd.Sort(); // Foreach classification, add it foreach (string classification in classificationsToAdd) { string fullClassification = MOG_Filename.JoinClassificationString(node.FullPath, classification); // Only add library classifications if (MOG_Filename.IsParentClassificationString(fullClassification, MOG_Filename.GetProjectLibraryClassificationString())) { TreeNode classificationNode = new TreeNode(classification); // Is this a non-MOG folder? if (!MOG_ControllerProject.IsValidClassification(fullClassification)) { classificationNode.ForeColor = Color.LightGray; } // Assign the default node checked state classificationNode.Checked = node.Checked; classificationNode.Tag = new Mog_BaseTag(classificationNode, classification, RepositoryFocusLevel.Classification, false); ((Mog_BaseTag)classificationNode.Tag).PackageNodeType = PackageNodeTypes.Class; node.Nodes.Add(classificationNode); classificationNode.Name = classificationNode.FullPath; SetImageIndices(classificationNode, GetClassificationImageIndex(classificationNode.FullPath)); classificationNode.Nodes.Add(new TreeNode(Blank_Node_Text)); } } EndUpdate(); }