public void RefreshItem(MOG_Command command) { // No reason to bother if they have no library working directory if (MOG_ControllerLibrary.GetWorkingDirectory().Length == 0) { return; } // Make sure this contains an encapsulated command? MOG_Command encapsulatedCommand = command.GetCommand(); if (encapsulatedCommand != null) { // No reason to bother if they are in a different project if (string.Compare(MOG_ControllerProject.GetProjectName(), encapsulatedCommand.GetProject(), true) != 0) { return; } // Check if this encapsulatedCommand contains a valid assetFilename? if (encapsulatedCommand.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { // No reason to bother if this asset's classification doesn't match their mCurrentClassification if (string.Compare(CurrentClassification, encapsulatedCommand.GetAssetFilename().GetAssetClassification(), true) != 0) { return; } } // Can we find the asset node of this file? int itemid = FindListItem(encapsulatedCommand.GetAssetFilename().GetAssetFullName()); if (itemid == -1) { // Check if this was a post command? if (encapsulatedCommand.GetCommandType() == MOG_COMMAND_TYPE.MOG_COMMAND_Post) { // Create a new item ListViewItem item = CreateListViewItemForAsset(encapsulatedCommand.GetAssetFilename()); if (item != null) { LibraryListView.Items.Add(item); itemid = FindListItem(encapsulatedCommand.GetAssetFilename().GetAssetFullName()); } } } // Now check if we finally found our itemid? if (itemid != -1) { ListViewItem item = LibraryListView.Items[itemid]; if (item != null) { int classificationIdx = FindColumn("Classification"); int nameIdx = FindColumn("Name"); int statusIdx = FindColumn("Status"); int userIdx = FindColumn("User"); int commentIdx = FindColumn("Comment"); int localFileIdx = FindColumn("LocalFile"); int repositoryFileIdx = FindColumn("RepositoryFile"); int localTimestampIdx = FindColumn("Local Timestamp"); int serverTimestampIdx = FindColumn("Server Timestamp"); int fullname = FindColumn("Fullname"); int extensionIdx = FindColumn("Extension"); // Determin the type of encapsulated command switch (encapsulatedCommand.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease: UpdateItem(item); break; case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest: string status = ""; string comment = encapsulatedCommand.GetDescription(); string username = encapsulatedCommand.GetUserName(); if (String.Compare(MOG_ControllerProject.GetUserName(), encapsulatedCommand.GetUserName(), true) == 0) { status = "CheckedOut"; } else { status = "Locked"; } item.ImageIndex = MogUtil_AssetIcons.GetLockedBinaryIcon(item.SubItems[repositoryFileIdx].Text); item.SubItems[commentIdx].Text = comment; item.SubItems[userIdx].Text = username; item.SubItems[statusIdx].Text = status; UpdateListViewItemColors(item, status); break; case MOG_COMMAND_TYPE.MOG_COMMAND_Post: item.SubItems[repositoryFileIdx].Text = MOG_ControllerLibrary.ConstructBlessedFilenameFromAssetName(encapsulatedCommand.GetAssetFilename()); UpdateItem(item); break; case MOG_COMMAND_TYPE.MOG_COMMAND_RemoveAssetFromProject: // Make sure to remove this file just incase it had been previously synced MOG_ControllerLibrary.Unsync(encapsulatedCommand.GetAssetFilename()); // Proceed to delete this item RemoveItem(itemid); break; } // Update the item's colors UpdateListViewItemColors(item, item.SubItems[statusIdx].Text); } } } }
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); } } } }