コード例 #1
0
 /// <inheritdoc />
 public void FreezeCapacity(bool compact)
 {
     _heapResizing = new HeapNoResizing();
     if (compact)
     {
         Compact();
     }
 }
コード例 #2
0
        public void Process(string sourceFile, string destinationFile, string type, int width, int height, int x, int y)
        {
            #region SourceFileExistenceCheck
            //check if sourceFile exists, if not, throw exception
            if (!File.Exists(sourceFile))
            {
                throw new PrimeHoldingImage.Exception.FileNotFoundException();
            }
            #endregion
            #region ActionCheck (resize type)
            //check which action is chosen
            switch (type.ToLower())
            {
            case "crop":
                this.converter = new Crop();
                break;

            case "keepaspect":
                this.converter = new KeppAspect();
                break;

            case "scew":
                this.converter = new Scew();
                break;

            //if none of the above actions matches, throw IlegalOperationException
            default: throw new IlegalOperetaionException();
            }
            #endregion
            #region DestionationFileNameCheck
            //Check if source and destionation file names are the same.
            if (Path.GetFullPath(sourceFile) == Path.GetFullPath(destinationFile))
            {
                throw new DestinationFileNameException("Cant write destinationFile over sourceFile.");
            }
            #endregion
            #region DestinationFileDirectoryExistanceCheck

            if (!Directory.Exists(Path.GetDirectoryName(destinationFile)))
            {
                throw new PrimeHoldingImage.Exception.DirectoryNotFoundException();
            }
            #endregion
            #region DestinationFileFormatCheck
            //check if the file's extension is supported
            string extension = Path.GetExtension(destinationFile);
            if (extension == ".png" || extension == ".jpeg" || extension == ".jpg" || extension == ".gif")
            {
            }
            else
            {
                throw new DestinationFileTypeException();
            }
            #endregion
            this.converter.Resize(sourceFile, destinationFile, width, height, x, y);
        }
コード例 #3
0
ファイル: GameViewport.cs プロジェクト: notexplosive/machina
        public GameViewport(Point viewportSize, ResizeBehavior resizeBehavior)
        {
            ViewportSize = viewportSize;
            if (resizeBehavior == ResizeBehavior.FreeAspectRatio)
            {
                this.resizeStrategy = new FillStrategy();
            }
            else
            {
                this.resizeStrategy = new MaintainDesiredResolutionStrategy();
            }

            SetWindowSize(viewportSize);
        }
コード例 #4
0
ファイル: ResizeStrategyContext.cs プロジェクト: FMI-VT/API
 //here we use the strategies
 public ResizeStrategyContext(IResizeStrategy strategy)
 {
     this.strategy = strategy;
 }
コード例 #5
0
ファイル: MinMaxHeaps.cs プロジェクト: samaysar/dotdotnet
 /// <summary>
 /// Ctor with initial capacity, comparer and resizing strategy.
 /// Different in-built resizing strategy are available (<seealso cref="HeapNoResizing"/>, <seealso cref="StepHeapResizing"/>
 /// and <seealso cref="PercentHeapResizing"/>).
 /// </summary>
 /// <param name="initialCapacity">Initial capacity of the heap</param>
 /// <param name="comparer">Comparer instance. If not provided, then <seealso cref="Comparer{T}.Default"/> will be used.</param>
 /// <param name="resizeStrategy">Heap resizing strategy. If not provided, then <seealso cref="HeapNoResizing"/> will be internally used.</param>
 /// <exception cref="DdnDfException">When given capacity is negative.</exception>
 public ConcurrentMaxHeap(int initialCapacity,
                          IComparer <T> comparer         = null,
                          IResizeStrategy resizeStrategy = null) : base(new MaxHeap <T>(initialCapacity, comparer, resizeStrategy))
 {
 }
コード例 #6
0
 /// <summary>
 /// Ctor with initial capacity, comparer and resizing strategy.
 /// Different in-built resizing strategy are available (<seealso cref="HeapNoResizing"/>, <seealso cref="StepHeapResizing"/>
 /// and <seealso cref="PercentHeapResizing"/>).
 /// </summary>
 /// <param name="initialCapacity">Initial capacity of the heap</param>
 /// <param name="comparer">Comparer instance. If not provided, then <seealso cref="Comparer{T}.Default"/> will be used.</param>
 /// <param name="resizeStrategy">Heap resizing strategy. If not provided, then <seealso cref="HeapNoResizing"/> will be internally used.</param>
 /// <exception cref="DdnDfException">When given capacity is negative.</exception>
 public MaxHeap(int initialCapacity,
                IComparer <T> comparer         = null,
                IResizeStrategy resizeStrategy = null) : base(initialCapacity, resizeStrategy ?? new HeapNoResizing())
 {
     _comparer = comparer ?? Comparer <T> .Default;
 }
コード例 #7
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Initializes a new instance of the PrimeHolding.Tools.Resizer.ResizerContext class.
        /// </summary>
        ///
        /// <param name="resizer">  The resizer. </param>
        ///////////////////////////////////////////////////////////////////////////////////////////

        public ResizerContext(IResizeStrategy resizer)
        {
            this.resizer = resizer;
        }
コード例 #8
0
 /// <summary>
 /// Ctor with initial capacity and resizing strategy.
 /// Different in-built resizing strategy are available (<seealso cref="HeapNoResizing"/>, <seealso cref="StepHeapResizing"/>
 /// and <seealso cref="PercentHeapResizing"/>).
 /// </summary>
 /// <param name="initialCapacity">Initial capacity of the heap</param>
 /// <param name="resizeStrategy">Heap resizing strategy.</param>
 /// <exception cref="DdnDfException">When given capacity is negative or resizing strategy is not provided.</exception>
 protected AbstractSizableBinaryHeap(int initialCapacity, IResizeStrategy resizeStrategy) : base(initialCapacity)
 {
     _heapResizing = resizeStrategy.ThrowIfNull($"{nameof(resizeStrategy)} is not provided.");
 }