TreeNode AddFile(string path, RMSingleFileCollection sFCollection, bool pathCanBeTrimmed = false)
        {
            RMSingleFile singleFile = new RMSingleFile(sFCollection);

            singleFile.FileName = Path.GetFileName(path);
            if (pathCanBeTrimmed)
            {
                singleFile.Path = Helper.GetRelativePath(path, RootDirectory);
            }
            else
            {
                singleFile.Path = path;
                //singleFile.NonRelativePath = true;
            }

            TreeNode             tNode = new TreeNode();
            frmPackAssetTNodeTag tag   = new frmPackAssetTNodeTag(tNode, singleFile, RootDirectory);

            tNode.Text = tag.ToString();
            tNode.Tag  = tag;

            if (sFCollection.Files == null)
            {
                sFCollection.Files = new List <RMSingleFile>();
            }
            sFCollection.Files.Add(singleFile);

            return(tNode);
        }
 public static RMCollectionType GetRMCollectionType(this RMSingleFile file)
 {
     if (file.Parent == null)
     {
         throw new NullReferenceException(ExceptionMessages.RMPackage.COLL_NO_PARENT);
     }
     return(file.Parent.GetRMCollectionType());
 }
        public RMSingleFile Clone(RMSingleFileCollection parent)
        {
            RMSingleFile clone = new RMSingleFile(parent);

            clone.FileName           = FileName;
            clone.InstallationStatus = InstallationStatus;
            clone.InternalFileName   = InternalFileName;
            clone.Path  = Path;
            clone._path = _path;
            return(clone);
        }
            internal static RMSingleFileCollection RetrieveSingleFileCollection(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, RMSingleFileCollection.CollectionType typeOfCollection, RMPackage package)
            {
                log = new LogDataList();
                log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedAutoData(package.Name, path, typeOfCollection.ToRMCollectionType()), _namespace);
                RMSingleFileCollection newCollection = typeOfCollection.ToNewClassInstance(package);
                string fileExtension = typeOfCollection.ToFileExtension();

                if (newCollection == null)
                {
                    return(null);
                }
                string[] files = null;
                try
                {
                    files = Directory.GetFiles(path, "*." + fileExtension);
                }
                catch (Exception ex)
                {
                    log.WriteErrorLog(LoggerMessages.RMPackage.Error.RetrieveAutoError(path, package.Name, typeOfCollection.ToRMCollectionType()), _namespace, ex);
                    return(null);
                }
                if (files == null || files.Length == 0)
                {
                    return(null);
                }

                for (int i = 0; i < files.Length; i++)
                {
                    string originalFileName = Path.GetFileNameWithoutExtension(files[i]);
                    if (string.IsNullOrWhiteSpace(originalFileName))
                    {
                        continue;
                    }
                    RMSingleFile newDataFile = new RMSingleFile(newCollection);
                    if (trimRootPath)
                    {
                        newDataFile.Path = Helper.GetRelativePath(files[i], rootPath);
                    }
                    else
                    {
                        newDataFile.Path = files[i];
                    }
                    newDataFile.FileName = originalFileName;
                    newCollection.Files.Add(newDataFile);
                    log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedFile(package.Name, files[i], typeOfCollection.ToRMCollectionType()), _namespace);
                }
                if (newCollection.Files.Count == 0)
                {
                    return(null);
                }
                return(newCollection);
            }
        bool RemoveAsset(TreeNode tNode)
        {
            string _namespace             = MethodBase.GetCurrentMethod().ToLogFormatFullName();
            frmPackAssetTNodeTag assetTag = tNode.Tag as frmPackAssetTNodeTag;

            if (assetTag == null)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_NULL, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                return(false);
            }
            if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMAudioFile)
            {
                RMAudioFile audioFile = assetTag.Object as RMAudioFile;
                if (audioFile == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                if (audioFile.Parent == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                audioFile.Parent.Files.Remove(audioFile);
                assetTag.AssociatedNode.Remove();
                return(true);
            }
            else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMCharImageFile)
            {
                RMCharImageFile charImageFile = assetTag.Object as RMCharImageFile;
                if (charImageFile == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                if (charImageFile.Parent == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                charImageFile.Parent.Files.Remove(charImageFile);
                assetTag.AssociatedNode.Remove();
                return(true);
            }
            else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMGenFile)
            {
                RMGenFile genFile = assetTag.Object as RMGenFile;
                if (genFile == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                if (genFile.Parent == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                genFile.Parent.Files.Remove(genFile);
                assetTag.AssociatedNode.Remove();
                return(true);
            }
            else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMMovieFile)
            {
                RMMovieFile movieFile = assetTag.Object as RMMovieFile;
                if (movieFile == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                if (movieFile.Parent == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                movieFile.Parent.Files.Remove(movieFile);
                assetTag.AssociatedNode.Remove();
                return(true);
            }
            else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMSingleFile)
            {
                RMSingleFile singleFile = assetTag.Object as RMSingleFile;
                if (singleFile == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                if (singleFile.Parent == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                singleFile.Parent.Files.Remove(singleFile);
                assetTag.AssociatedNode.Remove();
                return(true);
            }
            else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMTilesetFile)
            {
                RMTilesetFile tilesetFile = assetTag.Object as RMTilesetFile;
                if (tilesetFile == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                if (tilesetFile.Parent == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                tilesetFile.Parent.Files.Remove(tilesetFile);
                assetTag.AssociatedNode.Remove();
                return(true);
            }
            Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
            Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
            return(false);
        }