|
Are you asking how to determine the clicked point on an image, even if the image is larger than the area it's being displayed in and the image is scrolled to one side??
If so, you don't need the scroll offset.
Create a UserControl, put a Panel on the UserControl and set it's AutoScroll property to true. Then put another Panel inside the first one. Expose a property in the UserControl to take an Image. In the setter for the Image, set the second Panel's size to match the image size. Now, when you click on the second Panel (the one showing the image), you handle the Click property of that Panel control. You'll get the coordinates of the click, relative to the upper left corner of the image Panel.
|
|
|
|
|
Hello,
yes I am trying to get the coordinates of a clicked image - the absolute
coordinates - not those relative to the top corner of the panel, but
relative to the top corner of the image when I've scrolled way past it. I've already tried your method, which is why I want the offset.
thanks
pcjd
|
|
|
|
|
Offset relative to what?? I don't understand your explanation.
|
|
|
|
|
Hello,
I want to get the coodinate (horizontal only) of a point on the image
after I have scrolled a certain way along the X-axis of the image. So
initially, the image is displayed (perhaps showing a range of X values from 0 to 500). As I scroll along the image, using your method, the X coordinate I want would be (clicked value of X + scroll bar offset) - as the clicked value of X only gives the coordinated relative to the panel and NOT the image. As an aside, I have already done this in Delphi 6, but this is a port to C#, and it appears that I will need to use hscrollbar and get its offset from hscrollbar.Value, as it appears this cannot be obtained from the panel scrollbar.
regards
pcjd
|
|
|
|
|
You don't need the scrollbar values. I've done the very same thing wihtout them, well getting the clicked offset anyway. Since the panel is exactly the size of the image, you get the coordinates of where the user clicked in the panel, relative to the top left corner of the panel. This translates to getting the coord's in the image itself.
I'm failing to see where the problem is and why you think this doesn't work.
|
|
|
|
|
Hello,
maybe I'm doing this incorrectly. Just to summerise, I have two panels,
the outer panel1 has Autosize = true, the inner panel2 has panel2.BackgroundImage = (Image)MyImage. I've set the width of the outer panel to 775, and the inner panel to 2000 (which is enough for all images). After I initially load an image and I click on a specific point on the right of the image I get the cursor position as 650,446. If I then scroll the image, but still keeping this point in view, clicking on it gives a cursor position of 340,446 (the point has visually moved to the left). The absolute value should be 650 + (scroll offset), not 340. Hope I'm making myself clear.
regards
pcjd
|
|
|
|
|
pcjd63 wrote: outer panel1 has Autosize = true,
Useless as you set the absolute size of the panel. Did you actually mean to say you set the AutoScroll property to true?
pcjd63 wrote: the inner panel to 2000 (which is enough for all images).
You would normally set this inner panel to the same size as the image itself when you set it's background image property to the image.
pcjd63 wrote: I click on a specific point on the right of the image I get the cursor position as 650,446. If I then scroll the image, but still keeping this point in view, clicking on it gives a cursor position of 340,446 (the point has visually moved to the left). The absolute value should be 650 + (scroll offset), not 340. Hope I'm making myself clear.
It would appear that you're handling the click event of the wrong panel. You need to handle the click of the INNER panel, not the outer one.
I've done this myself, creating a UserControl that does exactly this, and a lot more. Whenever you click on the image being viewed, it fires off an ImageClick event with the coordinates of the mouse click relative to the image, not the outer panel, and all I did was raise the new ImageClick event, reusing the MouseEventArgs.Location property given by the inner panel's Click event.
|
|
|
|
|
Hello,.
yes, sorry, it was a typo, I meant Autoscroll, not AutoSize.
All of the images are of a fixed (large) width, which is why I set the width of the inner panel to 2000.
I am handling the click event of the inner panel, and whether I use
Cursor.Position.X or MousePosition.X I get the same X values, which are relative to the panel, not the image.
if you are getting the correct absolute coords - I must be doing something wrong.
thanks for your patience
pcjd
|
|
|
|
|
If you're handling the mouse click of the inner panel, no matter where you click on it, repeatedly, the mouse coord's will not change with the scrolling of the outer panel.
Next, why are you settings the size of the inner panel so much larger than the actual image contained within?? Just set it's size to the size of the image and you won't have to do any funky math to get the coords mapped to the image.
I told you everything I'm doing. It's as simple as my description.
|
|
|
|
|
<if you="re handling the mouse click of the inner panel, no matter where you click on it, repeatedly, the mouse coord" s="" will="" not="" change="" with="" the="" scrolling="" of="" outer="" panel.="">
Eactly, this is what I'm trying to get round by using hscrollbar, as by using Autoscroll=true, there is no way to get the scrollbar position (offset)
<next,>
Doesn't make any difference whether I fix the panels width, or set it to the image width (all images have the same width anyway)
the 'funky math' is simply the addition of the scrollbar value (hScrollBar1.Value) to the X coodinate of the clicked point.
thanks for your help - lets call it a day
regards
pcjd
|
|
|
|
|
Hi guys,
I have a sql image field where I am saving pdf's to. I am now trying to archive these by converting them back to pdf's. I haven't been able to find any resources on how to do that. Please if anybody knows how to do this then I will appreciate it.
Thanks in advance
Sameer
|
|
|
|
|
Google for "save image to SQL database VB.NET". You'll find a tons of examples. A PDF file is no different than handling an image file.
|
|
|
|
|
I wasn't trying to save images/pdf's, I am doing that already, I was trying to extract them back to pdf's. I got it to work, thank you.
Sameer
|
|
|
|
|
Yep, and just about all the examples I've seen have the cofde to do BOTH sides of the operation, save and retrieve.
|
|
|
|
|
|
You are a life saver. Thank you very much.
Sameer
|
|
|
|
|
You are welcome
|
|
|
|
|
I'm trying to generate a new GUID in order to pass it as a value to a SQL Server 2005 db, however it is not working.
try
{
conAppDB.Open();
string _createNewTaskQuery = (@"INSERT INTO [teamwiki].[dbo].[task]
([task_ref
VALUES @task_ref);
string _newGUID = Guid.NewGuid().ToString();
SqlCommand cmdCreateNewTaskQuery = new SqlCommand(_createNewTaskQuery, conAppDB);
cmdCreateNewTaskQuery.Parameters.AddWithValue("@task_ref", _newGUID);
cmdCreateNewTaskQuery.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
finally {
conAppDB.Close();
}
Error:
System.Data.SqlClient.SqlException was unhandled by user code
Message="Incorrect syntax near '@task_ref'."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=15
LineNumber=19
Number=102
Procedure=""
Server="JCAMILLERI\\SQLEXPRESS"
State=1
StackTrace:
at TaskEntry.btnMultifunction_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\TaskEntry\TaskEntry.aspx.cs:line 108
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Jon
|
|
|
|
|
query is wrong, try:
INSERT INTO [teamwiki].[dbo].[task] ([task_ref]) VALUES (@task_ref);
|
|
|
|
|
SQL Server has the NEWID function which works pretty good too. Depending on what you need the guid for it may be better generated in the DB instead of the application layer.
Also, a pedantic comment. Using consistent variable naming will result in better code. While I prefer using the prefix m for members, others choose an _, however, few if any use the _ prefix for local variables and if they do they would do so consistently.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
Thanks. I've actually tried using the SQL server NEWID function, however, although it was working fine when querying the database directly, VS 2005 (Team Edition) with .NET 2.0 had a hard time parsing the NEWID() part within the string containing the INSERT statement.
Comments noted as well, I hurried to mock up the problematic code
Jon
|
|
|
|
|
jon_80 wrote: VS 2005 (Team Edition) with .NET 2.0 had a hard time parsing the NEWID() part within the string containing the INSERT statement
That's perhaps the problem... Why would you try to make the C# code parse the query at all? It's just a string that it sends to the database.
What does your code look like?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Show the code you tried.
INSERT INTO table ( ID , ... ) VALUES ( NEWID() , ... )
should work fine.
|
|
|
|
|
Hi,
Could anyone point me at a good article on using IConfigurationSectionHandler. The Microsoft documentation shows how to implement the interface, but I can't find an example of calling the interface's Create function.
What are typical parameters for:
object IConfigurationSectionHandler.Create( object parent, object configContext, XmlNode section )?
Any help would be most appreciated.
Best wishes, Patrick
|
|
|
|
|
You sure you want to be using that Interface?
From the docs: " Important IConfigurationSectionHandler is deprecated in .NET Framework 2.0 and above. But, because it is used internally, it has been kept. You can find an example at How to: Create Custom Configuration Sections Using IConfigurationSectionHandler. If you use the previous example, please build it with the .NET Framework version 1.0 or 1.1.
In .NET Framework version 2.0 and above, you must instead derive from the ConfigurationSection class to implement the related configuration section handler. You can find an example at How to: Create Custom Configuration Sections Using ConfigurationSection. "
from http://msdn.microsoft.com/en-us/library/system.configuration.iconfigurationsectionhandler.aspx[^]
|
|
|
|
|