Click here to Skip to main content
15,900,725 members
Home / Discussions / C#
   

C#

 
GeneralRe: Execute a C# App without installing .Net Framework ! Pin
Mohammad Dayyan18-Mar-09 3:57
Mohammad Dayyan18-Mar-09 3:57 
AnswerCozy :) Pin
Eddy Vluggen18-Mar-09 4:18
professionalEddy Vluggen18-Mar-09 4:18 
GeneralRe: Cozy :) Pin
benjymous18-Mar-09 4:40
benjymous18-Mar-09 4:40 
AnswerRe: Execute a C# App without installing .Net Framework ! Pin
12Code18-Mar-09 4:25
12Code18-Mar-09 4:25 
GeneralRe: Execute a C# App without installing .Net Framework ! Pin
Mohammad Dayyan18-Mar-09 4:29
Mohammad Dayyan18-Mar-09 4:29 
AnswerRe: Execute a C# App without installing .Net Framework ! Pin
EliottA18-Mar-09 4:51
EliottA18-Mar-09 4:51 
GeneralRe: Execute a C# App without installing .Net Framework ! Pin
Mohammad Dayyan18-Mar-09 6:21
Mohammad Dayyan18-Mar-09 6:21 
QuestionDrop File not working Pin
oneiros18-Mar-09 2:08
oneiros18-Mar-09 2:08 
Hi,

I am developing an application to catalog your comic collections. In the comic info form I thought I would add an image drop utility so the user can add images from the comic into the comic's details. I thought it was working fine, but it seems it is not. So, this comic info form is opened from the main form. Then it has a tab control with different tabs. The one I'm interested in is the Images tab. I have set the AllowDrop property of all of them to true. The control I want to drop the images in is a FlowLayoutPanel that i have called flpImages. Finally, I am running Windows Vista Ultimate.

The code for the two events (DragOver and DragDrop) is the following:

private void pbImages_DragOver(object sender, DragEventArgs e)
{
try
{
if (e.Data.GetDataPresent(DataFormats.FileDrop) && (e.AllowedEffect & DragDropEffects.Copy) != 0)
e.Effect = DragDropEffects.Copy;
}
catch
{
System.Diagnostics.Debugger.Break();
}
}

private void pbImages_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
this.AddImages((string[])e.Data.GetData(DataFormats.FileDrop));
}

The AddImages code (although it never gets there)

private void AddImages(string[] filenames)
{
try
{
this.Cursor = Cursors.WaitCursor;
string destPath = Application.StartupPath + "\\Temp\\";
if (!Directory.Exists(destPath))
Directory.CreateDirectory(destPath);
foreach (string file in filenames)
{
// Create new picturebox to hold the image
PictureBox pb = new PictureBox();
pb.Width = 60;
pb.Height = pb.Width * pbImgDisplay.Height / pbImgDisplay.Width;
pb.BorderStyle = BorderStyle.FixedSingle;
pb.Name = "pbImage_" + (this.flpImages.Controls.Count + 1).ToString();
pb.Click += new EventHandler(this.pbImages_Click);

// Add the image to the new picturebox
// Get the image the user opened
Image theImage = Image.FromFile(file);
if (theImage.Width > theImage.Height)
theImage.RotateFlip(RotateFlipType.Rotate90FlipXY);
// Break the file name to get the image extension
string[] pieces = file.Split(Convert.ToChar("."));
double scale = 0;
// Since the image's size we want is the large picture box size, we save the image in that size in the temp
// folder first.
if (theImage.Width > this.pbImgDisplay.Width || theImage.Height > this.pbImgDisplay.Height)
{
scale = Math.Min((double)this.pbImgDisplay.Width / (double)theImage.Width, (double)this.pbImgDisplay.Height / (double)theImage.Height);
theImage = theImage.GetThumbnailImage((int)Math.Round(theImage.Width * scale, 0), (int)Math.Round(theImage.Height * scale, 0), null, (IntPtr)0);
}
string img = destPath + "temp_img_" + (this.flpImages.Controls.Count + 1).ToString() + "." + pieces[pieces.Length - 1];
theImage.Save(img);

// Now we need to create the thumbnail for the smaller picbox.
if (theImage.Width > pb.Width || theImage.Height > pb.Height)
{
scale = Math.Min((double)pb.Height / (double)theImage.Height, (double)pb.Width / (double)theImage.Width);
theImage = theImage.GetThumbnailImage((int)Math.Round(theImage.Width * scale, 0), (int)Math.Round(theImage.Height * scale, 0), null, (IntPtr)0);
}
img = destPath + "temp_thumb_" + (this.flpImages.Controls.Count + 1).ToString() + "." + pieces[pieces.Length - 1];
theImage.Save(img);
pb.ImageLocation = img;

this.flpImages.Controls.Add(pb);
this.imagesDescription.Add(String.Empty);
}
this.tabImages.Focus();
this.pbImages_Click(this.flpImages.Controls[this.flpImages.Controls.Count - 1], new EventArgs());
this.Cursor = Cursors.Default;
this.btnRemoveImage.Enabled = true;
this.tbImageNotes.Enabled = true;
}
catch (Exception exc)
{
MessageBox.Show("Error Adding the Image File.\n\n" + exc.Message);
}
}

