Orientation of PhoneApplicationPage not changing when message box is displayed WIndows phone - c#

In my Windows phone application, when the message box is displayed and if the phone is rotated, only the message box is getting rotated, whereas the UI behind it remains in the previous orientation.
It seems like the "Orientation changed" event of the page is not getting triggered when the message box is being displayed.
Although the UI behind the message box is not so prominent, I could find that the native messaging app of windows phone follows this behavior. I mean if the message box is displayed and the orientation is changed, the list behind the message box is also changed.
This image is of the native messaging app.
This image is from my application
You can notice the list behind the both the images.
Can I get some help in achieving this behavior ?

MessageBox.Show(string msg) is a synchronized method, meaning the method won't return until you dismiss the message box by pushing one of its buttons. So UI thread is blocked, and the OrientationChanged is only handled after the message box is dismissed since the event handler is running on UI thread, too.
MessageDialog.ShowAsync, which is only available on Windows Phone 8.1, should not have this limitation.
One alternative to MessageBox is the Popup control. You can lay it on top of your page, and set it IsOpen to true/false to show/hide it. Make it look good on both Landscape and Portrait orientations using ViewStates, just like other normal controls.

Related

Keyboard shows up after textbbox clicked ,then the mobile view scrolls wrong

The websites are MVC C# with kendo UI. It is no problem with the computer and ios phone(iphone) devices.But on Android, if the user clicked the website's textbox, the keyboard shows up and the websites scrolls, the user can not see the focus of the textbox. On the computer and ios phone, the user clicks the textbox,the view stands still and does not scroll. So I use the following CSS code on javascript of cshtml to fix:
#media screen and (max-width: 580px) and (max-height: 350px)and (min-height: 200px){
html {
display:block!important;
overflow:hidden!important;
}
}
If the textbox has clicked, the keyboard shows up and makes view smaller. While the view is smaller, the view can't scroll and it reveals the same correct view with a computer device and ios phone. But, it is only correct on some Android devices.So how can I use CSS to make the view of the website does not scroll when the keyboard shows up on Android phone device? Thanks!
The following is success case in ios phone device:
1.website
2.select event and open event window
3.Scroll down to the textbox
4.scroll down the textbox and focus the the end part of the text in textbox ,then keyboard shows up.It's no problem on this ios phone case ,but on android phone case,it will scroll up to wrong place.

.NET NotifyIcon displays a toast notification twice in Windows 10

I use the .NET Framework System.Windows.Forms.NotifyIcon class to display a tray icon and tray notifications. When I call ShowBalloonTip on its instance, first the previously displayed notification displays again, then it hides, and only after a while does the expected one is displayed. It seems that historical notifications are displayed first unless I remove them manually from the notification center.
What can I do programmatically to prevent showing the historical notifications again?
Here's how I initialize the notify icon:
notifyIcon.Icon = Properties.Resources.tray_icon;
notifyIcon.Visible = true;
notifyIcon.BalloonTipTitle = Language.TrayMessageTitle;
Here's how I show the toast:
notifyIcon.BalloonTipIcon = icon;
notifyIcon.BalloonTipText = message;
notifyIcon.ShowBalloonTip(0);
The icon is either ToolTipIcon.Error or ToolTipIcon.Info, and I don't show a toast with the same icon twice, so they always toggle. But this does not seem to matter.
The timeout param is 0, because it's not used since Windows Vista.
The toast is displayed as a result of an application state change, not as a result of a user action like clicking.
So I decided to stick with disposing the notify icon instance and recreating it every time I display a toast notification. I don't think it's fine, but I couldn't find a better solution.
I also dispose the notify icon on application shutdown to clean the notification center from previously displayed notifications. Otherwise, the last one displays first when another application displays a toast.

WinRT MediaElement: Detect changes from fullscreen to normal when IsFullWindow is true and AreTransportControlsEnabled is true

