|
kinda' late but maybe it will help ... Application.StartupPath
|
|
|
|
|
Radu Sorin wrote: kinda' late but maybe it will help ... Application.StartupPath
Thanks... it's not late all things I do in C# for now are only my learning so more I know better...
I'll implement all options to see if there is any difference...
|
|
|
|
|
I have a bitmap (300x471) which I added as a resource.
I wanted to modify the bitmap and display it.
My picture box control has also same dimensions. (300x471)
void Smile_Load(object sender, System.EventArgs e)
{
_Background = Book.CSharp.Properties.Resources.Monaliza;
_Final = new Bitmap(_Background.Width, _Background.Height);
Graphics fg = Graphics.FromImage(_Final);
fg.DrawImage(_Background, 0.0F, 0.0F);
fg.Dispose();
pictureBox1.Image = _Final;
}
problem: If I give picture box actual bitmap (pictureBox1.Image = Background) it fits inside the control.
But if just copy to new bitmap, then it does not fit and control scales to bigger bitmap and only show partially which is very annoying.
I looked different articles and it looks perhaps this is done by AutoScaleDimensions
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
I played and also even removed, but no effect.
Any idea?
A prompt answer will be very appreciated.
agha.khan@hotmail.com
Agha Khan
|
|
|
|
|
Yep, I would suspect the automatic scaling.
Maybe you can replace
fg.DrawImage(_Background, 0.0F, 0.0F);
by
fg.DrawImageUnscaled(_Background, 0.0F, 0.0F);
FYI both also accept int coordinates, no need for floats here.
Luc Pattyn
|
|
|
|
|
Thank you for prompt reply.
But it did not work.
Agha Khan
|
|
|
|
|
Some ideas:
I do not know what is happening, you could check if the result has anything to do
with your scaling, just try to see what percentage of width and height is drawn...
You should try to figure out which part fails: the copying of the bitmap, or the
picturebox showing the image.
You dont need the Graphics to copy the bitmap, you could simply do
_Final=new Bitmap(_Background);
check if this works OK, if so you can still create a Graphics for it and modify it at will.
Luc Pattyn
|
|
|
|
|
Thank you.
I did not have much control on Picture box, so I changed control to
partial class Display : System.Windows.Forms.Panel
And override the paint function.
As for as display is concern, it worked fine, but scaling problem still persist.
As you suggested I used
_Final=new Bitmap(_Background);
And I looked the dimensions of bitmap and they are correct.
Only when I look at it is wrong.
When I increase the size of display I can see the whole, but bigger bitmap.
Best regards
Agha Khan
Agha Khan
|
|
|
|
|
The bitmap is drawn with the same physical size. That size is expressed in inches and not pixels. As the new bitmap that you have created does not have the same resolution (pixels per inch) as the bitmap that you are drawing, it will be drawn at a different pixel size.
You can either set the resolution of the new bitmap to the same as the bitmap that you are drawing (or the other way around if you like):
_Final.HorizontalResolution = _Background.HorizontalResolution;<br />
_Final.VerticalResolution = _Background.VerticalResolution;
or you can draw the bitmap specifying the pixel size:
fg.DrawImage(_Background, 0, 0, _Background.Width, _Background.Height);
---
Year happy = new Year(2007);
|
|
|
|
|
Perhaps I need more experiments, but it looks it works.
Thank you everyone.
Best regards,
Agha Khan
|
|
|
|
|
I'm currently trying to create an OpenDialog that is similar to the Windows Explorer in appearance.
(TreeView on the left, ListView on the right)
To get the logical drives is pretty simple. I just use the Directory.GetLogicalDrives() method.
However, I didn't find anything similar to access network drives, like in the Network-node
in the Windows Explorer TreeView.
I found a few solutions, that take hundreds of lines of code to get the result, that this one method
achieves for the logical drives.
Is there no shorter way? If there is one, what is it?
|
|
|
|
|
Is there a reason why you're not using the common OpenFileDialog? Unless there is some technical reason or compelling user scenario for not doing so, I'd suggest using the common Windows dialogs because they help to keep a consistent user interface across applications and therefore breeds familiarity for the user. In addition, if Microsoft decides to revamp the dialogs, your application will automatically inherit the improvements. Plus, it's a lot less work.
Anyway, just my humble opinion. I realize that the common dialogs won't work well in every possible situation.
-Phil
|
|
|
|
|
The common OpenFileDialog can't be modified (At least not without some rather complicated hacking.).
I just thought it would be a lot nicer to have one dialog instead of using the common dialog and opening a custom dialog upon closing the common one, to ask the user for all the remaining settings.
With my custom OpenDialog filtering is a lot more flexible. I can not only filter files by their ending, but also display them in the listView without it.
|
|
|
|
|
Hi all,
I have a large processing job that is taking an hour or two. I have a simple form that contains a statusbar panel that informs the user with progress. At the moment the update is a text string but I might move to a progress bar in the future. However, the main question is this:
If I click elsewhere (outside the program) and then return focus to the form, the statusbar text does not redraw and update. It ends up stuck on wherever it was when I left it. Furthermore, it even does this if I simply move the form slightly without losing focus.
Can someone advice what to do to maintain the updates?
TIA
Jerry
|
|
|
|
|
Are you doing your processing in the same thread as the GUI runs in? It sounds like it. If so, you have two options - you can either break out your processing to another thread, or you can simply make sure you call Application.DoEvents() regularly.
Hope that helps
|
|
|
|
|
Application.DoEvents() fixed it! Thanks!!
|
|
|
|
|
Im using a 3rd party DLL to create a graph. When calling some methods within this DLL i get exceptions because the control is running in a internet trusted zone. I do not have access to the 3rd party DLLs code so i cant add 'new UIPermission().Assert();' statements within the DLLs.
Is there a tool/way of signing a DLL so it will be trusted? i already sign the DLLs with my certifcate.
Regards,
Gareth.
|
|
|
|
|
The 3rd party company fixed the problem for me by removing some offending code.
Regards,
Gareth.
|
|
|
|
|
Hi everyone!
Please tell me what below statement mean
<br />
Regex regex = new Regex(@"[:_.\w]+\s*=\s*(""[^""]*"")|('[^']*')\s*"); <br />
Thanks
|
|
|
|
|
It's a regular expression that matches a string of the form SomeKey = "Some Value" or SomeKey = 'Some Value'.
SomeKey can be a string consisting of :, _, . and any alphanumeric character, while Some Value can be a string consisting of anything except the speech marks that contain it. There can also be any amount (or none) of whitespace around the = sign.
Hope that helps.
-- modified at 12:46 Sunday 21st January, 2007
|
|
|
|
|
Thank you ............ it helped alot
|
|
|
|
|
It creates a Regex object with the string as pattern. Regex is short for regular expression, and is used for pattern matching.
---
Year happy = new Year(2007);
|
|
|
|
|
Hi all,
I've recently been working on an IRC bot in C# (yes, I know there are a thousand others that could probably do what I want, but it was for the experience as much as anything) - the core of the bot works perfectly fine, but one of the subsystems, a plugin system, is giving me no end of grief.
To support unloading plugins, I isolated plugins in their own appdomain, and so far that has worked just fine, but I recently implemented a few changes - I decided to write an auto-updater as a plugin, so I set the plugin appdomain to use shadow copying, and strongly named assemblies (for a bit of security). The auto-updater queries a server regularly, and downloads any new or updated assemblies to the plugin directory, before reloading the plugins.
Now from what I've read, if shadow copying is enabled, when an assembly is loaded, it will first be copied to the shadow directory and then loaded from there, and any subsequent load attempts will use newer assemblies from the plugin directory (rather than the shadow copied version) if they exist. However, if I try to load the new assembly specifying a complete AppName, and the assembly version has changed, the load fails, with the fusion logs remarking that it found an assembly (purportedly in the plugin directory), but that it has the plugin version of the previously loaded assembly (I've checked in explorer, and it is definitely the correct version).
I've been able to work around this by loading by using the codebase, but that has an unacceptable downside in that it doesn't check that the public key token matches.
The only thing I can think of is that the previous version of the assembly is still loaded in a different appdomain. If anyone has any suggestions, or could put me right if I've made any incorrect assumptions, I'd appreciate it. The code is available, but I'd prefer not to check this broken code into my SVN if I don't have to.
Apologies if that was too rambling, but it's early in the morning and I'm running low on caffeine.
|
|
|
|
|
Hi All
How would I prevent a user from entering only numeric values into list view colum? Is there a specifiec event I could use to capture KeyPress events?
Many thanks in advance
Ross
|
|
|
|
|
I would like to make the first column in my ListView readonly but dont know how. Can anyone help please. Eg. I have three columns in my ListView:
SubjectName Option1 Option2
----------- ------- -------
Crabs ? ?
Fish ? ?
Something ? ?
Grass ? ?
Flowers ? ?
I need to make the SubjectName column read only so that the users can only enter an option in option1 or option2 without changing the text in the SubjectName column.
Many thanks in advance
Ross
|
|
|
|
|
AFAIK a listview (in details mode) gives one column that may or may not be modified
(depending on LabelEdit), all others are read-only.
So I suspect you need another kind of control.
Luc Pattyn
|
|
|
|