All I get is an icon that indicates that nothing can be dropped (the forbidden icon) and can't drop anything. Can anyone help?
AnswerRe: Drop File not working Pin
Xmen Real 18-Mar-09 2:34
professional Xmen Real 18-Mar-09 2:34 
GeneralRe: Drop File not working Pin
oneiros18-Mar-09 3:40
oneiros18-Mar-09 3:40 
GeneralRe: Drop File not working Pin
Xmen Real 18-Mar-09 3:50
professional Xmen Real 18-Mar-09 3:50 
GeneralRe: Drop File not working Pin
oneiros18-Mar-09 4:00
oneiros18-Mar-09 4:00 
GeneralRe: Drop File not working Pin
Xmen Real 18-Mar-09 4:07
professional Xmen Real 18-Mar-09 4:07 
AnswerRe: Drop File not working Pin
oneiros18-Mar-09 9:39
oneiros18-Mar-09 9:39 
QuestionHow to replace the PDF file present in temporary internet files folder? Pin
svt gdwl18-Mar-09 1:14
svt gdwl18-Mar-09 1:14 
AnswerRe: How to replace the PDF file present in temporary internet files folder? Pin
Eddy Vluggen18-Mar-09 1:27
professionalEddy Vluggen18-Mar-09 1:27 
JokeRe: How to replace the PDF file present in temporary internet files folder? Pin
Xmen Real 18-Mar-09 2:43
professional Xmen Real 18-Mar-09 2:43 
GeneralRe: How to replace the PDF file present in temporary internet files folder? Pin
Eddy Vluggen18-Mar-09 2:53
professionalEddy Vluggen18-Mar-09 2:53 
GeneralRe: How to replace the PDF file present in temporary internet files folder? Pin
Xmen Real 18-Mar-09 3:01
professional Xmen Real 18-Mar-09 3:01 
QuestionWeb Control Issue - c# Pin
rohithnair18-Mar-09 0:34
rohithnair18-Mar-09 0:34 
Question[Message Deleted] Pin
Ramkithepower17-Mar-09 23:52
Ramkithepower17-Mar-09 23:52 
AnswerRe: Error Handing in Seperate frame Pin
benjymous17-Mar-09 23:52
benjymous17-Mar-09 23:52 
QuestionHow to create control like textbox dot matrix Pin
lmquyen17-Mar-09 23:40
lmquyen17-Mar-09 23:40 
AnswerRe: How to create control like textbox dot matrix Pin
benjymous17-Mar-09 23:52
benjymous17-Mar-09 23:52 
AnswerRe: How to create control like textbox dot matrix Pin
Xmen Real 18-Mar-09 2:38
professional Xmen Real 18-Mar-09 2:38 

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.