Context: WinRT, Universal Apps, XAML, C#
I am creating a video player application in which one of the requirements is that the video plays exclusively in fullscreen, and when the video returns from fullscreen, the video should be stopped and the user should be taken to a summary page. Currently I am using MediaElement.IsFullWindow and MediaElement.AreTransportControlsEnabled in order to play the video in fullscreen and it works perfectly well, when the video ends I grab the MediaEnded event and take the user back to the summary page, setting IsFullWindow to false and AreTransportControlsEnabled to false.
The only problem is that Transport Controls have a fullscreen button that takes the user back to the non-fullscreen layout and the video keeps on playing.
On most applications this would be great, but on this one, I need to stop the video when it happens.
Unfortunately, when this happens, IsFullWindow is not set to false, the SizeChanged event for the MediaElement is not fired and there seems to be no other notification that the user has decided to leave fullscreen mode.
So I am trapped in a situation in which I am unable to find out whether the video is truly playing in fullscreen or not.
If I pause the video and the user plays it again, since IsFullWindow is true, it will go back to fullscreen and if I let the video play to the end everything works fine and the user goes to the summary page.
Does anybody have any suggestions on how I may be able to detect this change in order to stop the video?
An alternative solution is not to use transport control provided by media element and create your own custom media controls .
See this MSDN link which explains how to create custom media transport controls
When changed IsFullWindow status fires SizeChanged of Window.Current instead of MediaElement. You just should attach to this event
Window.Current.SizeChanged += this.OnWindowSizeChanged;
and check IsFullWindow of MediaElement when it fired.
private void OnWindowSizeChanged(object sender, WindowSizeChangedEventArgs windowSizeChangedEventArgs)
{
if (!this.mediaElement.IsFullWindow)
{
}
else
{
}
}
I ended up using the Microsoft Player Framework which gives me events and properties to control all I needed without having to write my own code and incur in design work for the video player control assets.
You can overcome this issue by binding, IFullWindow MediaElement property with "TwoWay" mode, and act accordingly to its value on set :)
You may use a DispatcherTimer called every 100 ms, check the status of the IsFullWindow property, and if property value changes, fire an event or call your own function.

How show an UIElement like MessageBox in current display frame. [ Windows Phone 8.0+ ]

My question is how can I show an UIElement for some time (ex. 5s) in current display frame when application is running foreground. Example ToastPrompt from Coding4Fun library or native MessageBox. My goal is to show something like Android style Toast Notification. Can you give me some help?
Here is what I want make but on Windows Phone:
You can create custom UserControl with layout you need and animation to display it for seconds
When you need to show your UserControl - get an instance of current Page ((App.Current as App).RootFrame and find root element to add your control to. Look at VisualTreeHelper class, which can help you to do this

C# progress bar not synced with download (WebClient class)

I am coding a system which has a small FTP module included inside, it's not the main feature at all, but needed...
I must link the progressbar with the WebClient class event DownloadProgressChangedEventHandler and AsyncCompletedEventHandler, the progressbar increment is ok, and the ASyncCompletedEventHandler launch a MessageBox (as intended), the problem is that the progress bar see to load too slow...
problem :
My MessageBox pop at 100% (launched by the event handler), BUT when the MessageBox pop my progress bar is only at +-80% (but the .VALUE is really 100), the first though I had was that they have added a "smooth" effect in Windows Vista which slow down the progressbar relatively to it's true value.
If any of you have experienced the same problem thanks for your help.
For those of you who want to know, Vista actually add a "smoothing" to the loadingbar change, it look like the "Tweening effect" of Flash.
I tried on Windows XP and the bar reach 100% exactly when the value reach 100. On Vista it look like they have decided that the "loading" would be splitted over a delay X.
Before you display your message box, call Application.DoEvents() to force all the pending Windows queued messages to be processed. Your progress bar is probably not getting a chance to paint itself one last time before the message box displays.
Why not simply set the progress bar value to 100% on the same DownloadProgressChangedEventHandler event handler that displays the message box?

Categories

Resources