|
|
Thanks for the link. This is certainly a great resource to have. It looks like the Xpath string is still blowing up even with a \'
|
|
|
|
|
instead of \', have you tried ' instead?
|
|
|
|
|
Yes, and " Those values are inserted into the string, but I guess it is not read as an xpath query since I still get an invalid token message.
|
|
|
|
|
Try this and see if it works:
string oldText = catName;
string newText = oldText.Replace("'", @"\'");
Chase Davis
|
|
|
|
|
Thanks Chase. This is exactly what I needed to do to get the string to contain \' BUT it looks like the xpath string is still blowing up when SelectNodes() is called. I don't think it recognizes the escape sequence. I also tried including ' but it didn't recognize that either. I do appreciate the help though.
|
|
|
|
|
Hi folks,
I have a deployment project which set's up registery entries for using redmonnt.dll and any other things which are neccessary.
First I create a printer setup over the redirect port manually and extract all entries from the registry. (I hope they are all )
This procedure produces a printer icon within the printer explorer and provides a new available printer in the print dialog of applications.
If I run my installer all reg entries were made (device, port, ...), but no printer icon is available and my printer is inaccessible to the applications print dialog.
Do you have me some hints, what additional work do I need to do.
Thanks.
|
|
|
|
|
Ok, I know it is long...
In an OpenFile() routine I am trying to change the color on the text of a file at a specific position, and do this prior to it loading into a RichTextBox.Text property. I can do this with the findSequenceNumbers() routine below;
If I do it after it loads by using the findSequenceNumbers() routine it takes about 3 - 4 minutes dpending on the file size as it scrolls thru the text box.
I want to perform this formatting using the RichTextBox.RTF property however I do not understand it, nor do I understand where I would fit it in. I did create the file and save it after I formatted it as an RTF document and when I open it in a text editor this is what is at the top;
{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Courier New;}}
{\colortbl ;\red0\green0\blue139;}
\viewkind4\uc1\pard\lang1033\f0\fs20
A formatted line with the color change looks like this;
2007/08/13 14:00:03 [144007]ARES_EINDICATION 010.050.016.010 420.1.01 (6901) RX 68 bytes 69 01 26 02 28 A4 AA 20 76 96 51 44 50 76 08 45 46 00 34 02 02 C7 88 \cf1\b 01\cf0\b0 C7 88 AA 50 76 08 45 46 20 76 96 51 44 D7 07 08 0D 0D 3B 3B 00 00 10 06 0A 06 06 06 06 06 06 0A 0A 06 06 06 06 0A 0A 9B 67 5F 91 F8 \par
-------------------------------------------
private void OpenFile()
{
try
{
if (OpenFileDialog.ShowDialog() == DialogResult.OK)
{
string strExt;
strExt = System.IO.Path.GetExtension(OpenFileDialog.FileName);
strExt = strExt.ToLower();
if (OpenFileDialog.FileName == "")
{
return;
}
switch (strExt)
{
default:
if (strExt == ".rtf")
{
rtbDoc.LoadFile(OpenFileDialog.FileName, RichTextBoxStreamType.RichText);
}
else
{
StreamReader rtfReader;
rtfReader = new StreamReader(OpenFileDialog.FileName);
rtbDoc.Text = rtfReader.ReadToEnd();
rtfReader.Close();
rtfReader = null;
rtbDoc.SelectionStart = 0;
rtbDoc.SelectionLength = 0;
}
break;
case ".dat":
rtbDoc.Text = Streamer.LayoutInput(OpenFileDialog.FileName);
break;
}
currentFile = OpenFileDialog.FileName;
rtbDoc.Modified = false;
this.Text = "Train Control Editor: " + currentFile.ToString();
}
else
{
MessageBox.Show("Open File request cancelled by user.", "Cancelled");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString(), "Error");
}
}
-------------------------------------------
private void findSequenceNumbers()
{
toolStripStatusLabel.Visible = toolStripProgressBar.Visible = true;
toolStripProgressBar.Value = 0;
int lineNum = 0;
bool startingNewLine = true;
FontStyle style = FontStyle.Bold;
string[] lines = rtbDoc.Lines;
string text = rtbDoc.Text;
toolStripProgressBar.Maximum = text.Length;
for (int i = 0; i < text.Length; i++)
{
if (startingNewLine)
{
if ((lines[lineNum].Contains("ARES_EINDICATION")) || (lines[lineNum].Contains("ARES_INDICATION")))
{
i += 169;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.DarkBlue;
}
else if (lines[lineNum].Contains("]CODELINE_INDICATION_MSG"))
{
i += 160;
rtbDoc.Select(i, 2);
rtbDoc.SelectionFont = new Font(rtbDoc.SelectionFont, rtbDoc.SelectionFont.Style ^ style);
rtbDoc.SelectionColor = Color.DarkBlue;
}
else
{
i += lines[lineNum].Length - 1;
}
startingNewLine = false;
Application.DoEvents();
}
if (text[i] == '\n')
{
startingNewLine = true;
lineNum++;
}
toolStripProgressBar.Value = i;
}
toolStripStatusLabel.Visible = toolStripProgressBar.Visible = false;
rtbDoc.Select(0, 0);
rtbDoc.ScrollToCaret();
}
--------------------------------------------------
Thanks,
Brian
|
|
|
|
|
Hi!
Although I cannot really follow what you're trying to do, it seems as if a different way would be much easier:
Create a (invisible) RichTextBox , load the RTF document into this box, find the lines you want to colorize using the Text property of the RTB, select them and then assign the SelectionColor you want.
Afterwards you can simply assign the invisible RTB's Rtf property to the target RTB and you're done.
If you really want to modify the RichText yourself, I suggest reading the Rich Text Format (RTF) Specification, version 1.6[^], but a quick scan through the introduction will show you that it's not as easy as you might think.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I have tried having the RichTextBox is both visible and invisible. No difference in the time it takes for the SelectionColor. It takes 3 -4 minutes regardless.
My goal is to speed up the process for this.
If I select all text and change it to BOLD it takes a second or two, if I change the color of all the text it takes the same time.
Your right the RTF spec is not easy.
Brian
|
|
|
|
|
I don't have a quick and easy answer for you, but you probably weren't expecting one. I can offer a little help though, I hope. I have used RichTextBox controls a little bit, but what I was doing was writing a simple "report, " saving it to a file, sending it to a client application that then displayed the file in a RichTextBox control.
Anyway, you said you wanted to use the .Rtf property. I didn't use it, but as I understand it, you'd need to load your rtf-formatted text into a string object, then
<br />
string rtfString = ;<br />
rtbDoc.Rtf = rtfString ;<br />
What I did was:
<br />
richTextBox.LoadFile ( path ) ;<br />
I don't think that the .Rtf property is going to be much help, though. Here are my assumptions about things you've done so far:
You have data in a text-based file captured from a device or other source.
You opened a data file in Wordpad and found the text of interest.
You changed the interesting text to bold and blue.
You saved the result as .rtf file.
A portion of that file is shown in your post.
<br />
\cf1\b 01\cf0\b0<br />
This portion of that text means color foreground #1 from color table, bold, 01 (which is the interesting text), color foreground #0 (back to default color), bold off. The color table is defined on line 2:
<br />
{\colortbl ;\red0\green0\blue139;}<br />
I don't think that the 3 - 4 minute delay really has anything to do with rtf issues. I think that's time taken for findSequenceNumbers to parse the strings. I'd try putting some debug statements before and after a call to it. Find out how much time it is taking.
If my first assumption above is correct, my approach would be to process the data file a line at a time, looking for the tokens as seen in findSequenceNumbers and embedding the rtf instructions
<br />
\cf1\b <br />
and the like in the lines. Of course you'd also have to put the other rtf stuff in your StringBuilder or whatever. Not sure if that's really going to speed things up or not, it's just another way to skin the cat.
Hope this helps a little.
BDF
|
|
|
|
|
Your assumptions were correct.
Puts things in a different perspective, and I appreciate the answer.
'
Brian
|
|
|
|
|
Hi friends
Well i m new to this concept and I want to know the OS info of other pcs which are connected through lan.
But I m getting below error
"User credentials cannot be used for local connections"
Can any one please tell me wants wrong with the below code.
ConnectionOptions co = new ConnectionOptions();
co.Username = "abhi";
co.Password = "Software123";
ManagementScope ms = new ManagementScope("\\abhi\\root\\cimv2", co);
ObjectQuery oq = new ObjectQuery("Select * from Win32_OperatingSystem");
ManagementObjectSearcher mo = new ManagementObjectSearcher(ms,oq);
ManagementObjectCollection AllObjects = mo.Get();
foreach (ManagementObject DemoObject in AllObjects)
{
Console.WriteLine("Resource Name : " + DemoObject["Caption"].ToString());
Console.WriteLine("Resource Name : " + DemoObject["Version"].ToString());
Console.WriteLine("Resource Name : " + DemoObject["Manufacturer"].ToString());
Console.WriteLine("Resource Name : " + DemoObject["csname"].ToString());
Console.WriteLine("Resource Size : " + DemoObject["WindowsDirectory"].ToString());
Abhishek
Mumbai, India
|
|
|
|
|
Please refer to this site:
www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22105229.html#discussion[^]
ConnectionOptions cno = new ConnectionOptions();
cno.Impersonation = ImpersonationLevel.Impersonate;
cno.EnablePrivileges = true;
cno.Username = "adminUid";
cno.Password = "adminPwd";
ManagementScope ms = new ManagementScope(@"\\remote_pc\root\cimv2", cno);
ObjectQuery qry = new ObjectQuery("Select * from Win32_Process");
ManagementObjectSearcher srch = new ManagementObjectSearcher(ms, qry);
ManagementObjectCollection col = srch.Get();
|
|
|
|
|
HI all,
My client asked me convert the VS.NET2003 solution into VS.NET 2005. I resolved compile time issue and build my installer successfully. When executed, it is giving me exception at certain places.
1.Marshal.ActiveObject("XXX"), Exception occurred at this place.
this works fine when i build code using 2005.
2.I have a web-services which polls for any updates after periodic interval (configurable), if updates are available then download the updates and restart the exe.
Even if the interval is set to 10 to 15 mins, the exe is restarting within less than a minute.
--> Is there any specific requirement in VS 2005.
Both the problems appeared in VS 2005 build only.
Any pointers are greatly appreciated.
Thanks in advance
Abhi Lahare
|
|
|
|
|
Abhi Lahare wrote: this works fine when i build code using 2005
If it is working fine when you build on 2005, where is it causing the problem?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi All
How I Can save the value from TextBox Control with formate as
the value in textbox is 12036 and the value save as formate 12036,00 in DataBase How I Can Do that by use the Formate string
thank for any body hellp me
Thaer
|
|
|
|
|
Lets clarify.
Textbox = "12036"
Formatted Textbox Value = "12036,00"
You want "12036,00" in the database, but you get "12036". To preserve this value in the database, make sure the column you are saving to is a string column. If you save to a numeric/decimal column, then it will save the number without the formatting.
Hope this helps.
Hogan
|
|
|
|
|
Snorkie,
I think 12036,00 actually means 12306.00. Some cultures use (e.g. most of Europe excluding the UK & Ireland) "," as the decimal separator. Some cultures (mostly Arabic) use a something like a forward slash. So much for maths being a universal language!
|
|
|
|
|
snorkie wrote: make sure the column you are saving to is a string column
If it is number store it as number. Let UI decide how to formate that number.
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
You should do something like:
decimal amount = decimal.Parse(textBoxName.Text);
where textBoxName is the name of your text box. You should save this into the database as a decimal data type, the formatting is not important. You should also look up decimal.TryParse as it will probably be more useful.
|
|
|
|
|
Hello,
You should convert the string to a double value, using double.TryParse (with the CurrentCulture setting).
And than do the String Format.
Here an example with a dynamic number of decimal places:
string text = "123";
string formatedText;
int NumberDecPoints = 2;
double d = 0;
if(double.TryParse(text, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.CurrentCulture,out d))
{
formatedText = String.Format("{0:F" + NumberDecPoints.ToString() + "}", d);
}
All the best,
Martin
|
|
|
|
|
Are you trying to save the value from the TextBox Control '12036' to the database as '12036.00'? Two things I would check. Make sure the column in the database is a varchar, string or a decimal value. Second, use the decimal.Parse method to get the correct format, then send it to the database.
|
|
|
|
|
Hi,
Actually I want to execute all events of web application through request….,
but I only succeed for button's click event and not for all other like image button and anchor element like that…….
The difference between button event & image button event is that button event is related to delegate System.EventHandler and image button to System.Web.UI.ImageClickEventHandler. The link button event also works fine through request because it's event also related to delegate System.EventHandler....
I have also problem with how to call the click event of anchor element bcaz it is client side element.
I am implementing all these from windows application…..., If u have any information then please reply….……..
Bye....
Dipti
|
|
|
|
|
i have to develope an image processing program.
images r face pics.
i find acne scars, shadowed areas then draw lines around of them.
how do i do ? how can i find out this scars.
where is the start point?
|
|
|
|