|
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[^]
|
|
|
|
|
Good point - thanks. I had forgotten reading that important statement about 9 o' clock this morning (it's been a long day).
I actually started using the ConfigurationSection method, but I got side-tracked when I tried to figure out how to implement a collection as one of the properties. Could anyone point me at an example of how to do this?
Best wishes, Patrick
|
|
|
|
|
Good morning message board,
I am trying to read data from an xml string, and am getting a Object reference not set to an instance of an object. I am assuming this is because the following line of code is not finding a node in the xml string where profileURL is a string:
profileURL = xmlDoc.SelectSingleNode("fql_query_response/user/profile_url").Value;
The xml string i am trying to read is as follows:
<br />
fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true"><br />
<user> <br />
<profile_url>http:
</user><br />
/code><br />
<br />
Any help with this would be greatly appreciated as im not really clear why i am not registering a hit on a node. <br />
<br />
Thanks for the help, <br />
<br />
JL <br />
<br />
<div class="ForumMod">modified on Tuesday, January 20, 2009 1:16 PM</div>
|
|
|
|
|
Hello all,
I have coded a quite-complex (for me) website that contains many controls and some loaded code-behind pages. I launched the website, no problems there. A few months after all files are gone in a harddisk crash. Now I have a fully functioning ASP.NET website at hosting company's computer, but no code behind files... As long as website works, noo problem I thought, I can work on it "someday" in the future. But now hosting company changed their configuration and one of the user controls that contained hard-coded directory path does not work anymore (oh yes I know I shouldn't have hardcoded and instead used settings files... But "it" happens)... I really don't have time to code all that stuff and code behind pages contained many SEO tweaks, I don't think I can get them all right in one go (last time it took mo more than 2 months to get it almost-right).
I have temporarily solved the situation by removing the problematic user control. Now website works but that spot looks kinda empty and in a week or so I have to put there something and I don't really feel like coding the entire code behind pages. It took me 2 months to get together this babe...
My question is this: Is there an easier way around? For instance, can't I just write a single replacement user control and have it compiled? When I tried it (on VS 2005) it tells me the website is already pre-built and refuses to build/publish the website. When I wrote a simple user control, inserted in site.master and clicked on Preview I can see it's working, but I can't publish/build. So I figure there should be a way...
Any recommendations please? (P.S. I am a newbie and I am not a professional programmer; please take it easy on me )
Thanks,
Haluk
|
|
|
|
|