static IToastProvider GetImplementation() { if (implementation == null) { implementation = Xamarin.Forms.DependencyService.Get <IToastProvider>(); } return(implementation); }
/// <summary> /// Opens the tab. /// </summary> /// <param name="toastProvider">Provides a surface for displaying toast messages to the user.</param> /// <exception cref="OperationCanceledException">The user has been informed of an error and has confirmed the resulting cancellation.</exception> public void Open(IToastProvider toastProvider) { ToastProvider = toastProvider; Show(); if (!_startupDone) { Application.DoEvents(); // Load the file data for the tab try { OnInitialize(); } #region Error handling catch (OperationCanceledException) { OnClose(); throw new OperationCanceledException(); } //catch (ArgumentException) //{ // Msg.Inform(this, Resources.InvalidFilePath, MsgSeverity.Error); // OnClose(); // throw new OperationCanceledException(); //} catch (NotSupportedException) { Msg.Inform(this, Resources.InvalidFilePath, MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } catch (FileNotFoundException ex) { Msg.Inform(this, Resources.FileNotFound + "\n" + ex.FileName, MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } catch (IOException ex) { Msg.Inform(this, Resources.FileNotLoadable + "\n" + ex.Message, MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } catch (UnauthorizedAccessException ex) { Msg.Inform(this, Resources.FileNotLoadable + "\n" + ex.Message, MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } catch (InvalidDataException ex) { Msg.Inform(this, Resources.FileDamaged + "\n" + ex.Message + (ex.InnerException == null ? "" : "\n" + ex.InnerException.Message), MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } catch (Direct3D9NotFoundException) { Msg.Inform(this, Resources.DirectXMissing, MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } catch (Direct3DX9NotFoundException) { Msg.Inform(this, Resources.DirectXMissing, MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } catch (Direct3D9Exception ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } catch (SlimDX.DirectSound.DirectSoundException ex) { Msg.Inform(this, ex.Message, MsgSeverity.Error); OnClose(); throw new OperationCanceledException(); } #endregion } // Initialize/update the data display try { OnUpdate(); } #region Error handling catch (NotSupportedException) { Msg.Inform(this, Resources.InvalidFilePath, MsgSeverity.Error); ForceClose(); throw new OperationCanceledException(); } catch (FileNotFoundException ex) { Msg.Inform(this, Resources.FileNotFound + "\n" + ex.FileName, MsgSeverity.Error); ForceClose(); throw new OperationCanceledException(); } catch (IOException ex) { Msg.Inform(this, Resources.FileNotLoadable + "\n" + ex.Message, MsgSeverity.Error); ForceClose(); throw new OperationCanceledException(); } catch (UnauthorizedAccessException ex) { Msg.Inform(this, Resources.FileNotLoadable + "\n" + ex.Message, MsgSeverity.Error); ForceClose(); throw new OperationCanceledException(); } catch (InvalidDataException ex) { Msg.Inform(this, Resources.FileDamaged + "\n" + ex.Message + (ex.InnerException == null ? "" : "\n" + ex.InnerException.Message), MsgSeverity.Error); ForceClose(); throw new OperationCanceledException(); } #endregion // Replace the "Loading" message with the actual title Text = NameUI + @": " + Path.GetFileName(FilePath); _startupDone = true; }