Exemple #1
0
		/// <summary>
		/// Gets the available physical memory.
		/// </summary>
		/// <param name="units"></param>
		/// <returns></returns>
		public static long GetAvailableMemory(SizeUnits units)
		{
			long availableBytes = Convert.ToInt64(MemoryPerformanceCounter.NextValue());

			if (units == SizeUnits.Bytes)
				return availableBytes;
			else if (units == SizeUnits.Kilobytes)
				return availableBytes / 1024;
			else if (units == SizeUnits.Megabytes)
				return availableBytes / 1048576;
			else
				return availableBytes / 1073741824;
		}
 public CacheSize(int size, SizeUnits units)
 {
     this.Size = size;
     this.Units = units;
 }
Exemple #3
0
        protected Int64 ConvertSizeToMiB(Int64 size, SizeUnits inputUnit)
        {
            switch (inputUnit)
            {
                case SizeUnits.B:
                    return (Int64) Math.Ceiling((double) (size / 1024 / 1024));
                case SizeUnits.KB:
                    return (Int64) Math.Ceiling((double) (size / 1024));
                case SizeUnits.GB:
                    return size * 1024;
                case SizeUnits.TB:
                    return size * 1024 * 1024;
            }

            return size;
        }
        private Vector2 StandardOffset(Vector2 size, SizeUnits sizeUnits, Vector2 spriteSize, float dpi)
        {
            Vector2 offset = new Vector2();
            if (sizeUnits == SizeUnits.Pixels)
            {
                offset = size;
            }
            else if (sizeUnits == SizeUnits.DIPs)
            {
                offset = size * dpi / 96.0f;
            }
            else if (sizeUnits == SizeUnits.Normalized)
            {

                offset = spriteSize * size;
            }
            return offset;
        }