Ejemplo n.º 1
0
        /// <summary>
        /// Resizes the specified image using the specified parameters.
        /// </summary>
        /// <param name="sourceFile">The source file.</param>
        /// <param name="param">The parameters.</param>
        /// <returns></returns>
        private bool tryResizeImage(string sourceFile)
        {
            string targetFile = getTargetFileName(sourceFile);

            if (File.Exists(targetFile))
            {
                FileNameCollisionEventArgs e = new FileNameCollisionEventArgs();
                OnFileNameColission(e);
                switch (e.Action)
                {
                    case FileNameCollisionEventArgs.CollisionAction.Skip:
                        return true;

                    case FileNameCollisionEventArgs.CollisionAction.AbortOperation:
                        return false;

                    case FileNameCollisionEventArgs.CollisionAction.KeepBoth:
                        targetFile = getSafeTargetFileName(sourceFile);
                        break;
                }
            }

            try
            {
                return ResizeImage(sourceFile, targetFile);
            }
            catch (OutOfMemoryException)
            {
                // Ignore and try next.
                return true;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Event handler for the FileNameCollision event.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="Thumbler.Model.FileNameCollisionEventArgs"/> 
 /// instance containing the event data.</param>
 private void FileNameColission(object sender, FileNameCollisionEventArgs e)
 {
     // TODO: Ask user
     e.Action = FileNameCollisionEventArgs.CollisionAction.KeepBoth;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Raises the <see cref="E:FileNameColission"/> event.
 /// </summary>
 /// <param name="e">The <see cref="Thumbler.Model.FileNameColissionEventArgs"/>
 /// instance containing the event data.</param>
 protected virtual void OnFileNameColission(FileNameCollisionEventArgs e)
 {
     if (FileNameColission != null)
         FileNameColission(this, e);
 }