Click here to Skip to main content
15,887,175 members
Home / Discussions / C#
   

C#

 
AnswerRe: I need an ebay program Pin
Dave Kreskowiak13-Jan-10 6:25
mveDave Kreskowiak13-Jan-10 6:25 
QuestionVC# 2008 Pin
AlucardCode13-Jan-10 1:37
AlucardCode13-Jan-10 1:37 
AnswerRe: VC# 2008 Pin
monstale13-Jan-10 2:34
monstale13-Jan-10 2:34 
GeneralRe: VC# 2008 Pin
AlucardCode13-Jan-10 3:19
AlucardCode13-Jan-10 3:19 
AnswerRe: VC# 2008 Pin
DaveyM6913-Jan-10 3:06
professionalDaveyM6913-Jan-10 3:06 
GeneralRe: VC# 2008 Pin
AlucardCode13-Jan-10 3:21
AlucardCode13-Jan-10 3:21 
AnswerRe: VC# 2008 Pin
Rick Shaub13-Jan-10 3:21
Rick Shaub13-Jan-10 3:21 
Questioncombining 2 codes Pin
djsproject13-Jan-10 1:35
djsproject13-Jan-10 1:35 
hello everybody i have one csharp .net code that selects multiple images.
string[] extensions = new string[] {"jpg", "gif", "bmp", /*...*/};
foreach (string extension in extensions)
{
    FileInfo[] FileJpg = FileDirectory.GetFiles(string.Format("*.{0}", extension));
    foreach (FileInfo File in FileJpg)
    {
        ImageList.Add(File.Name, File.FullName);
        checkedListBox1.Items.Add(File.Name);
    }
}

and a second code that performs rotation on one image.
namespace ImageRotation
{
    public partial class Form1 : Form
    {
        private Image loadedImage;

        public Form1()
        {
            InitializeComponent();
        }

        private Image RotateImage(Image inputImg, double degreeAngle)
        {
            //Corners of the image
            PointF[] rotationPoints = { new PointF(0, 0),
                                        new PointF(inputImg.Width, 0),
                                        new PointF(0, inputImg.Height),
                                        new PointF(inputImg.Width, inputImg.Height)};

            //Rotate the corners
            PointMath.RotatePoints(rotationPoints, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f), degreeAngle);

            //Get the new bounds given from the rotation of the corners
            //(avoid clipping of the image)
            Rectangle bounds = PointMath.GetBounds(rotationPoints);

            //An empy bitmap to draw the rotated image
            Bitmap rotatedBitmap = new Bitmap(bounds.Width, bounds.Height);

            using (Graphics g = Graphics.FromImage(rotatedBitmap))
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;

                //Transformation matrix
                Matrix m = new Matrix();
                m.RotateAt((float)degreeAngle, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f));
                m.Translate(-bounds.Left, -bounds.Top, MatrixOrder.Append); //shift to compensate for the rotation

                g.Transform = m;
                g.DrawImage(inputImg, 0, 0);
            }
            return (Image)rotatedBitmap;
        }

        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            if (loadedImage != null)
                pictureBox1.Image = RotateImage(loadedImage, (double)tRotation.Value);
            pictureBox1.Refresh();
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    loadedImage = Image.FromFile(openFileDialog1.FileName);
                    pictureBox1.Image = loadedImage;

                    //Reset rotation value
                    tRotation.Value = 0;
                }
                catch (Exception)
                {
                    MessageBox.Show("Image invalid.");
                }
            }
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.vcskicks.com/");
        }
    }

    public static class PointMath
    {
        private static double DegreeToRadian(double angle)
        {
            return Math.PI * angle / 180.0;
        }

        public static PointF RotatePoint(PointF pnt, double degreeAngle)
        {
            return RotatePoint(pnt, new PointF(0, 0), degreeAngle);
        }

        public static PointF RotatePoint(PointF pnt, PointF origin, double degreeAngle)
        {
            double radAngle = DegreeToRadian(degreeAngle);

            PointF newPoint = new PointF();

            double deltaX = pnt.X - origin.X;
            double deltaY = pnt.Y - origin.Y;

            newPoint.X = (float)(origin.X + (Math.Cos(radAngle) * deltaX - Math.Sin(radAngle) * deltaY));
            newPoint.Y = (float)(origin.Y + (Math.Sin(radAngle) * deltaX + Math.Cos(radAngle) * deltaY));

            return newPoint;
        }

        public static void RotatePoints(PointF[] pnts, double degreeAngle)
        {
            for (int i = 0; i < pnts.Length; i++)
            {
                pnts[i] = RotatePoint(pnts[i], degreeAngle);
            }
        }

        public static void RotatePoints(PointF[] pnts, PointF origin, double degreeAngle)
        {
            for (int i = 0; i < pnts.Length; i++)
            {
                pnts[i] = RotatePoint(pnts[i], origin, degreeAngle);
            }
        }

        public static Rectangle GetBounds(PointF[] pnts)
        {
            RectangleF boundsF = GetBoundsF(pnts);
            return new Rectangle((int)Math.Round(boundsF.Left),
                                 (int)Math.Round(boundsF.Top),
                                 (int)Math.Round(boundsF.Width),
                                 (int)Math.Round(boundsF.Height));
        }

        public static RectangleF GetBoundsF(PointF[] pnts)
        {
            float left = pnts[0].X;
            float right = pnts[0].X;
            float top = pnts[0].Y;
            float bottom = pnts[0].Y;

            for (int i = 1; i < pnts.Length; i++)
            {
                if (pnts[i].X < left)
                    left = pnts[i].X;
                else if (pnts[i].X > right)
                    right = pnts[i].X;

                if (pnts[i].Y < top)
                    top = pnts[i].Y;
                else if (pnts[i].Y > bottom)
                    bottom = pnts[i].Y;
            }

            return new RectangleF(left,
                                  top,
                                 (float)Math.Abs(right - left),
                                 (float)Math.Abs(bottom - top));
        }
    }
}


