Replacement for Touch.FrameReported in Windows Phone 8.1 / Windows 10 Mobile - windows-phone-8.1

In my old Windows Phone 8.0 project i use Touch.FrameReported for Multitouch detect. But I can't find it in Windows Phone 8.1 and Windows 10 Mobile Universal App.
Is there a similar command in wp 8.1 and wp 10 ?

Use the CoreWindow.Pointer*** events. You can distinguish the fingers (touch contacts) by comparing the Pointer.PointerId property.
private void PointerPressedHandler(object sender, PointerRoutedEventArgs e)
{
if (e.Pointer.PointerDeviceType != PointerDeviceType.Mouse)
{
var point = e.GetCurrentPoint(this);
var pointerId = point.PointerId;
// TODO
}
e.Handled = true;
}

Related

Close popup on hardwarebutton backpressed in windows phone 8.1 application

I have a popup that comes on a click event of button..
But I am unable to close the popup..I want to close popup on hardwarebutton_backpress event..
Can anyone plzz tell me how to do so..
I am using this code to show popup
Public void showpopup_click()
{
Popup p =new Popup();
p.child= new Mypopup();
p.Isopen=true;
}
Here Mypopup is my user control..
I am using visual studio and developing a windows phone 8.1 app..
Another approach, in my opinion better, is using the IsLightDismissEnabled property where you don't need to check whether a popup is already open or not, or if you have multiple open popups, everything is handled automatically.
var popup = new Popup();
popup.IsLightDismissEnabled = true;
popup.IsOpen = true;
You have to subscribe to the Windows.Phone.UI.Input.HardwareButtons.BackPressed event to handle the back button with custom logic. If you store the Popup in a field, you can easily set IsOpen property to false.
Like this:
private Popup _popup;
public void showpopup_click()
{
_popup = new Popup();
_popup.Child = new Mypopup();
_popup.IsOpen = true;
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs args)
{
_popup.IsOpen = false;
args.Handled = true;
Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed;
}
In the event handler, you need to set the args.Handled property to true to prevent the application close on the back button pressed. You also need to unsubcrise from the event to avoid memory leak.

Dispaly time current position media in TextBlock - Windows Phone 8.0 Silverlight

I develop an application in Windows Phone 8.0 Silverlight that play media with MediaElement. So, i want display time current position media in TextBlock during media is playing, How to do?
Thanks.
You can use a DispatcherTimer to update the textblock. Like this:
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 1);
timer.Tick += timer_Tick;
timer.Start();
To get current position, in timer_Tick function, use yourPlayer.Position.ToString():
void timer_Tick(object sender, EventArgs e)
{
textBlock.Text = yourPlayer.Position.ToString();
}

Assigning an event handler that runs on another thread

I'm trying to fit the windows phone 8 image capture code into a legacy model where I essentially have
var _autoResetEvent = new AutoResetEvent(true);
...
_autoResetEvent.Reset();
CameraCaptureTask cameraCaptureTask = new CameraCaptureTask();
cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);
cameraCaptureTask.Show();
_autoResetEvent.WaitOne();
...
void cameraCaptureTask_Completed(object sender, PhotoResult e) {
SaveImage(e);
}
Is there a way to get the event handler to run the completed event on another thread so that the AutoResetEvent won't be blocking it from running when it is called?

Geolocator position changed event

I am developing a running tracker/pedometer app, I am using geolocator for the same,I am keeping the movement threshold property of the geoLocator to 10 here is my piece of code.
button click event
private void StartButton_Click(object sender, RoutedEventArgs e)
{
myLocator = new Geolocator();
myLocator.DesiredAccuracy = PositionAccuracy.Default;
myLocator.MovementThreshold = 10;
myLocator.ReportInterval=500;
myLocator.PositionChanged += myGeoLocator_PositionChanged;
_startTime = System.Environment.TickCount;
_timer.Start();
}
void myGeoLocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
Dispatcher.BeginInvoke(() =>
{
var coord = new GeoCoordinate(args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude);
if (_line.Path.Count > 0)
{
var previousPoint = _line.Path.Last();
distance += coord.GetDistanceTo(previousPoint);
var millisPerKilometer = (1000.0 / distance) * (System.Environment.TickCount - _previousPositionChangeTick);
_kilometres += Math.Round(distance, 2);
distanceLabel.Text = string.Format("{0:f2} meters", _kilometres);
MessageBox.Show("Changed");
}
else
{
Map.Center = coord;
}
_line.Path.Add(coord);
_previousPositionChangeTick = System.Environment.TickCount;
});
}
The problem is that the position changed event is only getting called once, I am trying to debug the code in emulator by changing the location points but still the event do not get called. where am I doing wrong??
Your code will work on a real device. However, in order to test on the emulator, try by setting the DesiredAccuracy property to High.
From How to test apps that use location data for Windows Phone:
If your app uses the GeoCoordinateWatcher class, you have to specify a value of GeoPositionAccuracy.High in the constructor or in the DesiredAccuracy property of the class before you can test your app with the location sensor simulator. If you leave the accuracy at its default value of GeoPositionAccuracy.Default, the PositionChanged event doesn’t recognize position changes that occur in the location sensor simulator.
There is also another workaround, that consists on running the native Maps app, which seems to fix the problem:
Set a current location in the emulator.
Run your app. It reports the current location as Redmond.
Run the Maps application. It correctly goes to the location set in
step 1.
Run your app again. Now it uses the correct current location.
Source: http://social.msdn.microsoft.com/Forums/wpapps/en-US/c2cc57b1-ba1f-48fb-b285-d6cfbb8f393a/windows-phone-8-emulator-returns-microsofts-location-only

AS3 Why isn't RTMFP android to android connecting?

I'm making a connection with netconnection in AS3 Flash CS6. It works fine when I test the swf from my PC to the app on my Android. But when I install the app on 2 android devices they don't connect. Why is that? If I test with my PC and the two android devices it works too. How can I make it work with only the two android devices?
Here's the code I'm using:
var nc:NetConnection;
var group:NetGroup;
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.connect("rtmfp:");
function netStatus(event:NetStatusEvent):void{
switch(event.info.code){
// The connection attempt succeeded
case "NetConnection.Connect.Success":
setupGroup();
break;
// The NetGroup is successfully constructed and authorized to function.
case "NetGroup.Connect.Success":
break;
// A new group posting is received
case "NetGroup.Posting.Notify":
trace("notify");
break;
case "NetGroup.SendTo.Notify":
trace("notify received");
break;
// user joins?
case "NetGroup.Neighbor.Connect":
break;
}
}
// Create a group
function setupGroup():void {
// Create a new Group Specifier object
var groupspec:GroupSpecifier = new GroupSpecifier("test");
// Enable posting
groupspec.postingEnabled = true;
//groupspec.routingEnabled=true;
// Specifies whether information about group membership can be exchanged on IP multicast sockets
groupspec.ipMulticastMemberUpdatesEnabled = true;
// Causes the associated NetStream or NetGroup to join the specified IP multicast group and listen to the specified UDP port.
groupspec.addIPMulticastAddress("225.225.0.1:30000");
// Constructs a NetGroup on the specified NetConnection object and joins it to the group specified by groupspec.
group = new NetGroup(nc,groupspec.groupspecWithAuthorizations());
// Set the NET_STATUS event listener
group.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
}
I suggest adding a default case statement to your switch. It may or may not shed some light on what is happening:
switch (event.info.code)
{
case "NetConnection.Connect.Success":
// etc... Not showing orig code
break;
// rest of the case statements here
// then lastly add this:
default:
trace(event.info.code);
}