|
i didnt get u @Ben what control means?????
|
|
|
|
|
Use <pre> tags to surround code blocks.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
I believe you mean <pre>code here<pre/> tags.
|
|
|
|
|
I think you should restate your question as it's not terribly clear. You want to provide a way to select multiple images for batch processing, and you want to display thumbnails, but it all stops there for me. What are you having difficulty with? Drawing images to the screen? If so, have a look at the Graphics class.
|
|
|
|
|
till now i have put a checkbox and i can select multiple images through it n it is displayed in the preview box but instead of seeing just the name of the images in the checklist box i want the thumbnails of the images to be displayed along with the check button
|
|
|
|
|
It seems that you want to use a CheckedListBox and display thumbs instead of filenames. To do so I believe you must use the OwnerDraw method. Try googling it though - surely many have done the same or something similar before you.
|
|
|
|
|
|
If i click on add photos a new window pops to select a particular folder in whcih images are present.But i cannot select the particular image i have to select the whole folder and the names of these images are then displayed in the checklist box.I want the thumbnails of these images to be displayed in this box.When i will select a particular image it will be displayed in the preview box,There is also a problem here i cannot c the whole image but only a part of it.......I hope this will help u to clear my doubt.
|
|
|
|
|
Hi,
one way to get what you want is this:
1. define a little MyImage class, containing a file name, a bitmap, a selected flag.
2. use a regular ListBox; it can show a collection of items of any type you choose (not just strings), so use it to hold instances of MyImage.
3. provide your own DrawItem handler to paint the MyImage any way you like (use Graphics.DrawString to show the file name, and DrawImage to draw a thumbnail)
4. add click and doubleclick handlers as you see fit.
As an example, this little article[^] uses an owerdrawn ListBox in order to get colored text lines.
|
|
|
|
|
djsproject wrote:
FileInfo[] FileJpg = FileDirectory.GetFiles("*.jpg");
FileInfo[] FileGif = FileDirectory.GetFiles("*.gif");
FileInfo[] FileBmp = FileDirectory.GetFiles("*.bmp");
FileInfo[] FileTif = FileDirectory.GetFiles("*.tif");
FileInfo[] FilePng = FileDirectory.GetFiles("*.png");
foreach (FileInfo File in FileJpg)
{
ImageList.Add(File.Name, File.FullName);
checkedListBox1.Items.Add(File.Name);
}
foreach (FileInfo File in FileGif)
{
ImageList.Add(File.Name, File.FullName);
checkedListBox1.Items.Add(File.Name);
}
foreach (FileInfo File in FileGif)
{
ImageList.Add(File.Name, File.FullName);
checkedListBox1.Items.Add(File.Name);
}
foreach (FileInfo File in FileTif)
{
ImageList.Add(File.Name, File.FullName);
checkedListBox1.Items.Add(File.Name);
}
foreach (FileInfo File in FilePng)
{
ImageList.Add(File.Name, File.FullName);
checkedListBox1.Items.Add(File.Name);
}
This is WTF. Use at least the following solution please:
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);
}
}
Also, set meaningful names for your controls, please. e.g. change 'button1' to 'buttonAddImage' or sth.
Greetings - Jacek
|
|
|
|
|
hey i want this code of rotating image with all the images that i have selected can somebody tell me how to get it done?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Text;
using System.Windows.Forms;
namespace ImageRotation
{
public partial class Form1 : Form
{
private Image loadedImage;
public Form1()
{
InitializeComponent();
}
private Image RotateImage(Image inputImg, double degreeAngle)
{
PointF[] rotationPoints = { new PointF(0, 0),
new PointF(inputImg.Width, 0),
new PointF(0, inputImg.Height),
new PointF(inputImg.Width, inputImg.Height)};
PointMath.RotatePoints(rotationPoints, new PointF(inputImg.Width / 2.0f, inputImg.Height / 2.0f), degreeAngle);
Rectangle bounds = PointMath.GetBounds(rotationPoints);
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;
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);
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;
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));
}
}
}
this code works for only one image.I want it to run for multiple images.In other words i want it to integrate with the above code.can somebody help..............
|
|
|
|
|
hi guys...i have a problem about string usage..i want to make capital letters of a text in the textbox after space...for example if textbox is entered like that mert efe i want to write like that Mert Efe..to do that i wrote that codes
public string Cevir(string text)
{
string temizlenmis = null;
for (int i = 0; i < text.Length; i++)
{
if ((i == 0) || (i==text.IndexOf(" ")+1))
temizlenmis += char.ToUpper(text[i]);
else
temizlenmis += char.ToLower(text[i]);
}
return temizlenmis;
}
and it works for two words but if i enter third word it doesnt work as i wished...it works like that if i enter three words like mert efe demir and it gives result Mert Efe demir
so what is wrong here ?
|
|
|
|
|
You are searching for the first space every time..
How about (untested)
public string TitleCase(string text)
{
StringBuilder result = new StringBuilder();
bool nextIsCap = true;
for (int i = 0; i < text.Length; i++)
{
if (nextIsCap)
{
result.Append(char.ToUpper(text[i]));
nextIsCap = false;
}
else
result.Append(char.ToLower(text[i]));
if (text[i] == ' ')
nextIsCap = true;
}
return result.ToString();
}
edit: ok that sucked, next try:
(also untested)
public static string ToTitleCase(string text)
{
char[] buffer = text.ToCharArray();
bool nextIsCap = true;
for (int i = 0; i < buffer.Length; i++)
{
if (nextIsCap)
buffer[i] = char.ToUpper(buffer[i]);
else
buffer[i] = char.ToLower(buffer[i]);
nextIsCap = buffer[i] == ' ';
}
return new string(buffer);
}
modified on Thursday, January 7, 2010 8:41 AM
|
|
|
|
|
thanks man
first one gives the result as i wished..but i didnt get the point what was my mistake
|
|
|
|
|
How about the second one, it should give the same result (right?)
Your mistake is that you search for the first space, you could fix it be adding ,i (yes that's all) to the call to IndexOf - but then it will still suck and I really recommend my second version (or the build-in function)
|
|
|
|
|
no man the second one didnt give the same result..it doesnt make capital first letter of first word...and where should i add the "i" ?? i used like
if ((i == 0) || (i == text.IndexOf[i](" ")+ 1))
and
if ((i == 0) || (i == text.IndexOf(" ")[i]+ 1))
but it given error
modified on Thursday, January 7, 2010 9:27 AM
|
|
|
|
|
if ((i == 0) || (i == text.IndexOf(" ", i)+ 1))
Well I said ,i , not [i]
|
|
|
|
|
I tested my second function, it works fine
edit: to be fair, when I first posted it it had a bug that made the first letter lower case, it was just that it said bool nextIsCap = false which obviously should have been true (but hey that's no reason to just forget about that function, it's a very simple fix and I fixed it the next minute or so)
|
|
|
|
|
thanks man i am really appreciated because of your help..
take care and thanks again
but my method doesnt work again even if write "i" as u said
|
|
|
|
|
You're welcome
|
|
|
|
|
You should use the method supplied by the .NET Framework called TextInfo.ToTitleCase() ; it's in the System.Globalization namespace, the easiest way to acquire the TextInfo object is to retrieve it from the CurrentCulture like so:
System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase("mert efe");
MSDN Reference: http://msdn.microsoft.com/en-us/library/system.globalization.textinfo.totitlecase.aspx[^]
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
|
|
|
|
|
hii Ben
thanks for you reply..i tried the method u suggested it is really good method..but i want to ask one more question about it...for example we have capital i like "İ" in turkish but it writes like I when it makes it capital..i think it is because of
TextInfo myTI = new CultureInfo("en-US",false).TextInfo;
so how i can use turkish characters instead of english ?
|
|
|
|
|
erdinc27,
You'll need to get the code letters for the Turkish culture, I'm not sure what they are but you should be able to find them rather quickly by searching the 'Net. Once you have those code letters you'll replace the "en-US" code with the Turkish code, then it will operate on the string using the Turkish alphabet.
Hold on a second here... Don't you think you might be putting the horse ahead of the cart?
|
|
|
|
|
Does the IPv6 protocol deal with UDP datagrams ???
|
|
|
|
|