can somebody help me to work this code for mutiple images that i have selected.Thanking u in advance.
AnswerRe: combining 2 codes Pin
0x3c013-Jan-10 2:25
0x3c013-Jan-10 2:25 
GeneralRe: combining 2 codes Pin
djsproject16-Jan-10 8:09
djsproject16-Jan-10 8:09 
QuestionSet the parent textbox value from child form Pin
pavanig912-Jan-10 23:37
pavanig912-Jan-10 23:37 
AnswerRe: Set the parent textbox value from child form Pin
Harvey Saayman12-Jan-10 23:42
Harvey Saayman12-Jan-10 23:42 
GeneralRe: Set the parent textbox value from child form Pin
pavanig913-Jan-10 0:52
pavanig913-Jan-10 0:52 
GeneralRe: Set the parent textbox value from child form Pin
Harvey Saayman13-Jan-10 0:55
Harvey Saayman13-Jan-10 0:55 
AnswerRe: Set the parent textbox value from child form Pin
DaveyM6913-Jan-10 0:22
professionalDaveyM6913-Jan-10 0:22 
QuestionDataGridView: SelectRow if EditMode=EditOnEnter Pin
Nigel Mackay12-Jan-10 23:33
Nigel Mackay12-Jan-10 23:33 
AnswerRe: DataGridView: SelectRow if EditMode=EditOnEnter Pin
Herman<T>.Instance13-Jan-10 7:45
Herman<T>.Instance13-Jan-10 7:45 
GeneralRe: DataGridView: SelectRow if EditMode=EditOnEnter Pin
Nigel Mackay13-Jan-10 18:25
Nigel Mackay13-Jan-10 18:25 
QuestionVirtualMode DataGridView - user presses Esc while editing Pin
Nigel Mackay12-Jan-10 23:31
Nigel Mackay12-Jan-10 23:31 
Questionpdf to text Pin
prem212-Jan-10 23:13
prem212-Jan-10 23:13 
AnswerRe: pdf to text Pin
SeMartens12-Jan-10 23:15
SeMartens12-Jan-10 23:15 
QuestionHow To directly Print Using Microsoft.Reporting.WinForms.ReportViewer Pin
Thaer Hamael12-Jan-10 22:23
Thaer Hamael12-Jan-10 22:23 
AnswerRe: How To directly Print Using Microsoft.Reporting.WinForms.ReportViewer Pin
Eddy Vluggen13-Jan-10 1:12
professionalEddy Vluggen13-Jan-10 1:12 
GeneralRe: How To directly Print Using Microsoft.Reporting.WinForms.ReportViewer Pin
Thaer Hamael13-Jan-10 1:38
Thaer Hamael13-Jan-10 1:38 
GeneralRe: How To directly Print Using Microsoft.Reporting.WinForms.ReportViewer Pin
Eddy Vluggen13-Jan-10 2:16
professionalEddy Vluggen13-Jan-10 2:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.