|
Hi everybody
I'm trying to recreate the tutorial for webbrowser automation that is posted in code project using c# 2005.
this tutorial shows how to get into google, write something in the text area, and than click the search button.
I've wrote this kind of app in c# 2003 many times, but in c# 2005, it seems that I just cannot find a way to click the search button.
can anyone explain how to do that? thanks alot!
|
|
|
|
|
K here is my problem, I have been racking my brain doing other things but cannot come up qith a way to make a polygon follow a line.
For instance, If I create a line Like this
<br />
Point[] lnePoints = new Point[]{new Point(10, 10), new Point(100, 10),<br />
new Point(100, 70), new Point(300, 70)};<br />
I want to draw a line but I want to Draw a polygon around this line, kind of like a focus shape that surrounds the line, not a rect or square
I started a function to do it but it got waaay to out there and never made it right, any Suggestions.
|
|
|
|
|
|
|
For each line calculate a new line offset the desired distance outwards (I hope you know what direction outwards is, if not I guess it is possible to find out, but I can't remember how - Google it).
For each calculated line, calculate the intersection with each of the neighbouring calculated lines. These are the new points.
There is a catch though - some of the very short lines might no longer be needed. If you after the intersection calculation get a line where the direction between the points are 180 degrees offset from the original line, then throw away this calulated line. This of course means you must recalculate the intersection points of the neighbouring calculated lines as they now intersects each other instead of your line.
Sorry if it is not clear - I did my best in a short time. Oh, and I do in no way claim this algorithm is fastest or easiest way to do this, but it should work.
Alternatively (depending on your needs) you might get away with drawing the outline with a wide pen (twice as wide as you want the focus area to extend) and then filling the polygon with the same color. This will basically draw the sourounding polygon you requested, but if you can use this "drawing" for anything depends on how you use it further on.
|
|
|
|
|
You're going to need to build a path that follows the line in the manner you've described, offsetting your points by a given factor so you draw all around it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thank you for your replys, I pounded it last night and almost got it done, here is what I did in a nutshell. I made two functions, one calcs one offset from the line and one calcs the other offset of the line.
I went through each point in the point array first I check to see which Direction it has come, then I check to see which direction it will be going, then I offset the new point accordingly. Sounds easier than doing it that's for sure. Have some kinks to work out but, In a nutshell I pass each function the point array of the origional line calculating both sets of the offsets, then I combine them together in order by adding each point to another point array the first set in order, then the second set in reverse order, add then to a path object then draw.
|
|
|
|
|
Hi everyone,
I have this small project. It reads from a file and populates a DataGridView. It has been working great when there were only 100 or 200 rows, but now there are 750 and it doesn't work well at all. I'm not sure what I am doing wrong.
When you first enter the page, there is a "SYNC" button. This opens the file, reads from it and populates the datagridview. Well, you can hit SYNC as many times as you want. What I am doing is when you press that button, clear the datagridview, and then re-populate it. I have tried DataGridView1.Rows.Clear(), and I have also tried ForEach loops that run a Rows.Remove() and Rows.RemoveAt() with no luck. I have 751 rows in there, and I have a message box pop up before it begins the Rows.RemoveAt() routine, then another message box that pops up after the foreach loop. It is taking like 30 seconds (I'm on a very very fast machine) to do this, and 98% of my system resources go to it. I'm not sure if it is trying to sort, or redraw or do something each time it deletes a row out of there or what. When the Rows.RemoteAt() routine finishes it has done what needed to be done (cleared out the datagridview completely), but it just takes way too long. I'm not sure exactly what it is that I can do to speed this up?? Any help would be extremely appreciated.
|
|
|
|
|
I need to create a form to act as InputBox like in VB6.
When I write, string temp = InputBox.Show(); it displays the form where I need to insert some text and click ok so that temp variable is set to text entered in InputBoxes text field.
I want to design each of my InputBoxes from the forms I added to my Project.
How can I make this kind of form?
|
|
|
|
|
Make the form of type dialog. Then when you show the form use ShowDialog instead of Show. You can then check the DialogResult to see what action the user returned. Create the form any way you want.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Thanks, that helped a lot.
Becouse I don't want to create an instance outside the InputBox, I've created a method inside the form.
public static string InputBox()<br />
{<br />
string tmp = "-1";<br />
frmReason reason = new frmReason();<br />
reason.ShowDialog();<br />
<br />
if (reason.DialogResult == DialogResult.OK)<br />
{<br />
tmp = txtReason.Text;<br />
}<br />
<br />
return tmp;<br />
}
This way I just need to call InputBox method: MessageBox.Show(frmReason.InputBox()); and I will get a form, write any text, and after clicking on ok (or enter) MessageBox will Show that text.
Thank you Ennis, very much.
|
|
|
|
|
I'm at a position where I cannot step thru my code to see where my problem is at. So I've got message boxes everywhere catching exception. So what is the best way to debug when you can't be there. Right now I'm catching the exception showing the message, the source, and the stack trace. Which I must admit is a little confusing. Any other suggestions.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Why do you say you cannot debug through your code?
I think you could use
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message + " " + ex.StackTrace);
}
|
|
|
|
|
I'm sorry, I meant I cannot step thru my code to see where my problem is at. Reason is this is socket app that requires a secured connection and that is on a network on the east coast.....I'm in the midwest.
Currently I am do the try and catch but putting it to a message box instead of the Trace function. I'll try that and see what the results are.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
When you use Trace you can have the code running without pressing the OK of the MessageBox and writing down the message on a piece of paper, while all the messages are going to be written in the Output window, so I would say it's more convenient.
I hope it helps.
Cheers
|
|
|
|
|
It is the most arduous but it really works when it has too.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Hi. I'm very new to Visual C#. I was wondering if someone could help me print the contents of a pictureBox.
I would like to be able to print just the image and be able to control the size of the image as well as the location of the image on the page.
Please help if you can.
|
|
|
|
|
Actually there are some very helpful tutorials on how to print bitmaps in C# available by searching google.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
...
PrintDocument printDoc = new PrintDocument();
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
printDoc.Print();
...
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
PictureBox picBox = new PictureBox();
picBox.Image = Image.FromFile(@"c:\mypic.jpg");
e.Graphics.DrawImage(picBox.Image, 5, 5);
}
|
|
|
|
|
Hello. I have the following function:
<br />
public BaseClass SpawnClass( ObjectType type )<br />
{<br />
BaseClass retval = null;<br />
<br />
float X = 5;<br />
float scale = 0.3429f;<br />
<br />
switch(type)<br />
{<br />
case ObjectType.Class1:<br />
{<br />
retval = new Class1(X,scale);<br />
break;<br />
}<br />
<br />
case ObjectType.Class2:<br />
{<br />
retval = new Class2(X,scale);<br />
break;<br />
}<br />
<br />
case ObjectType.Class3:<br />
{<br />
retval = new Class3(X,scale);<br />
break;<br />
}<br />
}<br />
<br />
return retval;<br />
}<br />
I have about 11 classes but I didn't want this to get too long. This works, but it's very ugly. Is there a better way to do this? I've thought about the "Gang of Four" design patterns, but I'm not sure if they would be less ugly. I noticed the TypeConverter class, but I don't know how to use it. Any suggestions?
I love to program!
|
|
|
|
|
Assuming the constructors are identical, I'd probably do something like:
public BaseClass SpawnClass(System.Type type)
{
float X = 5;
float scale = 0.3429f;
return (BaseClass) type.InvokeMember(type.FullName, System.Reflection.BindingFlags.CreateInstance, null, null, new object[] {X, scale});
}
That should work from what I remember, but it may need some tweaks to be work correctly.
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
That function looks like it depends on System.type, however the function I have depends on a custom enumeration (ObjectType). Would this way still work? Would there be a way to create a type using a string?
I love to program!
|
|
|
|
|
allenmpcx wrote: Would there be a way to create a type using a string?
Activator.CreateInstance
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
nevermind on that. Your method worked perfect because I can call Type.GetType() and pass in a string to get the type, so thats exactly what I did. Thanks a lot.
I love to program!
|
|
|
|
|
Hey guyz! I have a question how do I change in C# a number from such B8B80C00 byte-ordering into such one: 000CB8B8
Any help would be appreciated..
Regards,
Pawel
-- modified at 14:24 Wednesday 2nd August, 2006
|
|
|
|