|
Regions are intended to be used in GROUPING methods not splitting one method's body.
[EDIT]
Example:
#region Events//put here all/most of the event(s) handling code
#region Drawing//put here all the drawing methods
#region YouNameIt// put here all the...
[/EDIT]
|
|
|
|
|
Ahh...I understand.
Thanks!
|
|
|
|
|
|
Oh c'mon my friend...your statement helped me more than any other reading I did today
|
|
|
|
|
Ohh, well, in that case, glad that I could help
|
|
|
|
|
That may be only a personal or company standard. One can use regions wherever one darn well wants to.
I generally use them only to group methods and properties, but I may also use seperate files (partial classes) for that purpose if the code becomes large enough.
In my RPN transformer I use regions to mark off less-important code that the reader may not be interested in -- it should at least help with documentation and readability -- I don't want to read through a bunch of error-handling code when I'm trying to get a feel for the process flow of a method.
|
|
|
|
|
Also, if you are using a region in a method, it is a sure sign you should put some of your logic into another method and just call that method from your original method.
|
|
|
|
|
Thank you for your reply and the link!
|
|
|
|
|
You are welcome. FYI, the link is part of my generic signature and was not targeted at you specifically. Still, if you haven't read it yet, it is advisable that you do so.
|
|
|
|
|
Yes, but the additional method calls could become a bottleneck in a tight loop. And the resultant code could be even less readable. You need to examine each case on its own.
|
|
|
|
|
I'd say it's probably unlikely, as the JIT compiler is able to inline function calls. In any event, if it's a tight loop, it seems pretty weird that there would be a region in the code anyway, in which case a method call would also seem unnecessary to break out the logic. And my point was that if you are thinking of making a region in your method, it's probably because your are trying to compress a bunch of code into a smaller block and that is usually better done with a method call.
|
|
|
|
|
Hello,
I have building a download/update file for a C# desktop application in pieces. Now, I am at the following point; the application determines if the new file is required. If so, it forces a download to a local file folder inside the application that is already running (this works perfectly). NOW...how do I shut down the application and run the update and then restart the application, or can it be done without a restart? Can this all be done automatically and without user input? Or perhaps I should place the file in an external folder and force a restart and then force the program to run the file? If so, how is this done? I am confused. Any suggestions would be appreciated. Thank you....Pat
|
|
|
|
|
There are many possible solutions. One of the most elegant is to use a "plug-in" system.
At the other side a real easy way is to create a "SplahScreen" like app that checks for new
updates, installs them and starts the actual app. If no updates found, it just starts the app.
As for actual code especially for the elegant one is just too much to provide.
Google or search inside CP for "program/application updates".
|
|
|
|
|
If you had used ClickOnce the application could already be configured to download and install updates prior to starting. Of course you can do this by hand by using a starter app, like a splash screen, that performs the update.
Another way is to use shadow folders to run the app from and copy the updates to the installed location to be used the next time the app starts. Microsft uses this approach for .net framework assemblies to allow them to be updated while an application may be using them. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
i am developing an app that prints on label sheets, this requires setting the data in the OnPrintPage from pixel 0,0.
When i draw the document on the OnPrintPage in all looks ok with a PrintPreviewControl, but when i actually print the page with a printer it start printing with a margin, how do i get the printer to print the exact same as the PrintDocument and if the printer is not capable to print the margins then he should just ignore these pixels?! does it have with any margin settings? PageBounds?
|
|
|
|
|
I've run into similar problems and honestly haven't found a good way around them. You see, in my case, people can change the printer selection and so my program doesn't really know what margins a printer may have, etc. The best I can tell, you can specify margins, etc, but the system doesn't enforce them automatically. At least with the lower level functions, it's up to your code to enforce the margins.
My solution kludge was to compute the page margins in pixels for each device and then blank the margin rectangles after drawing and before printing each page. Don't forget that the PixelsPerInch numbers can be pretty strange for different devices.
Perhaps someone else has a better solution.CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Thanks for the reply.
The strange thing is that when i print to a PDF file with BullZip and from there to my printer he will ignore the margins just like i want. and if BullZip can so can we! BUT HOW?
|
|
|
|
|
I have my WebBrowser, tha is create in Windows,I load in this webbrowser a pdf like this form:
this.WebBrowser.Navigate("C:/Tmp/abc.pdf")
The problem that I have is that when I close this Form
in this event
private void frmSirMosDocPdf_FormClosed(object sender, FormClosedEventArgs e)
{
System.IO.File.Delete(("C:/Tmp/abc.pdf");
}
this part generted a error, it says you can´t access to this file, because is running with ohter process, please help me, how can i do, to give a solution.
Thanks.
|
|
|
|
|
not sure its easy to solve - in older pdf's/acrobat versions, when you opened a pdf in a browser and then closed it, acrobat would often still be left running as a process in the background. The only way to release the pdf was to kill all 'lurking' acrobat processes ..
have a look on your system, when you close the form, is acrobat still lurking there as a background process ?
(there are other utilities, do a google for 'sysinternals', now part of Microsoft, that show file usage/processes accessing etc - possibly discmon or psfile)
[edit] possibly 'Process Explorer or 'Handles' from sysinternals would doa better job of identifying whats 'locking' the file, but dont disregard the comments made by others here either [/edit]
'g'modified on Thursday, February 11, 2010 7:01 PM
|
|
|
|
|
As the other poster said, there is stuff still running in the background, though in my experience it is the WebBrowser Component. As it wraps an unmanaged resource you must ensure you Dispose of the WebBrowser when yoiu dispose of the Form. ie. in the Form Dispose method call Dispose on the WebBrowser, or it will remain in the background and hold a pointer to the PDF.
We had a similar problem with the WebBrowser retaining local cached copies of pages when we thought we had closed it down, all because we had not called Dispose.
|
|
|
|
|
Hi,
while the WebBrowser is showing a file, it might keep it open, preventing you deleting it; so you may have to navigate away from x in order to delete file x. One way should be to assign a dummy page, maybe like this:
myWebBrowser.DocumentText="<html><head></head><body></body></html>";
although
myWebBrowser.DocumentText="";
probably works equally well.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi,
sorry, my previous approach does not work.
while the WebBrowser is showing a file, it does keep it open, preventing you deleting it; so you must navigate away from x in order to delete file x. It works like this:
myWebBrowser.Navigate(anotherPage);
... wait a while
File.Delete(previousPage);
If you don't have anotherPage available, you can create a local one, hence:
string anotherPage="C:\temp\dummy.html";
File.WriteAllText(anotherPage, "<html><head></head><body></body></html>";
myWebBrowser.Navigate(anotherPage);
... wait a while
File.Delete(previousPage);
This works for me.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi everybody.
There is a property, it's named ImageFullPath1
public string ImageFullPath1 {get; set; }
I'm gonna fire an event whenever its value changed. I know I can beware of changing with INotifyPropertyChanged , but I wanna do it with events.
I don't know how I should do it.
Could you please guide me?
Thanks.
|
|
|
|
|
INotifyPropertyChanged uses events and is there just for what you are asking. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I just hate the fact that it uses a string, however.
|
|
|
|