|
I am using an Image Control that i found here:
http://www.codeproject.com/KB/vb/PanZoomExample.aspx
It is really good and very useful. I am building a map based system and need to retrieve the mouse coordinates on the map. The 'onclick', 'onmousedown','onemouseup' etc events are not working on this 'imagecontrol'. It doesnt trigger when i click anywhere on the map except for the border near the scrollbar. I tried with the normal picturebox control and it worked perfectly. But I obviously need to use this control because of the great features.
What should I do? why doesnt the event trigger on the image. I tried what someone (splater) had suggested on the messageboard of that page but to be honest i couldnt exactly understand what he meant........ mebbe coz im using VC# and some stuff might be diff from VB. I didnt understand what the drawingboard etc was.....I even tried getting the email id of the creator of that control but wasnt able to find it anywhere.
his is what i have been doing....... but it seems the events themselves are not firing..... nd i have no clue why
//imagecontrol name: img_Map
//clickPos is a global variable
<br />
private void img_Map_MouseDown(object sender, MouseEventArgs e)<br />
{<br />
clickPos.X = e.X;<br />
clickPos.Y = e.Y;<br />
MessageBox.Show("Down");
}<br />
<br />
private void img_Map_MouseUp(object sender, MouseEventArgs e)<br />
{<br />
MessageBox.Show("Up1");
if ((e.X == clickPos.X) && (e.Y == clickPos.Y))<br />
{<br />
MessageBox.Show("Up2");<br />
}<br />
}
I am doing this as the control also has panning feature when we click the mouse and move it. So i want it to give the coordinates only when the mousedown and mouseup occur at the same position (else it is panning).
But BOTH these events do not fire when i click on the image in the control. but it does work when i click on the border near the scrollbars.
I might be asking for a little too much, but if anyone could download that control and check it out, it would really be a huge favor.
http://www.codeproject.com/KB/vb/PanZoomExample.aspx
I am pretty much a newbie to C# and hence REALLY need HELP! Thanks to all those helping in advance.
|
|
|
|
|
123shailesh wrote: I am pretty much a newbie to C#
Which makes it ridiculous for you to be building a 'map based system' in C#. Someone is paying you to learn C# on the job ?
I answered this yesterday, but it looks like you're trying to take my advice ( well, it was the advice of someone who used the control before ). Assuming what they said had worked for them, I have to assume you're not hooking the events up ( in VB, they can be hooked up inline, in C# you need to do it in the designer, or in the constructor or load event ), or you're hooking them up to the wrong thing.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi all,
How to create ascii fonts(.ttf) in windows.Thank You.
|
|
|
|
|
|
Hi there,
I'm looking for some advise for a generic data fetch pattern for IDataReader I'm working on, as follow:
using(GenericDataReader reader = new GenericDataReader(cm.ExecuteReader()))
{
while (reader.Read())
{
orders.Add(reader.Get<Order>());
}
}
public class GenericDataReader : IDataReader
{
public T Get<T>(string name)
{
int i = _dataReader.GetOrdinal(name);
if (_dataReader.IsDBNull(i))
return default(T);
else
return (T)_dataReader.GetValue(i);
}
public T Get<T>() where T : ILoadable, new()
{
T entity = new T();
entity.Load(this, false);
return entity;
}
}
public interface ILoadable
{
void Load(GenericDataReader reader, bool deep);
}
class Order : ILoadable
{
int id;
Customer customer;
DateTime orderDate;
DateTime requiredDate;
DateTime? shippedDate;
List<OrderDetail> orderDetails;
public Order(){ }
public Order(GenericDataReader reader)
{
Load(reader, true);
}
#region ILoadable Members
public void Load(GenericDataReader reader, bool deep)
{
id = reader.Get<int>("OrderID");
customer = reader.Get<Customer>();
orderDate = reader.Get<DateTime>("OrderDate");
requiredDate = reader.Get<DateTime>("OrderRequiredDate");
shippedDate = reader.Get<DateTime?>("OrderShippedDate");
if (deep && reader.NextResult())
{
orderDetails = new List<OrderDetail>();
while (reader.Read())
{
orderDetails.Add(reader.Get<OrderDetail>());
}
}
}
#endregion
}
What do you think? Are there any major drawback with this model I'm missing? Are there any more clever way to do that?
I really appreciate your time reading this. As long we come to a conclusion I'll write an article for CP with that we learned about it.
TIA,
Rubens
EDIT: Added formatting
modified on Thursday, March 20, 2008 6:44 AM
|
|
|
|
|
Hi,
can you please edit your post and place code in <pre> and <code> like this?:
<pre><code>your code</code></pre>
that would really help me to at least read your code. Thank you.
|
|
|
|
|
Sorry Michal, here you go.
ty
|
|
|
|
|
I would consider two things.
First would be performance of return (T)_dataReader.GetValue(i); , I don't know exactly how GetValue works internally but I think that it is a bit slower than type specific method like GetInt32 becase there is more type conversion stuff. Plus by using type specific Get method you would save one of your type conversion return (T)_dataReader.GetValue(i) . Disadvantage is that you would have to use IF statement to determine which specific Get method to call.
Second thought is that I'm not sure if it is a best practice to have GenericDataReader to create businness objects. In my opinion objects like data readers should just get you a data and that is it. They should not be creating any business objects. Also I think that Business object should not work directly with data reader. It has lot of other work to do anyway. So I would suggest to create some BusinessDataObject that would take care of getting data from database, using GenericDataReader. And then any business object would just use relevant BusinessDataObject to load data.
|
|
|
|
|
Looking at System.Data.OleDb implementation through Reflector, GetInt32 and GetValue returns values based on column types, so I think both have similar performance. And, if I had to code an IF inside that generic method, I prefer to stick with current ADO.NET implementation
About your second thought, I share your feelings. My main point is to define a simple pattern for data fetch, probably in a structure like Entity (get/set/read) >> Data (DAL/.executeXXX) >> Business (work with loaded data) >> and so on.
Thank you for your comments, I really appreciate them.
Rubens
|
|
|
|
|
regarding GetValue you may check this link[^]
RubensFarias wrote: Thank you for your comments, I really appreciate them.
You are welcome. Those are just my thoughts, that may be wrong. And practical solution is often far far away from ideal design. Important thing is to get things done.
I wish you luck with your project.
|
|
|
|
|
Hello.
Please help me find out if its normal behavior of Socket class.
issue#1
- After connecting, first call to Socket.Send always returns immediately.
I know that Send puts data in buffer first, but not megabytes, right ?
Code:
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<br />
<br />
s.Connect("61.213.43.1", 30);<br />
<br />
int bytesSent = s.Send(bData, bData.Length, SocketFlags.None); <br />
<br />
s.Shutdown(SocketShutdown.Both);<br />
s.Close();
This code executes immediately. Including Shutdown & Close. This leads to issue #2:
- Socket.Close never blocks (even if MSDN says is should)
Code same as above but:
s.Close(9999);
or
s.LingerState = new LingerOption(true, 9999);<br />
s.Close(9999);
Please confirm such behavior, or suggest what might be wrong and how it works for you. Its very important to me, thank you in advance.
|
|
|
|
|
Can you check the following:
1. Do you have a firewall enabled...maybe blocking port 30 on the client or on the server side.
2. Check the return of the Connect() function.
3. Is the client on the same machine as the server?....that will definitely make the sending of data seemless! (you said that bytesSent = bData.Length...therefore the data is being sent somehow...)
Well a good thing to do (if you have the server code) is to display the received data to make sure if the data is being received.
____________________________________________________
Come Mutley, we have a race to win...!
|
|
|
|
|
Hello XeoN-Kc, thanks for reply.
However my problem is not about receiving sent data. And the server application even configured to not receive anything. (on purpose, and its Receive buffer set to 0 ).
The point is that independently from how server is functioning, after successful Connect, client's first Socket.Send can "send" data array of any size and return immediately.
And second problem is that Socket.Close(n), never waits n seconds, even if there is a lot of data still to be send.
|
|
|
|
|
I discovered an interesting occurance today.
The below code creates a compile time error as expected...
<br />
int i = 5;<br />
<br />
label1.Text = i;<br />
But this code works fine...
<br />
int i = 5;<br />
<br />
label1.Text = "Test " + i;<br />
I had a look on Lutz Roeder's Reflector but couldn't find an obvious reason why this works.
Could someone enlighten me?
Mark.
|
|
|
|
|
I'm pretty sure the + operator is overloaded in the System.String class to convert your int value to a string, then concatenate the 2 together.
|
|
|
|
|
Hi,
in string + something if something is not a string, the compiler will
replace it by something.ToString() automatically.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hi MarkBrock
Anything appended to a string is understood as string only by the compiler.
--Here 2 See Sharp--
I have not failed. I've just found 10,000 ways that won't work.
|
|
|
|
|
Interesting... I had initially thought it may have been something a little more synister deep under the covers of C#.
It's interesting that the C# developers decided to add functionality for converting non-string types if they are appended, but not for non-string types on their own.
Thanks for clearing that up guys.
Mark.
|
|
|
|
|
Hi I’m developing an internet ASP.NET application, which needs to interact with Microsoft Certification Authority Server, the
client (browser) will request a certificate to sign a file (word, pdf) later.
I'm really disoriented. Must I use CAPICOM? Signing in the server, and sending the certificate through an SSL connection? Is
there any class in the .Net Framework to interact with Certification Authority Service without CAPICOM or an external Api?
Where can i get a code example?
Regards
Sergio
|
|
|
|
|
Don't cross post. Read the forum rules.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I've been using a COM component for audio recording/editing in my forms application. Now since it does not work on Vista I must find a replacement.
Can anyone here hint me of a component, COM or pure managed code that fulfils the following needs:
* Recording direct to disc to wav-files
* Converting to/from Wav and OGG
* Audio editor for editing the sound file
* Plying sound in OGG and Wav files.
The component I’ve been using is from NCTsoft (www.nctsoft.com - > the link almost dead )
Thankful for any hints
/S
|
|
|
|
|
i need help with a quick program i am making, how would i exit a block of code in an if statement for example
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
code to be run here<br />
if (x ==5)<br />
{<br />
run more code<br />
exit this block<br />
}<br />
more code here<br />
}<br />
this is hard to explain but there is no other way i can think of doing this i know in visual basic there was something called exit sub (or something similiar been a while) that would leave it
thanks in advance
|
|
|
|
|
xxmikexx wrote: this is hard to explain but there is no other way i can think of doing this i know in visual basic there was something
look at the C# language documentation for break and return however I strongly suggest you get a beginners book on C# or stick to Visual Basically Garbage.
led mike
|
|
|
|
|
ok thanks alot it is just for the class i am in currently we have to learn a language of our choice i just needed this bit for the chapter i was working on
|
|
|
|
|
I shake my head in dismay and sadness, then realize that at least some of us will have job security for a long time to come from the sounds of it.
only two letters away from being an asset
|
|
|
|