public IsoFolderElement(TreeNode folderElement, bool isRoot, string childNumber)
        {
            Date     = folderElement.CreationTime;
            LongName = folderElement.Name;

            // If you need to use the short name, then you may want to change the naming method.
            if (isRoot)
            {
                ShortName = ".";
                LongName  = ".";
            }
            else
            {
                if (LongName.Length > 8)
                {
                    ShortName  = LongName.Substring(0, 8 - childNumber.Length).ToUpper().Replace(' ', '_').Replace('.', '_');
                    ShortName += childNumber;
                }
                else
                {
                    ShortName = LongName.ToUpper().Replace(' ', '_').Replace('.', '_');
                }
            }

            if (LongName.Length > IsoAlgorithm.FileNameMaxLength)
            {
                LongName = LongName.Substring(0, IsoAlgorithm.FileNameMaxLength - childNumber.Length) + childNumber;
            }
        }
 public sysDamageRoll(string n, string nl, int die, int number, int bonus, sysBaseStatistic per, int perdivide) : base()
 {
     this.Die         = die;
     this.Number      = number;
     this.Bonus       = bonus;
     this.BonusPer    = per;
     this.PerDivide   = perdivide;
     this.LongName    = toStringImpl();
     this.Name        = LongName.Substring(0, Math.Min(nwdbConst.LEN_SHORT, LongName.Length));
     this.ItemsDamage = new List <sysItemType>();
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of a LfsFileInfo from an IFile.
 /// </summary>
 /// <param name="file">The file from which to create a LfsFileInfo object for serialization.</param>
 /// <remarks>This constructor is used to convert from a user interface representation of a file in the
 /// menu layout to a LFS LfsFileInfo representation.</remarks>
 public LfsFileInfo(IFile file)
 {
     FileType  = file.FileType;
     Color     = file.Color;
     ShortName = file.ShortName;
     LongName  = file.LongName;
     if (string.IsNullOrEmpty(ShortName))
     {
         System.Diagnostics.Debug.WriteLine("Null or empty short name.");
     }
     if (string.IsNullOrEmpty(LongName))
     {
         System.Diagnostics.Debug.WriteLine("Null or empty long name.");
     }
     _forks = new ushort[MaxForks];
     if (file is FileNode)
     {
         var program = (FileNode)file;
         GlobalFileNumber      = program.GlobalFileNumber;
         GlobalDirectoryNumber = program.GlobalDirectoryNumber;
         if (string.IsNullOrEmpty(ShortName) && !string.IsNullOrEmpty(LongName) && (GlobalFileNumber != GlobalFileTable.RootDirectoryFileNumber))
         {
             ShortName = LongName.Substring(0, System.Math.Min(LongName.Length, FileSystemConstants.MaxShortNameLength));
         }
         Reserved = program.Reserved;
         for (int i = 0; i < _forks.Length; ++i)
         {
             _forks[i] = program.ForkNumbers[i];
         }
     }
     else
     {
         for (int i = 0; i < _forks.Length; ++i)
         {
             _forks[i] = GlobalForkTable.InvalidForkNumber;
         }
     }
 }
Example #4
0
        private string GetDefaultShortName()
        {
            string defaultShortName = string.IsNullOrEmpty(LongName) ? Model.ShortName : LongName.Substring(0, System.Math.Min(LongName.Length, FileSystemConstants.MaxShortNameLength));

            return(defaultShortName);
        }
Example #5
0
        private bool OnProgramDescriptionChanged(ProgramDescription previousDescription, ProgramDescription newDescription, bool validate)
        {
            if (previousDescription != null)
            {
                previousDescription.Files.PropertyChanged -= HandleProgramSupportFilesPropertyChanged;
            }

            // Do this work in LoadComplete.
            bool updatedCrc = false;

            // POSSIBLE BUG? We don't check for changes to .cfg file CRC here.
            if (Crc32 != 0)
            {
                if (Crc32 != newDescription.Crc)
                {
                    throw new InvalidOperationException(Resources.Strings.MenuLayout_DescriptionOutOfSync);
                }
            }
            bool updatedLongName = false;

            if (!string.IsNullOrEmpty(newDescription.Name))
            {
                bool replaceName = string.IsNullOrWhiteSpace(LongName);
                if (replaceName)
                {
                    if (newDescription.Name.Length > FileSystemConstants.MaxLongNameLength)
                    {
                        LongName = newDescription.Name.Substring(0, FileSystemConstants.MaxLongNameLength).Trim();
                    }
                    else
                    {
                        LongName = newDescription.Name.Trim();
                    }
                    updatedLongName = true;
                    updatedCrc      = true;
                }
            }
            if (updatedLongName || !string.IsNullOrEmpty(newDescription.ShortName))
            {
                bool replaceName = string.IsNullOrWhiteSpace(ShortName);
                if (replaceName && !string.IsNullOrEmpty(newDescription.ShortName))
                {
                    ShortName = newDescription.ShortName.Trim();
                    if (ShortName.Length > FileSystemConstants.MaxShortNameLength)
                    {
                        ShortName = ShortName.Substring(0, FileSystemConstants.MaxShortNameLength).Trim();
                    }
                }
                else if (replaceName && (LongName.Length > FileSystemConstants.MaxShortNameLength))
                {
                    ShortName = LongName.Substring(0, FileSystemConstants.MaxShortNameLength).Trim();
                }
                updatedCrc = true;
            }
            if (updatedCrc)
            {
                UpdateCrc();
            }
            newDescription.Files.ValidateSupportFile(ProgramFileKind.Rom, Crc32, newDescription, null, Configuration.Instance.ConnectedPeripheralsHistory, validate);
            newDescription.Files.PropertyChanged += HandleProgramSupportFilesPropertyChanged;
            return(updatedCrc);
        }