public void InitializeVirtual(string platform) { if (!mInitialized) { GameDataTreeView.BeginUpdate(); GameDataTreeView.Nodes.Clear(); mVirtual = true; // Populate our project tree ArrayList virtualDirectories = MOG_DBAssetAPI.GetAllProjectSyncTargetFilesForPlatform(platform); ArrayList fixedUpVirtualDirectories = new ArrayList(); foreach (string file in virtualDirectories) { // Only add files that have '\\' in front of them. These are files. Those // without '\\' are packages and the files that go into them if (file.StartsWith("\\")) { fixedUpVirtualDirectories.Add(file.TrimStart("\\".ToCharArray())); } else { // File did not have a starting '\', so just add it :) fixedUpVirtualDirectories.Add(file); } } mSyncTargetFiles = new DirectorySet(fixedUpVirtualDirectories); if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { mRoot = new TreeNode(MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory()); mRoot.Tag = new guiAssetTreeTag(MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(), mRoot, MOG_ControllerProject.GetCurrentSyncDataController(), false); VirtualExpand(mRoot, "", MOG_ControllerProject.GetCurrentSyncDataController()); FillDirectory(mRoot, MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(), SystemColors.InactiveCaptionText); GameDataTreeView.Nodes.Add(mRoot); mRoot.Expand(); } mInitialized = true; // If we have nothing for this tree, we should disable it... if (GameDataTreeView.Nodes.Count < 1) { GameDataTreeView.Visible = false; NoLocalDataLabel.Visible = true; } else { GameDataTreeView.Visible = true; NoLocalDataLabel.Visible = false; } GameDataTreeView.EndUpdate(); } }
private void XboxPropertiesForm_Closed(object sender, System.EventArgs e) { string prefsString = MOG_ControllerProject.GetProjectName() + "." + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName(); mUserMap = SyncUserMapComboBox.Text; mProjectMap = SyncProjectMapComboBox.Text; // Set the full filename of the selected user syncfile MogUtils_Settings.SaveSetting(prefsString, "UserSyncFile", mUserMap); MogUtils_Settings.SaveSetting(prefsString, "ProjectSyncFile", mProjectMap); }
private void GameDataCreateMenuItem_Click(object sender, System.EventArgs e) { try { // Create a directory as a child directory of a node if (GameDataTreeView.SelectedNode != null) { guiAssetTreeTag tag = GameDataTreeView.SelectedNode.Tag as guiAssetTreeTag; string directoryPath = tag.FullFilename + "\\NewDirectory"; TreeNode directory = CreateDirectoryNode(tag.FullFilename + "\\NewDirectory", null); // Now create the folder if (!DosUtils.DirectoryCreate(directoryPath)) { MOG_Prompt.PromptResponse("Create Directory", DosUtils.GetLastError(), MOGPromptButtons.OK); } else { // Now edit the name of this node GameDataTreeView.LabelEdit = true; GameDataTreeView.SelectedNode.Nodes.Add(directory); GameDataTreeView.SelectedNode = directory; GameDataTreeView.SelectedNode.BeginEdit(); } } else { // Create a directory at the root of the project string directoryPath = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory() + "\\NewDirectory"; TreeNode directory = CreateDirectoryNode(directoryPath, null); // Now create the folder if (!DosUtils.DirectoryCreate(directoryPath)) { MOG_Prompt.PromptResponse("Create Directory", DosUtils.GetLastError(), MOGPromptButtons.OK); } else { // Now edit the name of this node GameDataTreeView.LabelEdit = true; GameDataTreeView.SelectedNode = directory; directory.BeginEdit(); } } } catch (Exception ex) { MOG_Report.ReportMessage("Create Directory", ex.Message, ex.StackTrace, MOG_ALERT_LEVEL.CRITICAL); } }
static public void ModifyLocalWorkspace_Complete() { // Walk through all of our workspaces foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values) { // Check if this is the current workspace? or // Check if this workspace is active? if (workspace == MOG_ControllerProject.GetCurrentSyncDataController() || workspace.IsAlwaysActive()) { workspace.ModifyLocalWorkspace_Complete(); } } }
static public void SuspendPackaging(bool value) { // Walk through all of our workspaces foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values) { // Check if this is the current workspace? or // Check if this workspace is active? if (workspace == MOG_ControllerProject.GetCurrentSyncDataController() || workspace.IsAlwaysActive()) { workspace.SuspendPackaging(value); } } }
private void TagOkButton_Click(object sender, EventArgs e) { if (TagNameTextBox.Text.Length != 0) { if (MOG_ControllerProject.TagCreate(MOG_ControllerProject.GetCurrentSyncDataController(), TagNameTextBox.Text)) { Close(); } else { MOG_Prompt.PromptMessage("Create Tag", "Error in creating the tag"); } } }
private void BrowseButton_Click(object sender, System.EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { ofd.InitialDirectory = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(); } if (ofd.ShowDialog() == DialogResult.OK) { CommandTextBox.Text = ofd.FileName; } }
private int AppendSummary(string section, string comment, Color nodeColor) { // Get all the file copies if (mSummary.SectionExist(section)) { string[] keys = mSummary.GetSectionKeys(section); foreach (string key in keys) { // Get the asset/file information from the summary file string assetName = mSummary.GetString(section, key); string fileName = key; // Trim any starting '\' if (fileName != null && fileName.Length > 0) { fileName = fileName.TrimStart("\\".ToCharArray()); } try { string fullfilename = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory() + "\\" + fileName; ListViewItem item = new ListViewItem(); item.Text = Path.GetFileName(fileName); item.ForeColor = nodeColor; FileInfo file = new FileInfo(fullfilename); item.SubItems.Add(file.LastWriteTime.ToShortDateString() + " " + file.LastWriteTime.ToShortTimeString()); item.SubItems.Add(comment); item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(fullfilename); SummaryListView.Items.Add(item); } catch (Exception e) { MOG_Report.ReportMessage("Update Summary", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR); } } return(mSummary.CountKeys(section)); } return(0); }
public void LatentInitialize() { mainForm.AssetManagerInboxListView.ContextMenuStrip = mInboxContextMenu.InitializeContextMenu("{Inbox}"); mainForm.AssetManagerDraftsListView.ContextMenuStrip = mDraftsContextMenu.InitializeContextMenu("{Inbox}"); mainForm.AssetManagerSentListView.ContextMenuStrip = mOutboxContextMenu.InitializeContextMenu("{Outbox}"); mainForm.AssetManagerTrashListView.ContextMenuStrip = mTrashContextMenu.InitializeContextMenu("{Trash}"); if (!MOG_ControllerProject.IsProject() || !MOG_ControllerProject.IsUser()) { return; } RefreshAllWindows(); guiUserPrefs.LoadDynamic_LayoutPrefs("AssetManager", mainForm); mLocal.InitialiseLocalView(); mainForm.AssetManagerLocalDataExplorerSplitter.SplitPosition = mLocalExplorer.Width; mainForm.myLocalExplorerToolStripMenuItem.Checked = mLocalExplorer.Opened; mainForm.AssetManagerTasksSplitter.SplitPosition = mToDo.Width; MainMenuViewClass.bChangeLocalBranchRightPanelWidth = true; mainForm.AssetManagerLocalDataSplitter.SplitPosition = mTools.Width; MainMenuViewClass.bChangeLocalBranchRightPanelWidth = false; mainForm.myToolboxToolStripMenuItem.Checked = mTools.Opened; // Initialize our users toolBox MOG_ControllerSyncData sync = MOG_ControllerProject.GetCurrentSyncDataController(); if (sync != null) { // Initialize the local tools window mainForm.CustomToolsBox.Initialize(sync.GetPlatformName()); // DVC } else { mainForm.CustomToolsBox.Visible = false; } mInitialized = true; }
public static void SwitchCurrentWorkspaceBranch(string newBranchName) { // Check if this branch is changing? if (string.Compare(newBranchName, MOG_ControllerProject.GetCurrentSyncDataController().GetBranchName(), true) != 0) { // Push the new branch down into the current workspace if (MOG_DBSyncedDataAPI.SwitchWorkspaceBranch(MOG_ControllerSystem.GetComputerName(), MOG_ControllerProject.GetCurrentSyncDataController().GetProjectName(), MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName(), MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(), MOG_ControllerProject.GetCurrentSyncDataController().GetUserName(), newBranchName)) { // Update our loaded workspace MOG_ControllerProject.GetCurrentSyncDataController().SetBranchName(newBranchName); } } }
static public string GetAssetSize(string asset) { string size = "n/a"; try { // Make sure we have a valid workspace? if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { // Attempt to obtain the size of this asset for the active platform MOG_Properties pProperties = new MOG_Properties(new MOG_Filename(asset)); pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()); size = FormatSize(pProperties.Size); } } catch { } return(size); }
public static bool RebuildLocalPackage(MOG_Filename packageFilename) { if (packageFilename.IsLocal()) { // Walk through all of our workspaces foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values) { // Check if this is the current workspace? or // Check if this workspace is active? if (workspace == MOG_ControllerProject.GetCurrentSyncDataController() || workspace.IsAlwaysActive()) { // We need to know how to handle a local package rebuild differently than a network package rebuild // MOG_Command rebuildPackageCommand = MOG_CommandFactory.Setup_PackageRebuild(packageFilename.GetEncodedFilename(), workspace.GetPlatformName(), ""); // // Send our package merge command to the server // return MOG_ControllerSystem.GetCommandManager().SendToServer(rebuildPackageCommand); } } } return(false); }
public ArrayList LocateAssetBinary(MOG_Filename filename, AssetDirectories AssetDirectoryType) { string targetDir = ""; ArrayList binaryFiles = new ArrayList(); MOG_Properties assetProperties = new MOG_Properties(filename); switch (AssetDirectoryType) { case AssetDirectories.IMPORTED: targetDir = MOG_ControllerAsset.GetAssetImportedDirectory(assetProperties); break; case AssetDirectories.PROCESSED: string platformName = ""; // If we have a valid gameDataController? if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { platformName = MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName(); } targetDir = MOG_ControllerAsset.GetAssetProcessedDirectory(assetProperties, platformName); break; } if (targetDir.Length != 0 && DosUtils.Exist(targetDir)) { FileInfo [] files = DosUtils.FileGetList(targetDir, "*.*"); foreach (FileInfo file in files) { binaryFiles.Add(file.FullName); } } else { MOG_Prompt.PromptMessage("Asset View", "Asset (" + targetDir + ") does not exist or is a zero length file! Cannot View.", Environment.StackTrace); } return(binaryFiles); }
static public bool RemoveAssetFromWorkspaces(MOG_Filename assetFilename, bool bRespectAutoUpdate, BackgroundWorker worker) { bool bFailed = false; // Walk through all of our workspaces foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values) { // Check if this is the current workspace? or // Check if this workspace is active? if (workspace == MOG_ControllerProject.GetCurrentSyncDataController() || workspace.IsAlwaysActive()) { // Check if we have been instructed to respect the auto update flag? if (bRespectAutoUpdate) { // Check if this workspace has the auto update enabled? if (!workspace.IsAutoUpdateEnabled()) { // Skip this workspace as it doesn't have the auto update enabled continue; } } // Proceed to add the asset to this workspace MOG_Filename workspaceAsset = MOG_Filename.GetLocalUpdatedTrayFilename(workspace.GetSyncDirectory(), assetFilename); if (!workspace.RemoveAssetFromLocalWorkspace(workspaceAsset, worker)) { bFailed = true; } } } if (!bFailed) { return(true); } return(false); }
static public bool SetLoginBranch(string branch) { if (string.Compare(MOG_ControllerProject.GetBranchName(), branch, true) != 0) { if (MOG_ControllerProject.LoginProject(MOG_ControllerProject.GetProjectName(), branch) != null && string.Compare(MOG_ControllerProject.GetBranchName(), branch, true) == 0) { MessageBox.Show("You have been switched to a different branch of the project.\n" + "Please keep this in mind as you bless assets, browse project trees or configure project settings.\n\n" + " BRANCH: " + branch + "\n", "Changing Project Branch", MessageBoxButtons.OK); UpdateGuiBranch(MOG_ControllerProject.GetBranchName()); // Check if we have a current workspace? if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { // Check if this branch is different than our workspace's branch? if (string.Compare(branch, MOG_ControllerProject.GetCurrentSyncDataController().GetBranchName(), true) != 0) { // Switch the associated branch of the current workspace WorkspaceManager.SwitchCurrentWorkspaceBranch(branch); } } // Update the project manager if it has been initialized if (mainForm.mProjectManager != null) { mainForm.mProjectManager.BuildRepositoryTrees(true); } return(true); } MOG_Prompt.PromptMessage("Login Branch", "Could not login to selected branch!\nProject:" + MOG_ControllerProject.GetProjectName() + "\nBranch:" + branch, Environment.StackTrace); return(false); } return(true); }
/// <summary> /// Drag and drop routine for the platforms ListView /// </summary> private void PlatformViews_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { // We will only accept a ArrayListAssetManager type object if (e.Data.GetDataPresent("ArrayListAssetManager")) { // Get our array list ArrayList items = e.Data.GetData("ArrayListAssetManager") as ArrayList; List <string> filenames = new List <string>(); foreach (string item in items) { filenames.Add(item); } guiAssetController.UpdateLocal(filenames, true); } } else { MOG_Prompt.PromptMessage("Update Asset", "Could not update asset to your workspace because no workspace was found!", "", MOG_ALERT_LEVEL.ERROR); } }
/// <summary> /// Constructor takes an arraylist of files. We take this files and create a ram tree /// </summary> /// <param name="files"></param> public DirectorySet(ArrayList files) { mBank = new HybridDictionary(true); foreach (string file in files) { try { AddFilename(Path.GetDirectoryName(file), file, false); } catch (Exception e) { if (e.Message == "trying to add empty key") { string message = "Trying to add an asset with an empty key!\n\n" + "Binary Name: " + file + "\n"; MOG_Prompt.PromptMessage("Directory Set", message, e.StackTrace); } else if (e.Message == "duplicate key") { string message = "Two or more duplicate asset files are named the same and are pointing to the same target in your project!\n\n" + "Binary Name: " + file + "\n" + "Asset Name(s):" + "\n\tCan't determine without valid local workspace!\n" + "\nRemove one from the project trees to fix this conflict! Until this is fixed this asset will not be shown in your asset tree."; if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { string duplicateAssets = ""; ArrayList Assets = MOG_ControllerProject.MapFilenameToAssetName(file, MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()); if (Assets != null) { foreach (MOG_Filename asset in Assets) { // Make sure we have a valid match? if (asset != null && asset.GetOriginalFilename().Length > 0) { if (duplicateAssets.Length == 0) { duplicateAssets = "Asset Name(s): \n\t" + asset.GetAssetFullName(); } else { duplicateAssets = duplicateAssets + "\n\t" + asset.GetAssetFullName(); } } } } message = "Two or more duplicate asset files are named the same and are pointing to the same target in your project!\n\n" + "Binary Name: " + file + "\n" + duplicateAssets + "\n" + "\nRemove one of the above Assets from the project trees to fix this conflict! Until this is fixed this asset will not be shown in your tree."; } MOG_Prompt.PromptMessage("Directory Set", message, e.StackTrace); } else { string message = "Unhandled exception occurred while trying to add this file.\n" + "FILE: " + file + "\n\n" + e.Message; MOG_Prompt.PromptMessage("Directory Set", message, e.StackTrace); } } } }
void CommandEventCallBack_Invoked(MOG_Command command) { switch (command.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError: case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException: #region MOG_COMMAND_NotifySystemException MOG_ALERT_LEVEL level = MOG_ALERT_LEVEL.ALERT; switch (command.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemAlert: level = MOG_ALERT_LEVEL.ALERT; break; case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemError: level = MOG_ALERT_LEVEL.ERROR; break; case MOG_COMMAND_TYPE.MOG_COMMAND_NotifySystemException: level = MOG_ALERT_LEVEL.CRITICAL; break; } MOG_Prompt.PromptMessage(command.GetTitle(), command.GetDescription(), command.GetSource(), level); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_LockPersistentNotify: #region MOG_COMMAND_LockPersistentNotify // Check if this is the same project? MOG_Command lockInfo = command.GetCommand(); if (lockInfo != null) { // Check if we are on the locks tab? if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Locks", true) == 0) { if (mainForm.mLibraryManager != null) { mainForm.mLibraryManager.RefreshItem(command); } } // Check if this lock is related to our project? if (MOG_Filename.IsClassificationValidForProject(lockInfo.GetAssetFilename().GetOriginalFilename(), MOG_ControllerProject.GetProjectName())) { // Check if we are on the workspace tab? if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Workspace", true) == 0) { if (mainForm.mAssetManager != null) { mainForm.mAssetManager.RefreshLockStatus(command); // JohnRen - Removed because this is just too slow when the server sends us a ton of locks at startup // mainForm.LocalBranchMogControl_GameDataDestinationTreeView.RefreshFileLockStatus(command); mainForm.mAssetManager.mLocal.RefreshLockStatus(command); } } // Check if we are on the project tab? else if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0) { if (mainForm.mProjectManager != null) { mainForm.mProjectManager.UpdateAsset(command); } } // Check if we are on the library tab? else if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Library", true) == 0) { if (mainForm.mLibraryManager != null) { mainForm.mLibraryManager.RefreshItem(command); } } // Check if this notify just got processed? if (command.GetOptions().Contains("{Processed}")) { // Check if we have a local workspace defined? MOG_ControllerSyncData workspace = MOG_ControllerProject.GetCurrentSyncDataController(); if (workspace != null) { // Time to check if this was our lock that just got released? if (string.Compare(lockInfo.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0 && string.Compare(lockInfo.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0) { // Is this lockInfo for an asset? if (lockInfo.GetAssetFilename().GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { // Check the user's privilege MOG_Privileges privileges = MOG_ControllerProject.GetPrivileges(); if (!privileges.GetUserPrivilege(MOG_ControllerProject.GetUserName(), MOG_PRIVILEGE.IgnoreSyncAsReadOnly)) { MOG_Filename bestAssetFilename = lockInfo.GetAssetFilename(); // Check if there is a better inbox asset that can be substituted? MOG_Filename inboxAssetFilename = MOG_ControllerInbox.LocateBestMatchingAsset(bestAssetFilename); if (inboxAssetFilename != null) { bestAssetFilename = inboxAssetFilename; } // Check if this asset has it's files synced as read only? MOG_Properties properties = new MOG_Properties(bestAssetFilename); if (properties.SyncAsReadOnly) { switch (lockInfo.GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: workspace.SetLocalFileAttributes(lockInfo.GetAssetFilename(), FileAttributes.Normal); break; case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease: workspace.SetLocalFileAttributes(lockInfo.GetAssetFilename(), FileAttributes.ReadOnly); break; } } } } } } } } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ViewUpdate: #region MOG_COMMAND_ViewUpdate // Make sure this is relevant to our active project? if (string.Compare(command.GetProject(), MOG_ControllerProject.GetProjectName(), true) != 0) { break; } if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0) { // Process the auto process and package commands switch (MOG_AssetStatus.GetType(command.GetDescription())) { case MOG_AssetStatusType.Modified: case MOG_AssetStatusType.Unprocessed: // Check to see if this command comes from us if (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) != 0) { break; } // Check for Auto Process if (mainForm.AssetManagerAutoProcessCheckBox.Checked && string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0) { guiAssetController.Process(command.GetDestination()); } break; //KLK - This may be overkill because we are on the Project tab and why do we want to change their local package button case MOG_AssetStatusType.Packaged: break; case MOG_AssetStatusType.Unpackaged: case MOG_AssetStatusType.Repackage: case MOG_AssetStatusType.PackageError: case MOG_AssetStatusType.Unpackage: // We just got a new asset. Make sure we inform the gui that a package is now required if (mainForm.mAssetManager != null) { mainForm.mAssetManager.RefreshWindowsBoth(command); } break; } } //if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Workspace", true) == 0) if (true) { if (string.Compare(command.GetDescription(), "UnGrouped", true) == 0) { command.SetDestination(""); } try { // Filter out updates to other computers that share our username and project if ((string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) != 0) && (string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Copied), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Unpackaged), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Repackage), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Packaged), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.PackageError), true) == 0 || string.Compare(command.GetDescription(), MOG_AssetStatus.GetText(MOG_AssetStatusType.Unpackage), true) == 0)) { return; } else { mainForm.mAssetManager.RefreshWindowsBoth(command); } } catch (Exception e) { Debug.Write(e.ToString()); } // JohnRen - Changed... // The ViewUpdate command contains the computer name of who generated the view command...not the computer name of the originator of the rip // Because of this, AutoUpdate local would not work anytime somebody else's slave performed the rip. // Changed the AutoUpdate events to respect the login user instead of the computer name because this will be 100% correct... // However, multiple users will experience the event if they are logged in as the same user. // // Process the auto process and package commands // // only do this code if the command came from us // if (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0) MOG_Filename destinationFilename = new MOG_Filename(command.GetDestination()); if (string.Compare(destinationFilename.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0) { switch (MOG_AssetStatus.GetType(command.GetDescription())) { case MOG_AssetStatusType.Modified: case MOG_AssetStatusType.Unprocessed: // Check for Auto Process if (mainForm.AssetManagerAutoProcessCheckBox.Checked) { // Only auto-process this if it is in the drafts folder if (destinationFilename.IsDrafts()) { // Make sure we are the ones that requested it if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 && (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0)) { guiAssetController.Process(command.GetDestination()); } } } break; case MOG_AssetStatusType.Imported: // Only auto-process this if it is in the drafts folder if (destinationFilename.IsDrafts()) { // Make sure we are the ones that requested it if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 && (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0)) { guiAssetController.UpdateLocal(command.GetDestination(), false); } } break; case MOG_AssetStatusType.Processed: case MOG_AssetStatusType.Sent: // Check if the MainForm's AutoUpdate button is checked? if (mainForm.AssetManagerAutoUpdateLocalCheckBox.Checked) { // Only auto-process this if it is in the drafts folder if (destinationFilename.IsDrafts()) { // Make sure we are the ones that requested it if (string.Compare(command.GetUserName(), MOG_ControllerProject.GetUser().GetUserName(), true) == 0 && (string.Compare(command.GetComputerName(), MOG_ControllerSystem.GetComputerName(), true) == 0)) { // Check if we have a current workspace? if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { guiAssetController.UpdateLocal(command.GetDestination(), false); } } } } break; case MOG_AssetStatusType.Rebuilt: if (mainForm.mAssetManager != null) { mainForm.mAssetManager.RefreshActiveWindow(); } break; case MOG_AssetStatusType.Deleted: MOG_Filename assetName = new MOG_Filename(command.GetSource()); if (assetName.IsTrash() && mainForm.mAssetManager != null && mainForm.mAssetManager.mTrash != null && mainForm.AssetManagerInboxTabControl.SelectedTab.Name == "AssetManagerTrashTabPage") { mainForm.mAssetManager.mTrash.RefreshRemove(command); } else if (assetName.IsLocal() && mainForm.mAssetManager != null) { MOG_Filename tempAssetName = new MOG_Filename(command.GetSource()); } break; } } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_RegisterEditor: #region MOG_COMMAND_RegisterEditor // We just lost an Editor WorkspaceManager.RegisterEditor(command.GetWorkingDirectory()); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ShutdownEditor: #region MOG_COMMAND_ShutdownEditor // We just lost an Editor WorkspaceManager.ShutdownEditor(command.GetWorkingDirectory()); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionLost: #region MOG_COMMAND_ConnectionLost // The server was shutdown Bitmap DisconnectedIcon = new Bitmap(mainForm.StatusBarImageList.Images[1]); mainForm.MOGStatusBarConnectionStatusBarPanel.Icon = System.Drawing.Icon.FromHandle(DisconnectedIcon.GetHicon()); mainForm.MOGStatusBarConnectionStatusBarPanel.Text = "Disconnected"; mainForm.MOGStatusBarConnectionStatusBarPanel.ToolTipText = "Server is disconnected!"; #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ConnectionNew: #region MOG_COMMAND_ConnectionNew Bitmap ConnectedIcon = new Bitmap(mainForm.StatusBarImageList.Images[0]); mainForm.MOGStatusBarConnectionStatusBarPanel.Icon = System.Drawing.Icon.FromHandle(ConnectedIcon.GetHicon()); mainForm.MOGStatusBarConnectionStatusBarPanel.Text = "Connected"; mainForm.MOGStatusBarConnectionStatusBarPanel.ToolTipText = mainForm.RefreshConnectionToolText(); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_Complete: #region MOG_COMMAND_Complete // Make sure this contains an encapsulated command? if (command.GetCommand() != null) { // Determin the type of encapsulated command switch (command.GetCommand().GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_Post: #region MOG_COMMAND_PostComplete if (mainForm != null) { // Check if we are on a tab that cares about this event? if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0) { if (mainForm.mConnectionManager != null) { // Only listen for the final Post w/o any assetFilename listed or else we would cause too many full refreshes if (command.GetCommand().GetAssetFilename().GetOriginalFilename().Length == 0) { // Refresh the pending package listview mainForm.mConnectionManager.RefreshMerging(); // Refresh the pending post listview mainForm.mConnectionManager.RefreshPosting(); } } } // Check if this remove was successful? if (command.GetCommand().IsCompleted()) { // Someday this would be nice, but the library tab does refresh when it gets reselected so we need to process this event even though we are on another tab // // Check if we are on a tab that cares about this event? // if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Library", true) == 0) // { if (command.GetCommand().GetAssetFilename().IsLibrary()) { if (mainForm.mLibraryManager != null) { mainForm.mLibraryManager.RefreshItem(command); } } // } // Check if we are on a tab that cares about this event? if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Project", true) == 0) { if (mainForm.mProjectManager != null) { mainForm.mProjectManager.MakeAssetCurrent(command.GetCommand().GetAssetFilename()); } } } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_ReinstanceAssetRevision: #region MOG_COMMAND_ReinstanceAssetRevision // Check if this remove was successful? if (command.GetCommand().IsCompleted()) { if (mainForm.mProjectManager != null) { mainForm.mProjectManager.RemoveAssetFromProject(new MOG_Filename(command.GetCommand().GetSource())); mainForm.mProjectManager.MakeAssetCurrent(command.GetCommand().GetAssetFilename()); } if (mainForm.LibraryExplorer != null) { mainForm.LibraryExplorer.LibraryListView.RefreshItem(command); } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_RemoveAssetFromProject: #region MOG_COMMAND_RemoveAssetFromProject // Check if this remove was successful? if (command.GetCommand().IsCompleted()) { if (mainForm.mProjectManager != null) { mainForm.mProjectManager.RemoveAssetFromProject(command.GetCommand().GetAssetFilename()); } if (mainForm.LibraryExplorer != null) { mainForm.LibraryExplorer.LibraryListView.RefreshItem(command); } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkPackageMerge: case MOG_COMMAND_TYPE.MOG_COMMAND_LocalPackageMerge: case MOG_COMMAND_TYPE.MOG_COMMAND_EditorPackageMergeTask: case MOG_COMMAND_TYPE.MOG_COMMAND_NetworkPackageRebuild: WorkspaceManager.EndPackaging(command.GetCommand().GetWorkingDirectory()); break; } } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveConnection: #region MOG_COMMAND_NotifyActiveConnection if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0) { if (mainForm.mConnectionManager != null) { mainForm.mConnectionManager.UpdateConnections(command); } } #endregion break; // These are the all around locks requested commands from the server case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveLock: #region MOG_COMMAND_NotifyActiveLock switch (command.GetCommand().GetCommandType()) { case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockReadRequest: case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRelease: case MOG_COMMAND_TYPE.MOG_COMMAND_LockWriteRequest: if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Locks", true) == 0) { if (mainForm.mLockManager != null) { mainForm.mLockManager.RefreshLockWindows(command); } } break; } #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshProject: #region MOG_COMMAND_RefreshProject MainMenuProjectsClass.MOGGlobalRefreshProject(mainForm); #endregion break; case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshApplication: break; case MOG_COMMAND_TYPE.MOG_COMMAND_RefreshTools: break; // These are the all around general commands from the server case MOG_COMMAND_TYPE.MOG_COMMAND_NotifyActiveCommand: #region MOG_COMMAND_NotifyActiveCommand // The command manager needs to know about all commands if (string.Compare(MOG_ControllerProject.GetActiveTabName(), "Connections", true) == 0) { if (mainForm.mConnectionManager != null) { mainForm.mConnectionManager.UpdateCommands(command); } } #endregion break; } }
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 BuildMerge(bool ShowSyncWindow, bool silent, string tag, string filter, bool updateModifiedMissing, bool cleanUnknownFiles) { //get the sync data controller MOG_ControllerSyncData gameDataHandle = MOG_ControllerProject.GetCurrentSyncDataController(); //if we don't have one infom the user that we need one if (gameDataHandle == null) { MOG_Prompt.PromptMessage("Update Build", "Cannot update a build without a valid local Workspace and Workspace tab created. Create a local Workspace first then try again.", Environment.StackTrace); return; } SyncLatestForm update = new SyncLatestForm(mainForm, mainForm.mAdministratorMode, tag, filter, mDefaultUpdateBuildType, gameDataHandle.GetSyncDirectory(), mCurrentVersion, mHidePlatforms, updateModifiedMissing, cleanUnknownFiles); try { //if we are expected to show the SyncWindow if (ShowSyncWindow) { if (update.ShowDialog(mainForm) == DialogResult.OK) { // Make sure we update our local variables that could get changed within the dialog tag = update.SyncTag; updateModifiedMissing = update.UpdateBuildCheckMissingCheckBox.Checked; cleanUnknownFiles = update.UpdateBuildCleanUnknownFilesCheckBox.Checked; } else { //the result is not ok, so do not proceed with the sync return; } } //get the sync directory from the SyncDataController string targetProjectPath = gameDataHandle.GetSyncDirectory(); // Get the current SyncData controller MOG_ControllerSyncData sync = MOG_ControllerProject.GetCurrentSyncDataController(); if (sync != null) { // Check if the user has specified a cleaning? if (cleanUnknownFiles) { // Check if we need to clean the workspace? string startingPath = sync.GetSyncDirectory(); try { MogUtil_WorkspaceCleaner cleaner = new MogUtil_WorkspaceCleaner(); cleaner.Clean(startingPath); } catch (Exception ex) { MOG_Prompt.PromptMessage("Clean", "The cleaner exited with the following error (" + ex.Message + ")"); } } // Attempt to use the dialog's MOG_LocalSyncInfo MOG_LocalSyncInfo localSyncInfo = update.mLocalSyncInfo; if (localSyncInfo == null) { // Looks like we need to build our own MOG_LocalSyncInfo string computerName = MOG_ControllerSystem.GetComputerName(); string projectName = MOG_ControllerProject.GetProjectName(); string platformName = MOG_ControllerProject.GetPlatformName(); string syncDirectory = MOG_ControllerProject.GetCurrentSyncDataController().GetSyncDirectory(); string userName = MOG_ControllerProject.GetUserName(); string classification = MOG_ControllerProject.GetProjectName(); localSyncInfo = new MOG_LocalSyncInfo(computerName, projectName, platformName, syncDirectory, tag, userName, classification, ""); } // Check if we want to update missing sync.SyncRepositoryData(MOG_ControllerProject.GetProjectName(), update.Exclusions, update.Inclusions, updateModifiedMissing, localSyncInfo); // Show the summary file SyncLatestSummaryForm summary = new SyncLatestSummaryForm(sync.GetSyncLog()); if (silent) { summary.Show(mainForm); } else { summary.ShowDialog(mainForm); } } guiUserPrefs.SaveDynamic_LayoutPrefs("AssetManager", mainForm); update.Dispose(); } catch (Exception e) { MOG_Report.ReportMessage("Update", "Could not perform update due to error:\n\n" + e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.ERROR); } }
/// <summary> /// Update an existing ListView node for the asset manager inboxes /// </summary> /// <param name="pProperties"></param> /// <param name="nodeColor"></param> /// <returns></returns> public static void UpdateListViewItem(ListViewItem item, MOG_Filename asset, string status, MOG_Properties pProperties) { string date = ""; string size = ""; string creator = ""; string owner = ""; string group = ""; string target = ""; // Check if we have a properties? if (pProperties != null) { // If we have a valid gameDataController, set our platform scope if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { // Set our current platform pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()); } // Gather the following info from our properties date = MOG_Time.FormatTimestamp(pProperties.CreatedTime, ""); size = guiAssetController.FormatSize(pProperties.Size); creator = pProperties.Creator; owner = pProperties.Owner; group = pProperties.Group; // Check if this is a packaged asset? if (pProperties.IsPackagedAsset) { // Check if we have have any package assignments in our propeerties? ArrayList packages = pProperties.GetPackages(); if (packages.Count == 0) { // Indicate this is a packaged asset w/o any package assignments target = "Missing package assignment..."; } else if (packages.Count == 1) { MOG_Property package = packages[0] as MOG_Property; MOG_Filename packageName = new MOG_Filename(MOG_ControllerPackage.GetPackageName(package.mPropertyKey)); string packageGroupPath = MOG_ControllerPackage.GetPackageGroups(package.mPropertyKey); string displayString = MOG_ControllerPackage.CombinePackageAssignment(packageName.GetAssetLabel(), packageGroupPath, ""); target = "{Package} " + displayString + " in " + MOG_Filename.GetAdamlessClassification(packageName.GetAssetClassification()); } else { target = "{Package} " + packages.Count + " Assignments..."; } } else if (pProperties.SyncFiles) { // Get the formatted SyncTarget of this asset target = MOG_Tokens.GetFormattedString("{Workspace}\\" + pProperties.SyncTargetPath, asset, pProperties.GetPropertyList()); } } item.Text = asset.GetAssetLabel(); // Populate the item's SubItems // I tried for a long time to be smart here and use ColumnNameFind(thisListView.Columns, "Name") but // I kept running into walls because this function is used by a lot of workers outside of the ListView's thread. // So, I gave up and am just going to do it the ugly brute force way! YUCK!! item.SubItems[(int)AssetBoxColumns.NAME].Text = asset.GetAssetLabel(); item.SubItems[(int)AssetBoxColumns.CLASS].Text = asset.GetAssetClassification(); item.SubItems[(int)AssetBoxColumns.TARGETPATH].Text = target; item.SubItems[(int)AssetBoxColumns.DATE].Text = date; item.SubItems[(int)AssetBoxColumns.SIZE].Text = size; item.SubItems[(int)AssetBoxColumns.PLATFORM].Text = asset.GetAssetPlatform(); item.SubItems[(int)AssetBoxColumns.STATE].Text = status; item.SubItems[(int)AssetBoxColumns.CREATOR].Text = creator; item.SubItems[(int)AssetBoxColumns.RESPPARTY].Text = owner; item.SubItems[(int)AssetBoxColumns.OPTIONS].Text = ""; item.SubItems[(int)AssetBoxColumns.FULLNAME].Text = asset.GetEncodedFilename(); item.SubItems[(int)AssetBoxColumns.BOX].Text = asset.GetBoxName(); item.SubItems[(int)AssetBoxColumns.GROUP].Text = group; // Set the item's Icons item.ImageIndex = MogUtil_AssetIcons.GetFileIconIndex(asset.GetEncodedFilename(), pProperties); if (MogMainForm.MainApp != null && MogMainForm.MainApp.mAssetManager != null) { // mAssetStatus.GetStatusInfo() is sort of a black sheep and should maybe become static item.StateImageIndex = MogMainForm.MainApp.mAssetManager.mAssetStatus.GetStatusInfo(status).IconIndex; } // Set the item's color item.ForeColor = MOG_AssetStatus.GetColor(status); // Check if this is a local item that has been blessed? if (asset.IsLocal() && string.Compare(status, MOG_AssetStatus.GetText(MOG_AssetStatusType.Blessed), true) == 0) { // Mark local blessed items with light gray item.ForeColor = Color.LightGray; } }
private void SyncSaveButton_Click(object sender, System.EventArgs e) { SyncSaveFileDialog.InitialDirectory = MOG_ControllerProject.GetUser().GetUserToolsPath(); // Save this custom sync file if (SyncSaveFileDialog.ShowDialog() == DialogResult.OK) { string syncFilename = SyncSaveFileDialog.FileName; MOG_Ini syncFile = new MOG_Ini(syncFilename); foreach (TreeNode sectionNode in XboxSincTreeView.Nodes) { string section = sectionNode.Text; foreach (TreeNode keyNode in sectionNode.Nodes) { string key = keyNode.Text; if (keyNode.Nodes.Count > 0) { foreach (TreeNode valNode in keyNode.Nodes) { string val = valNode.Text; syncFile.PutString(section, key, val); } } else { syncFile.PutSectionString(section, key); } } } // Verify that the newly created sync file has the correct number amount of sections if (syncFile.SectionExist("Filemap")) { if (syncFile.CountKeys("Filemap") > 0 && string.Compare(SyncProjectMapComboBox.Text, "None") == 0) { MOG_Prompt.PromptMessage("Missing syncfile data", "The required 'FILEMAP' section was not found in this custom sync file. Aborting..."); syncFile.CloseNoSave(); return; } } else { MOG_Prompt.PromptMessage("Missing syncfile data", "The required 'FILEMAP' section was not found in this custom sync file. Aborting..."); syncFile.CloseNoSave(); return; } // Make sure we have a valid root definition if (syncFile.SectionExist(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName())) { if (syncFile.CountKeys(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()) > 0 && string.Compare(SyncProjectMapComboBox.Text, "None") == 0) { MOG_Prompt.PromptMessage("Missing syncfile data", "The required '" + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName() + "' section was not found in this custom sync file. Aborting..."); syncFile.CloseNoSave(); return; } } else { MOG_Prompt.PromptMessage("Missing syncfile data", "The required '" + MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName() + "' section was not found in this custom sync file. Aborting..."); syncFile.CloseNoSave(); return; } // Save out our new syncFile syncFile.Save(); SyncSaveButton.Enabled = false; mUserMap = syncFile.GetFilename(); } }
/// <summary> /// Refresh an assets status from a ViewUpdate Command /// </summary> public void RefreshBox(MOG_Filename add, MOG_Filename del, MOG_Command command) { lock (mAssetManager) { ListView currentViewAdd = mAssetManager.IsolateListView(add.GetBoxName(), add.GetFilenameType(), add.GetUserName()); ListView currentViewDel = mAssetManager.IsolateListView(del.GetBoxName(), del.GetFilenameType(), del.GetUserName()); // Don't continue if we don't have a valid add and del box if ((currentViewAdd == null) && (currentViewDel == null)) { return; } // Begin the update if (currentViewAdd != null) { currentViewAdd.BeginUpdate(); } if (currentViewDel != null) { currentViewDel.BeginUpdate(); } string status = command.GetDescription(); mAssetManager.mainForm.mSoundManager.PlayStatusSound("AssetEvents", status); try { // Obtain the properties from the command MOG_Properties pProperties = null; string[] commandProps = command.GetVeriables().Split("$".ToCharArray()); if (commandProps != null) { ArrayList realProps = new ArrayList(); // Convert the commandProps into a list of real Properties for (int i = 0; i < commandProps.Length; i++) { // Confirm this appears to be a valid prop? if (commandProps[i].StartsWith("[")) { MOG_Property commandProp = new MOG_Property(commandProps[i]); // Make sure the property was initialized correctly? if (commandProp.mSection.Length > 0 && commandProp.mKey.Length > 0) { // Add this realProp realProps.Add(commandProp); } } } // Construct the pProperties from the realProps pProperties = new MOG_Properties(realProps); // If we have a valid gameDataController, set our platform scope if (MOG_ControllerProject.GetCurrentSyncDataController() != null) { pProperties.SetScope(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()); } } // Check if we are just updating an item in the same list? if (currentViewAdd == currentViewDel) { // Check to see if this item already exists? int targetIndex = mAssetManager.ListViewItemFindFullItem(del, currentViewDel); int sourceIndex = mAssetManager.ListViewItemFindFullItem(add, currentViewAdd); if (sourceIndex != -1) { // Update the existing item ListViewItem item = currentViewAdd.Items[sourceIndex]; guiAssetManager.UpdateListViewItem(item, add, status, pProperties); // If there was also a target index, we need to delete it because the source became the target. if (targetIndex != -1 && targetIndex != sourceIndex) { ListViewItem removeItem = currentViewAdd.Items[targetIndex]; // Make sure to clear our stateImage index which will clear the checked state before we attempt to remove the node or we will throw removeItem.StateImageIndex = 0; currentViewAdd.Items.Remove(removeItem); } } // Special case when we are dealing with a renamed file else if (targetIndex != -1 && sourceIndex == -1) { // Get the old item ListViewItem item = currentViewDel.Items[targetIndex]; // Update it to the new renamed item guiAssetManager.UpdateListViewItem(item, add, status, pProperties); } else { // Add a new item CreateListViewItem(currentViewAdd, add, status, pProperties); // Make sure we always keep our tab's text up-to-date mAssetManager.UpdateAssetManagerTabText(add); } } else { // Looks like we may need to do both the add and the remove // Check if we have the currentViewDel? if (currentViewDel != null) { int index = mAssetManager.ListViewItemFindFullItem(del, currentViewDel); if (index != -1) { ListViewItem item = currentViewDel.Items[index]; // Make sure to clear our stateImage index which will clear the checked state before we attempt to remove the node or we will throw item.StateImageIndex = 0; // Remove the item from the list currentViewDel.Items.Remove(item); // Make sure we always keep our tab's text up-to-date mAssetManager.UpdateAssetManagerTabText(del); } } // Check if we have the currentViewAdd? if (currentViewAdd != null) { // Check to see if this item already exists? int sourceIndex = mAssetManager.ListViewItemFindFullItem(add, currentViewAdd); if (sourceIndex != -1) { // Update the existing item ListViewItem item = currentViewAdd.Items[sourceIndex]; guiAssetManager.UpdateListViewItem(item, add, status, pProperties); } else { // Add a new item CreateListViewItem(currentViewAdd, add, status, pProperties); // Make sure we always keep our tab's text up-to-date mAssetManager.UpdateAssetManagerTabText(add); } } } } catch (Exception ex) { MOG_Report.ReportSilent("RefreshBox", ex.Message, ex.StackTrace); } // End the update if (currentViewAdd != null) { currentViewAdd.EndUpdate(); } if (currentViewDel != null) { currentViewDel.EndUpdate(); } } }
static public bool AddAssetToWorkspaces(MOG_Filename assetFilename, bool userInitiated, BackgroundWorker worker) { bool bFailed = false; // Open the asset now to save time later so it doesn't need to be opened for each workspace MOG_ControllerAsset asset = MOG_ControllerAsset.OpenAsset(assetFilename); if (asset != null) { try { // Walk through all of our workspaces foreach (MOG_ControllerSyncData workspace in mWorkspaces.Values) { bool bAddAsset = false; // Check if this workspace is active? if (workspace.IsAlwaysActive()) { bAddAsset = true; } // Imported asset has special logic else if (asset.GetProperties().Status == MOG_AssetStatus.GetText(MOG_AssetStatusType.Imported)) { // Check if this asset originated from within this workspace? (special case added for SmartBomb so editor will always update the workspace of an object sent from the editor) if (DosUtils.PathIsWithinPath(workspace.GetSyncDirectory(), asset.GetProperties().SourcePath)) { bAddAsset = true; } // Check if the user actually initiated this event? else if (userInitiated && workspace == MOG_ControllerProject.GetCurrentSyncDataController()) { bAddAsset = true; } } // All other assets should simply go into the current else if (workspace == MOG_ControllerProject.GetCurrentSyncDataController()) { bAddAsset = true; } // Should this asset be added? if (bAddAsset) { // Decide if the user wants to be notified about the asset's update bool bInformUser = userInitiated; // Check if no worker was specified? or // Check if this isn't the active workspace? if (worker == null || workspace != MOG_ControllerProject.GetCurrentSyncDataController()) { // Don't bother the user about any problems bInformUser = false; } // Check if we can add this asset to the local workspace? if (workspace.CanAddAssetToLocalWorkspace(asset, bInformUser)) { // Check if this asset comming from an inbox? and // Check if this asset comming from our inbox? and // Check if this asset's current state is 'Imported' and // Check if this asset originated from this workspace? // Finally, Make sure this wasn't user initiated? if (assetFilename.IsWithinInboxes() && string.Compare(assetFilename.GetUserName(), MOG_ControllerProject.GetUserName(), true) == 0 && string.Compare(asset.GetProperties().Status, MOG_AssetStatus.GetText(MOG_AssetStatusType.Imported), true) == 0 && MOG_Filename.IsWithinPath(workspace.GetSyncDirectory(), asset.GetProperties().SourcePath) && !userInitiated) { // Looks like we can proceed to import if (!workspace.AddAssetToLocalUpdatedTray(asset, worker)) { bFailed = true; } // Continue on to the next asset continue; } // Proceed to add the asset to this workspace if (!workspace.AddAssetToLocalWorkspace(asset, worker)) { bFailed = true; } } } } } finally { asset.Close(); } } else { bFailed = true; } if (!bFailed) { return(true); } return(false); }
private void PopulateSyncTree(MOG_Ini ProjectPlatfromSinc, MOG_Ini userPlatfromSinc) { // Clear our list XboxSincTreeView.Nodes.Clear(); #region Project platform defaults // Load the project platform defaults TreeNode parentPlatform = new TreeNode(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName()); if ((ProjectPlatfromSinc != null) && (ProjectPlatfromSinc.SectionExist("xbox"))) { for (int x = 0; x < ProjectPlatfromSinc.CountKeys("Xbox"); x++) { TreeNode node = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyNameByIndexSLOW("Xbox", x))); TreeNode child = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyByIndexSLOW("Xbox", x))); node.Checked = true; node.Nodes.Add(child); parentPlatform.Nodes.Add(node); } } // Add user nodes if (userPlatfromSinc != null) { if (userPlatfromSinc.SectionExist("xbox")) { for (int x = 0; x < userPlatfromSinc.CountKeys("Xbox"); x++) { TreeNode node = new TreeNode(FormatString(userPlatfromSinc.GetKeyNameByIndexSLOW("Xbox", x))); TreeNode child = new TreeNode(FormatString(userPlatfromSinc.GetKeyByIndexSLOW("Xbox", x))); node.Checked = true; node.ForeColor = Color.Blue; node.Nodes.Add(child); parentPlatform.Nodes.Add(node); } } } XboxSincTreeView.Nodes.Add(parentPlatform); #endregion #region Filemaps // Load project Filemaps TreeNode parentFileMaps = new TreeNode("FileMap"); if ((ProjectPlatfromSinc != null) && (ProjectPlatfromSinc.SectionExist("FileMap"))) { for (int x = 0; x < ProjectPlatfromSinc.CountKeys("FileMap"); x++) { TreeNode node = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyNameByIndexSLOW("FileMap", x))); TreeNode child = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyByIndexSLOW("FileMap", x))); node.Checked = true; node.Nodes.Add(child); parentFileMaps.Nodes.Add(node); } } // Add user nodes if (userPlatfromSinc != null) { if (userPlatfromSinc.SectionExist("FileMap")) { for (int x = 0; x < userPlatfromSinc.CountKeys("FileMap"); x++) { TreeNode node = new TreeNode(FormatString(userPlatfromSinc.GetKeyNameByIndexSLOW("FileMap", x))); node.ForeColor = Color.Blue; node.Checked = true; TreeNode child = new TreeNode(FormatString(userPlatfromSinc.GetKeyByIndexSLOW("FileMap", x))); node.ForeColor = Color.Blue; node.Nodes.Add(child); parentFileMaps.Nodes.Add(node); } } } XboxSincTreeView.Nodes.Add(parentFileMaps); #endregion #region Remaps // Load Remaps TreeNode parentRemaps = new TreeNode("ReMap"); if ((ProjectPlatfromSinc != null) && (ProjectPlatfromSinc.SectionExist("ReMap"))) { for (int x = 0; x < ProjectPlatfromSinc.CountKeys("ReMap"); x++) { TreeNode node = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyNameByIndexSLOW("ReMap", x))); node.Checked = true; node.Nodes.Add(FormatString(ProjectPlatfromSinc.GetKeyByIndexSLOW("ReMap", x))); parentRemaps.Nodes.Add(node); } } if ((userPlatfromSinc != null) && (userPlatfromSinc.SectionExist("ReMap"))) { for (int x = 0; x < userPlatfromSinc.CountKeys("ReMap"); x++) { TreeNode node = new TreeNode(FormatString(userPlatfromSinc.GetKeyNameByIndexSLOW("ReMap", x))); node.Checked = true; node.ForeColor = Color.Blue; node.Nodes.Add(FormatString(userPlatfromSinc.GetKeyByIndexSLOW("ReMap", x))); parentRemaps.Nodes.Add(node); } } XboxSincTreeView.Nodes.Add(parentRemaps); #endregion #region Exclusions // Load Exclusions TreeNode parentExclusions = new TreeNode("Exclusion"); if ((ProjectPlatfromSinc != null) && (ProjectPlatfromSinc.SectionExist("Exclusion"))) { for (int x = 0; x < ProjectPlatfromSinc.CountKeys("Exclusion"); x++) { TreeNode node = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyNameByIndexSLOW("Exclusion", x))); node.Checked = true; node.Nodes.Add(FormatString(ProjectPlatfromSinc.GetKeyByIndexSLOW("Exclusion", x))); parentExclusions.Nodes.Add(node); } } // Add user nodes if (userPlatfromSinc != null) { if (userPlatfromSinc.SectionExist("Exclusion")) { for (int x = 0; x < userPlatfromSinc.CountKeys("Exclusion"); x++) { TreeNode node = new TreeNode(FormatString(userPlatfromSinc.GetKeyNameByIndexSLOW("Exclusion", x))); node.ForeColor = Color.Blue; node.Checked = true; TreeNode child = new TreeNode(FormatString(userPlatfromSinc.GetKeyByIndexSLOW("Exclusion", x))); node.ForeColor = Color.Blue; node.Nodes.Add(child); parentExclusions.Nodes.Add(node); } } } XboxSincTreeView.Nodes.Add(parentExclusions); #endregion }