|
Hi,
I have asked this question about a day ago and I was given a very good answer about some concepts I was not aware of-- Region.Translate, and Matrix.Transform. So I've been
experimenting with them and I'm able to now draw Rects and Translate and Rotate them
but I still haven't solved what I ultimately want to do...
/////////////////////
PointF pt_1 = new PointF(0,0)
PointF pt_1 = new PointF(100,100)
public void DrawLine(Graphics g)
{
SolidBrush brush = new SolidBrush(Color.SteelBlue);
Pen pen = new Pen(brush, 10);
g.DrawLine(pen, pt_1.X, pt_1.Y, pt_2.X, pt_2.Y);
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
DrawLine(e.Graphics);
}
////////////////////////////////////////////
How do I change to my own coordinate system and have it permanently stay that way?
That is, I want (0,0) to always be the center of the Form, no matter what event fires.
What I have (not the test code above) is a program that can draw vectors on an XY axis.
I can do it-- only because I've hard-coded the coordinates for the Graph Origin, which
besides being a lousy way to do things, also prevents me from any more progress....
Any (further) help would be greatly appreciated.. thanks
|
|
|
|
|
Since reading your post two days ago, I've tried implementing this in as many ways as I could think. Unfortunately, I just can't get it to stick. I think that you will have to translate the coordinates for every message/event that you receive.
Admittedly, you don't have too much work ahead of you. For messages/events that require painting, you only need to do the Graphics.TranslateTransform( Width / 2, Height / 2 ) call. For messages/events that have client coordinates associated with them, you'll need to subtract Width / 2 from the x and Height / 2 from the y . Finally, with messages/events that have screen coordintates, you need to call PointToClient(Point) and then subtract like the last call.
I would write three static methods in a helper class with signatures like:
Point CenteredPointFromClient( Point point, Form form );
int CenteredPointFromScreen( Point point, Form form );
void CenteredGraphics( Graphics g, Form form );
I wish a better solution existed. I don't think that it does because it would mess up the way that the .NET runtime draws child controls. Sorry.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
plz email me jema_r84@yahoo.com
im try to study it now..huhuhu
|
|
|
|
|
Have you thought about buying a book or searching the internet for tutorials.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
|
|
|
|
|
Please see below on what I am trying to do...
Want to get the property value little differently...
Thanks in advance,
Shrini
<br />
class myItem<br />
{<br />
public myItem(){}<br />
public myItem(int EntryID)<br />
{<br />
_EntryID = EntryID;<br />
}<br />
int _EntryID;<br />
public int EntryID<br />
{<br />
get { return _EntryID; }<br />
set { _EntryID = value; }<br />
}<br />
}<br />
}<br />
class myItemList<br />
{<br />
public List<myItem> GetItems()<br />
{<br />
List<myItem> itemCollection = new List<myItem>();<br />
for(int i = 0; i < 5, i++<br />
{<br />
item.Add(i);<br />
}<br />
return itemCollection<br />
}<br />
}<br />
class myClass<br />
{<br />
public void ABCD()<br />
{<br />
myItemList myItems = new myItemList();<br />
List<myItem> Items = myItems.GetItems()<br />
<br />
<br />
<bold>WHAT I WANT TO DO IS HERE...</bold><br />
<br />
I know I can access the Items property like this...<br />
<br />
Items[0].EntryID<br />
<br />
But I want to be able to pass in the name 'EntryID' Dynamically...<br />
<br />
string fld = "EntryID"<br />
<br />
Items[0][fld]<br />
<br />
Is this possible?<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
|
|
|
|
|
Yes, either by using reflection (a bit messy IMO), or implementing an index property in the myItem class:
int this[string key] {
get {
switch(key) {
case "EntryId": return this._EntryID;
default: throw new ArgumentException("No property with the name '" + key + "'.", "key");
}
}
}
---
b { font-weight: normal; }
|
|
|
|
|
Took me little bit of thinking... Ofcourse it is System.Reflection...
What I am doing is some what similar to DTS where you match field names from one database to another for transfering data...
Here I have to match Property names to fields and these names are coming from outside...
<br />
Type type = myItems[0].GetType();<br />
PropertyInfo info = type.GetProperty(PROPERTYNAME);<br />
System.Windows.Forms.MessageBox.Show(info.GetValue(myItems[i], null).ToString());<br />
|
|
|
|
|
Hello everyone!
Iam coding a little tool in C# which could be used as image downloader from websites.
Via httpget I retrieve the pagecontent of the entire website and put all that into a textbox objekt (like a console)
now I want to extract any "http:\\xxxxxxxxxxxxxxxxx.jpg" links and put them into a new string. But I have no idea.
can you help me?
|
|
|
|
|
regular expressions perhaps? you can do pattern matching to get the urls and such. im sure that there is a class out there that will download the actual source of a given webpage, you can then parse that source string to retrieve the href to jpg files. keep in mind that a lot of people are ussing CSS and there might not be any direct links in the source document, you might have to go to the CSS files to find jpg urls...hope thats what you were looking for.
|
|
|
|
|
Yes thats true.
but css is not the problem. the problem is javascript. to download images in javascript links i have to find out the name of the image file (eg: xxxxx.jpg) and then i have to build up a new string containing filename and url.
steps
-----
1. find out jpg filenames
2. build a new string containing filenames and url
3. filter big images (to avoid thumb downloading)
4. perhaps modify filenames (eg: xxxxxxx_thumb.jpg ----> xxxxxx.jpg)
5. download stuff
|
|
|
|
|
ger_creal wrote: I want to extract any "http:\\xxxxxxxxxxxxxxxxx.jpg" links and put them into a new string
Stay tuned for an article (that I'll be uploading very shortly) that will let you do this with ease!
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
|
I am working on my final year project of BS ( computer science) of University of karachi. My project is to deliver application's access rights to any users in the domain dynamically. I know this could be happen by accessing Group policy of any Organizational unit in which that user belong.
but the problem is that , i was unable to access group policy / software restriction policy in C# or any other .net language.
I am accessing active directory in c# using System.DirectoryService namespace. but this could not contain any support of accessing group policy. Pleas help me, my project deadline date is very near.
-- modified at 7:22 Sunday 1st January, 2006
|
|
|
|
|
Hello there!
I want to know is there any possible method to be notified when the computer (which is a member in a LAN) is disconnected?
The program is running on the computer, and I want to be notified when the computer is disconnected and connected.
Thanks
|
|
|
|
|
Hi,
On my C# winforms project I have received some fairly large rounded buttons from the graphics department. Since they are large I cannot cheat and take their rectangular outline as "hotspot" area for mouse enter/leave (to change cursor to hand, and back) and click.
So with other words the code Rectangle.IntersectsWith(Control.MousePosition) doesn't do it for me. I need some code that is Circle.IntersectsWith(Control.MousePosition) .
Did anybody encounter this problem, and has a simple solution for it? Or can give me tips how to handle this problem?
Tnx.
|
|
|
|
|
|
Tnx, I created a GraphicsPath, added an ellipse. From that I created a new Region, and on mouseover I check if the mouseposition is Visible (Region.IsVisible)
|
|
|
|
|
If its a real circle than Pythagoras could help:
public bool IsWithin(Button button, int x, int y) {
int halfButtonSize = button.Width / 2;
int distFromCenterX = x - halfButtonSize;
int distFromCenterY = y - halfButtonSize;
int distFromCenterTotal = Math.Sqrt(distFromCenterX * distFromCenterX
+ distFromCenterY * distFromCenterY);
if (distFromCenterTotal <= halfButtonSize)
OnButtonClick(EventArgs.Empty);
}
|
|
|
|
|
Hi everybody
i work on a project that need notifyicon . i create a form and put a notify control on it every thing was ok since i notice that i can not hide form from user . i don't need form att all so i want to hide it . i test visible , minimize and showintaskbar property of form but at last i noticed that form apeare in switch menu (Alt + Tab ) .
can i hide form or can i use notify without a form ?
please help me
thanks
Regards Amir Jalaly
|
|
|
|
|
Override the OnLoad event of the form. You can change the Opacity of the form to 0 to hide it, or change its Visible property to false. You can also change the forms ShowInTaskbar property to false.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for your help but i do these form is hided but in alt+tab ( mean switch between forms ) icon of form is apeared
have more suggestion?
Regards Amir Jalaly
|
|
|
|
|
This[^] article on MSDN ought to do the trick.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Tanks
i do all that you say and my problem is solved
but i think that that article is about vb 6 . have any about .net ?
Regards Amir Jalaly
|
|
|
|
|
Yeah, the code is written in VB6, but it demonstrates the technique and is easily converted to VB.NET. All you have to do is put a little effort into it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have a project that I am working on that requires me to dynamically create the connection string to a SQL Server database. All of our SQL Servers are published within Active Directory. Within SQL Server there is a tab that allows you to add the instance of SQL to Active Directory. This can also be done for a database after SQL has been added to AD (the options tab at the bottom).
With the database and the SQL instance published in AD I should be able to query AD to find the location of the database, i.e., What server is database X on?, I have looked through System.DirectoryServices and have not been able to find how to do this. Your help is greatly appreciated.
MAGrimsley
|
|
|
|