|
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..
|
|
|
|
|
Hi there good people !
I've got strange problem with query into C# code to MySQL database. The point is i got this query:
m_insert_cmd2 = new MySqlCommand("INSERT INTO tb_rezerwacja (kwota, ilosc_osob, w_tym_ilosc_dzieci, data_od, data_do, FK_pokoj_id, FK_zamowienie_id) VALUES (, '" + tbPrice.Text + "', '" + tbNumberOfPeople.Text + "', '" + tbChildren.Text + "', '" + tbStartDate.Text + "', '" + tbEndDate.Text + "', @pokoj_id, @zamowienie_id)", m_conn);
which is working but put all field in database to NULL without parameters : @pokoj_id and @rezerwacja_id - that's good. All tb.. are editboxes no matter what i write to them it always put nulls in database. I tried a lot of combinations with this query but i can;t do it working 100%.
For example this query works fine (if i put static data) it's all put in database, no nulls:
m_insert_cmd2 = new MySqlCommand("INSERT INTO tb_rezerwacja (kwota, ilosc_osob, w_tym_ilosc_dzieci, data_od, data_do, FK_pokoj_id, FK_zamowienie_id) VALUES (' 345', '3', '3', '0000-00-21', '0000-00-21', @pokoj_id, @zamowienie_id)", m_conn);
What i do wrong, please help.
best regards,
nighttrain
|
|
|
|
|
I think here is problem:
nighttrain_ wrote: VALUES (,
It should be
VALUES (
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
i tried it and the same wrong result, still NULLS
|
|
|
|
|
I know this sounds really basic - but have you tried running this in debug mode and outputting the values of these objects:
System.Diagnostics.Debug.WriteLine(tbPrice.Text);
System.Diagnostics.Debug.WriteLine(tbNumberOfPeople.Text);
System.Diagnostics.Debug.WriteLine(tbChildren.Text);
System.Diagnostics.Debug.WriteLine(tbStartDate.Text);
System.Diagnostics.Debug.WriteLine(tbEndDate.Text);
Just to make sure that they contain what you expect them to contain...
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
Mayby it's lame but how can I use this debug mode, i create a button and paste Yours:
System.Diagnostics.Debug.WriteLine(tbPrice.Text);
System.Diagnostics.Debug.WriteLine(tbNumberOfPeople.Text);
System.Diagnostics.Debug.WriteLine(tbChildren.Text);
System.Diagnostics.Debug.WriteLine(tbStartDate.Text);
System.Diagnostics.Debug.WriteLine(tbEndDate.Text);
mayby it's lame question but how should i do that?
|
|
|
|
|
I don't have the visual studio IDE at work but you will need do something like select debug from a menu at the top and F5 to start debugging - you will also need to open what I believe is called the "output" window.
Best thing is to google how to debug in Visual studio - wish I could be of more help...
Being able to use the debug facilities is a must have skill for C# clickety[^]
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|
|
I don't know, a textbox.Text should never be NULL, but there's an awful lot of bad technique there.
0) Use parameters for all the values
1) Don't use strings for numeric and date values
2) Try using NumericUpDowns and DateTimePickers
|
|
|
|
|
i start debug and open Output Window but it's strange what i saw:
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'D:\_Programowanie\_Moje projekty\OKIENKOWE\HMS\HMS\hms\branches\hms.application\bin\Debug\hms.application.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Deployment\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 'vshost.NotifyLoad' (0x1500) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x954) has exited with code 0 (0x0).
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'D:\_Programowanie\_Moje projekty\OKIENKOWE\HMS\HMS\hms\branches\hms.application\bin\Debug\hms.application.exe', Symbols loaded.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\MySql.Data\5.2.7.0__c5687fc88969c44d\MySql.Data.dll'
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'hms.application.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 'vshost.RunParkingWindow' (0x10b8) has exited with code 0 (0x0).
The thread '<No Name>' (0xba8) has exited with code 0 (0x0).
The program '[5072] hms.application.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[5072] hms.application.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
Anyone could look at that and write something about it ?
|
|
|
|
|
Firstly, if at all possible, you should use parameterised queries, and if not, you must escape the contents of those text boxes before creating the query string. At the moment, if those are free text boxes, there is a huge SQL injection hole in this code.
Secondly, you should be using a DateTimePicker or similar for the dates, and using myDateTimePicker.Value.ToString("yyyy-MM-dd") to get them in database format. Edit from the subthread below: If you are using parameterised queries, you should (of course) pass the date as a DateTime. The string formatting is only if you are building a query string. Ideally you should use a numeric text box type as well but inexplicably that doesn't exist in the standard framework.
Thirdly, I suspect the immediate cause of the problem is that the dates are not in a valid format. See what the string you are actually creating really looks like, and compare it to a static query that works.
modified on Thursday, July 21, 2011 1:02 PM
|
|
|
|
|
BobJanova wrote: using myDateTimePicker.Value.ToString("yyyy-MM-dd") to get them in database
format
No, don't do that; just put the DateTime in a parameter.
|
|
|
|
|
I did start my answer with 'if at all possible, use a parameterised query'. Yes, that is better if it's possible (and it almost always is).
|
|
|
|
|
Yes, but as a DateTime, not as a String.
|
|
|
|
|