Thanks for the detailed explanation. After a more extensive searching I found out how to use xml_parser for blogspot feed. It certainly seems easier than regex.
fdsfsa76f7sa6
Posts
-
xml regex (for php) -
xml regex (for php)I'd like to extract data from blogspot feed. I've used regex only for Rainmeter, so this is what I came up with:
(?siU)</id><published>(.*)</published><updated>.*</updated><title type='text'>(.*)</title>.*<link rel='alternate' type='text/html' href='(.*)'
I assume the "(?siU)" part is wrong. What would be the correct format?
I've also heard about php's xml_parser, but I think regex is faster. Still, how would I extract same data as in above (broken) regex with xml_parser in php?
Thanks in advance!
-
Choice of .NET Framework versionIf my applications (mainly WinForms, C#) work in older versions of .NET Framework, should I publish them in older or new version? Is there any criteria that I should look for? Thanks in advance!
-
Control in front of another one at all timesI hope you can give me at least a hint in the right direction... Was it win32-like code or just overriding some functions? I'm more interested in how to keep a panel visually in front at all times. Thanks for the help.
-
Control in front of another one at all timesI know I'm asking a lot, but could you please try to write an example code how to keep a control in front visually and how to make it click-through-able? Thanks in advance!
-
Control in front of another one at all timesIt's a Panel on top of ScrollableControl. I have painted a custom "toolbar" on my form (it's just a drawing, not a control), and I want to add shadow to it. To achieve a look as if drawings in ScrollableControl are going under the toolbar-drawing, I need to separate the shadow into a control and put over it. The shadow-panel is 2 pixels high, has transparent background and has 2 black lines with different alpha value painted on it. Adding the shadow to the ScrollableControl instead of to the form doesn't work, because vertical scrollbar gets over the shadow (gets focused) and I'd also have to keep the shadow steady on scrolling (every control you put inside ScrollableControl will get scrolled). It's the least important thing, but I always like to add some eye-candy to my applications.
-
Control in front of another one at all timesAlready tried, doesn't work, because as soon as user actives the control below, parts of it come in front. I changed the z-order by writing
this.Controls.SetChildIndex(myControl, 0);
Do you know any other way?
-
Control in front of another one at all timesIs there any way to keep control in front of another one at all times? I've been searching for quite a while and I've found nothing that really works. I've also tried with BringToFront method whenever the control beneath it gets focused and it doesn't really work as I want it to. Thanks in advance!
-
Painting on transparent background multiple timesNope, still same problem. I don't see how this would work, because I think that anything you paint, it gets painted over the background and not the background itself (tried overriding OnPaintBackground, doesn't work either). It seems like it's an issue with clear-type, because I can notice red and green (or blue) outline around the drawn shapes getting thicker - same outline as if you'd take a screenshot and zoomed-in or use the magnifier tool on a clear-type text.
-
Painting on transparent background multiple timesDoesn't work, same issue. Image (the drawings) get thicker on each painting event. So destroying and creating panels is only option that I know of that works.
-
Painting on transparent background multiple timesThe problem is that I have the panel inside a custom-made ScrollableControl. The program needs to draw some "drawing" on it as many times as user wants, each time a different drawing. As I've said the issue is only with transparent background and it seems it's a common problem. If you're just painting strings, then you can fix it by writing:
e.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
But this makes the text look "ugly" and I also need to draw shapes. I fixed it for now by removing the panel from the scrollable-control, creating a new panel and adding it back to the control...
this.someControl.SuspendLayout();
this.someControl.Controls.Remove(this.someControl.aPanel);
this.someControl.aPanel = new Panel();
this.someControl.aPanel.BackColor = Color.Transparent;
this.someControl.aPanel.Paint += new //...
//...
this.someControl.Controls.Add(this.someControl.aPanel);
this.someControl.ResumeLayout();Of course I had to make the panel public.
-
Painting on transparent background multiple timesI have a panel with transparent background, that I want to paint on multiple times. It paints alright the first time, but each time after that the drawing gets thicker. This problem is only with transparent backgrounds, drawing anything on it multiple times will make a drawing thicker on each painting event. Any ideas how to overcome this problem?
modified on Sunday, September 12, 2010 8:10 AM
-
Multi-threading and function recursion with a form [modified]Thanks, I think I understand ThreadPool a bit better now, but I still have some questions: -Should I worry about the limit of 25 threads or will ThreadPool remove finished ones when the program queues 26th+ thread? -Is there any safe way to abort/stop a thread from ThreadPool, such as with a flag within the function, so that it gets aborted at the right time? I have 3 different functions to work on a separate thread, so I basically just need 3 different threads (not counting the STAThread and BeginInvoke threads). The functions can be launched any number of times though (but only one instance at the time), so the finished WorkItems should be removed if there's no way of reusing them. Thanks in advance!
modified on Friday, September 10, 2010 4:59 AM
-
Multi-threading and function recursion with a form [modified]I'm using my own thread now, because I've read that ThreadPool should be only used for short operations. I replaced the waiting flag with ThreadState, so I managed to eliminate _waiting. I set the thread's IsBackground property to true, so that it gets aborted on exit. But I want to abort the thread early myself in certain situations and I've read that using Abort() method isn't a wise thing to do. The only other way that I can think of is to create a flag, which is checked after each function call. If true, the function will return. The function gets 52 calls deep at most, usually around 10 calls deep. However, I don't know if this will really "destroy the thread", or will the thread just be stopped. Will creating a new ThreadingWrappper object (to the same variable) destroy the thread? Thanks in advance!
-
Multi-threading and function recursion with a form [modified]Thanks, that's great. Heading to MSDN now to get some understanding about ThreadPool.QueueUserWorkItem and WaitCallBack... Thanks again!
-
Multi-threading and function recursion with a form [modified]Thanks! Surprisingly (since I didn't really add much), the code below works alright. However, I had to set the BackgroundWorker to sleep, otherwise the recursive function "skips" if user clicks the button multiple times really fast. Anyway to fix this? Also, am I doing this whole thing the right way?
void ButtonClick(object sender, EventArgs e)
{
if (running)
{
trigger.Set();
trigger.WaitOne();
label.Text = data.ToString();
}
else
{
running = true;
worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(Work);
worker.RunWorkerAsync();
trigger.WaitOne();
label.Text = data.ToString();
}
}void Work(object sender, DoWorkEventArgs w)
{
recursive(0);
}void recursive(int num)
{
if (num % 4 == 2)
{
data = num;
trigger.Set();
trigger.WaitOne();
Thread.Sleep(1);
}
recursive(num + 1);
}Thanks again for the help!
-
Multi-threading and function recursion with a form [modified]Thanks for the reply. BackgroundWorker class seems better for my situation, but I still don't really know what I'm doing. Here is what I tried as a test, but it gives me synchronization error.
public partial class Window : Form
{
bool running = false;
BackgroundWorker worker;
int num = 0;
public Window()
{
InitializeComponent();
this.button.Click += new EventHandler(ButtonClick);
}void ButtonClick(object sender, EventArgs e) { if (running) { // synchronization error here, I think it's // because there's no thread to pulse Monitor.Pulse(this); } else { running = true; worker = new BackgroundWorker(); worker.DoWork += new DoWorkEventHandler(Work); // Work never executes w or w/o this: worker.RunWorkerAsync(); } } void Work(object sender, DoWorkEventArgs w) { ++num; label.Text = num.ToString(); Monitor.Wait(this); Work(null, null); }
}
Also, the function Work should have additional parameters, but this is not possible, because DoWork event requires only object and DoWorkEventArgs and nothing more. Would calling another function from function Work (and adding Wait statement to that function) work properly? Thanks in advance!
-
Multi-threading and function recursion with a form [modified]I haven't done multi-threading before, so I need a bit of help with this. I have a form with a button. When user clicks on the button for the first time, a recursive function is called. When a certain condition in the function is true, I want the function to wait where it's at for the next button click. An example:
void ButtonClick(object sender, EventArgs e)
{
if (running)
{
//Monitor.Pulse(this) - notify the function to continue
}
else functionCall(0);
}void functionCall(int num)
{
if (num % 2 == 0)
{
displaySomething();
//Monitor.Wait(???) - wait for a button click
}
functionCall(num + 1);
}How would I do this? If I understand correctly, I have to create a class for the thread that's going to run the recursive function. The second thread should wait for the main thread (Monitor.Wait(MainThread???)) to give a pulse, but how would I define the main thread?
modified on Monday, September 6, 2010 2:37 PM