Turn off default sound when displaying MessageBox in WP7 - c#

Is there a way to turn off the sound that the Messagebox plays when it is displayed in WP7?

There's no way to change this behaviour with the Silverlight MessageBox class. If, however, you use Guide.BeginShowMessageBox (from the XNA libraries) you can control whether sounds are played or not.

No, currently there is no way you can disable the sound that is triggered by the MessageBox class. That is a feature tied to the system and unless the device is on mute, the sound will be played.
With XNA's async version you can do this, though (as mentioned by Matt):
Guide.BeginShowMessageBox("Title", "Text", new List<string>() { "OK" }, 0, MessageBoxIcon.None, new AsyncCallback(YourCallback), null);
Here, MessageBoxIcon defines the sound and not the icon (which is nonexistent on Windows Phone for a MessageBox).
Note: you need yo add a reference to Microsoft.Xna.Framework.GamerServices.

Related

Keyboard not showing when being prompted by UITextField

In iOS 13.2, I'm noticing that my keyboard no longer shows up in my apps on the simulator and a real device. When I tap inside a UITextField, nothing happens but the cursor blinking inside the textfield. Is anyone else having this problem or know how to solve?
UPDATE
The problem originates from removing storyboard files and initiating a rootViewController programmatically
var windowScene = new UIWindowScene(session, connectionOptions);
Window = new UIWindow(windowScene);
Window.RootViewController = new ViewController();
Window.MakeKeyAndVisible();
After that, I just noticed the keyboard doesn't show again in a new project.
This looks like a bug when you try use a programatic approach to setting a rootViewController in the new SceneDelegate opposed to how we used to in AppDelegate.
I got around this by keeping the dumb storyboard which sets the rootViewController inside and keeping SceneDelegate.cs clean for the moment and my keyboard works again. Thanks for all your answers.
set textfiled delegate.
#IBOutlet weak var urlTextField: UITextField!
override func viewDidLoad() {
self.urlTextField.delegate = self // urlTextField it is your textfield outlet
}
If you delete this line of code, the keyboard does not appear, but if this exists, the keyboard does come up.
About simulator : You can check setting in iOS simulator firsrt .
Have a look at this screenshot ,be sure Use Hardware Keyboard not be selected . Or you can select it and unselect it again , then keyboard will show.
Restart app to check whether keyboard can be shown.

Playing a video without opening another window or having the buttons

I have a C# WinForms application, when you press a button at run-time, the application has to play a video but not in another new window, I want it to be in the form itself, also I don't have to see the Play/Pause/Stop etc. buttons of the Windows Media Player, just to have the video playing and when it ends return to the beginning where the button is situated. I couldn't find a question similar to this one, anyone has any ideas ? If any more information is needed just let me know.
Thanks alot!
Using Windows Media Player Control:
You can hide control buttons by setting uiMode property to none.
You can enable loop mode using settings.setMode method and setting loop to true
You can set a file path to play, by assign a path to URL property.
Since the settings.autoStart property is true by default, when you set the url, the player plays the media. Also you can use commands like Ctlcontrols.play or other control commands.
Sample Code
this.axWindowsMediaPlayer1.uiMode = "none";
this.axWindowsMediaPlayer1.settings.setMode("loop", true);
this.axWindowsMediaPlayer1.URL = #"d:\video1.wmv";
Resources
How to: Embed Windows Media Player on a Form
AxWindowsMediaPlayer Object Properties, Methods and Events

Is my code legal in Android usage?

