|
Hi...
I am doing an ad blocker in c#. The blocker will remove ads by stripping HTML tags that matches one or more keywords.
Example: these tags will (have to) be stripped...
<a href="http://myserver.com/mydir/ads/page.htm">Test link 1</a> ... [matches keyword '/ads']
<a href="http://myserver.com/mydir/page.htm"><img width=10 height=10 scr=adserve.myserver2.com/sponsor.gif> ... [matches 'adserve']
I am having problem coming up with regular expression pattern to give me the full matching tag, that is, like
<a href="http://myserver.com/mydir/ads/page.htm">Test link 1</a>
....when i am scanning for keyword '/ads'..
of coz the scanning is a loop, and the keyword is stored in a variable .. e.g. strKey.
the pattern : @"<a\s.*\shref=\S*", strKey, @"\S*(>|\s)"
doesnt work as it would return anything between the first "<a" (no qoutes) and the last space.
the pattern: @"href=\S*", strKey, @"\S*(>|\s)"
does not give the result i wanted.
I have tried to refer to MSDN, but things seem complex and beyond my understanding capability. I really hope someone
can help me to come up with the right regex pattern.
the tags i will (have to) examine include ... IMG SRC, A HREF, IFRAME SRC
thanks
|
|
|
|
|
|
Thanks for the reply, but I am still unclear on how to modify my pattern ...
can u please post the full pattern here?
thanks.
|
|
|
|
|
i mean, can u be more specific? exactly where to add? for which pattern?
my program has to cater to tags like these:
<a href="http://myserver.com/ads/page.htm" >test</a> [note the space]
<a href="http://myserver.com/ads/page.htm" id="1">test2</a>
<a href="http://myserver.com/ads/page.htm"><img width=20 height=20 src=sponsor.gif></a>
<img width=20 height=20 src='sponsor.gif'>
i wanna extract the full tag that matches the keywords, yet accomodate for the loose nature of html.
please advise. i have no experience using regex, and all references i have doesnt seem helpful. msdn library is confusing me...
|
|
|
|
|
Okay, I have a list box that has image file names i want to display the images in another form to allow the user to preview the image before i select it.......could anybody help me!!!
Thanks Alot!!!
Da Intern
|
|
|
|
|
This is what I've done for sending data from one form to another. It's along the lines for what you're looking for.
(1). Declare a public object of your child form in your parent form ex:
public FormNumber2 Form2 = new FormNumber2();
(2). Make sure your listbox (m_ListBox) is declared public on the child form so you can set/get it's data from the parent form.
(3). Declare a string at the top of your child form:
public string m_sFileRemoved;
(4). This code needs to be in your child form.
if( m_ListBox.SelectedItems.Count > 0 )
{
string sSelectedItem = m_ListBox.SelectedItem.ToString();
m_sFileRemoved = sSelectedItem ;
m_ListBox.Items.Remove( sSelectedItem );
}
(5). Put this code in your parent form where you want to get and show the selected file from the listbox.
// read 5a below.
Form2.ShowDialog();
string sFileToBeRemoved = Form2.m_sFileRemoved;
this.Focus();
(5a). This will help you add data to the listbox before you show it (since you declared the control public) from the parent form.
this.Form2.m_ListBox.Items.Add( "File info: string" );
Hope this helps.
|
|
|
|
|
okay im lost..............okay i have 8 images that i want to display in another form that pops up after you select an image from a listbox on the parent form. the 8 images are selectable from the parent and i want them to be viewable in the child.
please help me out.........im kinda lost
Da Intern
|
|
|
|
|
Ok, I think this is what you're going to want to do.
On the parent form get the selected index of the listbox and pass that into the child form. On the child form take that index id and set that in the imagelist and picturebox controls to display the correct image when that form is loaded.
Parent form code:
int iLBID = listbox1.SelectedIndex;
ChildForm CForm = new ChildForm( iLBID );
CForm.ShowDialog( this );
CForm.Dispose();
this.Focus();
Child form code:
private int m_iSelID;
// Constructor code.
public ChildForm( int iLBID )
{
m_iSelID = iLBID;
pictureBox1.Image = imageList1.Images[m_iSelID];
}
** remember to add a picturebox and an imagelist control to your child form. Load up the imagelist control in design mode and then set the picturebox image index to the index selected in the parent listbox.
Hope this helps. 
|
|
|
|
|
This is whats in my parentForm:
private void tbimage_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
<br />
<br />
<br />
switch (tbimage.SelectedIndex) <br />
{<br />
case 0 :<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break;<br />
case 1 :<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break;<br />
case 2 :<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break;<br />
case 3 :<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break; <br />
case 4:<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break;<br />
case 5 :<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break;<br />
case 6 :<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break;<br />
case 7 :<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break; <br />
case 8 :<br />
myImgForm.pBox1.Image = Image.FromFile("magic5.gif");<br />
break;<br />
}
My parent Form is called FmMain
MyChild Form is called PreImg
My Picture Box is called pBox1
My Combo Box is called tbimage
My imagelist is called imagelist1
please help
just tell me when im gettin annoying
im just tryin to get through this final part
Da Intern
|
|
|
|
|
How do i use this....................okay, i have a form that has a list of file names, when those file names are selected i want a seprate form to pop-up showing each selected image. so if i selected image 1 then a form should pop-up showing image 1.
Please help
P.s. i've done alot already i think my brain is on "E", so could please help!!!
Thanks
Da Intern
|
|
|
|
|
and its member function?
|
|
|
|
|
I have several lists with different items. All of them should have copy, cut paste, delete and custom capabilities working from context menus, main menu and toolbar.
If no item of a given type is selected, the buttons and menus entries for that kind should be grey.
When selecting an item the menus and items should change accordingly.
When choosing a menu entry or toolbar button, the action should be applied to the selected item.
Basically, have the same behaviour office or developer studio have.
What is the best way of implementing such thing?
Who’s responsible to recognize the selected item? How?
How do I apply actions over the selected Item? Using events?
Does Visual Studio or .Net framework natively support a specific way of solving this?
Thanks.
|
|
|
|
|
Microsoft solves this problem by using a Command Manager class:
http://msdn.microsoft.com/library/default.asp?url=/msdnmag/issues/02/10/commandmanagement/TOC.ASP
|
|
|
|
|
I have created a diagram building application (something
like a "diet Visio" ) with an abstract Shape class every
drawing shape have to inherit.
My program has plug-in support so users can create their
own shapes (derived from my abstract Shape class). The
plug-ins are placed in a separat folder. The dll files in
this folder are dynamically loaded at startup.
Of course, I want my program to be able to save and load a
drawing. I use the BinaryFormatter and Stream classes to
serialize the drawing. This looks ok, but when I
deserialize the same file, I get an exception
(i.e) "Rectangle.dll not found" (or something like that),
because this file is a plug-in, dynamically loaded at
startup.
So (finally) my question is: What is the best way to
serialize and deserialize an object (consisting of
dynamically loaded objects) like my drawing object?
Any help and suggestion are appreciated.
Øyvind.
|
|
|
|
|
Hi,
I'm trying to get several browser panels on top of each other each with a different opacity. I was wondering if there was any way of setting the opacity for a panel, or if any one had any ideas as to how to go about achieving this effect.
thanks
dror.
|
|
|
|
|
Please take a look at this article on devhood, http://www.devhood.com/messages/message_view-2.aspx?thread_id=70534
What I want to do is essentially have a class which contains all static members of my applications settings and have it serialized out.
Something along the lines of this,
class MySettings
{
public static bool isConstant;
public static bool doReports;
}
After serialization using the XmlSerializer class, I hope to get something like this,
<?xml version="1.0"?>
<appSettings>
<add name="isConstant" value="true">
<add name="doReports" value="false">
</appSettings>
The main reason for serializing this is because the App.exe.config is read-only, so any changes to the settings don't persist. This is where the serialization comes into play. If I can get it to output into the xml file above, I'm golden.
The problem now, is getting it into the correct format. I see two problems with this.
One, the class contains all static members so when I call XmlSerializer.Serialize( <stream>, <object to serialize> ) I don't have an object to use.
Problem two, for each member variable how to output the xml <add key="isConstant" value="true" />, etc.
This is about as far as I get . . .
[XmlRoot("appSettings")]
class Settings
{
public static bool isConstant;
public static bool doReports;
}
Which as you can see, isn't far. I don't know how to have the <add> element for each member variable. It won't let me add [XmlElement("add")] before each member variable. (it complains about using the same element name) And I don't know how to get the correct attributes into the xml.
Any ideas? Or better ways of doing this?
Thanks.
|
|
|
|
|
Is there a C# equivalent of the VB.net keyword Shared ?
IE:
Public <big>Shared </big>Function DoSomething(ByVal MyValue As Integer) As String
{
'do something
}
Steve
McLenithan
Is Bert Evil? | Homer: "Hello, operator, gimme the number for 911!"
|
|
|
|
|
static
Do you not have the documentation install it is all there.
Bo Hunter
|
|
|
|
|
That's what I thought... Just wanted to be sure;) Thanks
Steve
McLenithan
Is Bert Evil? | Homer: "Hello, operator, gimme the number for 911!"
|
|
|
|
|
Hi all,
I am trying to figure out what I need to do to write an Add in for internet explorer using C#.
What interfaces do I have to implement and where is the documentation for the IE object model.
Any help will be appreciated.
Regards,
Rahul
kingtiny@cs.cmu.edu
|
|
|
|
|
I don't know anything about this topic but if you like it I know that Wrox press has about exacctly about this topic. You can check wrox.com for more information or at least get source code for somme sample.
Mazy
No sig. available now.
|
|
|
|
|
Check out this[^] article.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
|
leppie wrote:
Check out this[^] article.
That is too cool. I was interested in this a few months ago. Did not see that one sneek in, it is bookmarked now
Rocky Moore <><
|
|
|
|
|
hi guys,
I build a class using C# Library class option. How can i make this class available in a web service?
Thanks
|
|
|
|