|
Does this[^] article help?
/ravi
|
|
|
|
|
I .Net Framework 2 there is a very useful calls called the System.Net.WebClient class. This class contains methods that allow you to quickly make http and https requests and process the return. You can set headers and post information. I have used it to create a http post to remote servers and receive a response. Here is some code:
<br />
Byte [] PostData = System.Text.Encoding.ASCII.GetBytes("hello world");<br />
System.Net.WebClient client = new System.Net.WebClient();<br />
Byte[] Response = oClient.UploadData("http://www.somewhereintheworld.com", "POST", PostData);<br />
return System.Text.Encoding.ASCII.GetString(Response);<br />
These first line just turns the post data I want to send into a byte array. I create the WebClient object on the second line and then on the third line I tell the client to send the data to the target website as a post action with the byte array I have created. This returns a byte array that I then need to turn back into a string which is done on the last line.
Happy browsing.
|
|
|
|
|
Hello!!
I want to convert .bmp image to Jpeg image in C#. so kindly help me out.
thx
B!z
|
|
|
|
|
Snippet:
Image objImage = Image.FromFile("test.bmp"); <br />
objImage.Save("test_output.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
|
|
|
hi i'm Rajakumar, i'm doing a project c#. in that my application contains datas in two data grids, consider 3 rows and 3 columns each. i've to read those data and have to store in another datagrid but i couldn't able to read those data for multiply.
please can anyone help me to solve this problem.
my mail id is rj.rajakumar@gmail.com
|
|
|
|
|
Why are you storing in another data grid? Why not just put the data into an array and work from there?
"I really like comments where I don't have to answer stupid questions" - stfx
|
|
|
|
|
In articles/books i have method convert color image to grayscale.
This is the method :
ImageGrayscale=(Red+Green+Blue)/3
but i don't understand to convert bit image pixel to integer.
so, please help me to apply this method in C# language programming.
Thanks
Haloha...!!!!
|
|
|
|
|
Hi,
the Image class gives each pixel a Color value, which is basically a 32-bit number
(4 bytes, for alpha,red,green,blue). To make it a grayscale image, you should make
sure all pixels have no color by giving them the same value for red, green and blue.
So basically you could do (pseudocode!):
foreach (pixel pix in image) {
int gray=(R+G+B)/3;
pix.color=new color(gray,gray,gray);
}
For normal sized images this would be rather slow, you could consider using pointers.
Remark: CodeProject holds a good series of articles on image operations by Christian Graus.
You may want to read these.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
That method is wrong. To get good greyscale, you need to weight the pixels according to how our eyes work.
My image processing articles include a greyscale filter, but you can also do it far easer with a color matrix, there are plenty of examples online. My article answers your questions, tho.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
foreach(FileInfo file in files) {
}
you need to declare a type for thw variable 'file'
which could also be a string, or something else depeneding on what 'files' contains.
-- modified at 7:56 Friday 26th October, 2007
Dammit, i hate when people delete topics. It just leave posts floating around.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
The Undefeated wrote: Dammit, i hate when people delete topics. It just leave posts floating around.
Not to mention it is very inconsiderate to other members. Someone may have the same question, and it had been answered. But they will never know because the question was deleted. Not that it matters, most people don't search articles, the forums, or google anyways.
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
The Undefeated wrote: Dammit, i hate when people delete topics. It just leave posts floating around.
Same here. That is usually why I copy the original post in my reply
"I really like comments where I don't have to answer stupid questions" - stfx
|
|
|
|
|
Hi
I need to resize or compress a word document or a Pdf file by programmatically
any third party tool also fine we are ready to buy.
Any Ideas or suggestion? please welcome.
Thanks
Vijai
Vijai
|
|
|
|
|
Upgraded some code from VB to C#.
Select Case whatever
Case x To y
' mmhmm
Case Is > z
' yeesh
Case Else
' ??
End Select
So I changed this to:
switch (whatever) {
case x to y:
break;
case is > z:
break;
default:
break;
}
But, obviously To and Is don't convert. What do I use instead? Do I need to replace it all with if (x >= whatever >= y)
[update] Forgot to put the closing brace in the code sample.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
Ninja-the-Nerd wrote: But, obviously To and Is don't convert. What do I use instead? Do I need to replace it all with if (x >= whatever >= y)
In this case, with only 3 options I would say this is your best bet.
if(whatever > x && whatever < y)<br />
{<br />
}<br />
else if(whatever > z)<br />
{<br />
}<br />
else<br />
{<br />
}
|
|
|
|
|
So it can't be done then? Nuts.
Incidentally how do you convert If searchString Like "p#" Then
I've written a strLeft function to do what VB6 did. It works well enough, I could change it and check for if (functionClass.strLeft(searchString,4) == "page") .
Thanks btw.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
You can use searchString.StartsWith(p)
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
C# doesn't have the same concept behind switch statements as VB. It can be done, but you would need to list all of the values between "x" and "y". The "is > z" can't be represented by a case, however.
Your best bet would be to do either rework your logic so you can use the switch, which would probably mean defining more specific cases and using the default case to handle the "is > z" condition, or to use if/else blocks.
|
|
|
|
|
Hi, I'm currently working on a website that has a treeview that represents folders in a virtual directory and also a datalist that allows users view files in a given folder, or text search, etc.
I am using ASP.NET and C# and hope to implement a function where if the mouse is hovering over an imagebutton in the datalist - the folder for that given file will be highlighted in the TreeView.
The TreeView and DataList are kept in diffent controls (ascx files) so I have been using EventHandlers in trying to solve my problem. Also, as far as I can tell - ASP.NET does not contain an 'onmouseover' attribute for ImageButtons so I have been using JavaScript to detect and fire the event.
The DataList is kept in its own control, which is then placed into its parent control that also holds the TreeView. There is a lot of code so I will try and submit the code that I think is relevant:
DataList Control.aspx: (javascript)
function highlightNode(event)
{
javascript:setTimeout('__doPostBack(\'<% =btnCheat.ClientID %>\',\'\')',0)
// alert(event);
}
function mouseOut(event)
{
javascript:setTimeout('__doPostBack(\'<% =btnMouseOutCheat.ClientID %>\',\'\')',0)
//alert("mouseOut")
}
This is where I believe I may be going wrong - the setTimeout means that the highlightNode function is repeatedly called with onmouseover, could someone advise on how to rewrite this diffently so that it does not repeatedly call a method?
The post backs called on each of these functions simulate the clicking of asp:buttons that will enable me to access the code-behind from the onmouseover event, here is the code-behind for the DataList control.
DataList.ascx.cs:
imgBtnFileType.Attributes["onmouseover"] = "highlightNode('" + HoverID + "')";
imgBtnFileType.Attributes["onmouseout"] = "mouseOut(event)";
These attributes are added in the ItemDataBound method for the DataList, where I add onmouseover and onmouseout to my image button. HoverID is the value I am passing to the event and is a ViewState variable that will be used to identify the Folder that I wish to highlight.
protected void btnCheat_Click(object sender, EventArgs e)
{
RaiseMouseOverEvent();
}
protected void btnMouseOutCheat_Click(object sender, EventArgs e)
{
HoverID = 0;
RaiseMouseOutEvent();
}
Above are the events called when I simulate a button click with my javascript.
public EventHandler evtMouseOver;
public EventHandler evtMouseOut;
Again, I am using EventHandlers as the TreeView is kept in a separate ascx file.
protected void RaiseMouseOutEvent()
{
if (evtMouseOut != null)
evtMouseOut(this, new EventArgs());
}
protected void RaiseMouseOverEvent()
{
if (evtMouseOver != null)
evtMouseOver(this, new EventArgs());
}
Next, here is what is going on in my other ascx file that contains both the TreeView and DataList control:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ucDataList.evtMouseOut += new EventHandler(ucDataList_evtMouseOut);
ucDataList.evtMouseOver += new EventHandler(ucDataList_evtMouseOver);
}
The events are passed from the DataList control ^ ...
void ucDataList_evtMouseOver(object source, EventArgs e)
{
string hoverNode = ucDataList.HoverID.ToString();
tv1.FindNode(hoverNode).Select();
}
void ucDataList_evtMouseOut(object source, EventArgs e)
{
if (ucDataList.HoverID == 0)
{
if (tv1.SelectedNode != null)
tv1.SelectedNode.Selected = false;
}
}
..and the following methods ^ are called. As far as I can tell - these methods should select a given folder and unselect respectively.
Thus far, I am having the problem that I already mentioned in that the javascript is repeatedly calling the highlightNode function() when a mouseoverevent is fired and beyond that - I don't seem to be reaching the eventHandlers. I was reaching the EventHandlers at an earlier stage while debugging and not sure why I'm not anymore I don't think I've changed anything.
I hope I've been clear with my problem and would REALLY appreciate any help and advice as to finding a solution. I am new to ASP.NET, c# and javascript and apologise if I've been unclear in my explanation.
thanks,
Dave
|
|
|
|
|
b>You can raise server side event when the mouse over the imagebutton.
function Show()
{
document.getElementById('<%=ImageButton1.ClientID%>').click();
}
ServerSide code
protected void Page_Load(object sender, EventArgs e)
{
ImageButton1.Attributes.Add("onmouseover", "Show();");
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
// Write your event handler...
}
Shanmugam R
|
|
|
|
|
I want to be able to raise an event without actually clicking on the image buttons - which is why I am including buttons that do nothing but raise the event when the image button is hovered over.
-- I've now managed to highlight the node by hovering over the image button using the line of code from the previous post (below).
document.getElementById('<%=btnMouseOutCheat.ClientID %>').click();
Only as before, the mouseover event is continually raised when this happens - when I only really want to fire the event once on mouseover and again with mouseout.
Any ideas anyone?
-- modified at 9:16 Friday 26th October, 2007
|
|
|
|
|
You have to use ajax then. You don't have any other option.
Ben
|
|
|
|
|
The whole DataList control (ascx file) is enclosed in an UpdatePanel in the parent control - and I am having the problem that I already mentioned.
Do you mean that I need to use an ashx handler? If so, any ideas how I might go about writing that?
thanks,
Dave
|
|
|
|
|
Hi
I m getting this error while Grabbing the frame n sending it using sockets to other application.
"Unable to cast COM object of type 'System.__ComObject' to interface type...... This Operation failed because the QueryInterface call on the COM component for the interface with IDD'{6B652FFF-11FE-4FCE-92AD-0266B5D7C78F}' failed due to following error: No such interface supported(Exception from HRESULT:0x80004002(E_NOINTERFACE))"
Plz try to help me out ASAP.
Shanzay
|
|
|
|
|
Hi,
i m using a datagridview to show and update data from sql server. everything works ok, bud when i change a row and click on save changes, it does not update the datasource. to breng changes in the database i have to go first on a other row ( by clicking on a other row) and then klik on save changes, then it works. anyone any idea ?
|
|
|
|