|
Hi all,
I want to sending an XML string using webservice installed at server to the client using IP(internet IP) and then further want to save it in the from of XML file.
can anybody tell me how to do it???
Thanks in advance.
Ankur
|
|
|
|
|
can we hide focus from grid cell
amit
|
|
|
|
|
|
how do i redirect to anther page when i only know the path of the libery?
|
|
|
|
|
Your post doesn't make much sense. Redirect what?
wrote: when i only know the path of the libery?
Is not clear at all.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
how to deactivate grid cell if it is active.
amit
|
|
|
|
|
I want to know what is happening in these lines of code:
a)
public class cAppBarDisplay:AppBar
{
cMessageProcessing CMS;
public cAppBarDisplay(cMessageProcessing cMP)
{
CMS = cMP;
}
}
->cMessageProcessing CMS;
By this mean are we creating a refrence?
->and what the constructer is actually doing?
CMS & cMP both are refrence of same class
Thanks in advance,
plz describe in a bit detail.
|
|
|
|
|
humdumof wrote: ->cMessageProcessing CMS;
By this mean are we creating a refrence?
You created a field called CMS, which you can set to reference an instance of cMessageProcessing. This happens when you do CMS = cMP for example.
humdumof wrote: CMS = cMP;//exactly what is happening here
You assign the parameter cMP to the field CMS. They now hold the same reference to an instance of the cMessageProcessing class (not a reference to the class itself).
|
|
|
|
|
AlwiNus wrote: You assign the parameter cMP to the field CMS. They now hold the same reference to an instance of the cMessageProcessing class (not a reference to the class itself).
Not a refrence to the class itself?
By this what u mean?
also CMS=cMP;
Does it mean we can access all the methods of cMessageProcessing thru CMS?
& what is use of doing all this in constructor?
|
|
|
|
|
humdumof wrote: Not a refrence to the class itself?
By this what u mean?
When you use a class you create an instance of it. Kinda like if i want a bowl of cereal, i have to get myself a bowl and some cereal, and probably some milk. Then my bowl of cereal that i can eat, would be an instance of a bowl of cereal... if you follow me.
When you pass the instance of your class to the constructor your passing a reference (pointer) to it.
humdumof wrote: also CMS=cMP;
Does it mean we can access all the methods of cMessageProcessing thru CMS?
& what is use of doing all this in constructor?
Yes, you can access all the methods of the class through CMS.
The use of this, is that you can make use of the same instance of a class, in as many different classes as you like. So you can make 1 instance of your class, and pass it to 2 other classes for example. Then both classes will work on the same instance.
EDIT: As for why you should actually do this in the constructor: If the new class depends on having an instance of cMessageProcessing (ie it uses it) and it does not get passed a reference or create its own instance, then it will probably crash. By passing it to the constructor, you can guarantee that the new class will always have an instance of cMessageProcessing, it would be impossible to instatiate the class (ie myClass = new MyClass()) without passing the correct parameters.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
buddy, U have a typical class code with u.
Just look in the code its just a constructor with one parameter which is initiallising the value passed by the parameter to the local class variable.
|
|
|
|
|
I am writing a program using System.Timers.Timer to trigger the webcam to capture an image and saved in a file.
The image saving function is workable when it works standalone (by clicking a button). However, when I call the image saving function in the OnTimedEvent (event-triggering function) it fails. It will pop up the following error message:
"System.NullReferenceException: Object reference not set to an instance of an object...."
I lately found that the Data could not be retrieved from the clipboard when the clipboard is being used by another process...
Following is the Caputure function of the webCam device... (in Device.cs)
public Image Capture()<br />
{<br />
try{<br />
if (deviceHandle != 0)<br />
{<br />
SendMessage(deviceHandle, WM_CAP_EDIT_COPY, 0, (IntPtr)0);<br />
IDataObject ido = Clipboard.GetDataObject();<br />
if (ido.GetDataPresent(DataFormats.Bitmap))<br />
{<br />
return ((Bitmap)ido.GetData(DataFormats.Bitmap));<br />
}<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
}<br />
return null;<br />
<br />
}
Following is the timer triggering function...
private void OnTimedEvent(object source, ElapsedEventArgs e)<br />
{<br />
<br />
SavingOnePic(Directory.GetCurrentDirectory(), txtSavingName.Text.ToString());<br />
<br />
}
Following is the saving Function, it works when it is called from a button click event. however, does not work in the above OnTimedEvent function.
private void SavingOnePic(string savingPath, string fileName)<br />
{<br />
<br />
try<br />
{<br />
<br />
if (!Directory.Exists(@savingPath+@"\capturedImage")) <br />
{<br />
Directory.CreateDirectory(@savingPath + @"\capturedImage");<br />
fileIndex = 0;<br />
}else{<br />
string[] fileList = Directory.GetFiles(@savingPath + @"\capturedImage",<br />
fileName + "*.png");<br />
<br />
fileIndex = fileList.Length;<br />
}<br />
<br />
Image image = selectedDevice.Capture();<br />
<br />
image.Save(@savingPath + @"\capturedImage\" + fileName + <br />
"_000" + fileIndex.ToString() + ".png", ImageFormat.Png);<br />
<br />
fileIndex++;<br />
<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
}<br />
}
|
|
|
|
|
And the question is ...
SkyWalker
|
|
|
|
|
Sorry that I didn't mention it clearly.
I want to know why the SavingOnePic function in OnTimedEvent cannot run.
I found that the clipboard does not have any data if the SavingOnePic function in OnTimedEvent. But I don't know how to solve it
Thanks
|
|
|
|
|
You can try to use a System.Windows.Forms.Timer instead, which is tread-safe. If i remember it correctly the System.Timers.Timer isn't (not sure though).
Also, when you mention that you get an exception, it is more helpful if you post the full exception, including stack trace etc..
HTH
|
|
|
|
|
As you already said, there is no data of that type in your clipboard.
You cannot retrieve what does not exist
Therefore, you should avoid "calling" methods of non-existing methods:
IDataObject ido = Clipboard.GetDataObject();
if (ido != null)
{
}
else
{
return;
}
SkyWalker
|
|
|
|
|
Is it because System.timers.timer is not thread-safe, so no data can be retrieved from Clipboard. If it is the case, how can I make the System.timers.timer be thread-safe?
|
|
|
|
|
How do i apply regular expression to find for host name from the text below and it prints out Host name: IT786P20??
Host Name: IT786P20
OS Name: Microsoft Windows XP Professional
|
|
|
|
|
Hi
The question is if you really want to use a regular expression for this. wouldn't a string operation do the job?
someting like
string blah = @"Host Name: IT786P20
OS Name: Microsoft Windows XP Professional"
int colonIndex = blah.IndexOf(":");
string HostName = blah.SubString(colonIndex+1,blah.IndexOf("\r",colonIndex+1)-colonIndex+1).Trim();
Console.WriteLine(HostName);
btw. if you want to work with regular expressions i would recommend you to get expresso it's a free tool with a great regex-Builder and Tester.
here[^]
greets
m@u
|
|
|
|
|
yes i have tried using the regex-builder but i do not know what is the syntax for making a regular expression. my ultimate purpose of using regular expression is becuase i wan to use regular expression to find the text that i want from a text file.
btw is there any software that allows me to type in a word to match from a sample text and gives me the regular expression syntax?
|
|
|
|
|
ah ok.. but you could still use String Operations for it
will that "Machine Name: someName" occur only once in the file?
if so, there's almost no difference between doing it the String Operation - Way or with Regex..
what you mean with syntax?
basically if you want to match a word this already IS a regular Expression
it's no problem to say Regex r = new Regex("Machine Name:");
or in your case, to get the Machine Name "Machine Name: (?<machinename>\w)".
if you use it like that, after applying the regex on your string with Match() you can say
string MachineName = myMatch.Groups["MachineName"].Value;
|
|
|
|
|
i mean syntax like this:
(?sx-m)[^\r\n].*?(? :\.|\?|!)\s)
It gave me an error like this
Error 1 No overload for method 'Regex' takes '1' arguments
Sry to bother u but can u give me a complete code if i were to give u a psuedo code??
|
|
|
|
|
lordbearsg wrote: It gave me an error like this
Error 1 No overload for method 'Regex' takes '1' arguments
hmm.. that's strange.. in .net 1.1 and 2.x it works if you only pass the pattern to the constructor.
what other Parameter does it want?
|
|
|
|
|
/// using System.Text.RegularExpressions;(NameSpace for Regular Exprestion...)
public static bool IsAlphaNumeric(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithSpace(String strToCheck)
{
Regex objAlphaNumericSpacePattern = new Regex(@"^[a-zA-Z0-9\s]*$");
return !objAlphaNumericSpacePattern.IsMatch(strToCheck);
}
public static bool IsNumericWithDot(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[0-9.]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsNumeric(String strToCheck)
{
Regex objNumericPattern = new Regex(@"^[0-9]*$");
return !objNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithDot(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9.]");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithDotPeriodSpace(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9\s.,]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithDotPeriodSpaceHyphen(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9\s.,-]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithDotPeriodSpaceHyphenSlash(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9\s.,-/]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithSlash(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9/]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAmount(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^(\d{1,12}|(\d{1,12}\.{1}\d{1,3}){1})$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAmountBECost(String strToCheck)
{
Regex objAmountPattern = new Regex(@"^(\d{1,8}|(\d{1,8}\.{1}\d{1,3}){1})$");
return !objAmountPattern.IsMatch(strToCheck);
}
<div class="ForumMod">modified on Tuesday, December 18, 2007 4:08:49 AM</div>
|
|
|
|
|
None of these would work, as you are returning not IsMatch, so it will return true if its not matched.
The . in some places need to be escaped too, as it will match anything, if unescaped.
xacc.ideIronScheme a R5RS/R6RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|