|
OK, so you want to strip the <b> and </b> tags, you want ALL the other text, including the text inside the bold tags ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
simply i don't want the or in the above i want to exclude them, any help plzz...
regards
|
|
|
|
|
simply i don't want the <b> or </b> in the above i want to exclude them, any help plzz...
thanx and regards
|
|
|
|
|
sorry i didn't see your replys , only when i whent out of the message bord and then returned i found out that i've repeated myself.....
ya actually i just want to exclude the <b> and </b>: eg. (.+(not <b>nor</b>))
|
|
|
|
|
If your just want to remove a fixed part of your string, you could simply use string.Replace("<b>", ""); followed by string.Replace("</b>", ""); to strip out the bold tags.
What remains can then be parsed with regex, of course.
mav
|
|
|
|
|
thanx mav but this will replace the tags witch a space i suppose i just want exclude the tags from appearing with the group when i use this expression:
<td.+><font.+><a.+>(.+)"
i get results desired like:
<prog>Hi to All
but also get undesired extras some times():
<prog>Bob Harris
thanx and regards
|
|
|
|
|
ignore the above i've forgoten to disable html:
<td.+><font.+><b><a.+>(.+)</a></b></font></td>"
i get results desired like:
<Prog>Hi to All</Prog>
but also get undesired extras some times(</b>):
<Prog>Bob Harris</b></Prog>
thanx and regards
|
|
|
|
|
hi there how wud i exclude a certain tag or character using regular exp.:
<a.+>(every character but not the <b> or </b>tag )</a>
!!!!
thanx and regards..
|
|
|
|
|
Match all either side of the tag, and then return the matches ( so the tab is left out ).
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
<a.*><b>(.*+)not any </b><b>or</b></a>
what "expressions" can i use to do the above
|
|
|
|
|
Oh, I see. You want to find inside the tag. Just use non greedy evaluators, and end up with an expression that matches the end. Or use look ahead.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
can u please show me this with an expressions, i'm quite ignorant in regex ....
thanx
|
|
|
|
|
ignore above message:
<a.*>(.*+)not any or
what "expressions" can i use to do the above ..cheers
|
|
|
|
|
You forgot to turn off HTML tags, so I can't see your correction....
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
<a.*>((.*+)not any <b>or</b>)</a>
what "expressions" can i use to do the above
cheers
|
|
|
|
|
Hi Folks
I've got a seperate thread running in my application, that is processing a tree search. This works fine.
My OnPaint event draws the image generated by the enviroment by passing in the graphics handle of the window. The invalidated region since the previous onPaint call, is requested, and then the screen is invalidated. This also works fine.
My problem comes when right clicking or double clicking on the window in the task bar when hidden, or clicking on it while visible to minimise it, which throws an ArgumentException, with 'Invalid Parameter Used'.
As my derived thread does not call any of the windows components, and simply works on a recursive stack function which manipulates an enviroment. So, as far as I can see the threads are completely seperate and do not rely on each other for information. So i do not know why these errors are being raised.
Can anyone explain why this is happening?
Cheers
Cat
|
|
|
|
|
Catalyst,
Please post some sample code. That would help disabiguate what you mean by "tree" and "environment".
If I understand correctly, it sounds like the threat is still interacting with OnPaint . Like nearly every other member of a Control class, painting must be done - unless double buffered - in the same thread on which the control was created using Control.Invoke . The OnPaint is actually a message handler for the Windows WM_PAINT message. When you force and update from a separate thread this message may be sent to the wrong thread and would cause problems that Control.Invoke solves by making sure messages (which are event sent to set text, like setting TextBox.Text ) are sent on the right thread.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
All the graphics are double buffered on a seperate thread.
The OnPaint event of the control calls the enviroment with a graphics handler:
My enviroment contains the following code:
<br />
public void RenderEnviroment(Graphics g, int width, int height)<br />
{<br />
Image i = new Bitmap(width,height);<br />
Graphics gfx = Graphics.FromImage(i);<br />
<br />
int buffer = 5;<br />
gfx.FillRectangle(new SolidBrush(Color.Black),0,0,buffer+(buffer+100)*WIDTH, buffer+(buffer+100)*HEIGHT);<br />
<br />
for (int x=1;x<WIDTH-1;x++)<br />
{<br />
for(int y=1;y<HEIGHT-1;y++)<br />
{<br />
Tile t = this.g_Enviroment[x,y];<br />
if (t != null)<br />
gfx.DrawImage(t.TileImage,buffer + (100*(x-1)) + (buffer*(x-1)),buffer + (100*(y-1)) + (buffer*(y-1)));<br />
}<br />
}<br />
<br />
gfx.DrawString("Permutations Tested: " + permChecked.ToString(),<br />
new Font(FontFamily.GenericMonospace,14),<br />
new SolidBrush(Color.White),<br />
buffer,height-100);<br />
<br />
g.DrawImage(i,0,0);<br />
}<br />
This is called from the OnPaint method of my form, where env is a gloval Enviroment variable:
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
env.RenderEnviroment(e.Graphics,this.ClientRectangle.Width,this.ClientRectangle.Height);<br />
Thread.Sleep(100);<br />
<br />
Region r = env.GetInvalidatedRegion();<br />
this.Invalidate(r);<br />
}<br />
The Tree is largely irellevant, as it runs on a seperate thread and does not interact with the form at any point. Enviroment contains a 2D grid, which is modified by the spawned thread, but is only read by the Painting thread.
Hope that helps
Cata
|
|
|
|
|
Never block the painting handler. This can severely cause the application to hang since painting messages are sent almost continually. So long as RenderEnvironment doesn't do anything in a separate thread, execution is blocked until it's done then GetInvalidatedRegion will run. The Thread.Sleep(100) should not be necessary.
Even though you're not modifying the control you are modifying the 2D grid (I assume a multi-dimensional array) in another thread. If OnPaint or it's callers access that while it's being written this could very easily cause a problem. Use an object (same reference; typically a static reference property will do) to lock between writing and reading the grid.
Depending on how often it's written or read, you might consider even using a ReaderWriterLock , which is documented in the .NET Framework SDK. The important thing is that something isn't reading the grid while something else (the other thread) is writing it.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi Heath,
Cheers for the reply. I changed the 2D array to volatile, as i only have 1 thread writing to it 3.5 million times a second, and it's read from only 60, an exactly up to date reading is not essential. It seems to have speeded the program up slightly.
I added a try / catch block on the on the RenderEnviroment, and discovered that when the program is minimised, the client area that I was using to base my rectangle off was 0,0, which threw an error when trying to construct a bitmap, the error that was thrown without the try block always reverted back to the Main method of the application.
I should have thought of it earlier, but it's sorted the problem out now.
Cheers
Tris
|
|
|
|
|
It would seem that you're forcing a repaint, then. Windows will send a visible window the WM_PAINT message (which in Windows Forms translates to the OnPaint handler, which fires the Paint event) along with the clipping rectangle that needs to be redrawn (redrawing only this rectangle or just objects that intersect it yields better performance for your application). If you force an update you will run into problems like you are now.
I recommend not forcing an update, but simply invalidate. Windows will send a WM_PAINT message ASAP if your window is visible. If it's not visible, then there's no point to send the message and you won't run into problems that you had when the app was minimized.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Well, I do have a problem then.
I don't want the screen to refresh continuously without pause, because this will pull processor time from my other thread which is more important. My display is purely so I can see what is going on.
If i don't force the on paint, the screen will only ever refresh if i do something to it manualy, like resize or min/maximise. I see no point in running a seperate thread that invalidates my screen 15-20 times a second, because it will simply eat more cpu time.
Can you suggest another solution to this problem?
|
|
|
|
|
When the application is idle or you ask the window manager to update the application, the invalidate region for the window for which painting is requested is redrawn (unless the application ignore the clipping region and redraws everything). This is key to having an efficient control: do not draw the whole thing.
Invalidate the region you need (perhaps the entire control; it depends on your requirements) and let the application update the window by placing the WM_PAINT message in the message queue. Set Thread.IsBackground to true and Thread.Priority to a lower priority so that your main application thread can concentrate on painting (or give it a higher priority).
At the very least, you must force the repaint in the right thread but shouldn't block by using Thread.Sleep because enough requests fast enough could mean that the message queue grows large and your visible graph won't match your in-memory graph.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Currently my GetInvalidatedRegion() method returns the entire area, but it's not fully implemented yet, it needs a bit of work so that it can return the area that changed since the last call to the method.
I'm not entirely sure what you're saying here though.
Are you saying spawn a new thread with lower priority to loop through Invalidating the appropriate region?
Or are you saying lower the thread priority in the OnPaint method so that it won't chew up as much juice?
I'm guessing it's not the second as that repaints once every 10 seconds.
My main application thread is the one that launches the form, and inside that it creates a WorldEnviroment object which it sets running.
C
|
|
|
|
|
Give priority to the main thread so that painting is done more often. You can also make sure your invalidated region is updated by calling Control.Update in the thread in which the control was created (your main application thread). Sleeping, again, will just mean that messages keep queuing up instead of getting handled ASAP.
Think about this: you tell the control to redraw about once every 50ms, but you sleep for 100ms. That means that for each redraw roughly 2 paint messages have been queued (taking into account how long it takes to paint). That sure adds up in a short amount of time and then either your visual graph and object graph will be out of sync, or your application's performance will be hindered since the queue will be filled with paint messages and may not process user input messages, for example, as quickly. You really need to benchmark your application to check for performance problems.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|