Calculate the distance between two fingers in Windows Phone 8 - events

As we know, we can calculate the distance between two fingers in Windows Phone 7 using the toolkit's gesteuresevices. It would be like this:
ManipulationStartedEventArgs.GetPosition(UIElment, fingerIndex);
Is there a similar method in Windows Phone to achieve this without toolkit?

So, you want actual distance between user's fingers in real world, i.e. in centimeters? It should be easy: you need to know distance in pixels, then you need to know physical size of one pixel, and then you multiply.
Now, to get the physical size of one pixel, you'd need to know the phone's screen size. You'd need to know the phone model for that, which you can get by DeviceStatus class. Then you'd need a database of phone's screen sizes, which you'll need to build yourself. For Nokia phones, you could check official website (here's an example). So, for Lumia 920 size of one pixel is 0,07578125 x 0,075520833 mm.
Next, you'd need to get the multitouch event. For that, you'd use ManipulatienStarted, ManipulationDelta, and ManiputalionComplete events. See this MSDN article for more info.
Hope I understood you correct and this will work for you. If you need more info or explanations, just let me know in comments.

i dont think so that you can use gesture services without toolkit....
there is a toolkit available for this
Microsoft.Phone.Controls.Toolkit
this will work fine for you....

Related

Is there any way to get live telemetry data from the DJI Mavic 2 Zoom to another unit, say a computer?

As part of a course on my university we've been given the task of taking the live wind telemetry from a drone and then feeding it to a neural network so that it gives better estimates than just using a sensor.
The research we've concluded so far tells us that our drone, the DJI Mavic 2 Zoom, is only compatible with the Windows SDK but not the onboard SDK.
Simply our question is; is there any way for us to send the raw wind speed and direction data from the drones sensors to a computer?
Create Android application with DJI Mobile SDK and send data from msdk to your computer with wifi.
The SDK only provides the wind warning level(0, 1 and 2). It does not provide any information regarding the direction from which the wind is blowing or the actual speed of the wind.
The aircraft tries to stay in it's current position on it's own, even if there is moderate wind blowing. However the drone does not tell the user how much it has to work in which direction to negate the effect of the wind.
I assume you're better off with accessing real time wind information for your position from a weather service on the internet, if that's available in your country.
I've done a wind meter app.
The best method is:
Fly against the wind
In virtualstick use angle mode, and set pitch and roll to 0 This will let the drone drift with the wind.
Slowly rotate the yaw.
Meassure the speed, when it stop increasing, the gps-speed gives you the windspeed and direction.
Warning, in strong wind you have to fly for quite a while against the wind.
The yaw rotation needs to be done due to the drone is never exactly leveled, and it will pick up speed at one direction. If turned, it cancel that out.
Send the info to a server over internet/wifi.
I've done this on an android phone connected the controller.
Windows api doesn't seem to support virtualsticks, which I find strange. In that case it must be done on android or ios, and trasnmitted to a server. I might be wrong since I never used the windows api.

Is there a way to change the font size unit for Xamarin?

I think I already know the answer, but I have to ask. So we developed an update which includes an option for users to have larger text size. Apparently, they didn't notice this until now because they want the font size to be the same on smaller phones and big phones. (even though the app had different font sizes before we did this, but i digress). So we see that the same number of words is consistent whether it's an iPhone 5 or iPhone 6S+. And I understand we just give the FontSize attribute a value and the phone determines how big it should be.
Is there any way to force it to be the same font size no matter what kind of phone it is? Before I get backlash, I am not setting a different FontSize value. It's the same, but depending on how big or small your actual phone is, it might APPEAR to be bigger or smaller. Which we would like to do away with.
I also understand that FontSize uses points for iOS, and DP for Android. So I guess the only way to achieve what management wants is to (if we can) change the unit to pixels or something? Obviously, I'm pretty confused because this seems to be working as expected, just a really odd request from management which I hope someone has some insight on?
Ended up using a value converter that looked at the type of device and scaled it appropriately. Not the best way, but it works.

How do GUI developers deal with variable pixel densities?

Todays displays have a quite huge range in size and resolution. For example, my 34.5cm × 19.5cm display (resulting in a diagonal of 39.6cm or 15.6") has 1366 × 768 pixels, whereas the MacBook Pro (3rd generation) with a 15" diagonal has 2880×1800 pixels.
Multiple people complained that everything is too small with such high resolution displays (see example). That is simple to explain when developers use pixels to define their GUI. For "traditional displays", this is not a big problem as the pixels might have about the same size on most monitors. But on the new monitors with much higher pixel density the pixels are simply smaller.
So how can / should user interface developers deal with that problem? Is it possible to get the physical size of the screen? Is it possible to set physical sizes instead of pixel-based ones? Is that still a problem (it's been a while since I last read about it) or was that fixed meanwhile?
(While css seems to support cm, when I try here it, it is not the set size).
how can / should user interface developers deal with that problem?
Use a toolkit or framework that support resolution independence. WPF is built from the ground up to be resolution-independent, but even old framework like Windows Forms can learn new tricks. OSX/iOS and Windows (or browser if we're talking about web) itself may try to take care the problem by automatic scaling, but if there's bitmap graphic involved, developers might need to provide different bitmaps such in Android (which face most varying resolution and densities compared to other OS)
Is it possible to get the physical size of the screen?
No, and developers shouldn't care about it. Developers should only care about the class of the device (say, different UI for tablet and smartphone), and perhaps the DPI to decide which bitmap resource to use. Vector resource and font should be scaled by the framework.
Is that still a problem (it's been a while since I last read about it) or was that fixed meanwhile?
Depend on when you last read about it. Windows support is still spotty, even for the internal apps itself, and while anyone developing in WPF or UWP have it easy, don't expect major third party apps to join soon. OSX display scaling seems to work a bit better, while modern mobile OS are either running on limited range of resolution (iOS and Windows Phone) or handle every resolution imaginable quite nicely (Android)
There are a few ways to deal with different screen sizes, for example when I make mobile apps in java, I either use DIP(Density Independent Pixels; They stay at a fixed size) or make objects occupy a percentage of the screen with simple math. As for web development, you can use VW and VH (Viewport Width and Viewport Height), by adding these to the end of a value instead of px, the objects take up a percentage of the viewport. For example 100vh takes 100% of the viewport height. Then what I think is the best way to do it, but time consuming, is to use a library like Bootstrap that automatically resizes elements, even when the window is resized. W3Schools has a good tutorial on bootstrap and more detailed explainations on any of these options can be looked up with an easy google search.
The design of the GUI in today display diversity era is real challenge. I would suggest several hints, mainly about the GUI applications design:
Never set or expect constant pixel size of the text - the user can change it from the system settings of the OS. Use some real-world measures for the text and check its pixel size when drawing. Provide some way to put the random size text in the boundaries of the window.
Never set or expect constant pixel size of the GUI widgets. Try to position them on the window in some adaptive way - according to the size of the window. Most GUI widget toolkits today have such instruments.
Never set or expect constant pixel size dialog windows. Let the OS to choose the size for you and then use what you get (X). Or, if you need to set some size and position (Windows), define it as a percent of the screen size.
If possible use scalable image formats for the icons. SVG is great for icons actually. Using sets of bitmap icons with different sizes is acceptable, but highly non-optimal as memory use and still will not provide perfect scaling in most cases.

Changing how windows displays using Win API?

While I have some experience with the WinAPI I do not have a ton, so I have a question for people who do have much experience in it. My question concerns what the limit of our power is. Can we change how windows fundamentally displays?
For example, can I cause windows to render a screen size bigger than the display and pan across it, kind of like workspaces but without separation? Can I apply distortion to the top and bottom of the screen? If distortion is not possible can I have an application mirror what windows is displaying with very little delay?
The biggest question I have is the first one, because if I can make windows render virtual workspaces and pan seamlessly between them then I figure it is possible to make a separate application which handles the distortion on a mirrored image of the desktop. Again, apologies for the vague questions, but I really want to know if we are able to do this stuff, at least in theory, before I dive deep into learning more on the API. If the WinAPI does not allow it is there another way to do this kind of stuff in Windows?
EDIT: Some clarification. What I want to do is basically extend the desktop to a very large size (not sure on exact size yet), both vertically and horizontally. Section the large desktop into workspaces of a specific size which can seamlessly be transitioned across and windows moved across. It would transition workspaces based on a head tracking device and/or mouse movement. Note that when I say workspaces this could be achieved by zomming in and then panning the zoom as well. I also need to be able to distort the screen, such as curving the edges, and render the screen twice. That is the bare minimum of what I am wanting to do.
Yes, you can. The most feasible way I come up with is using a virtual graphics driver (like what Windows Remote Desktop does, which creates a virtual graphics card and a virtual display). Sadly you will lose the ability to run some programs needing advanced graphics API (such as 3D games, 3D modelling tools or so).
There're some examples:
http://virtualmonitor.github.io/
https://superuser.com/questions/62051/is-there-a-way-to-fake-a-dual-second-monitor
And remember Windows has a limit on display resolution (for each and for altogether). I don't remember the exact number but it should be less than 32768*32768.

Windows Phone 7 - Device Independent Pixels?

Android has a nice way to make screen elements scaleable so they look good on most devices. One of those is Device Independent Pixels:
basics of device-independent-pixels
Is there anything similar to dips on Windows Phone 7?
What about autosizing a control to its contents? Such as width=wrap_content?
Thanks!
WP7 devices always have the same resolution so you shouldn't need to worry about DPI.
While devices can have different physical sizes they shouldn't differ too much. If you are really concerned you shoudl simply design and test on devices with the smallest and largest physical sizes.
If you still run into issue then it's probably due to trying to put too much on the screen. If that's the case then you should redesign the app.
One of the original design objectives for WP7 was to create a platform which did not suffer the consequences of device fragmentation such as wildly differing screen sizes and resolutions. As such there is no need to have to code for them.
NB This is the case for WP7, however WP8 supports 3 resolutions. For details on how to support WP8 see http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206974(v=vs.105).aspx
Not sure if that answers your question, but the Grid control is usually the best approach when you want to create a layout that adapts to different sizes.
I don't know of an equivalent to Android's device-independent pixels, though.

Resources