I want measuring tool in project that will be same as measure it in Firefox (add-on). How to do this?
To get such a think to work you'll need an application that runs as a tray icon or something like that. Then you open your application and tell him, that you'd like to measure.
Now, you'll go and put a transparent window onto the whole screen(s) and wait for a mouse move event. Within the mouse move event, you'll check the mouse button state. If it is going to be hit you know the starting position and you can draw some kind of user-control at this position and if the user releases the mouse button, you're going to stop the resizing of your user-control.
The user-control itself should be semi-transparent and checking for the resizing and/or paint events, to draw the ruler lines around the border.
Last but not least you can show some kind of tooltip or labelcontrol in relation to the position and size of your user-control and screen bounds to give some status informations.
To get a good starting point about how to get the transparent overlay part done, you can take a look into ObjectListView Overlay.
--EDIT--
One solution could be:
Create a separate transparent windows form
Upon certain key press, for instance Ctrl+Shift+R, show your app with lower transparency level; so that user can see the background.
Draw ruler upon form load
You may allow user to move the ruler window with mouse click.
Related
Basically I have a MouseDown event where I move the window. I want to be able to snap my WPF app to the nearest screen corner by a certain threshold (i.e. 20 pixels), not just a screen edge but the nearest corner.
Which events should I use to accomplish this? I saw some articles but they seem overkill that are subclassing the Window class, etc.
I know I will loop through every corner of the screen and every corner of my app window but I am not sure which events I need to use and which property of the WPF Window gives me the exact coordinates of the window extents.
We can get the location of the screen by SystemParameters.WorkArea.Width(x1) and SystemParameters.WorkArea.Height(y1),and you window's size are this.width(x2) and this.Height(y2).So,we get the four location of corners:(0,0),(x1-x2,0),(0,y1-y2),(x1-x2,y1-y2).
Then,we can use the MouseLeftButtonUp and down event of the window,i tried that but only I clicked in the window it worded.Moving the window when clicking the title bar of it can't trigger event.I thick maybe we can Customize the title bar and write the event in it's MouseLeftButtonUp and down.
I'm currently developing a 3D viewer application in WPF, and for ergonomy reasons I want my mouse to go to the other border of the screen if it goes into one.
For example, if my mouse goes into the top screen border, set I set my mouse position to the bottom of my screen.
Same for left/right.
How can I actually detect my mouse position in WPF? The only position I can get is related to the software and not the entire screen.
Also, it would be great if it could support dual monitors. (So the mouse is re-set only if it goes into the second monitor)
based on the informative answers to the s.o. question here:
How do I get the current mouse screen coordinates in WPF?
I think the simpler way to go is the windows.forms method, unless your 3d graphics are updating a lot of computation and you don't want the extra .net unboxed loop performance margin hit. According to this msdn reference:
http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position.aspx
the Cursor.Position property is settable, so should be settable from WPF app, although you want to do some research and testing before committing to a lot of code on that
I have a silverlight application in which I have to click on some pictures, if I hover over them for 3 seconds approx.
The problem is that if the pictures are a bit small in size, and the mouse moves a little, it moves out of the respective picture clicking area and selects another picture.
I have tried using a custom image in place of the default mouse cursor, but can this mouse be enlarged in some way so that it has a larger clicking area under it and not only the tip of the mouse pointer?
I think you're thinking about this the wrong way around. The mouse pointer simply defines a coordinate on the screen, rather than an area. If you want mouseover/click etc to be more generous, and give a wider area of interaction, you should make the target area larger.
So in the case of some small image, you can surround it with a larger area to handle the mouseover or click events, for example by surrounding it by a transparent border (note that elements with a transparent background will receive mouse events, unlike elements with no background).
I have a problem with WPF application/presentation for Tablet PC with (multi-) touch screen. One "slide" of the presentation consists of Canvas on background and of a small UserControl. This UserControl is invisible at start, but whenever user touches the screen, it becomes visible and if user moves his finger, the control moves accordingly ("following" the finger, like a cursor). Then, when user stops touching the screen, the control becomes invisible again.
This is not very hard to do using the TouchDown, TouchUp and TouchMove event handlers and it works fine if user touches the screen with just one finger. However, when user holds one finger on position X (e.g. canvas coordinates [100,100]) and another finger on position Y (e.g. [500, 100]), the UserControl starts jumping between positions X and Y, which doesn't look very well...
Now I'd like the screen to react only to one touch at the time, which I can do in operating system (Windows 7) using Control Panel -> Pen and Touch -> Touch by unchecking item "Enable multi-touch gestures and inking".
This works fine, exactly as I want it to, unfortunately it's not very convenient, because sometimes I need to use the multi-touch and I can't change it every time I decide to use the application...
That's why I'd like to ask if there is any way how to disable the multi-touch programmaticaly, in the application (or just in WPF UserControl) where I need it. Thanks a lot in advance for any help.
Take a look at the TouchDevice.Id property. You can get this from the event arguments passed to the touch events and it will allow you to uniquely identify the touch events so that you don't confuse the first touch with subsequent parallel touches.
You can convert the C++ code from the following question to C#: Programatically enable / disable multitouch finger input?
The CodeProject article, "Single App Instance in C#: Yet Another Way" has a C# implementation of the Win32 GlobalAddAtom() function and PInvoke.net has a reference page for SetProp().
You can use a boolean eg. IsCurrentTouched, set it true if user touches and the control is shown, and set it back to false when the touch is released.
While IsCurrentTouched is true don't react to other touches. So you are able to use multitouch only when needed ;-)
I'm pasting an image from the game im building.
the matrix of empty cells you see are made of PictureBox[][].
I wan't whenever I drop a coin to one of the columns... I want it to go down but the purple stuff will hide the falling coin and the gray color you see wont hide it.
How do I make this effect?
please notice that in each PictureBox control I have set the BG Image as you can see
Don't do it like that.
Create custom control. In custom control, override Paint, and then draw COIN sprite first, then draw mask over it. Be sure that you use double-buffered painting here.
It will work like a charm, trust me!
And, since you are (I gueess) building 5-in-a-row game here, your custom control will be able to paint occupied slots as well.
By designing custom control, you'll be able to hide all the animation and graphics stuff away from your main form.
I don't think it is possible like that. Controls in WinForms cannot be transparent, that is the problem
I would think in three directions:
Forgetting about controls and
painting everything OnPaint event of
the form. It is not too complicated
(well it would be more complicated
to detect some mouse events like you
did now, as you wouldn't know which
graybox is hit, but rather just
mouse coordinates)
Experimenting with coin as a form
(forms can be transparent)
Possibly using WPF with same logic
you did, as controls can be
transparent there
Controls in Windows Forms can be transparent. You need to set the TransparencyKey of the Form to some color that you never plan on using (many people seem to love/hate Magenta for this), and then set the BackgroundColor of each PictureBox to the same color. The result should be a transparent PictureBox with its Image drawn over it. I'm pretty sure this won't work with the BackgroundImage property, mind you- just the Image property.
One potentially unwanted side effect of this method is that you'll be able to see whatever's behind your form (the desktop, other application windows, etc.) through the transparent places in the PictureBox.