I am showing one MessageBox inside manipulationStarted event(or Tap Event ) of an image and that is causing App poor responsiveness when we perform store monitoring test in V2012.
Xaml Image control -
<Image HorizontalAlignment="Left" Height="100" VerticalAlignment="Top"
Width="104" Margin="90,60,0,0" Grid.Row="1"
ManipulationStarted="Image_ManipulationStarted_1"
Source="Background.png"/ >
Event Code –
private void Image_ManipulationStarted_1(object sender,
ManipulationStartedEventArgs e)
{
var m = MessageBox.Show("The file will be saved here.", "File Save", MessageBoxButton.OKCancel);
if (m == MessageBoxResult.OK)
{
int temp = 10;
}
}
When I perform "Automated tests" in open store test kit for above sample code, it is causing poor responsiveness and that cause to certification failure when we upload app the the market place. Here are the steps -
Right click on Application Name in the solution explore in Visual Studio 2012
Open store test kit -> Automated test -> Start Windows Phone Analysis -> Select App Analysis -> Click on Start Session (App will start)
Application Will start running
Perform the Tap event on the image, MessageBox will appear and click OK.
Click on End Session (App Will Exit) in V2012.
The result of App Analysis will be shown in Summary. In that summary you can see the Red Line in front of Responsiveness means the application responsiveness is poor which causes certification failure.
My requirement is like that only. I have one image (As a Button) and on click i.e Tap i want to do some operation.
Note – Build is targeted to WP7 but application is running on WP8 emulator.
Regards
Mukesh Sharma
Putting up a modal dialog inside an event handler will lock up the calling thread until the dialog is dismissed. That may give poor responsiveness rating.
What you may want to try is to in the event handler just disable the image for manipulation and dispatching the MessageBox to a time after the event handler has returned, something like (the untested);
private void Image_ManipulationStarted_1(object sender,
ManipulationStartedEventArgs e)
{
// <disable image manipulation here>
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
var m = MessageBox.Show("The file will be saved here.",
"File Save", MessageBoxButton.OKCancel);
if (m == MessageBoxResult.OK)
{
int temp = 10;
}
// <enable image manipulation again>
}
}
Related
I have discovered the limitation of displaying prompts when they are invoked from a popup window. Specifically verified with CommunityToolkit.Maui Popups.
Here's the details:
In the Map page I have this handler for the map clicked event:
void mapClicked(object sender, MapClickedEventArgs e) {
var pin = new Pin {
Label = "Here's where it is",
Location = e.Location
};
map.Pins.Add(pin);
}
I wanted to allow the user to edit the pin label when clicking on the it, like so:
pin.InfoWindowClicked += async (s, args) => {
string pinName = ((Pin)s).Label;
await DisplayPromptAsync("Enter new label", "enter new label");
};
However, this didn't work as no DisplayPrompt was shown. I tried running it in the main thread, to no avail either.
UPDATE. I've figured it out, see answer below.
The problem arises when attempting to bring up the prompt from a popup window. Evidently, one can't have a DisplayPromptAsync (or DisplayAlert for that matter) on top of a popup.
On a platform-specific level in iOS the error message reads:
Attempt to present <UIAlertController> on <Microsoft_Maui_Controls_Platform_Compatibility_ShellFlyoutRenderer> (from <Microsoft_Maui_Controls_Platform_Compatibility_ShellFlyoutRenderer>) which is already presenting <CommunityToolkit_Maui_Core_Views_MauiPopup>.
I have a winform app in visual studio. On the main interface I have panels ( home panel, about us panel & contact us panel ). When I click the button that takes me to the home panel, I want the video to be there already( in Windows media player obviously ). And to be played automatically when the “ home panel button “ is clicked. The client shouldn’t have to go and look for the video.
Is there a way to do this?
Please help.
Add WMP control to the "Toolbox" panel in Visual Studio: https://learn.microsoft.com/en-us/windows/desktop/wmp/using-the-windows-media-player-control-with-microsoft-visual-studio
Drag WMP control from Toolbox to your Home panel in the form designer.
Add the video to the project and in it's properties, choose "Copy if newer" in "Copy to Output Directory" option.
Override Form.OnLoad or find another suitable place and add code that gives the player the URL of the video and sets other properties.
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var location = Assembly.GetExecutingAssembly().Location;
var folder = Path.GetDirectoryName(location);
var path = Path.Combine(folder, "small.avi");
axWindowsMediaPlayer1.URL = path;
axWindowsMediaPlayer1.uiMode = "none";
// autoplay if current page index is 0 (home?)
if (tabControl1.SelectedIndex == 0)
axWindowsMediaPlayer1.Ctlcontrols.play();
}
If you want the player to restart playback everytime the page gets displayed, add handler to TabControl.SelectedIndexChanged event:
this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.TabControl1_SelectedIndexChanged);
and implement it like this:
private void TabControl1_SelectedIndexChanged(object sender, EventArgs e)
{
if (tabControl1.SelectedIndex == 0)
axWindowsMediaPlayer1.Ctlcontrols.play();
}
Following the Embarcadero docs at this link i'm testing notifications on iOS (in FMX app built with C++). I've done the follownig:
Added #include <System.Notification.hpp> to the header file
Set FMLocalNotificationPermission to true
Dropped TNotificationCenter component on the form
Then, i put the following code in a button click:
void __fastcall TForm1::ScheduleNotificationClick(TObject *Sender)
{
if (NotificationCenter1->Supported()) {
TNotification *myNotification = NotificationCenter1->CreateNotification();
__try {
myNotification->Name = "MyNotification";
myNotification->AlertBody = "C++ for your mobile device is here!";
// Fire in 10 seconds
myNotification->FireDate = Now() + EncodeTime(0, 0, 10, 0);
// Send notification to the notification center
NotificationCenter1->ScheduleNotification(myNotification);
}
__finally {
myNotification->DisposeOf();
}
}
}
Once in a while it works...but rarely and never more than once. Most of the time it doesn't at all (repeated deleting and reinstall of app).
Next, i tried the "Present the Notification Message Immediately" code they provide:
void __fastcall TForm1::PresentNotificationClick(TObject *Sender)
{
if (NotificationCenter1->Supported()) {
TNotification *myNotification = NotificationCenter1->CreateNotification();
__try {
myNotification->Name = "MyNotification";
myNotification->AlertBody = "C++ for your mobile device is here!";
// Set Icon Badge Number (for iOS) or message number (for Android) as well
myNotification->Number = 18;
myNotification->EnableSound = False;
// Send notification to the notification center
NotificationCenter1->PresentNotification(myNotification);
}
__finally {
myNotification->DisposeOf();
}
}
}
Nothing happens at all with this code. I've tried this from scratch several times and i'm as sure as i can be that i'm coding it per their examples. I'm using 10.3 (Embarcadero® C++Builder 10.3 Version 26.0.32429.4364). I would think my code has a problem except once in blue moon it works.
My target is iPhone running 12.1.4 and i've tried building with SDK11.4 and SDK12.0, no difference. When i first run app i get the "allow or don't allow" popup and my app subsequently shows up in the Notification settings - just doesn't work.
russ
UPDATE 3-25-2019: If I run that top block of code (from a button click on iPhone) it will now run everytime - but ONLY IF i immediately kill the app after clicking. 10 seconds later it fires the notification. Why won't the notification appear if i leave my app running??
Are you sure you are calling "PresentNotificationClick" from the TButton when you click it?
All is in the title. I'm actually developing a kind of image gallery and I would like the user slip with one finger to the right to see the next picture and to the left picture for the previous. Whence my question : Is there a way to capture the event when the user slip his finger on the screen in Windows Phone?
You can use the GestureService in the Silverlight Control Toolkit for Windows Phone. In your UI element, add the following piece of code.
XAML:
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="OnFlick"/>
</toolkit:GestureService.GestureListener>
.cs:
private void OnFlick(object sender, FlickGestureEventArgs e)
{
var vm = DataContext as SelectedCatalogViewModel;
if (vm != null)
{
// User flicked towards left
if (e.HorizontalVelocity < 0)
{
// Load the next image
LoadNextPage(null);
}
// User flicked towards right
if (e.HorizontalVelocity > 0)
{
// Load the previous image
LoadPreviousPage();
}
}
}
Have a look here : Implement Swipe event on WP8
Hope it helps!
I'm looking for a photo gallery for Windows Phone 7. Something that looks and works the same as the built-in photo viewer (slide photo's using a flick action, resize using pinch, drag). When you flick the image you can see it sliding to the next image...and snaps the list to that image.
I already built the resize and drag functionality for the images. I just can't figure out how to create the actual photo slider.
Can anyone point me into the right direction?
Things i've tried:
Pivot Viewer (doesn't work because it interferes with the drag functions of the image, haven't been able to disable the pivot viewer touch)
Plain listbox (can't find how to snap to the current image)
Thanks in advance
Actually I've implemented exactly what you are saying in one of my apps,
You need to use Silverlight Control TOolkit's gesture listener to capture Drag and Pinch from touch.
define a CompositeTransformation for your image and set it's scale (on pinch) and Offset (in drag).
Obviously when the image is not zoom, drag can trigger going to next image.
To make it feel smoother, you may want to define a storyboard on your page resources to use (instead of just settings Offset)
I hope it can help/
Drag handlers pseudo code for slider effect:
<Canvas>
<Image x:Name="imgImage" Source="{Binding ...}" Width="..." Height="...">
<Image.RenderTransform>
<CompositeTransform x:Name="imgImageTranslate" />
</Image.RenderTransform>
</Image>
</Canvas>
private void GestureListener_DragCompleted(object sender, DragCompletedGestureEventArgs e)
{
if (e.Direction == System.Windows.Controls.Orientation.Horizontal)
{
var abs = Math.Abs(PANEL_DRAG_HORIZONTAL);
if (abs > 75)
{
if (PANEL_DRAG_HORIZONTAL > 0) // MovePrevious;
else //MoveNext();
e.Handled = true;
}
}
}
double PANEL_DRAG_HORIZONTAL = 0;
private void GestureListener_DragDelta(object sender, DragDeltaGestureEventArgs e)
{
if (e.Direction == System.Windows.Controls.Orientation.Horizontal)
{
PANEL_DRAG_HORIZONTAL += e.HorizontalChange;
var baseLeft = -imgImage.Width / 2;
if (PANEL_DRAG_HORIZONTAL > 75) imgImageTranslate.OffsetX = baseLeft + PANEL_DRAG_HORIZONTAL;
else if (PANEL_DRAG_HORIZONTAL < -75) imgImageTranslate.OffsetX = baseLeft + PANEL_DRAG_HORIZONTAL;
else imgImageTranslate.OffsetX = baseLeft;
}
}
}
private void GestureListener_DragStarted(object sender, DragStartedGestureEventArgs e)
{
PANEL_DRAG_HORIZONTAL = 0;
}
What about using a ScrollViewer with horizontal orientation? Of course, you will have to manually detect user actions and implement the proper response (with a couple of properly set Storyboards).
Even a better approach would be writing your own custom control that will view images. A good place to start is this - a CoverFlow control in Silverlight. Once you get the idea how you can bind your image collection to a custom control, all you need is handle user gestures on the currently selected item.