I asked a question recently about how to disable the back button is Android, after a while I got it working with these lines of code
public override void OnBackPressed ()
{
// base.OnBackPressed (); /* Comment this base call to avoid calling Finish() */
// Do nothing
}
And just recently someone commented this
Disabling the back button is counter-intuitive and breaks the device
usage contract imposed by Android. So i suggest you rethink.
-Question-
What would be a possible change to this? I dont want to be able to press the back button when playing my quiz game because that would make be able to cheat. New to android Development
Instead of simply making the back button do nothing, you could have it create a popup asking something along the lines of "Are you sure you want to leave the quiz? (This will count as a loss)". And have it take the user back to the main page of your app if he confirms (instead of back to the previous page).
Why not imitate what many websites do and make it so going 'back' to a page works but doesn't display any information?
It depends on your code, but perhaps you can make your buttons and text (or whatever it is you don't want them interacting with) change to be unseen whenever they move on to a new page. Or just throw up a message that says 'You can't do that' to cover the page that they'll only ever see if they go back to view it again.

MediaElement possible memory leak on new media load?

I am developing WPF app for a media player in c# and I am using the mediaElement control to host media.
As I want the user to be able to load both video and images in the player, I ve made a simple if-then-else statement inside the mediaOpened event, to check every time that a new media is loaded, if it hasTimespan (and therefor the player sees it as a video) or else as a picture.
To check if this if/else statement was working, I placed a message box in each case to give me feedback that indeed the player recognizes correctly the media type.
So far so good.
I load a video, everything goes as expected and I get my message box saying "video!".
But when I load a 2nd video the message box appears 2 times.
When I load one more video, the message box appears 3 times!
Even weirder, if I load a picture next, the message box appears 4 times but instead of a sequence of message boxes like this,
"video!" "video!" "video!" "picture!", I get
"picture!" "picture!" "picture!" "picture!".
It seems that the player is storing the media (or the mediaOpened events) in some kind of a list and every time I load a new one, it checks all the media in that list and gives me a message for each one. (I haven't wrote any code to support a playlist feature yet, so I don't know where these media could be being stored...)
I ve tried stating the mediaElement's source as null when the user presses the load new media button, to make sure the mediaElement source is clean before the new media gets loaded, but it did not have any effect.
Does this sound like a memory leak?
Am I missing a specific unloading event that I should call upon media change?
Thank you!
So it turns out that in most online examples on how to develop a mediaplayer,
everybody suggests using this next line upon clicking the load button in the player:
mediaElement.MediaOpened += new RoutedEventHandler(mediaElement_MediaOpened);
but no one seems to be aware that these media need to be unloaded when you load a new one, which is possible by placing the exact opposite, before we set the new source of the media element, so it would be in this order for example:
mediaElement.MediaOpened -= new RoutedEventHandler(mediaElement_MediaOpened);
mediaElement.Source = new Uri(dlg.FileName);
mediaElement.MediaOpened += new RoutedEventHandler(mediaElement_MediaOpened);
Hope this helps somebody out there!

C# WinForms Wait on form to proceed

I'm tired and hungry, so I might of missed it, but from what I can see no existing post covers this...
I'm writing a plugin for an application. My plugin loads a form to get some data specifically, it uses the webcam to scan for a barcode. Once it's found a barcode, the form hides itself (incase it's needed again later). This is how I currently call the form that does the barcode work:
string readData = null;
if (eye == null)
{
System.Windows.Forms.Application.EnableVisualStyles();
eye = new CamView();
}
eye.Show();
if (eye.found)
{
readData = eye.readData;
}
return readData;
So, my problem is that eye.show() doesn't block. It makes the form appear and carries right on before there's a chance for the barcode to appear. I imagine I need to use some form of threading or locking, but my crude attempts to do so have just frozen the interface completely.
The "eye" form is basically just a viewfinder for the webcam, and relies on the camera_OnImageCapture event to make it do it's image checks for the barcode.
Is there an elegant way to make the application calling the plugin wait for the form to finish? Or do I just need to add an accept button to the "eye form?"
Cheers. And humble apologies if this is in anyway a repost.
.ShowDialog();
http://msdn.microsoft.com/en-us/library/c7ykbedk.aspx
"You can use this method to display a modal dialog box in your application. When this method is called, the code following it is not executed until after the dialog box is closed."
You are on the right track. You change the code to show CamView as a modal dialog but do no add an Accept button. Instead change camera_OnImageCapture to close the dialog.

Categories