Exemplo n.º 1
0
        private void AddFiles(string[] files)
        {
            ShowProgressBar(true, files.Count());
            foreach (var file in files)
            {
                UpdateProgressBar();
                var path = file;
                var fileName = System.IO.Path.GetFileName(path);
                var extention = Path.GetExtension(path);

                using (var image = Image.FromFile(file))
                {
                    var img = new Img { FullPath = file, FileName = fileName, Width = image.Width, Height = image.Height, FileExtention = extention };
                    AllImages.Add(img);
                }
            }

            ShowProgressBar(false);

            RepopulateListBox();
        }
Exemplo n.º 2
0
        private string GetNewFileLocation(Img img, bool convert = false)
        {
            if (chkOverwrite.Checked && !convert)
            {
                return img.FullPath;
            }
            else
            {
                var fileName = Path.GetFileNameWithoutExtension(img.FullPath);
                var extention = convert ? ".png" : Path.GetExtension(img.FullPath);

                var fileLocation = FolderLocation + fileName + extention;

                return fileLocation;
            }
        }
Exemplo n.º 3
0
        private int GetWidth(Img img)
        {
            int width;
            var isPixels = txtMeasurment.SelectedIndex == 0;
            if (isPixels)
            {
                width = Int32.Parse(txtWidth.Text);
            }
            else // Percent
            {
                width = (int)Math.Round(img.Width * (Double.Parse(txtWidth.Text) / 100));
            }

            return width;
        }
Exemplo n.º 4
0
        private int GetHeight(Img img)
        {
            int height;
            var isPixels = txtMeasurment.SelectedIndex == 0;
            if (isPixels)
            {
                height = Int32.Parse(txtHeight.Text);
            }
            else // Percent
            {
                height = (int)Math.Round(img.Height * (Double.Parse(txtHeight.Text) / 100));
            }

            return height;
        }