That's an API function that I'm P/Invoking. It's not exposed externally in it's full ugliness.
Luc Pattyn wrote:
you'd better use int everywhere, there's too many casts right now
The API uses UINT for all these values so I'm using the same. The casts are for list creation as they require ints. I have thought about creating a genericlist that can hold UInt32.MaxValue elements to make sure there is no problem even with a rediculous number of devices available.
Luc Pattyn wrote:
what is "this"? isn't everything static there?
The finalizer runs on each MidiDevice instance. Only the lists in that class are static.
Luc Pattyn wrote:
I would never expect "this" in KeepAlive, as it is "this" that is running the code anyhow.
I did some reading up on the finalizer and that is not necessarily the case. Any objects the instance would normally hold could have already been finalized or in a race condition with this finalizer. Using this prevents this. This is what I've gathered from the brief reading I've done and should not be interpreted as fact!
Luc Pattyn wrote:
and do you really need it?
I don't think so as the static list is keeping it alive anyway AFIK.
If this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
May i ask why you want to achieve something like that? Since your Page inherits from base type Page it allways should have access to the Session-Property. One thing you can try is to implement a BasePage-class that inherits from Page. In this class you set the access to Session as a private Member. e.g.:
actually this was asked to me in an interview.. and my answer was to clear all the session variables on the page_init;
he told that is there some kind of markup in the page which does this thing of skipping the session values for a single page... so is there any other way around...
Customer wants to draw a rectangle on the image and when zoom in and zoom out the position of the drawn rectangle should resize respectively.
say a some text in the image and i have drawn a rectangle for that text. If i zoom the image the rectangle should also changes so they still covers that text on the image.
I don't want to paint (paste) the rectangle on the image because like to change the position the rectangle when ever user likes (i have achived this part so don't need ti wary on this)
I have load the image in the picture box and drawn some rectangles. Now like to zoom the image (along with drawn rectangle) as below code. My problem is when i zoom the image the Rectangle in the top of the image aligned correctly (at the new position) but the x point of the rectangle in the 3/4 (of the height of picture box)slightly move right.
How can resize the all rectangles?
Thanks in advance......
//sz to get the previous picture box size.double ratio = 0d;
if (sz1.Width >= Convert.ToInt16(sz.Width * 2.2))
sz1.Width += 50;
sz1.Height += 50;
ratio = Convert.ToDouble(sz1.Width) / Convert.ToDouble(pictureBox1.Width);
pictureBox1.Size = sz1;
// get the Image rectangle value to set the offset
PropertyInfo pInfo = pictureBox1.GetType().GetProperty("ImageRectangle",
rect1 = (Rectangle)pInfo.GetValue(pictureBox1, null);
n2 = rect1.Y - n3;
n3 = rect1.Y;
Point pf = pictureBox1.Location;
pictureBox1.Location = pf;
for (c = 0; c <= (rectangles.Count - 1); c++)
rect1.X = Convert.ToInt16(Convert.ToDouble(rectangles[c].X) * ratio);
rect1.Width = Convert.ToInt16(Convert.ToDouble(rectangles[c].Width) * ratio);
//N2 TO ADUST THE Y POSITION OF DRAWN RECTANGLE
rect1.Y = Convert.ToInt16(Convert.ToDouble(rectangles[c].Y) * ratio) + n2;
rect1.Height = Convert.ToInt16((Convert.ToDouble(rectangles[c].Height) * ratio);
// RECTANGLE LIST TO COLLECT ALL RECTANGLE VALUES
to me this is yet another proof PictureBox is not a good Control at all: as soon as you want to do more than just showing an image as is, it starts to work against you.
Here is my approach:
- use whatever Control you choose, and paint everything yourself, on top of it, using a Paint handler; I typically suggest a Panel.
- use Graphics.DrawImage() to paint (part of) the image
- and Graphics.DrawRectangle() to paint the rectangle
- and Graphics.DrawString() to paint the text.
optionally use any of the transform methods to change the origin (TranslateTransform), rotation (RotateTransform), or scaling (ScaleTransform). The big advantage is these work identically on all drawing components (image, rectangle, text), provided the transforms are executed before any of the drawing occurs.
Warning: initially you may make some mistakes in determining the correct transformations and your drawing parts may lie outside the view, therefore it is recommended to start with a view larger than is required.
I have painted the image on the panel and drawn rectangle. now i like to move the rectangle and i succeed on that. My problem is when i use panel.invalidate in paint or in mouse move, panle get refeshed every time (all the things getting blink every time when i move the mouse over the panel).
SO i used panel.invalidate in other events (mouse click, mouse move down)and can't able to see the moving of rectangle. (the panel only get refreshed after i release the mouse left click)
My question is how can refesh the panle so the moving rectangle will only get refeshed rather than all drawn things in panel (just to top blink very time i move the rectangle or get refersh such just it should not seen in naked eye).
Yes everything will be redrawn all the time, to make that happen unnoticed you should consider using double-buffering; this article[^] has an example. You should also make sure to keep your Paint handler lightweight, i.e. avoid Control.CreateGraphics, Image.FromFile, and other expensive operations.
FWIW: for really complex graphics (what you described is not), you could also repaint the relevant parts only, i.e. rely on clipping, probably based on the rectangular hull of the old and new rectangle.
Have loaded the image and drawn the rectangle over the panel. When zoom the panel the rectangle position also changed. if i drawn a rectangle over a text on the image and when zoomed the panel the rectangle needs to cover that text portion after zoomed.
I have a dll named A.dll with strong name, another assembly B references A.dll. I place A.dll in c:\myapp, also A.dll is installed in GAC.
I hope assembly B loads the A.dll from c:\myapp not GAC. But it always load the A.dll from GAC. My question is how to load a referenced dll from specified local location not GAC.
seems like a legitimate question; say you have an application up and running, using DLL from GAC; then you want to work on the next version while the current one remains available, so you want a development session using a "local" evolution of said DLL.
would be fine; it is an array capable of holding ten (references to an) rdata objects.
Would I use set/set methods to access that data
you could have public variables (data members) in your class, however this isn't considered good practice; you could have public properties (known as getters/setters to some), that would be perfect.
You should pay more attention to the case of identifiers, the formatting of your code, and a lot more. I strongly suggest you buy and study an introductory book on C#, it is the best (and fastest) way to learn the language properly, as it is bound to present you all the necessary knowledge in a structured and consistent way; of course you should experiment while studying. So go to the book store and look at some books, choose one, and enjoy.