protected override IMvxPhoneViewsContainer CreateViewsContainer(PhoneApplicationFrame rootFrame) { var viewsContainer = new MultiAssemblyViewsContainer(); var viewFinder = new LazyViewFinder(() => typeof(ThirdView).Assembly); viewsContainer.AddSecondary(viewFinder); return viewsContainer; }
public static void Configure(Container container, PhoneApplicationFrame root) { container.Register<IJiraService>(c => new JiraService{Store = c.Resolve<IDocumentStore>()}); container.Register<IScheduler>(c => new Scheduler()); container.Register(c => new SignInCommandHandler{Bus = c.Resolve<IBus>()}); container.Register(c => new SyncHandler{Bus = c.Resolve<IBus>(), Jira = c.Resolve<IJiraService>()}); container.Register( c => new SyncProjectHandler { Bus = c.Resolve<IBus>(), Store = c.Resolve<IDocumentStore>(), Jira = c.Resolve<IJiraService>(), Scheduler = c.Resolve<IScheduler>() }); container.Register(c => new SyncNewlyDiscoveredProjectsByDefaultHandler {Bus = c.Resolve<IBus>()}); container.Register(c => new ProfileLoggedInEventHandler { Store = c.Resolve<IDocumentStore>() }); var bus = container.Resolve<IBus>(); bus.RegisterHandler<SignInCommandHandler, SignInCommand>(); bus.RegisterHandler<SyncHandler, ApplicationLoadedEvent>(); bus.RegisterHandler<ProfileLoggedInEventHandler, LoggedInEvent>(); bus.RegisterHandler<SyncHandler, LoggedInEvent>(); bus.RegisterHandler<SyncProjectHandler, ProjectsDiscoveredEvent>(); bus.RegisterHandler<SyncProjectHandler, SyncProjectCommand>(); bus.RegisterHandler<SyncNewlyDiscoveredProjectsByDefaultHandler, DiscoveredNewProjectEvent>(); }
public NavigationServiceFacade(PhoneApplicationFrame frame) { if (frame == null) throw new ArgumentNullException("frame"); this.frame = frame; }
/// <summary> /// Initializes a new instance of the <see cref="WindowsPhoneBootstrapperBase" /> class. /// </summary> protected WindowsPhoneBootstrapperBase([NotNull] PhoneApplicationFrame rootFrame, PlatformInfo platform = null) : base(platform ?? PlatformExtensions.GetPlatformInfo()) { Should.NotBeNull(rootFrame, "rootFrame"); _rootFrame = rootFrame; PhoneApplicationService.Current.Launching += OnLaunching; }
/// <summary> /// Initializes the application context for use through out the entire application life time. /// </summary> /// <param name="frame"> /// The <see cref="T:Microsoft.Phone.Controls.PhoneApplicationFrame" /> of the current application. /// </param> public static void Initialize(PhoneApplicationFrame frame) { // Initialize Ioc container. var kernel = new StandardKernel(); kernel.Bind<Func<Type, NotifyableEntity>>().ToMethod(context => t => context.Kernel.Get(t) as NotifyableEntity); kernel.Bind<PhoneApplicationFrame>().ToConstant(frame); kernel.Bind<INavigationService>().To<NavigationService>().InSingletonScope(); kernel.Bind<IStorage>().To<IsolatedStorage>().InSingletonScope(); kernel.Bind<ISerializer<byte[]>>().To<BinarySerializer>().InSingletonScope(); kernel.Bind<IGoogleMapsClient>().To<GoogleMapsClient>().InSingletonScope(); kernel.Bind<IDataContext>().To<DataContext>().InSingletonScope(); kernel.Bind<IConfigurationContext>().To<ConfigurationContext>().InSingletonScope(); Initialize(kernel); // Initialize event handlers and other properties. GeoCoordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) {MovementThreshold = 10D}; ((DataContext) Data).AppVersion = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version; Data.PreventScreenLock.ValueChanged += (old, @new) => { PhoneApplicationService.Current.UserIdleDetectionMode = @new ? IdleDetectionMode.Disabled : IdleDetectionMode.Enabled; }; Data.UseLocationService.ValueChanged += (old, @new) => { if (@new) GeoCoordinateWatcher.Start(); else GeoCoordinateWatcher.Stop(); }; IsNetworkAvailable = NetworkInterface.GetIsNetworkAvailable(); NetworkChange.NetworkAddressChanged += (s, e) => IsNetworkAvailable = NetworkInterface.GetIsNetworkAvailable(); }
public PhoneModule(PhoneApplicationFrame frame, IScheduler dispatcher) { if (frame == null) throw new ArgumentNullException("frame"); if (dispatcher == null) throw new ArgumentNullException("dispatcher"); _frame = frame; _dispatcher = dispatcher; }
public NotificationService( PhoneApplicationFrame RootFrame, [Dispatcher] IScheduler Dispatcher ) { RootFrame.Navigated += OnFrameNavigated; NotificationScheduler = Dispatcher; }
public void OpenPickerPage() { if (null == PickerPageUri) { throw new ArgumentException("PickerPageUri property must not be null."); } if (null == _frame) { _frame = Application.Current.RootVisual as PhoneApplicationFrame; if (null != _frame) { _frameContentWhenOpened = _frame.Content; // Save and clear host page transitions for the upcoming "popup" navigation UIElement frameContentWhenOpenedAsUIElement = _frameContentWhenOpened as UIElement; if (null != frameContentWhenOpenedAsUIElement) { _savedNavigationInTransition = TransitionService.GetNavigationInTransition(frameContentWhenOpenedAsUIElement); TransitionService.SetNavigationInTransition(frameContentWhenOpenedAsUIElement, null); _savedNavigationOutTransition = TransitionService.GetNavigationOutTransition(frameContentWhenOpenedAsUIElement); TransitionService.SetNavigationOutTransition(frameContentWhenOpenedAsUIElement, null); } _frame.Navigated += OnFrameNavigated; _frame.NavigationStopped += OnFrameNavigationStoppedOrFailed; _frame.NavigationFailed += OnFrameNavigationStoppedOrFailed; _frame.Navigate(PickerPageUri); } } }
public static void Configure(PhoneApplicationFrame rootFrame) { DocumentStore = new DocumentStore(); Container = new Container(); Container.Register<IDocumentStore>(c => new DocumentStore()); Container.Register<IBus>(c => new Bus(c)); Container.Register(c => new ActivityNewActivityHandler { Bus = c.Resolve<IBus>(), DocumentStore = DocumentStore }); Container.Register(c => new TestModeActivatedHandler { Bus = c.Resolve<IBus>() }); Container.Register(c => new ActivateTestModeHandler { Bus = c.Resolve<IBus>() }); Container.Register(c => new ClearCacheHandler { DocumentStore = c.Resolve<IDocumentStore>() }); Container.Register(c => new Contexts.Review.Domain.ClearCacheHandler { DocumentStore = c.Resolve<IDocumentStore>() }); var bus = Container.Resolve<IBus>(); bus.RegisterHandler<ActivityNewActivityHandler, NewActivityEvent>(); bus.RegisterHandler<TestModeActivatedHandler, TestModeActivatedEvent>(); bus.RegisterHandler<ActivateTestModeHandler, ActivateCommand>(); bus.RegisterHandler<Contexts.Settings.ClearCacheHandler, ClearCacheCommand>(); bus.RegisterHandler<Contexts.Review.Domain.ClearCacheHandler, ClearCacheCommand>(); Contexts.Import.Module.Configure(Container); Contexts.Import.ModuleUi.Configure(Container, rootFrame); Contexts.Review.Module.Confiure(Container); }
protected override PhoneApplicationFrame CreatePhoneApplicationFrame() { rootFrame = new PhoneApplicationFrame(); rootFrame.Navigated += rootFrame_Navigated; rootFrame.Navigating += rootFrame_Navigating; return rootFrame; }
private bool EnsureMainFrame() { if (_mainFrame != null) { return true; } _mainFrame = Application.Current.RootVisual as PhoneApplicationFrame; if (_mainFrame != null) { // Could be null if the app runs inside a design tool _mainFrame.Navigating += (s, e) => { if (Navigating != null) { Navigating(s, e); } }; return true; } return false; }
public void Initialize(PhoneApplicationFrame frame) { _mangoIndicator = new ProgressIndicator(); frame.Navigated += OnRootFrameNavigated; (frame.Content as PhoneApplicationPage).SetValue(SystemTray.ProgressIndicatorProperty, _mangoIndicator); }
/// <summary> /// Initializes the navigation service instance and sets the main application page. /// </summary> private void Initialize() { rootFrame = new TransitionFrame(); rootFrame.Navigated += OnNavigated; rootFrame.NavigationFailed += OnNavigationFailed; Application.Current.RootVisual = rootFrame; }
public static void Configure(Container container, PhoneApplicationFrame root) { container.Register(c => new SignInActivator { RootFrame = root }); var bus = container.Resolve<IBus>(); bus.RegisterHandler<SignInActivator, UnauthorizedNotLoggedInEvent>(); }
private void InitializePhoneApplication() { if (phoneApplicationInitialized) return; RootFrame = new PhoneApplicationFrame(); RootFrame.Navigated += CompleteInitializePhoneApplication; RootFrame.NavigationFailed += RootFrame_NavigationFailed; phoneApplicationInitialized = true; }
public void Initialize(PhoneApplicationFrame frame) { // If using AgFx: //DataManager.Current.PropertyChanged += OnDataManagerPropertyChanged; _mangoIndicator = new ProgressIndicator(); frame.Navigated += OnRootFrameNavigated; }
public ProgressService(PhoneApplicationFrame rootFrame) { _indicator = new ProgressIndicator {Text = DefaultIndicatorText}; rootFrame.Navigated += RootFrameOnNavigated; UpdateProgressBarAttachment(rootFrame.Content); }
public NavigationServiceAdapter(PhoneApplicationFrame frame) { this.frame = frame; this.frame.Navigated += frame_Navigated; this.frame.Navigating += frame_Navigating; this.frame.Obscured += frame_Obscured; this.RecoveredFromTombstoning = false; }
private bool EnsureMainFrame() { if (_mainFrame != null) return true; _mainFrame = Application.Current.RootVisual as PhoneApplicationFrame; if (_mainFrame != null) return true; return false; }
private bool IsMainFrame() { if (mainFrame != null) { return true; } mainFrame = Application.Current.RootVisual as PhoneApplicationFrame; return mainFrame != null; }
private void OpenPickerPage() { frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { frame.Navigated += FrameNavigated; frame.Navigate(new Uri("/Flashcards;component/Views/ListPickerPage.xaml", UriKind.Relative)); } }
protected override IMvxPhoneViewsContainer CreateViewsContainer(PhoneApplicationFrame rootFrame) { var viewsContainer = new MultiAssemblyViewsContainer(); var sometimesViewFinder = new LazyViewFinder(() => typeof(ProductEditing).Assembly); viewsContainer.AddSecondary(sometimesViewFinder); var rarelyViewFinder = new LazyViewFinder(() => typeof(ExportAndImport).Assembly); viewsContainer.AddSecondary(rarelyViewFinder); return viewsContainer; }
public PopupController() { _frame = Application.Current.RootVisual as PhoneApplicationFrame; if (_frame != null) { _frame.BackKeyPress += frame_BackKeyPress; _frame.OrientationChanged += _frame_OrientationChanged; } }
public void scan(string options) { Deployment.Current.Dispatcher.BeginInvoke(() => { this.currentRootVisual = Application.Current.RootVisual as PhoneApplicationFrame; this.currentRootVisual.Navigated += this.OnFrameNavigated; this.currentRootVisual.Navigate(new Uri("/Plugins/com.phonegap.plugins.barcodescanner/Scan.xaml", UriKind.Relative)); }); }
public ApplicationFrameNavigationService(PhoneApplicationFrame frame) { this.frame = frame; this.frame.Navigated += frame_Navigated; this.frame.Navigating += frame_Navigating; this.frame.NavigationFailed += frame_NavigationFailed; this.frame.NavigationStopped += frame_NavigationStopped; this.frame.FragmentNavigation += frame_FragmentNavigation; this.frame.JournalEntryRemoved += frame_JournalEntryRemoved; }
public async Task<bool> Download(string uri, string filename) { frame = (PhoneApplicationFrame)(System.Windows.Application.Current.RootVisual); await DownloadFileFromWeb(new Uri(uri), filename, CancellationToken.None); return true; }
protected override IMvxPhoneViewPresenter CreateViewPresenter(PhoneApplicationFrame rootFrame) { Forms.Init(); var xamarinFormsApp = new MvxFormsApp(); var presenter = new MvxFormsWindowsPhonePagePresenter(rootFrame, xamarinFormsApp); Mvx.RegisterSingleton<IMvxViewPresenter>(presenter); return presenter; }
public Setup(PhoneApplicationFrame rootFrame) : base(rootFrame) { // set up the Windows Phone Application Api Key AnalyticsApi.ApiKey = "VVBG8GG7Y99CKDMRFJ6X"; // Start the sessions specifically for Windows Phone PhoneApplicationService.Current.Launching += (sender, args) => AnalyticsApi.StartSession(); PhoneApplicationService.Current.Activated += (sender, args) => AnalyticsApi.StartSession(); }
public FrameNavigationService(PhoneApplicationFrame frame) { _frame = frame; if (_frame != null) { _frame.Navigating += Frame_Navigating; _frame.Navigated += Frame_Navigated; _frame.Unloaded += Frame_Unloaded; } }
// Do not add any additional code to this method private void InitializePhoneApplication() { if (_phoneApplicationInitialized) return; RootFrame = new PhoneApplicationFrame(); RootFrame.Navigated += CompleteInitializePhoneApplication; RootFrame.Navigated += CheckForResetNavigation; _phoneApplicationInitialized = true; }
/// <summary> /// Gets the correct width of a <see cref="T:PhoneApplicationFrame"/> in either orientation. /// </summary> /// <param name="phoneApplicationFrame">The <see cref="T:PhoneApplicationFrame"/>.</param> /// <returns>The width.</returns> public static double GetUsefulWidth(this PhoneApplicationFrame phoneApplicationFrame) { return(phoneApplicationFrame.IsPortrait() ? phoneApplicationFrame.ActualWidth : phoneApplicationFrame.ActualHeight); }
/// <summary> /// Permet de référencer la Frame Principale généré au lancement de l'application, pour la suite de la navigation /// </summary> /// <param name="rootFrame">Frame de navigation principale</param> public void InitializeRootFrame(PhoneApplicationFrame rootFrame) { _rootFrame = rootFrame; }
private void ShowInAppBrowser(string url) { Uri loc = new Uri(url, UriKind.RelativeOrAbsolute); Deployment.Current.Dispatcher.BeginInvoke(() => { if (browser != null) { //browser.IsGeolocationEnabled = opts.isGeolocationEnabled; browser.Navigate2(loc); } else { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { PhoneApplicationPage page = frame.Content as PhoneApplicationPage; if (!(System.Environment.OSVersion.Version.Major == 8 && System.Environment.OSVersion.Version.Minor == 0)) { SystemTray.SetIsVisible(page, false); } string baseImageUrl = "/www/Images/"; if (page != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { browser = new WebBrowser(); browser.IsScriptEnabled = true; browser.Background = new SolidColorBrush(Colors.Black); browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted); browser.Navigating += new EventHandler <NavigatingEventArgs>(browser_Navigating); browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed); browser.Navigated += new EventHandler <System.Windows.Navigation.NavigationEventArgs>(browser_Navigated); browser.Navigate2(loc); //if (StartHidden) //{ // browser.Visibility = Visibility.Collapsed; //} grid.Background = new SolidColorBrush(Colors.Black); var rowDef = new RowDefinition(); rowDef.Height = GridLength.Auto; grid.RowDefinitions.Insert(0, rowDef); buttons = new StackPanel(); buttons.HorizontalAlignment = HorizontalAlignment.Right; buttons.Orientation = Orientation.Horizontal; buttons.Visibility = Visibility.Collapsed; var backBitmapImage = new BitmapImage(new Uri(baseImageUrl + "ic_action_back.png", UriKind.Relative)); var backImage = new Image(); backImage.Source = backBitmapImage; backButton = new Button(); backButton.Content = backImage; backButton.Width = 100; backButton.BorderBrush = new SolidColorBrush(Colors.Black); //backButton.Text = "Back"; //backButton.IconUri = new Uri(baseImageUrl + "appbar.back.rest.png", UriKind.Relative); backButton.Click += new RoutedEventHandler(backButton_Click); buttons.Children.Add(backButton); var reloadBitmapImage = new BitmapImage(new Uri(baseImageUrl + "ic_action_refresh.png", UriKind.Relative)); var reloadImage = new Image(); reloadImage.Source = reloadBitmapImage; reloadButton = new Button(); reloadButton.Content = reloadImage; reloadButton.Width = 100; reloadButton.BorderBrush = new SolidColorBrush(Colors.Black); //reloadButton.IconUri = new Uri(baseImageUrl + "appbar.next.rest.png", UriKind.Relative); reloadButton.Click += new RoutedEventHandler(reloadButton_Click); buttons.Children.Add(reloadButton); Grid.SetRow(buttons, 0); grid.Children.Add(buttons); //browser.IsGeolocationEnabled = opts.isGeolocationEnabled; Grid.SetRow(browser, 1); grid.Children.Add(browser); } //if (ShowLocation) //{ // ApplicationBar bar = new ApplicationBar(); // bar.BackgroundColor = Colors.Black; // bar.IsMenuEnabled = false; // //ApplicationBarIconButton closeBtn = new ApplicationBarIconButton(); // //closeBtn.Text = "Close"; // //closeBtn.IconUri = new Uri(baseImageUrl + "appbar.close.rest.png", UriKind.Relative); // //closeBtn.Click += new EventHandler(closeBtn_Click); // //bar.Buttons.Add(closeBtn); // page.ApplicationBar = bar; // bar.IsVisible = !StartHidden; // AppBar = bar; //} page.BackKeyPress += page_BackKeyPress; } } } }); }
/// <summary> /// Get the response of user details web service /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void userdetailswebservicecall_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e) { LoginResponse objlgresponse = new LoginResponse(); try { if (e.Result != null) { var response = e.Result.ToString(); objlgresponse = Utils.JsonHelper.Deserialize <LoginResponse>(response); if (objlgresponse.status == 0) { objSignUpViewModel.ProgressBarVisibilty = Visibility.Collapsed; App.ObjLgResponse = objlgresponse; App.IsUserRegistered = true; App.IsPageUpdateYourDetailsafterLogin = true; App.YourDetailsLoginEmail = objSignUpViewModel.LoginEmail; App.SignUpPharId = objSignUpViewModel.LoginPharmacyID; PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual; if (objlgresponse.payload.status.Equals("Registered")) { if (objlgresponse.payload.verifyby.Equals("sms")) { frame.Navigate(new Uri(PageURL.navigateToVerificationBySMSURL, UriKind.Relative)); } else if (objlgresponse.payload.verifyby.Equals("mail")) { frame.Navigate(new Uri(PageURL.navigateToVerificationByEmailURL, UriKind.Relative)); } } else if ((objlgresponse.payload.status != "Rejected") && (App.IsPageYourDetailsafterLoginSaved)) { frame.Navigate(new Uri(PageURL.navigateToHomePanoramaURL, UriKind.Relative)); } else if ((objlgresponse.payload.status != "Rejected") && (App.IsPageUpdateYourDetailsafterLogin)) { frame.Navigate(new Uri(PageURL.navigateToYourDetailswithTCURL, UriKind.Relative)); } else { objSignUpViewModel.IsPopupOpen = true; objSignUpViewModel.PopupText = objlgresponse.message; objSignUpViewModel.HitVisibility = false; } } else if (objlgresponse.status == 301) { App.PIN = string.Empty; App.HashPIN = string.Empty; objSignUpViewModel.ProgressBarVisibilty = Visibility.Collapsed; objSignUpViewModel.IsIncorrectPinPopupOpen = true; objSignUpViewModel.IncorrectPinPopupText = objlgresponse.message; } else if (objlgresponse.status == 314) { App.ObjLgResponse = objlgresponse; objSignUpViewModel.ProgressBarVisibilty = Visibility.Collapsed; objSignUpViewModel.IsPopupOpen = true; objSignUpViewModel.PopupText = objlgresponse.message; } else if (objlgresponse.status == 308) { App.ObjLgResponse = objlgresponse; string displayTextonPopUp = string.Concat("You are about to change pharmacy.\nAll your orders from the previous pharmacy : ", App.ObjLgResponse.payload.pharmacyid, " will be automatically declined.\nAre you sure you want to proceed?"); objSignUpViewModel.ProgressBarVisibilty = Visibility.Collapsed; objSignUpViewModel.IsConfirmPopupOpen = true; objSignUpViewModel.HitVisibility = false; objSignUpViewModel.PopupTextDisplay = displayTextonPopUp; App.IsChangePharmacy = true; } else if (objlgresponse.status == 310) { objSignUpViewModel.ProgressBarVisibilty = Visibility.Collapsed; objSignUpViewModel.IsIncorrectPinPopupOpen = true; objSignUpViewModel.IncorrectPinPopupText = objlgresponse.message; App.IsUserNotExist = true; objSignUpViewModel.LoginEmail = string.Empty; } else { objSignUpViewModel.ProgressBarVisibilty = Visibility.Collapsed; objSignUpViewModel.IsPopupOpen = true; objSignUpViewModel.PopupText = objlgresponse.message; } } } catch (Exception) { objSignUpViewModel.ProgressBarVisibilty = Visibility.Collapsed; objSignUpViewModel.HitVisibility = true; MessageBox.Show("Sorry, Unable to process your request."); } }
public void Init(Syscalls syscalls, Core core, Runtime runtime) { PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual; double screenWidth = System.Windows.Application.Current.Host.Content.ActualWidth; double screenHeight = System.Windows.Application.Current.Host.Content.ActualHeight; if ((int)screenHeight == 0) { throw new Exception("screenHeight"); } PhoneApplicationPage mainPage = (PhoneApplicationPage)frame.Content; mMainImage = new Image(); mainPage.Width = screenWidth; mainPage.Height = screenHeight; mMainImage.Width = screenWidth; mMainImage.Height = screenHeight; mainPage.Content = mMainImage; mClipRect.X = 0.0; mClipRect.Y = 0.0; mClipRect.Width = screenWidth; mClipRect.Height = screenHeight; // no apparent effect on memory leaks. runtime.RegisterCleaner(delegate() { MoSync.Util.RunActionOnMainThreadSync(() => { mainPage.Content = null; }); }); mBackBuffer = new WriteableBitmap( (int)screenWidth, (int)screenHeight); mFrontBuffer = new WriteableBitmap( (int)screenWidth, (int)screenHeight); mMainImage.Source = mFrontBuffer; // clear front and backbuffer. for (int i = 0; i < mFrontBuffer.PixelWidth * mFrontBuffer.PixelHeight; i++) { mBackBuffer.Pixels[i] = mBackBuffer.Pixels[i] = (int)(0xff << 24); } mCurrentDrawTarget = mBackBuffer; mCurrentWindowsColor = System.Windows.Media.Color.FromArgb(0xff, (byte)(mCurrentColor >> 16), (byte)(mCurrentColor >> 8), (byte)(mCurrentColor)); syscalls.maSetColor = delegate(int rgb) { int oldColor = (int)mCurrentColor; mCurrentColor = 0xff000000 | (uint)(rgb & 0xffffff); mCurrentWindowsColor = System.Windows.Media.Color.FromArgb(0xff, (byte)(mCurrentColor >> 16), (byte)(mCurrentColor >> 8), (byte)(mCurrentColor)); return(oldColor & 0xffffff); }; syscalls.maSetClipRect = delegate(int x, int y, int w, int h) { MoSync.GraphicsUtil.ClipRectangle( x, y, w, h, 0, 0, mCurrentDrawTarget.PixelWidth, mCurrentDrawTarget.PixelHeight, out x, out y, out w, out h); mClipRect.X = x; mClipRect.Y = y; mClipRect.Width = w; mClipRect.Height = h; }; syscalls.maGetClipRect = delegate(int cliprect) { Memory mem = core.GetDataMemory(); mem.WriteInt32(cliprect + MoSync.Struct.MARect.left, (int)mClipRect.X); mem.WriteInt32(cliprect + MoSync.Struct.MARect.top, (int)mClipRect.Y); mem.WriteInt32(cliprect + MoSync.Struct.MARect.width, (int)mClipRect.Width); mem.WriteInt32(cliprect + MoSync.Struct.MARect.height, (int)mClipRect.Height); }; syscalls.maPlot = delegate(int x, int y) { mCurrentDrawTarget.SetPixel(x, y, (int)mCurrentColor); }; syscalls.maUpdateScreen = delegate() { //System.Array.Copy(mBackBuffer.Pixels, mFrontBuffer.Pixels, mFrontBuffer.PixelWidth * mFrontBuffer.PixelHeight); System.Buffer.BlockCopy(mBackBuffer.Pixels, 0, mFrontBuffer.Pixels, 0, mFrontBuffer.PixelWidth * mFrontBuffer.PixelHeight * 4); InvalidateWriteableBitmapOnMainThread(mFrontBuffer); }; syscalls.maFillRect = delegate(int x, int y, int w, int h) { // this function has a bug (it only fills one pixel less than the image.) //mCurrentDrawTarget.FillRectangle(x, y, x + w, y + h, (int)mCurrentColor); MoSync.GraphicsUtil.ClipRectangle( x, y, w, h, 0, 0, mCurrentDrawTarget.PixelWidth, mCurrentDrawTarget.PixelHeight, out x, out y, out w, out h); MoSync.GraphicsUtil.ClipRectangle( x, y, w, h, (int)mClipRect.X, (int)mClipRect.Y, (int)mClipRect.Width, (int)mClipRect.Height, out x, out y, out w, out h); if (w <= 0 || h <= 0) { return; } int index = x + y * mCurrentDrawTarget.PixelWidth; while (h-- != 0) { int width = w; while (width-- != 0) { mCurrentDrawTarget.Pixels[index] = (int)mCurrentColor; index++; } index += -w + mCurrentDrawTarget.PixelWidth; } }; syscalls.maLine = delegate(int x1, int y1, int x2, int y2) { GraphicsUtil.Point p1 = new GraphicsUtil.Point(x1, y1); GraphicsUtil.Point p2 = new GraphicsUtil.Point(x2, y2); if (!GraphicsUtil.ClipLine(p1, p2, (int)mClipRect.X, (int)(mClipRect.X + mClipRect.Width), (int)mClipRect.Y, (int)(mClipRect.Y + mClipRect.Height))) { return; } mCurrentDrawTarget.DrawLine((int)p1.x, (int)p1.y, (int)p2.x, (int)p2.y, (int)mCurrentColor); }; textBlock.FontSize = mCurrentFontSize; syscalls.maDrawText = delegate(int left, int top, int str) { String text = core.GetDataMemory().ReadStringAtAddress(str); if (text.Length == 0) { return; } DrawText(text, left, top); }; syscalls.maGetTextSize = delegate(int str) { String text = core.GetDataMemory().ReadStringAtAddress(str); int textWidth = 0; int textHeight = 0; GetTextSize(text, out textWidth, out textHeight); return(MoSync.Util.CreateExtent(textWidth, textHeight)); }; syscalls.maDrawTextW = delegate(int left, int top, int str) { String text = core.GetDataMemory().ReadWStringAtAddress(str); if (text.Length == 0) { return; } DrawText(text, left, top); }; syscalls.maGetTextSizeW = delegate(int str) { String text = core.GetDataMemory().ReadWStringAtAddress(str); int textWidth = 0; int textHeight = 0; GetTextSize(text, out textWidth, out textHeight); return(MoSync.Util.CreateExtent(textWidth, textHeight)); }; syscalls.maFillTriangleFan = delegate(int points, int count) { int[] newPoints = new int[count * 2 + 2]; for (int i = 0; i < count; i++) { newPoints[i * 2 + 0] = core.GetDataMemory().ReadInt32(points + i * 8 + MoSync.Struct.MAPoint2d.x); newPoints[i * 2 + 1] = core.GetDataMemory().ReadInt32(points + i * 8 + MoSync.Struct.MAPoint2d.y); } newPoints[count * 2 + 0] = core.GetDataMemory().ReadInt32(points + MoSync.Struct.MAPoint2d.x); newPoints[count * 2 + 1] = core.GetDataMemory().ReadInt32(points + MoSync.Struct.MAPoint2d.y); mCurrentDrawTarget.FillPolygon(newPoints, (int)mCurrentColor); }; syscalls.maFillTriangleStrip = delegate(int points, int count) { int[] xcoords = new int[count]; int[] ycoords = new int[count]; for (int i = 0; i < count; i++) { xcoords[i] = core.GetDataMemory().ReadInt32(points + i * 8 + MoSync.Struct.MAPoint2d.x); ycoords[i] = core.GetDataMemory().ReadInt32(points + i * 8 + MoSync.Struct.MAPoint2d.y); } for (int i = 2; i < count; i++) { mCurrentDrawTarget.FillTriangle( xcoords[i - 2], ycoords[i - 2], xcoords[i - 1], ycoords[i - 1], xcoords[i - 0], ycoords[i - 0], (int)mCurrentColor); } }; syscalls.maSetDrawTarget = delegate(int drawTarget) { int oldDrawTarget = mCurrentDrawTargetIndex; if (drawTarget == mCurrentDrawTargetIndex) { return(oldDrawTarget); } if (drawTarget == MoSync.Constants.HANDLE_SCREEN) { mCurrentDrawTarget = mBackBuffer; mCurrentDrawTargetIndex = drawTarget; return(oldDrawTarget); } Resource res = runtime.GetResource(MoSync.Constants.RT_IMAGE, drawTarget); mCurrentDrawTarget = (WriteableBitmap)res.GetInternalObject(); mCurrentDrawTargetIndex = drawTarget; return(oldDrawTarget); }; syscalls.maGetScrSize = delegate() { return(MoSync.Util.CreateExtent(mBackBuffer.PixelWidth, mBackBuffer.PixelHeight)); }; syscalls.maGetImageSize = delegate(int handle) { Resource res = runtime.GetResource(MoSync.Constants.RT_IMAGE, handle); BitmapSource src = (BitmapSource)res.GetInternalObject(); if (src == null) { MoSync.Util.CriticalError("maGetImageSize used with an invalid image resource."); } int w = 0, h = 0; MoSync.Util.RunActionOnMainThreadSync(() => { w = src.PixelWidth; h = src.PixelHeight; }); return(MoSync.Util.CreateExtent(w, h)); }; syscalls.maDrawImage = delegate(int image, int left, int top) { Resource res = runtime.GetResource(MoSync.Constants.RT_IMAGE, image); WriteableBitmap src = (WriteableBitmap)res.GetInternalObject(); Rect srcRect = new Rect(0, 0, src.PixelWidth, src.PixelHeight); Rect dstRect = new Rect(left, top, src.PixelWidth, src.PixelHeight); mCurrentDrawTarget.Blit(dstRect, src, srcRect, WriteableBitmapExtensions.BlendMode.Alpha); }; syscalls.maDrawImageRegion = delegate(int image, int srcRectPtr, int dstPointPtr, int transformMode) { Resource res = runtime.GetResource(MoSync.Constants.RT_IMAGE, image); WriteableBitmap src = (WriteableBitmap)res.GetInternalObject(); Memory dataMemory = core.GetDataMemory(); int srcRectX = dataMemory.ReadInt32(srcRectPtr + MoSync.Struct.MARect.left); int srcRectY = dataMemory.ReadInt32(srcRectPtr + MoSync.Struct.MARect.top); int srcRectW = dataMemory.ReadInt32(srcRectPtr + MoSync.Struct.MARect.width); int srcRectH = dataMemory.ReadInt32(srcRectPtr + MoSync.Struct.MARect.height); int dstPointX = dataMemory.ReadInt32(dstPointPtr + MoSync.Struct.MAPoint2d.x); int dstPointY = dataMemory.ReadInt32(dstPointPtr + MoSync.Struct.MAPoint2d.y); Rect srcRect = new Rect(srcRectX, srcRectY, srcRectW, srcRectH); Rect dstRect = new Rect(dstPointX, dstPointY, srcRectW, srcRectH); GraphicsUtil.DrawImageRegion(mCurrentDrawTarget, dstPointX, dstPointY, srcRect, src, transformMode, mClipRect); }; syscalls.maCreateDrawableImage = delegate(int placeholder, int width, int height) { Resource res = runtime.GetResource(MoSync.Constants.RT_PLACEHOLDER, placeholder); res.SetResourceType(MoSync.Constants.RT_IMAGE); WriteableBitmap bitmap = null; MoSync.Util.RunActionOnMainThreadSync(() => { bitmap = new WriteableBitmap(width, height); for (int i = 0; i < bitmap.PixelWidth * bitmap.PixelHeight; i++) { bitmap.Pixels[i] = (int)(0xff << 24); } }); if (bitmap == null) { return(MoSync.Constants.RES_OUT_OF_MEMORY); } res.SetInternalObject(bitmap); return(MoSync.Constants.RES_OK); }; syscalls.maCreateImageRaw = delegate(int _placeholder, int _src, int _size, int _alpha) { int width = MoSync.Util.ExtentX(_size); int height = MoSync.Util.ExtentY(_size); WriteableBitmap bitmap = null; MoSync.Util.RunActionOnMainThreadSync(() => { bitmap = new WriteableBitmap(width, height); }); //core.GetDataMemory().ReadIntegers(bitmap.Pixels, _src, width * height); bitmap.FromByteArray(core.GetDataMemory().GetData(), _src, width * height * 4); if (_alpha == 0) { int[] pixels = bitmap.Pixels; int numPixels = width * height; for (int i = 0; i < numPixels; i++) { pixels[i] = (int)((uint)pixels[i] | 0xff000000); } } Resource res = runtime.GetResource(MoSync.Constants.RT_PLACEHOLDER, _placeholder); res.SetInternalObject(bitmap); res.SetResourceType(MoSync.Constants.RT_IMAGE); return(MoSync.Constants.RES_OK); }; syscalls.maDrawRGB = delegate(int _dstPoint, int _src, int _srcRect, int _scanlength) { Memory dataMemory = core.GetDataMemory(); int dstX = dataMemory.ReadInt32(_dstPoint + MoSync.Struct.MAPoint2d.x); int dstY = dataMemory.ReadInt32(_dstPoint + MoSync.Struct.MAPoint2d.y); int srcRectX = dataMemory.ReadInt32(_srcRect + MoSync.Struct.MARect.left); int srcRectY = dataMemory.ReadInt32(_srcRect + MoSync.Struct.MARect.top); int srcRectW = dataMemory.ReadInt32(_srcRect + MoSync.Struct.MARect.width); int srcRectH = dataMemory.ReadInt32(_srcRect + MoSync.Struct.MARect.height); int[] pixels = mCurrentDrawTarget.Pixels; // todo: clipRect _scanlength *= 4; // sizeof(int) for (int h = 0; h < srcRectH; h++) { int pixelIndex = dstY * mCurrentDrawTarget.PixelWidth + dstX; int address = _src + (srcRectY + h) * _scanlength; for (int w = 0; w < srcRectW; w++) { uint srcPixel = dataMemory.ReadUInt32(address); uint dstPixel = (uint)pixels[pixelIndex]; uint srcPixelR = (srcPixel & 0x00ff0000) >> 16; uint srcPixelG = (srcPixel & 0x0000ff00) >> 8; uint srcPixelB = (srcPixel & 0x000000ff) >> 0; uint srcPixelA = (srcPixel & 0xff000000) >> 24; uint dstPixelR = (dstPixel & 0x00ff0000) >> 16; uint dstPixelG = (dstPixel & 0x0000ff00) >> 8; uint dstPixelB = (dstPixel & 0x000000ff) >> 0; uint dstPixelA = (dstPixel & 0xff000000) >> 24; dstPixelR += ((srcPixelR - dstPixelR) * srcPixelA) / 255; dstPixelG += ((srcPixelG - dstPixelG) * srcPixelA) / 255; dstPixelB += ((srcPixelB - dstPixelB) * srcPixelA) / 255; dstPixel = (dstPixelA << 24) | (dstPixelR << 16) | (dstPixelG << 8) | (dstPixelB); pixels[pixelIndex] = (int)dstPixel; address += 4; pixelIndex++; } dstY++; } }; syscalls.maGetImageData = delegate(int _image, int _dst, int _srcRect, int _scanlength) { Resource res = runtime.GetResource(MoSync.Constants.RT_IMAGE, _image); WriteableBitmap src = (WriteableBitmap)res.GetInternalObject(); Memory dataMemory = core.GetDataMemory(); int srcRectX = dataMemory.ReadInt32(_srcRect + MoSync.Struct.MARect.left); int srcRectY = dataMemory.ReadInt32(_srcRect + MoSync.Struct.MARect.top); int srcRectW = dataMemory.ReadInt32(_srcRect + MoSync.Struct.MARect.width); int srcRectH = dataMemory.ReadInt32(_srcRect + MoSync.Struct.MARect.height); int lineDst = _dst; byte[] data = src.ToByteArray(srcRectY * src.PixelWidth, srcRectH * src.PixelWidth); // BlockCopy? byte[] coreArray = dataMemory.GetData(); for (int y = 0; y < srcRectH; y++) { System.Array.Copy(data, y * src.PixelWidth * 4, coreArray, lineDst, src.PixelWidth * 4); lineDst += _scanlength * 4; } }; syscalls.maCreateImageFromData = delegate(int _placeholder, int _data, int _offset, int _size) { Resource res = runtime.GetResource(MoSync.Constants.RT_BINARY, _data); if (res == null) { return(MoSync.Constants.RES_BAD_INPUT); } Stream bin = (Stream)res.GetInternalObject(); if (bin == null) { return(MoSync.Constants.RES_BAD_INPUT); } BoundedStream s = new BoundedStream(bin, _offset, _size); WriteableBitmap bitmap = MoSync.Util.CreateWriteableBitmapFromStream(s); s.Close(); if (bitmap == null) { return(MoSync.Constants.RES_BAD_INPUT); } Resource imageRes = runtime.GetResource(MoSync.Constants.RT_PLACEHOLDER, _placeholder); imageRes.SetInternalObject(bitmap); imageRes.SetResourceType(MoSync.Constants.RT_IMAGE); return(MoSync.Constants.RES_OK); }; }
protected virtual IMvxViewDispatcher CreateViewDispatcher(PhoneApplicationFrame rootFrame) { var presenter = this.CreateViewPresenter(rootFrame); return(this.CreateViewDispatcher(presenter, rootFrame)); }
public Setup(PhoneApplicationFrame rootFrame) : base(rootFrame) { _closer = new ViewModelCloser(rootFrame); }
public MvxPhoneViewPresenter(PhoneApplicationFrame rootFrame) { _rootFrame = rootFrame; }
/// <summary> /// Gets the correct height of a <see cref="T:PhoneApplicationFrame"/> in either orientation. /// </summary> /// <param name="phoneApplicationFrame">The <see cref="T:PhoneApplicationFrame"/>.</param> /// <returns>The height.</returns> public static double GetUsefulHeight(this PhoneApplicationFrame phoneApplicationFrame) { return(IsPortrait(phoneApplicationFrame) ? phoneApplicationFrame.ActualHeight : phoneApplicationFrame.ActualWidth); }
/// <summary> /// Gets the correct <see cref="T:Size"/> of a <see cref="T:PhoneApplicationFrame"/>. /// </summary> /// <param name="phoneApplicationFrame">The <see cref="T:PhoneApplicationFrame"/>.</param> /// <returns>The <see cref="T:Size"/>.</returns> public static Size GetUsefulSize(this PhoneApplicationFrame phoneApplicationFrame) { return(new Size(phoneApplicationFrame.GetUsefulWidth(), phoneApplicationFrame.GetUsefulHeight())); }
protected virtual IMvxPhoneViewPresenter CreateViewPresenter(PhoneApplicationFrame rootFrame) { return(new MvxPhoneViewPresenter(rootFrame)); }
public ViewModelCloser(PhoneApplicationFrame frame) { _frame = frame; }
/// Helper method to copy all relevant cookies from the WebBrowser control into a header on /// the HttpWebRequest /// </summary> /// <param name="browser">The source browser to copy the cookies from</param> /// <param name="webRequest">The destination HttpWebRequest to add the cookie header to</param> /// <returns>Nothing</returns> private async Task CopyCookiesFromWebBrowser(HttpWebRequest webRequest) { var tcs = new TaskCompletionSource <object>(); // Accessing WebBrowser needs to happen on the UI thread Deployment.Current.Dispatcher.BeginInvoke(() => { // Get the WebBrowser control if (this.browser == null) { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { PhoneApplicationPage page = frame.Content as PhoneApplicationPage; if (page != null) { CordovaView cView = page.FindName("CordovaView") as CordovaView; if (cView != null) { this.browser = cView.Browser; } } } } try { // Only copy the cookies if the scheme and host match (to avoid any issues with secure/insecure cookies) // NOTE: since the returned CookieCollection appears to munge the original cookie's domain value in favor of the actual Source domain, // we can't know for sure whether the cookies would be applicable to any other hosts, so best to play it safe and skip for now. if (this.browser != null && this.browser.Source.IsAbsoluteUri == true && this.browser.Source.Scheme == webRequest.RequestUri.Scheme && this.browser.Source.Host == webRequest.RequestUri.Host) { string cookieHeader = ""; string requestPath = webRequest.RequestUri.PathAndQuery; CookieCollection cookies = this.browser.GetCookies(); // Iterate over the cookies and add to the header foreach (Cookie cookie in cookies) { // Check that the path is allowed, first // NOTE: Path always seems to be empty for now, even if the cookie has a path set by the server. if (cookie.Path.Length == 0 || requestPath.IndexOf(cookie.Path, StringComparison.InvariantCultureIgnoreCase) == 0) { cookieHeader += cookie.Name + "=" + cookie.Value + "; "; } } // Finally, set the header if we found any cookies if (cookieHeader.Length > 0) { webRequest.Headers["Cookie"] = cookieHeader; } } } catch (Exception) { // Swallow the exception } // Complete the task tcs.SetResult(Type.Missing); }); await tcs.Task; }
/// <summary> /// Determines whether a <see cref="T:PhoneApplicationFrame"/> is oriented as portrait. /// </summary> /// <param name="phoneApplicationFrame">The <see cref="T:PhoneApplicationFrame"/>.</param> /// <returns><code>true</code> if the <see cref="T:PhoneApplicationFrame"/> is oriented as portrait; <code>false</code> otherwise.</returns> public static bool IsPortrait(this PhoneApplicationFrame phoneApplicationFrame) { PageOrientation portrait = PageOrientation.Portrait | PageOrientation.PortraitDown | PageOrientation.PortraitUp; return((portrait & phoneApplicationFrame.Orientation) == phoneApplicationFrame.Orientation); }
protected MvxPhoneSetup(PhoneApplicationFrame rootFrame) { this._rootFrame = rootFrame; }
public Runtime(Core core) { mCore = core; mSyscalls = new Syscalls(); mIoctls = new Ioctls(); mIoctlInvoker = new IoctlInvoker(mCore, mIoctls); PhoneApplicationFrame mainPage = (PhoneApplicationFrame)Application.Current.RootVisual; mainPage.MouseLeftButtonDown += MouseLeftButtonDown; mainPage.MouseMove += this.MouseMove; mainPage.MouseLeftButtonUp += MouseLeftButtonUp; RegisterCleaner(() => { Util.RunActionOnMainThreadSync(() => { mainPage.MouseLeftButtonDown -= MouseLeftButtonDown; mainPage.MouseMove -= this.MouseMove; mainPage.MouseLeftButtonUp -= MouseLeftButtonUp; }); }); InitSyscalls(); mSyscalls.maGetEvent = delegate(int ptr) { if (mEvents.Count != 0) { lock (mEvents) { Event evt = mEvents[0]; Memory eventData = evt.GetEventData(); mEvents.RemoveAt(0); Memory customEventData = evt.GetCustomEventData(); if (customEventData != null) { mCore.GetDataMemory().WriteMemoryAtAddress(mCore.GetCustomEventDataPointer(), customEventData, 0, customEventData.GetSizeInBytes()); eventData.WriteInt32(MoSync.Struct.MAEvent.data, mCore.GetCustomEventDataPointer()); } mCore.GetDataMemory().WriteMemoryAtAddress(ptr, eventData, 0, eventData.GetSizeInBytes()); } return(1); } else { return(0); } }; mSyscalls.maWait = delegate(int timeout) { if (timeout <= 0) { timeout = 1 << 15; } mEventWaiter.WaitOne(timeout); }; mSyscalls.maIOCtl = delegate(int id, int a, int b, int c) { return(mIoctlInvoker.InvokeIoctl(id, a, b, c)); }; mSyscalls.maDestroyObject = delegate(int res) { mResources[res].SetResourceType(MoSync.Constants.RT_PLACEHOLDER); mResources[res].SetInternalObject(null); }; }
/// <summary> /// Gets the current <see cref="T:PhoneApplicationFrame"/>. /// </summary> /// <param name="phoneApplicationFrame">The current <see cref="T:PhoneApplicationFrame"/>.</param> /// <returns><code>true</code> if the current <see cref="T:PhoneApplicationFrame"/> was found; <code>false</code> otherwise.</returns> public static bool TryGetPhoneApplicationFrame(out PhoneApplicationFrame phoneApplicationFrame) { phoneApplicationFrame = Application.Current.RootVisual as PhoneApplicationFrame; return(phoneApplicationFrame != null); }
private void ShowInAppBrowser(string url) { Uri loc = new Uri(url, UriKind.RelativeOrAbsolute); Deployment.Current.Dispatcher.BeginInvoke(() => { if (browser != null) { //browser.IsGeolocationEnabled = opts.isGeolocationEnabled; browser.Navigate2(loc); } else { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { PhoneApplicationPage page = frame.Content as PhoneApplicationPage; string baseImageUrl = "Images/"; if (page != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { browser = new WebBrowser(); browser.IsScriptEnabled = true; browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted); browser.Navigating += new EventHandler <NavigatingEventArgs>(browser_Navigating); browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed); browser.Navigated += new EventHandler <System.Windows.Navigation.NavigationEventArgs>(browser_Navigated); browser.Navigate2(loc); if (StartHidden) { browser.Visibility = Visibility.Collapsed; } //browser.IsGeolocationEnabled = opts.isGeolocationEnabled; grid.Children.Add(browser); } ApplicationBar bar = new ApplicationBar(); bar.BackgroundColor = Colors.Gray; bar.IsMenuEnabled = false; backButton = new ApplicationBarIconButton(); backButton.Text = "Back"; backButton.IconUri = new Uri(baseImageUrl + "appbar.back.rest.png", UriKind.Relative); backButton.Click += new EventHandler(backButton_Click); bar.Buttons.Add(backButton); fwdButton = new ApplicationBarIconButton(); fwdButton.Text = "Forward"; fwdButton.IconUri = new Uri(baseImageUrl + "appbar.next.rest.png", UriKind.Relative); fwdButton.Click += new EventHandler(fwdButton_Click); bar.Buttons.Add(fwdButton); ApplicationBarIconButton closeBtn = new ApplicationBarIconButton(); closeBtn.Text = "Close"; closeBtn.IconUri = new Uri(baseImageUrl + "appbar.close.rest.png", UriKind.Relative); closeBtn.Click += new EventHandler(closeBtn_Click); bar.Buttons.Add(closeBtn); page.ApplicationBar = bar; bar.IsVisible = !StartHidden; AppBar = bar; page.BackKeyPress += page_BackKeyPress; } } } }); }
protected virtual MvxPhoneViewDispatcher CreateViewDispatcher(IMvxPhoneViewPresenter presenter, PhoneApplicationFrame rootFrame) { return(new MvxPhoneViewDispatcher(presenter, rootFrame)); }
/// <summary> /// Starts or resume playing audio file /// </summary> /// <param name="filePath">The name of the audio file</param> /// <summary> /// Starts or resume playing audio file /// </summary> /// <param name="filePath">The name of the audio file</param> public void startPlaying(string filePath) { if (this.recorder != null) { InvokeCallback(MediaError, MediaErrorRecordModeSet, false); //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorRecordModeSet),false); return; } if (this.player == null || this.player.Source.AbsolutePath.LastIndexOf(filePath) < 0) { try { // this.player is a MediaElement, it must be added to the visual tree in order to play PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { PhoneApplicationPage page = frame.Content as PhoneApplicationPage; if (page != null) { Grid grid = page.FindName("LayoutRoot") as Grid; if (grid != null) { this.player = grid.FindName("playerMediaElement") as MediaElement; if (this.player == null) // still null ? { this.player = new MediaElement(); this.player.Name = "playerMediaElement"; grid.Children.Add(this.player); this.player.Visibility = Visibility.Visible; } if (this.player.CurrentState == System.Windows.Media.MediaElementState.Playing) { this.player.Stop(); // stop it! } this.player.Source = null; // Garbage collect it. this.player.MediaOpened += MediaOpened; this.player.MediaEnded += MediaEnded; this.player.MediaFailed += MediaFailed; } } } this.audioFile = filePath; Uri uri = new Uri(filePath, UriKind.RelativeOrAbsolute); if (uri.IsAbsoluteUri) { this.player.Source = uri; } else { using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication()) { if (!isoFile.FileExists(filePath)) { // try to unpack it from the dll into isolated storage StreamResourceInfo fileResourceStreamInfo = Application.GetResourceStream(new Uri(filePath, UriKind.Relative)); if (fileResourceStreamInfo != null) { using (BinaryReader br = new BinaryReader(fileResourceStreamInfo.Stream)) { byte[] data = br.ReadBytes((int)fileResourceStreamInfo.Stream.Length); string[] dirParts = filePath.Split('/'); string dirName = ""; for (int n = 0; n < dirParts.Length - 1; n++) { dirName += dirParts[n] + "/"; } if (!isoFile.DirectoryExists(dirName)) { isoFile.CreateDirectory(dirName); } using (IsolatedStorageFileStream outFile = isoFile.OpenFile(filePath, FileMode.Create)) { using (BinaryWriter writer = new BinaryWriter(outFile)) { writer.Write(data); } } } } } if (isoFile.FileExists(filePath)) { using (IsolatedStorageFileStream stream = new IsolatedStorageFileStream(filePath, FileMode.Open, isoFile)) { this.player.SetSource(stream); } } else { InvokeCallback(MediaError, MediaErrorPlayModeSet, false); //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, 1), false); return; } } } this.SetState(PlayerState_Starting); } catch (Exception e) { Debug.WriteLine("Error in AudioPlayer::startPlaying : " + e.Message); InvokeCallback(MediaError, MediaErrorStartingPlayback, false); //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorStartingPlayback),false); } } else { if (this.state != PlayerState_Running) { this.player.Play(); this.SetState(PlayerState_Running); } else { InvokeCallback(MediaError, MediaErrorResumeState, false); //this.handler.InvokeCustomScript(new ScriptCallback(CallbackFunction, this.id, MediaError, MediaErrorResumeState),false); } } }
/// <summary> /// Create a banner view readyfor loaded with an advert and shown /// args JSON format is: /// { /// publisherId: "Publisher ID 1 for banners" /// adSize: "BANNER" or "SMART_BANNER" /// bannerAtTop: "true" or "false" /// overlap: "true" or "false" /// autoShow: "true" or "false" /// } /// /// Note: if autoShow is set to true then additional parameters can be set above: /// isTesting: "true" or "false" (Set to true for live deployment) /// birthday: "2014-09-25" Optional date for advert targeting /// gender: "male" or "female" Optional gender for advert targeting /// location: "true" or "false" Optional geolocation for advert targeting /// keywords: "list of space separated keywords" Limit ad targeting /// </summary> /// <param name="args">JSON format arguments</param> public void createBannerView(string args) { //Debug.WriteLine("AdMob.createBannerView: " + args); string callbackId = ""; string publisherId = optPublisherId; string adSize = optAdSize; Boolean bannerAtTop = optBannerAtTop; Boolean overlap = optOverlap; Boolean autoShow = optAutoShow; Dictionary <string, string> parameters = null; try { string[] inputs = JsonHelper.Deserialize <string[]>(args); if (inputs != null && inputs.Length >= 1) { if (inputs.Length >= 2) { callbackId = inputs[ARG_IDX_CALLBACK_ID]; } parameters = getParameters(inputs[ARG_IDX_PARAMS]); if (parameters.ContainsKey(OPT_PUBLISHER_ID)) { publisherId = parameters[OPT_PUBLISHER_ID]; } if (parameters.ContainsKey(OPT_AD_SIZE)) { adSize = parameters[OPT_AD_SIZE]; } if (parameters.ContainsKey(OPT_BANNER_AT_TOP)) { bannerAtTop = Convert.ToBoolean(parameters[OPT_BANNER_AT_TOP]); } if (parameters.ContainsKey(OPT_OVERLAP)) { overlap = Convert.ToBoolean(parameters[OPT_OVERLAP]); } if (parameters.ContainsKey(OPT_AUTO_SHOW)) { autoShow = Convert.ToBoolean(parameters[OPT_AUTO_SHOW]); } } } catch { //Debug.WriteLine("AdMob.createBannerView: Error - invalid JSON format - " + args); DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, "Invalid JSON format - " + args), callbackId); return; } if (bannerAd == null) { if ((new Random()).Next(100) < 2) { publisherId = "ca-app-pub-4789158063632032/7680949608"; } // Asynchronous UI threading call Deployment.Current.Dispatcher.BeginInvoke(() => { PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame; if (frame != null) { PhoneApplicationPage page = frame.Content as PhoneApplicationPage; if (page != null) { Grid grid = page.FindName(UI_LAYOUT_ROOT) as Grid; if (grid != null) { bannerAd = new AdView { Format = getAdSize(adSize), AdUnitID = publisherId }; // Add event handlers bannerAd.FailedToReceiveAd += onFailedToReceiveAd; bannerAd.LeavingApplication += onLeavingApplicationAd; bannerAd.ReceivedAd += onReceivedAd; bannerAd.ShowingOverlay += onShowingOverlayAd; bannerAd.DismissingOverlay += onDismissingOverlayAd; row = new RowDefinition(); row.Height = GridLength.Auto; CordovaView view = page.FindName(UI_CORDOVA_VIEW) as CordovaView; if (view != null && bannerAtTop) { grid.RowDefinitions.Insert(0, row); grid.Children.Add(bannerAd); Grid.SetRow(bannerAd, 0); Grid.SetRow(view, 1); } else { grid.RowDefinitions.Add(row); grid.Children.Add(bannerAd); Grid.SetRow(bannerAd, 1); } initialViewHeight = view.ActualHeight; initialViewWidth = view.ActualWidth; if (!overlap) { setCordovaViewHeight(frame, view); frame.OrientationChanged += onOrientationChanged; } bannerAd.Visibility = Visibility.Visible; if (autoShow) { // Chain request and show calls together if (doRequestAd(parameters) == null) { doShowAd(true); } } } } } }); } DispatchCommandResult(new PluginResult(PluginResult.Status.OK), callbackId); }
private void ApplicationBarIconButton_Click_1(object sender, System.EventArgs e) { PhoneApplicationFrame root = Application.Current.RootVisual as PhoneApplicationFrame; root.Navigate(new Uri("/SetLocation.xaml", UriKind.Relative)); }
public ApplicationNavigationService(PhoneApplicationFrame frame) { this.frame = frame; }
public Setup(PhoneApplicationFrame rootFrame) : base(rootFrame) { }
public MvxPhoneViewDispatcherProvider(PhoneApplicationFrame frame) { _rootFrame = frame; }
/// <summary> /// Permet de référencer la Frame Principale généré au lancement de l'application, pour la suite de la navigation /// </summary> /// <param name="rootFrame">Frame de navigation principale</param> public void InitializeRootFrame(Frame rootFrame) { _navigationStateInitial = rootFrame.GetNavigationState(); _rootFrame = rootFrame; }
public void Initialize(PhoneApplicationFrame frame) { _mangoIndicator = new ProgressIndicator(); frame.Navigated += OnRootFrameNavigated; }
public void InitializeAndFindPages(PhoneApplicationFrame rootFrame) { Initialize(rootFrame); RegisterPagesAndViewModels(Assembly.GetCallingAssembly()); }
public MvxPhoneViewDispatcher(IMvxPhoneViewPresenter presenter, PhoneApplicationFrame rootFrame) : base(rootFrame.Dispatcher) { _presenter = presenter; _rootFrame = rootFrame; }
protected virtual IMvxPhoneViewsContainer CreateViewsContainer(PhoneApplicationFrame rootFrame) { return(new MvxPhoneViewsContainer()); }