|
Hi,
bool someUsersWereFound = results.Count!=0;
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
modified on Wednesday, June 10, 2009 1:48 PM
|
|
|
|
|
Luc Pattyn wrote: Hi,
bool someUsersWereFound = results.Count!=0;
Smile
first off THANK YOU !
sorry for the noobieness how would I incorporate this into my code?
|
|
|
|
|
Hi,
MessageBox.Show(results.Count.ToString()+" user(s) found");
PS: I strongly suggest you buy and read a tutorial book on C#. It will teach you the essentials in a structured way.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Luc Pattyn wrote: Hi,
MessageBox.Show(results.Count.ToString()+" user(s) found");
PS: I strongly suggest you buy and read a tutorial book on C#. It will teach you the essentials in a structured way.
Smile
so the bool statment you showed me before i need to place that inside the foreach i understand the messagebox part just not the part on how to get the program to realise nothing is found then display the message nothing found. Iv tried and watched it when i debug the program but i cant fig it out.
Thanks again.
|
|
|
|
|
Hi
Is there a smart way todeserialize an object to form. Instead of typing textbox1.text = object.property..., after the object has been deserialized.
My form has a bunch of controls, and I was just looking for a different way of doing this. I am just looking for ideas I guess?
tom
|
|
|
|
|
Personally, I prefer writing the code to set the values of form elements. Often the pursuit of automagic code features will cause you more pain than it is worth. However, you could use reflection if you really wanted to in a poor man's data binding fashion or implement the data binding interfaces to make your object a valid data source. Or make an object data source for which to bind your object.
|
|
|
|
|
You could try looking at the documentation for ApplicationSettings this gives some examples of doing this sort of thing.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
where would I find those examples you are talking about
|
|
|
|
|
Try here[^], there are lots of useful links on that page, particularly the last one, immediately above the 'See Also'
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Tusen Takk - Norwegian for thank you so much
|
|
|
|
|
My pleasure.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Everyone
please look at following two line this is not working when i execute my prject
int div = Convert.ToInt32(textBox1.Text.Trim());
ptr[0] = ptr[1] = ptr[2] = (byte)((ptr[0] + ptr[1] + ptr[2]) / div);
but if i remove the first line and enter an integer value in place of div variable it works such as following line.
ptr[0] = ptr[1] = ptr[2] = (byte)((ptr[0] + ptr[1] + ptr[2]) / 3);
Following is the full listing may it help you to figurout the problem
a method that convert a bitmap from colored to grayscale
//////////////////////////////////////////////////////////////////////////
public Bitmap GrayScale(Bitmap bmpimg)
{
BitmapData bmpData = bmpimg.LockBits(new Rectangle(0, 0, bmpimg.Width, bmpimg.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int remain = bmpData.Stride - bmpData.Width * 3;
unsafe
{
byte* ptr = (byte*)bmpData.Scan0;
for (int i = 0; i < bmpData.Height; i++)
{
for (int j = 0; j < bmpData.Width; j++)
{
int div = Convert.ToInt32(textBox1.Text.Trim());
ptr[0] = ptr[1] = ptr[2] = (byte)((ptr[0] + ptr[1] + ptr[2]) / div);
ptr += 3;
}
ptr += remain;
}
}
bmpimg.UnlockBits(bmpData);
return bmpimg;
}
|
|
|
|
|
why is int div = Convert.ToInt32(textBox1.Text.Trim()); inside the nested loops? Are you planning on changing div while the image processing is going on? or are you just looking for ways to make it extremely slow?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
WinSolution wrote: this is not working when i execute my prject
What does this mean?
Are you getting an exception?
Does it do something you do not expect?
Have you single stepped, to see what value div is set to in your code?
What, which, something else?
BTW there are several articles here on CP that demonstrate converting to greyscale, have you looked at them.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks both
problem solved i was not handling exception and not i placed that code outside of the loops as follow
public Bitmap GrayScale(Bitmap bmpimg)
{
BitmapData bmpData = bmpimg.LockBits(new Rectangle(0, 0, bmpimg.Width, bmpimg.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int remain = bmpData.Stride - bmpData.Width * 3;
unsafe
{
byte* ptr = (byte*)bmpData.Scan0;
int div = 1;
try
{
div = Convert.ToInt32(textBox1.Text.Trim());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
for (int i = 0; i < bmpData.Height; i++)
{
for (int j = 0; j < bmpData.Width; j++)
{
ptr[0] = ptr[1] = ptr[2] = (byte)((ptr[0] + ptr[1] + ptr[2]) / div);
ptr += 3;
}
ptr += remain;
}
}
bmpimg.UnlockBits(bmpData);
return bmpimg;
}
|
|
|
|
|
Hi,
when you store the value of bmpData.Width in a local variable, your code will run some 20% faster.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
WinSolution wrote: div = Convert.ToInt32(textBox1.Text.Trim());
You should use int.TryParse to test if the entered text is a number or not.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
You may also handle the exception for ptr[0] = ptr[1] = ptr[2] = (byte)((ptr[0] + ptr[1] + ptr[2]) / div);
|
|
|
|
|
[Intro]
To keep the story short, I have created a Download manager creating various simultaneous HttpRequests and downloading the HttpResponses (of the files).
In brief, the relevant code looks somewhat like this...
dRequest = (HttpWebRequest)WebRequest.Create(txtURL.Text);
dRequest.AddRange(dFrom, dTo);
dResponse = (HttpWebResponse)dRequest.GetResponse();
Stream dStream = dResponse.GetResponseStream();
..And of course the download is saved etc etc etc. This all works fine.
[End of Intro]
Today I was told that I should enable compression (from the server side - whenever possible) when downloading the file in order to speed up the download even more... However, I have no idea how this works or how this can be achieved?
I am not asking for someone to do the code for me (although any examples are appreciated), but I would like to know how this can be achieved / how the system works, or what to search for, in order to achieve this?
Huge thanks!
|
|
|
|
|
|
Please go through the following article which contains exactly what you need
Using HTTP Compression for Faster Downloads[^]
If you need to increase the speed further then you may use the below code which actually deals in sockets and increases the speed to many folds when parallel downloading is going on.
public class MyWebResponse
{
public MyWebResponse()
{
}
public void Connect(MyWebRequest request)
{
ResponseUri = request.RequestUri;
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IPEndPoint remoteEP = new IPEndPoint(Dns.Resolve(ResponseUri.Host).AddressList[0], ResponseUri.Port);
socket.Connect(remoteEP);
}
public void SendRequest(MyWebRequest request)
{
ResponseUri = request.RequestUri;
request.Header = request.Method + " " + ResponseUri.PathAndQuery + " HTTP/1.0\r\n" + request.Headers;
socket.Send(Encoding.ASCII.GetBytes(request.Header));
}
public void SetTimeout(int Timeout)
{
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, Timeout * 1000);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, Timeout * 1000);
}
public void ReceiveHeader()
{
Header = "";
Headers = new WebHeaderCollection();
byte[] bytes = new byte[10];
while (socket.Receive(bytes, 0, 1, SocketFlags.None) > 0)
{
Header += Encoding.ASCII.GetString(bytes, 0, 1);
if (bytes[0] == '\n' && Header.EndsWith("\r\n\r\n"))
break;
}
MatchCollection matches = new Regex("[^\r\n]+").Matches(Header.TrimEnd('\r', '\n'));
for (int n = 1; n < matches.Count; n++)
{
string[] strItem = matches[n].Value.Split(new char[] { ':' }, 2);
if (strItem.Length > 0)
Headers[strItem[0].Trim()] = strItem[1].Trim();
}
// check if the page should be transfered to another location
if (matches.Count > 0 && (
matches[0].Value.IndexOf(" 302 ") != -1 ||
matches[0].Value.IndexOf(" 301 ") != -1))
// check if the new location is sent in the "location" header
if (Headers["Location"] != null)
{
try { ResponseUri = new Uri(Headers["Location"]); }
catch { ResponseUri = new Uri(ResponseUri, Headers["Location"]); }
}
ContentType = Headers["Content-Type"];
if (Headers["Content-Length"] != null)
ContentLength = int.Parse(Headers["Content-Length"]);
KeepAlive = (Headers["Connection"] != null && Headers["Connection"].ToLower() == "keep-alive") ||
(Headers["Proxy-Connection"] != null && Headers["Proxy-Connection"].ToLower() == "keep-alive");
}
public void Close()
{
socket.Close();
}
public Uri ResponseUri;
public string ContentType;
public int ContentLength;
public WebHeaderCollection Headers;
public string Header;
public Socket socket;
public bool KeepAlive;
}
2)
|
|
|
|
|
Thanks mate! It appears to be just what I wanted... Looks more complex then the methods I'm currently using but I guess that's the way to go... Thanks a lot
|
|
|
|
|
You welcome buddy
|
|
|
|
|
Hi,
I am pretty new to developing in InfoPath and SharePoint. I have the requirement to extract repeating table data from an InfoPath form using web part (written in C#).
I have been looking into how I might go about doing this but I don't seem to have come up with a solution.
I have tried getting the document as an XML document but it will not let me open it in the web part and claims I don't have the correct permissions, even though i have full permissions across the whole site (including on the document library)
Could anyone point me in the right direction or offer any advice?
Many thanks in advance,
Luke
|
|
|
|
|
For a label control i dynmically changed the font and color of the text and then i stored those values in the database(access) and i want to apply the values stored in the database to other labels. How to apply those stored values to other labels from the database. I retrieved those values from database i got the values as string , then how to apply these string values to change the color of the label.
|
|
|
|