Beispiel #1
0
        private void OnCLEMInitialiseResource(object sender, EventArgs e)
        {
            if (!this.FileExists)
            {
                string filename = FullFileName.Replace("\\", "\\­");
                if (filename == "")
                {
                    filename = "Not set";
                }

                string errorMsg = String.Format("Could not locate file [o={0}] for [x={1}]", filename, this.Name);
                throw new ApsimXException(this, errorMsg);
            }

            // get all pricing component names
            // put in a list that provides a link to the object so we can use this to set values
            var resources = FindAllAncestors <Zone>().FirstOrDefault();

            if (resources != null)
            {
                pricingComonentsFound = resources.FindAllDescendants <IResourcePricing>().ToList();
            }

            DataView dataView = new DataView(GetAllData())
            {
                Sort = $"{DateColumnName} ASC"
            };

            priceFileAsRows = dataView.ToTable().Rows;

            UpdatePricingToDate(clock.StartDate.Year, clock.StartDate.Month);
        }
Beispiel #2
0
 private void Init()
 {
     if (FullFileName != null)
     {
         Ext = FullFileName.Substring(FullFileName.LastIndexOf('.'));
     }
 }
Beispiel #3
0
        public override string ToString()
        {
            int    start    = FullFileName.IndexOf(@"\", FullFileName.Length - 23);
            string fileName = FullFileName.Substring(start);

            return(String.Format("{0}, {1}", fileName, LastAccess));
        }
 public AndroidLibInfo(string fullPath)
 {
     FullPath     = fullPath;
     FullFileName = Path.GetFileName(fullPath);
     // TODO: find a better way to extract base file name
     // Mapbox telemetry lib uses different naming that other android libs
     // <name>-<major>.<minor>.<patch> vs. <name>-<major>-<minor>-<patch>
     // okio-1.13.0, support-v4-25.1.0 vs. mapbox-android-telemetry-2-1-0
     BaseFileName = FullFileName.Substring(0, FullFileName.LastIndexOf("-"));
     AssetPath    = fullPath.Replace(Application.dataPath.Replace("Assets", ""), "");
 }
Beispiel #5
0
 private void OnCLEMInitialiseResource(object sender, EventArgs e)
 {
     if (!this.FileExists)
     {
         string filename = FullFileName.Replace("\\", "\\&shy;");
         if (filename == "")
         {
             filename = "Not set";
         }
         string errorMsg = String.Format("@error:Could not locate file [o={0}] for [x={1}]", filename, this.Name);
         throw new ApsimXException(this, errorMsg);
     }
     this.resourceFileAsTable = GetAllData();
 }
Beispiel #6
0
        /// <summary>
        ///		Obtiene el nombre de archivo relativo al proyecto
        /// </summary>
        public string GetRelativeFileNameToProject()
        {
            ProjectModel project = SearchProject();

            // Si existe el proyecto obtiene el nombre relativo
            if (project == null)
            {
                return(FullFileName.Substring(project.PathBase.Length + 1));
            }
            else
            {
                return(FullFileName);
            }
        }
Beispiel #7
0
    /// <summary>
    /// Checks if the properties of this music file instance matches the given search string.
    /// </summary>
    /// <param name="search">The search string.</param>
    /// <returns><c>true</c> if one of the properties of this music file instance matches the search string, <c>false</c> otherwise.</returns>
    public bool Match(string search)
    {
        if (string.IsNullOrWhiteSpace(search))
        {
            return(true);
        }
        search = search.ToUpper().Trim();
        bool found1 = Artist.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      Album.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      Title.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      Year.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      Track.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      FullFileName.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      OverrideName.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      TagStr.IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;

        string[] search2 = search.Split(' ');
        if (search2.Length <= 1 || found1)
        {
            return(found1);
        }
        bool found2 = true;

        foreach (string str in search2)
        {
            var tmpStr = str.ToUpper();
            found2 &= Artist.IndexOf(tmpStr, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      Album.IndexOf(tmpStr, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      Title.IndexOf(tmpStr, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      Year.IndexOf(tmpStr, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      Track.IndexOf(tmpStr, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      FullFileName.IndexOf(tmpStr, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      OverrideName.IndexOf(tmpStr, StringComparison.InvariantCultureIgnoreCase) != -1 ||
                      TagStr.IndexOf(tmpStr, StringComparison.InvariantCultureIgnoreCase) != -1;
        }
        return(found2);
    }
Beispiel #8
0
 /// <summary>
 /// Returns the hash code for this instance.
 /// </summary>
 /// <returns>
 /// A 32-bit signed integer that is the hash code for this instance.
 /// </returns>
 public override int GetHashCode()
 {
     return(FullFileName.GetHashCode());
 }
Beispiel #9
0
        private void OnCLEMInitialiseResource(object sender, EventArgs e)
        {
            if (!this.FileExists)
            {
                string errorMsg = String.Format("@error:Could not locate file [o={0}] for [x={1}]", FullFileName.Replace("\\", "\\&shy;"), this.Name);
                throw new ApsimXException(this, errorMsg);
            }

            //this.doSeek = true;
            this.soilNumIndex         = 0;
            this.cropNameIndex        = 0;
            this.yearIndex            = 0;
            this.monthIndex           = 0;
            this.amountKgIndex        = 0;
            this.nitrogenPercentIndex = 0;
            this.forageFileAsTable    = GetAllData();
        }
Beispiel #10
0
 public override int GetHashCode()
 {
     return(13 * ID.GetHashCode() + 17 * FullFileName.GetHashCode() + 19 * Size.GetHashCode());
 }
Beispiel #11
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     return(Message.GetHashCode() + LangElement.Position.FirstOffset.GetHashCode() + FullFileName.GetHashCode()
            + Flag.GetHashCode() + ProgramPoint.GetHashCode());
 }
        private void SetDVRMSProperties()
        {
            IDictionary           idMetaData;
            IDictionaryEnumerator ideMetaData;

            sClosedCaptioningPresent = "No";
            sIsHDContent             = "No";
            sIsDTVContent            = "No";
            if (VideoCatagory.ToUpper().Equals("SERIES") ||
                VideoCatagory.ToUpper().Equals("SPECIALS"))
            {
                sSeries       = GetSeries(FullFileName, FileGenre);
                sSeason       = GetSeason(FullFileName);
                sEpisode      = GetEpisode(FullFileName);
                sEpisodeTitle = GetEpisodeTitle(FullFileName);
                if (sSeason == null)
                {
                    sSeason = "N/A";
                }

                if (sEpisodeTitle == null)
                {
                    sEpisodeTitle = Name;
                }

                if (sEpisode == null)
                {
                    sEpisode = "N/A";
                }
            }
            try
            {
                dmeFMp3File = new DvrmsMetadataEditor(FullFileName);
                idMetaData  = dmeFMp3File.GetAttributes();
                ideMetaData = idMetaData.GetEnumerator();

                while (ideMetaData.MoveNext())
                {
                    MetadataItem miData = (MetadataItem)ideMetaData.Value;
                    if (VideoCatagory.ToUpper().Equals("MOVIES"))
                    {
                        if (miData.Name.Equals("Title"))
                        {
                            sTitle = miData.Value.ToString();
                        }
                    }
                    if (VideoCatagory.ToUpper().Equals("SERIES") ||
                        VideoCatagory.ToUpper().Equals("SPECIALS"))
                    {
                        if (miData.Name.Equals("WM/SubTitle"))
                        {
                            if (miData.Value.ToString().Trim() == "")
                            {
                                if (sEpisode != "N/A")
                                {
                                    sTitle = sEpisodeTitle;
                                }
                            }
                            else
                            {
                                sTitle = miData.Value.ToString();
                            }
                        }
                    }
                    if (miData.Name.Equals("WM/SubTitleDescription"))
                    {
                        sDescription = miData.Value.ToString();
                    }
                    if (miData.Name.Equals("WM/Genre"))
                    {
                        String [] sGenreExclude = { "/Movies", "/Movies.", "Movies.", "Movies", "/Series", "/Series.", "Series.", "Series" };
                        sGenre = miData.Value.ToString();
                        for (int i = 0; i < sGenreExclude.Length; i++)
                        {
                            sGenre = sGenre.Replace(sGenreExclude[i], "");
                        }
                    }
                    if (miData.Name.Equals("WM/MediaNetworkAffiliation"))
                    {
                        sNetworkAffiliation = miData.Value.ToString();
                    }
                    if (miData.Name.Equals("WM/MediaOriginalChannel"))
                    {
                        sChannel = miData.Value.ToString();
                    }
                    if (miData.Name.Equals("WM/MediaStationCallSign"))
                    {
                        if (miData.Value.ToString().Equals("Edited with VideoReDo Plus"))
                        {
                            sStationCallSign = "TIVO";
                            sStationName     = "Tivo-Extract";
                        }
                        else
                        {
                            sStationCallSign = miData.Value.ToString();
                        }
                    }
                    if (miData.Name.Equals("WM/MediaStationName"))
                    {
                        sStationName = miData.Value.ToString();
                    }
                    if (miData.Name.Equals("WM/MediaCredits"))
                    {
                        sCredits = CleanupCredits(miData.Value.ToString());
                    }
                    if (miData.Name.Equals("WM/ParentalRating"))
                    {
                        sParentalRating = CleanupRatings(miData.Value.ToString());
                    }
                    if (miData.Name.Equals("WM/ParentalRatingReason"))
                    {
                        sParentalRatingReason = CleanupRatings(miData.Value.ToString());
                    }
                    if (miData.Name.Equals("WM/ProviderRating"))
                    {
                        sProviderRating = CleanupProviderRatings(miData.Value.ToString());
                    }
                    if (miData.Name.Equals("WM/Year"))
                    {
                        sMovieYear = miData.Value.ToString();
                    }
                    if (miData.Name.Equals("Duration"))
                    {
                        sPlayTime          = pdamxUtility.FormatNanoseconds(miData.Value.ToString());
                        sUFPlayTime        = miData.Value.ToString();
                        nDurationInSeconds = (int)(Convert.ToDouble(miData.Value.ToString()) / 10000000);
                    }
                    if (miData.Name.Equals("WM/WMRVHDContent"))
                    {
                        if (miData.Value.ToString().ToUpper().Trim().Equals("TRUE"))
                        {
                            sIsHDContent = "Yes";
                        }
                        else
                        {
                            sIsHDContent = "No";
                        }
                    }
                    if (FullFileName.ToUpper().Trim().Contains("(HD-TP)"))
                    {
                        sIsHDContent = "Yes";
                    }
                    if (miData.Name.Equals("WM/WMRVDTVContent"))
                    {
                        if (miData.Value.ToString().ToUpper().Trim().Equals("TRUE"))
                        {
                            sIsDTVContent = "Yes";
                        }
                        else
                        {
                            sIsDTVContent = "No";
                        }
                    }
                    if (FullFileName.ToUpper().Trim().Contains("(HD)"))
                    {
                        sIsDTVContent = "Yes";
                    }
                    if (sStationName.ToUpper().Contains(" HD") || sStationName.ToUpper().Contains("-DT"))
                    {
                        sIsDTVContent = "Yes";
                    }
                    if (miData.Name.Equals("WM/VideoClosedCaptioning"))
                    {
                        sClosedCaptioningPresent = "Yes";
                    }
                }
                if (VideoCatagory.ToUpper().Equals("SPECIALS"))
                {
                    sGenre = FileGenre;
                }
                if (sGenre.Trim().Length == 0)
                {
                    sGenre = FileGenre;
                }
            }
            catch (Exception)
            {
                sGenre = FileGenre;
                if (VideoCatagory.ToUpper().Equals("MOVIES"))
                {
                    sTitle = Name;
                }
                if (VideoCatagory.ToUpper().Equals("SERIES") ||
                    VideoCatagory.ToUpper().Equals("SPECIALS"))
                {
                    if (sEpisodeTitle.Trim().Length > 0)
                    {
                        sTitle = sEpisodeTitle;
                    }
                    else
                    {
                        sEpisodeTitle = Name;
                    }
                }
            }
            if (VideoCatagory.ToUpper().Equals("SERIES") ||
                VideoCatagory.ToUpper().Equals("SPECIALS"))
            {
                if (sTitle == null)
                {
                    sTitle = sEpisodeTitle;
                }
                if (sTitle.Trim().Length == 0)
                {
                    sTitle = sEpisodeTitle;
                }
                if (sTitle.Trim().Length == 0)
                {
                    sTitle = Name;
                }
            }
        }
        private void ReadImageData(AssetPreloadData preloadData)
        {
            var sourceFile = preloadData.SourceFile;
            var reader     = sourceFile.AssetReader;

            if (!string.IsNullOrEmpty(FullFileName))
            {
                FullFileName = Path.Combine(Path.GetDirectoryName(sourceFile.FullFileName) ?? string.Empty, FullFileName.Replace("archive:/", string.Empty));
                var fileExists = File.Exists(FullFileName);
                if (!fileExists)
                {
                    FullFileName = Path.Combine(Path.GetDirectoryName(sourceFile.FullFileName) ?? string.Empty, Path.GetFileName(FullFileName));
                    fileExists   = File.Exists(FullFileName);
                }
                if (fileExists)
                {
                    ImageData = new byte[ImageDataSize];
                    using (var imageFileReader = new BinaryReader(File.OpenRead(FullFileName))) {
                        imageFileReader.BaseStream.Position = Offset;
                        imageFileReader.Read(ImageData, 0, ImageDataSize);
                    }
                }
                else
                {
                    throw new FileNotFoundException("Unexpected branch.");
                }
            }
            else
            {
                ImageData = new byte[ImageDataSize];
                reader.Read(ImageData, 0, ImageDataSize);
            }

            var textureFormat = (TextureFormat)Format;

            switch (textureFormat)
            {
            case TextureFormat.Alpha8:
                var bytes = Enumerable.Repeat <byte>(0xFF, ImageDataSize * 4).ToArray();
                for (var i = 0; i < ImageDataSize; i++)
                {
                    bytes[i * 4] = ImageData[i];
                }
                ImageData      = bytes;
                ImageDataSize  = ImageDataSize * 4;
                DdsMiscFlags2  = 0x41;
                DdsRgbBitCount = 0x20;
                DdsRBitMask    = 0xFF00;
                DdsGBitMask    = 0xFF0000;
                DdsBBitMask    = 0xFF000000;
                DdsABitMask    = 0xFF;
                break;

            case TextureFormat.ARGB4444:
                FixupXbox360(sourceFile);
                DdsMiscFlags2  = 0x41;
                DdsRgbBitCount = 0x10;
                DdsRBitMask    = 0xF00;
                DdsGBitMask    = 0xF0;
                DdsBBitMask    = 0xF;
                DdsABitMask    = 0xF000;
                break;

            case TextureFormat.RGB24:
                DdsMiscFlags2  = 0x40;
                DdsRgbBitCount = 0x18;
                DdsRBitMask    = 0xFF;
                DdsGBitMask    = 0xFF00;
                DdsBBitMask    = 0xFF0000;
                DdsABitMask    = 0x0;
                break;

            case TextureFormat.RGBA32:
                DdsMiscFlags2  = 0x41;
                DdsRgbBitCount = 0x20;
                DdsRBitMask    = 0xFF;
                DdsGBitMask    = 0xFF00;
                DdsBBitMask    = 0xFF0000;
                DdsABitMask    = 0xFF000000;
                break;

            case TextureFormat.ARGB32:
                DdsMiscFlags2  = 0x41;
                DdsRgbBitCount = 0x20;
                DdsRBitMask    = 0xFF00;
                DdsGBitMask    = 0xFF0000;
                DdsBBitMask    = 0xFF000000;
                DdsABitMask    = 0xFF;
                break;

            case TextureFormat.RGB565:
                FixupXbox360(sourceFile);
                DdsMiscFlags2  = 0x40;
                DdsRgbBitCount = 0x10;
                DdsRBitMask    = 0xF800;
                DdsGBitMask    = 0x7E0;
                DdsBBitMask    = 0x1F;
                DdsABitMask    = 0x0;
                break;

            case TextureFormat.R16:
                break;

            case TextureFormat.DXT1:
                FixupXbox360(sourceFile);
                if (HasMipMap)
                {
                    DdsPitchOrLinearSize = Height * Width / 2;
                }
                DdsMiscFlags2  = 0x4;
                DdsFourCC      = 0x31545844;
                DdsRgbBitCount = 0x0;
                DdsRBitMask    = 0x0;
                DdsGBitMask    = 0x0;
                DdsBBitMask    = 0x0;
                DdsABitMask    = 0x0;
                break;

            case TextureFormat.DXT5:
                FixupXbox360(sourceFile);
                if (HasMipMap)
                {
                    DdsPitchOrLinearSize = Height * Width / 2;
                }
                DdsMiscFlags2  = 0x4;
                DdsFourCC      = 0x35545844;
                DdsRgbBitCount = 0x0;
                DdsRBitMask    = 0x0;
                DdsGBitMask    = 0x0;
                DdsBBitMask    = 0x0;
                DdsABitMask    = 0x0;
                break;

            case TextureFormat.RGBA4444:
                DdsMiscFlags2  = 0x41;
                DdsRgbBitCount = 0x10;
                DdsRBitMask    = 0xF000;
                DdsGBitMask    = 0xF00;
                DdsBBitMask    = 0xF0;
                DdsABitMask    = 0xF;
                break;

            case TextureFormat.BGRA32:
                DdsMiscFlags2  = 0x41;
                DdsRgbBitCount = 0x20;
                DdsRBitMask    = 0xFF0000;
                DdsGBitMask    = 0xFF00;
                DdsBBitMask    = 0xFF;
                DdsABitMask    = 0xFF000000;
                break;

            case TextureFormat.ETC_RGB4:
                PvrPixelFormat = 0x16;
                break;

            case TextureFormat.ETC2_RGB:
                PvrPixelFormat = 22;
                break;

            case TextureFormat.ETC2_RGBA1:
                PvrPixelFormat = 24;
                break;

            case TextureFormat.ETC2_RGBA8:
                PvrPixelFormat = 23;
                break;

            default:
                throw new NotSupportedException($"Not supported: {textureFormat}");
            }
        }