|
Hi,
I want to write this project:
while load the form,the program(in Runtime),draws a Map on form,for exmple:Map of Asia,itself.
The program ask from the user about countries,for example,
Find Russia on the Map!
& the user must click on the map,on Russia.
I don't know where must I start,what algoritm do I use from this program?what namespace?or classes or Methodes?
Please,Gude me!
How do I start & continu & finish this program?
Thanks very much.
|
|
|
|
|
Mahtab777 wrote: while load the form,the program(in Runtime),draws a Map on form,for exmple:Map of Asia,itself.
The computer doesn't know how to draw a map of a specific country by itself, that information is not embedded into your PC and will have to be provided by you.
You could import a picture, show it in a PictureBox , and have the user click it. You would than have to translate the location of the pixel to a known country. The easiest way to do that is by coloring different regions with different colors; once you know the pixel where the user clicked, you know what color, and hence, what region.
Bastard Programmer from Hell
|
|
|
|
|
Hi
Thanks for your guideing,
I used this way that you suggest,
but,I don't want to use this way,
I want that Program,itself,draws map on form,& finds out that the user where clicked,
|
|
|
|
|
Them you are going to have to draw the map, and maintain a list of polygons that match the outlines of the regions. Then, when the user clicks on the map, you do a point in polygon check to see if they've clicked in the region.
|
|
|
|
|
if you want to draw it yourself, you'll need a data source that contains all the elements to draw, mostly these are area's (polygons), lines (polylines) and dots, each area or line or dot has certain charactiristics like water, road, ... if you have all that you'll also need to find a way to link all elements and to zoom in/out the map.
In short (I probably forgot to mention most of the stuff anyway) you'll need to find a provider for the geographical stuff. For a fee they'll provide you with some assemblies you can use as well as the database with all information in it (and with updates if necessary).
hope this clarifies things for you.
V.
|
|
|
|
|
Hi,
Thanks very much!
I want to use the Region class for Drawing Map on form & for Drawing countries on Map,
"Region" can helps me for this program?
Are there another ways for this program?
Are there a classes or components for creating & Drawing Map?
|
|
|
|
|
Mahtab777 wrote: "Region" can helps me for this program?
It might, if you have all the borders stored as points somewhere.
Mahtab777 wrote: Are there a classes or components for creating & Drawing Map?
Not in the Framework; you'll either have to write them or look for something similar.
Bastard Programmer from Hell
|
|
|
|
|
What I meant to say is, that if you want to draw a map you probably don't have the know-how (nor do I for that matter) to do it yourself within a reasonable amount of time. Normally such a task takes a lot of design and many resources to do it. If you need a map quickly you probably need a third party component (google maps perhaps?) or as someone already suggested a picture.
V.
|
|
|
|
|
this is a really boring question so sorry in advance...
i am writing a pdf viewer (don't ask why or i'll have to kill you) and have most of the code working BUT the scrollbars are driving me slightly nutz
i have the picturebox control set to autosize inside of a panel set to autoscroll
when i set the (generated) image into the picturebox i get a vscrollbar (as expected) and no hscrollbar (again as expected because i resize the form client area to fit the width of the page i'm displaying)
when i shrink the window (with the mouse) i would have expected the hscrollbar to show up but no .. it doesn't
i do catch the form resize event and if the the client area is wider than the page being displayed i change the picturebox size mode to centered so it looks nice
otherwise i have tried all the 217 posts i have read on the net and they all say the same thing and they all don't work for me here
any help greatly appreciated
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
How about dropping your PictureBox (full size) in a Panel , and let the panel worry about scrolling?
Bastard Programmer from Hell
|
|
|
|
|
ummmmm that's what i am doing no?
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
With the picturebox as large as the picture is, so it can scroll inside it's container?
The code below worked for me; is your picturebox by any chance smaller than it's container?
public partial class Form1 : Form
{
Panel somePanel;
PictureBox somePictureBox;
public Form1()
{
InitializeComponent();
this.somePanel = new Panel()
{
Dock = DockStyle.Fill,
AutoScroll = true,
};
this.somePictureBox = new PictureBox()
{
Size = Screen.PrimaryScreen.WorkingArea.Size,
BackColor = Color.Blue
};
this.somePanel.Controls.Add(somePictureBox);
this.Controls.Add(this.somePanel);
}
}
Bastard Programmer from Hell
|
|
|
|
|
eddy thnx for the reply again
i see that you are making your picturebox a fixed size yes?
mine has to change as they zoom in and out of the "image" as well as scroll
i have it kind of working (god only know how) but i know the code is horrendous as it has a bunch of "magic fudge factors" in it as i am not familiar enough with .NET / C# and graphics etc
i think i am not getting the actual screen dpi for the bitmap dpi, as that means i need to do some rather opaque calcs on the scaling factor for the pdf renderer and and and... *sigh*
i think if i had a fixed size picturebox the code would work properly as that is a "trivial" case yes?
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
l a u r e n wrote: i see that you are making your picturebox a fixed size yes?
Yup
l a u r e n wrote: i think if i had a fixed size picturebox the code would work properly as that is a "trivial" case yes?
It should be. You could try putting the PictureBox in a fixed-size container, and have that in a scrollable Panel again.
l a u r e n wrote: i have it kind of working
In a typical Dilbert-comic that gets translated to "it's ready to ship"!
Bastard Programmer from Hell
|
|
|
|
|
hehe yah no... not in my world
right now it is working but i *know* parts of it are not written properly so i have to figure those bits out and make them right
i have a proof of concept that is *good enough* to show the general approach and UI work but that sure as hell isn't a "product"
last 10% of the code == 90% of the time
*sigh*
anyways i will be asking embarrassingly dumb questions in the next few days i'm sure but that's what 9yrs of web dev does for a programmer
"mostly watching the human race is like watching dogs watch tv ... they see the pictures move but the meaning escapes them"
|
|
|
|
|
l a u r e n wrote: last 10% of the code == 90% of the time
Yup, last few percentages may take a bit long.
l a u r e n wrote: anyways i will be asking embarrassingly dumb questions in the next few days
There's no such thing as a dumb question, only posts without PRE tags.
..and some without a question at all, or with advertising.
Bastard Programmer from Hell
|
|
|
|
|
hello,
i have two tables containing a picture gallery
1. Album (parent) 2. Photo (child)
i want to show 'photo table' into gridview using a binding source. but 'photo table' show last column (which is the foreign key) as an object of 'Album table'. it is one of the property of LINQ. but how can i show only a single value (i.e: album name) from parent table (Album) into child table's gridview (Photo).
my current code is
private void Gallery_Load(object sender, EventArgs e)
{
TestAppDBDataContext db = new TestAppDBDataContext(AppConn.AppConnection);
photogalleryBindingSource.DataSource = db.photogalleries;
}
kindly help me!!
Regards,
Raza us Samad
|
|
|
|
|
Hi experts,
in my application there are two controls DragSource and DragDestination. User can drag objects from DragSource and drop them onto DragDestination.
Now I would like to have some kind of no-drop-zone from DragDestination's border 20 pixels to the inside. Like a frame but within the control, not around it.
DragEnter should fire when the mouse pointer reaches the inner, drag-allowed area.
How can I set the drag area differing from the overall control area?
Ciao,
luker
|
|
|
|
|
There is no property or function to set the area for a drag and drop operation inside a control.
If you want the DragEnter event raised only within certain borders, you'll have to get creative with control layouts and surround the control that is accepting the drag and drop with other controls, like Panels, that are painted the same color as your target drop control to creat the border.
Another option is to allow the DragEnter, DragHover, DragDrop and DragLeave events to fire as normal and just check the coordinates of the mouse inside your event handler to determine if anything should be done.
|
|
|
|
|
Hi,
Handle the DragOver event on the target and set the DragEventArgs.Effect value. The DragDrop event is suppressed when DragEventArgs.Effect is set to None.
private void panel2_DragOver(object sender, DragEventArgs e) {
Rectangle subRect = Rectangle.Inflate(panel2.ClientRectangle, -20, -20);
Point p = panel2.PointToClient(new Point(e.X, e.Y));
Boolean withinSubRect = subRect.Contains(p);
if (withinSubRect) {
e.Effect = DragDropEffects.All;
} else {
e.Effect = DragDropEffects.None;
}
}
Alan.
|
|
|
|
|
Hi,
For the below xml, I would like to get the parent and level of the entity node. For example, for the Business entity, token value should be BUSINESS; desc value should be Business News; parent should be PROD; level should be 1. From the below code, I'm getting token and desc values. Kindly guide me to get parent and level values. Thanks in advance.
foreach (XPathNavigator book in topicsXml.CreateNavigator().Select("//Entity"))
{
string token = book.SelectSingleNode("Token").Value;
string desc = book.SelectSingleNode("Description").Value;
string parent = ?
string level = ?
}
<CodeList>
<Entity>
<Token>PROD</Token>
<Description>prod</Description>---->level 0
<Entity>
<Token>BUSINESS</Token>
<Description>Business News</Description>---->level 1
<Entity>
<Token>COS</Token>
<Description>Company News</Description>---->level 2
<Entity>
<Token>ANA</Token>
<Description>Analyst Ratings</Description>---->level 3
<Entity>
<Token>ANAMOVES</Token>
<Description>Analyst Ratings, Estimates and Target Price Changes</Description>---->level 4
<Entity>
<Token>ANACHANGE</Token>
<Description>Analyst Rating Changes</Description>---->level 5
<Entity>
<Token>ANACUT</Token>
<Description>Analyst Downgrades</Description>---->level 6
<Entity>
<Token>ANACUTEVT</Token>
<Description>Analyst Ratings Cut Events, Announcements</Description>---->level 7
</Entity>
</Entity>
</Entity>
</Entity>
<Entity>
<Token>IP</Token>
<Description>Intellectual Property</Description>---->level 4
<Entity>
<Token>COPYRIGHT</Token>
<Description>Copyrights</Description>---->level 5
</Entity>
</Entity>
</Entity>
</Entity>
<Entity>
<Token>DRGPATENT</Token>
<Description>Drug Patents</Description>---->level 2
</Entity>
</Entity>
</Entity>
|
|
|
|
|
For the parent node, you can use .. to navigate upward the xml tree (like as it where a directory).
Using your Example, string parent = book.SelectSingleNode("../Token").Value; will get you the parent token of the current entity.
For the depth, you could try to count the number of entity parent nodes, like this:
string level = book.SelectSingleNode("count(ancestor::Entity)").Value;
I don't know if that will give you a 0-based or a 1-based value, you will have to do some tests.
|
|
|
|
|
string parent = book.SelectSingleNode("../Token").Value;
This returns the inner data of xml
value of parent: "PRODprodBUSINESSBusiness NewsCOSCompany NewsANAAnalyst RatingsANAMOVESAnalyst Ratings, Estimates and Target Price ChangesANACHANGEAnalyst Rating ChangesANACUTAnalyst DowngradesANACUTEVTAnalyst Ratings Cut Events, AnnouncementsIPIntellectual PropertyCOPYRIGHTCopyrightsDRGPATENTDrug Patents"
string level = book.SelectSingleNode("count(ancestor::Entity)").Value;
This line thrown exception, "Expression must evaluate to a node-set."
I hope I'll succeed in getting level by using ancestor, by giving correct syntax.
Please let me know how to get the parent value. Thank you
|
|
|
|
|
For the parent, it seems you are selecting a not-leaf node (I'd say an 'Entity' node), so, using value, you are getting the full content of that node, all descendants included.
If you want a string value, you must select a Token or a Description.
For the level, I forgot you can't use scalar function in XPath when selecting nodes. You can simply use Select and then Count the result: int level = book.Select("ancestor::Entity").Count;
|
|
|
|
|
Thank you, Mirko. Its working..
|
|
|
|