Inheritance: IApplication, IApplicationOverrides
Example #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <CameraPreview> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
            {
                app             = Windows.UI.Xaml.Application.Current;
                app.Suspending += OnAppSuspending;
                app.Resuming   += OnAppResuming;

                element                = e.NewElement;
                cameraOptions          = element.Camera;
                captureElement         = new CaptureElement();
                captureElement.Stretch = Stretch.UniformToFill;

                SetupCamera();
                SetNativeControl(captureElement);
            }
            if (e.OldElement != null)
            {
                capturePathCallbackAction = null;
                element.Capture           = null;
                element.StartCamera       = null;
                element.StopCamera        = null;
                captureFilename           = "temp";
            }
            if (e.NewElement != null)
            {
                capturePathCallbackAction = element.CapturePathCallback;
                element.Capture           = new Command(() => CaptureToFile());
                element.StartCamera       = new Command(async() => await StartPreviewAsync());
                element.StopCamera        = new Command(async() => await StopPreviewAsync());
                captureFilename           = element.Filename;
            }
        }
        public AutoSuspendHelper(Application app)
        {
            Reflection.ThrowIfMethodsNotOverloaded("AutoSuspendHelper", app, "OnLaunched");

            var launchNew = new[] { ApplicationExecutionState.ClosedByUser, ApplicationExecutionState.NotRunning, };
            RxApp.SuspensionHost.IsLaunchingNew = _activated
                .Where(x => launchNew.Contains(x.PreviousExecutionState))
                .Select(_ => Unit.Default);

            RxApp.SuspensionHost.IsResuming = _activated
                .Where(x => x.PreviousExecutionState == ApplicationExecutionState.Terminated)
                .Select(_ => Unit.Default);

            var unpausing = new[] { ApplicationExecutionState.Suspended, ApplicationExecutionState.Running, };
            RxApp.SuspensionHost.IsUnpausing = _activated
                .Where(x => unpausing.Contains(x.PreviousExecutionState))
                .Select(_ => Unit.Default);

            var shouldPersistState = new Subject<SuspendingEventArgs>();
            app.Suspending += (o, e) => shouldPersistState.OnNext(e);
            RxApp.SuspensionHost.ShouldPersistState =
                shouldPersistState.Select(x => {
                    var deferral = x.SuspendingOperation.GetDeferral();
                    return Disposable.Create(deferral.Complete);
                });

            var shouldInvalidateState = new Subject<Unit>();
            app.UnhandledException += (o, e) => shouldInvalidateState.OnNext(Unit.Default);
            RxApp.SuspensionHost.ShouldInvalidateState = shouldInvalidateState;
        }
		protected override void OnElementChanged (VisualElementChangedEventArgs e)
		{
			base.OnElementChanged (e);

			if (e.OldElement != null || Element == null) {
				return;
			}

			try {
				app = Application.Current;
				app.Suspending += OnAppSuspending;
				app.Resuming += OnAppResuming;

				HardwareButtons.BackPressed += OnBackButtonPressed;

				var container = ContainerElement as Canvas;

				SetupUserInterface ();
				SetupEventHandlers ();
				SetupLiveCameraStream ();
				container.Children.Add (page);
			} catch (Exception ex) {
				Debug.WriteLine (@"      ERROR: ", ex.Message);
			}
		}
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            try
            {
                _app             = Application.Current;
                _app.Suspending += OnAppSuspending;
                _app.Resuming   += OnAppResuming;
                _isActivePage    = true;

                SetupUserInterface();
                SetupBasedOnStateAsync();

                this.Children.Add(_page);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"      ERROR: ", ex.Message);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SuspensionService"/> class.
        /// Based on WinRTSuspensionHost in ReactiveUI.Mobile
        /// </summary>
        public SuspensionService(Application app, ISubject<LaunchActivatedEventArgs> launched)
        {
            var launchNew = new[] { ApplicationExecutionState.ClosedByUser, ApplicationExecutionState.NotRunning, };
            this.IsLaunchingNew = launched
                .Where(x => launchNew.Contains(x.PreviousExecutionState))
                .Select(x => x.Arguments);

            this.IsResuming = launched
                .Where(x => x.PreviousExecutionState == ApplicationExecutionState.Terminated)
                .Select(x => x.Arguments);

            var unpausing = new[] { ApplicationExecutionState.Suspended, ApplicationExecutionState.Running, };
            this.IsUnpausing = launched
                .Where(x => unpausing.Contains(x.PreviousExecutionState))
                .Select(x => x.Arguments);

            var shouldPersistState = new Subject<SuspendingEventArgs>();
            app.Suspending += (o, e) => shouldPersistState.OnNext(e);
            this.ShouldPersistState =
                shouldPersistState.Select(x =>
                {
                    var deferral = x.SuspendingOperation.GetDeferral();
                    return Disposable.Create(deferral.Complete);
                });

            var shouldInvalidateState = new Subject<Unit>();
            app.UnhandledException += (o, e) => shouldInvalidateState.OnNext(Unit.Default);
            this.ShouldInvalidateState = shouldInvalidateState;
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            try
            {
                app = Application.Current;
                app.Suspending += OnAppSuspending;
                app.Resuming += OnAppResuming;

                SetupUserInterface();
                SetupCamera();

                this.Children.Add(page);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"      ERROR: ", ex.Message);
            }
        }
Example #7
0
        static UnoXamlHostBase()
        {
            //TODO: These lines should be set in a different location, possibly in a more general way (for multi-window support) https://github.com/unoplatform/uno/issues/8978
            Windows.UI.Core.CoreDispatcher.DispatchOverride = d =>
                                                              global::System.Windows.Application.Current.Dispatcher.BeginInvoke(d);
            Windows.UI.Core.CoreDispatcher.HasThreadAccessOverride =
                global::System.Windows.Application.Current.Dispatcher.CheckAccess;
            if (MetadataProviderDiscovery.MetadataProviderFactory is null)
            {
                MetadataProviderDiscovery.MetadataProviderFactory = type =>
                {
                    if (typeof(WUX.Application).IsAssignableFrom(type))
                    {
                        WUX.Application application = null;

                        WUX.Application.Start(_ =>
                        {
                            application = (WUX.Application)Activator.CreateInstance(type);
                        });

                        return((WUX.Markup.IXamlMetadataProvider)application);
                    }

                    return(null);
                };
            }

            _metadataContainer = XamlApplicationExtensions.GetOrCreateXamlMetadataContainer();
        }
 public AppExceptionHandle(Application app)
 {
     if (null == app)
     {
         return;
     }
     app.UnhandledException += app_UnhandledException;
 }
Example #9
0
        public static void AddExternalViews(this Windows.UI.Xaml.Application application)
        {
            var resourceDictionary = new ResourceDictionary()
            {
            };

            // var resourceFile =  "ExternalViews/Views/ColleaguesView.xaml";
            // var colleagueResource = new Uri(resourceFile,UriKind.RelativeOrAbsolute);
            // Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary{Source = colleagueResource});
        }
Example #10
0
        public static void Hook(string apiKey, string token, Application app)
        {
            GlobalConfig.ApiKey = apiKey;
            GlobalConfig.Token = token;

            GlobalConfig.ErrorDataProviders.Add(new PackageInfoProvier());
            ReportingService.Init();

            _app = app;
            _app.UnhandledException += OnException;
        }
        /// <summary>
        /// Hook into various events to automatically track suspend, resume, page navigation,
        /// social sharing etc.
        /// </summary>
        /// <param name="application">Application object to hook into.</param>
        private static void HookEvents(Application application)
        {
            application.Resuming += applicationResume;
            application.Suspending += applicationSuspend;
            application.UnhandledException += applicationException;

            attachedFrame = Window.Current.Content as Frame;
            if (attachedFrame != null)
                attachedFrame.Navigated += FrameNavigated;

            attachedDataTransferManager = DataTransferManager.GetForCurrentView();
            attachedDataTransferManager.TargetApplicationChosen += socialShare;
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Page> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || Element == null)
            {
                return;
            }

            XElement = e.NewElement as DynamicChartsSample;

            try
            {
                _app                    = Application.Current;
                _app.Suspending        += Suspending;
                _app.Resuming          += Resuming;
                _app.EnteredBackground += EnteredBackground;
                _app.LeavingBackground += LeavingBackground;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"ERROR: ", ex.Message);
            }
        }
Example #13
0
 public static void Init(Windows.UI.Xaml.Application app)
 {
     app.UnhandledException += CurrentDomain_UnhandledException;
     Init();
 }
Example #14
0
 public GtkApplicationExtension(object owner)
 {
     _owner       = (Application)owner;
     _ownerEvents = (IApplicationEvents)owner;
 }
Example #15
0
 public WpfApplicationExtension(object owner)
 {
     _owner = (Application)owner;
 }
 public ApplicationEvents(Application This)
 {
     this.This = This;
 }
Example #17
0
        public void InitChrome(Application app, ApplicationView applicationView)
        {
            app.DebugSettings.IsTextPerformanceVisualizationEnabled = false;
            app.DebugSettings.IsBindingTracingEnabled = false;
            app.DebugSettings.IsOverdrawHeatMapEnabled = false;
            app.DebugSettings.EnableFrameRateCounter = false;


            var titleBar = applicationView.TitleBar;

            titleBar.BackgroundColor = Colors.Transparent;
            titleBar.ForegroundColor = Colors.Black;

            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
            titleBar.ButtonBackgroundColor = Colors.Transparent;
            titleBar.ButtonForegroundColor = Colors.Black;
            titleBar.InactiveBackgroundColor = Colors.Transparent;
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

        }
Example #18
0
 public static void SetTitleTheme(Application instance)
 {
     ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
     titleBar.BackgroundColor = (Color)instance.Resources["MenuTitleColorBlue"];
     titleBar.ForegroundColor = Colors.GhostWhite;
     titleBar.ButtonBackgroundColor = (Color)instance.Resources["MenuTitleColorBlue"];
     titleBar.ButtonForegroundColor = Colors.GhostWhite;
 }
        /// <summary>
        /// Unhook events that were wired up in HookEvents.
        /// </summary>
        /// <param name="application">Application object to unhook from.</param>
        private static void UnhookEvents(Application application)
        {
            application.Resuming -= applicationResume;
            application.Suspending -= applicationSuspend;
            application.UnhandledException -= applicationException;

            if (attachedFrame != null)
                attachedFrame.Navigated -= FrameNavigated;

            attachedDataTransferManager.TargetApplicationChosen -= socialShare;
        }
Example #20
0
        /// <summary>
        /// Starts Countly tracking session.
        /// Call from your App.xaml.cs Application_Launching and Application_Activated events.
        /// Must be called before other SDK methods can be used.
        /// </summary>
        /// <param name="serverUrl">URL of the Countly server to submit data to; use "https://cloud.count.ly" for Countly Cloud</param>
        /// <param name="appKey">app key for the application being tracked; find in the Countly Dashboard under Management > Applications</param>
        public static async Task StartSession(string serverUrl, string appKey, Application application = null)
        {
            if (String.IsNullOrWhiteSpace(serverUrl))
            {
                throw new ArgumentException("invalid server url");
            }

            if (String.IsNullOrWhiteSpace(appKey))
            {
                throw new ArgumentException("invalid application key");
            }

            ServerUrl = serverUrl;
            AppKey = appKey;

            if (application != null)
            {
                IsExceptionsLoggingEnabled = true;

                application.UnhandledException -= OnApplicationUnhandledException;
                application.UnhandledException += OnApplicationUnhandledException;
            }

            Events = await Storage.LoadFromFile<List<CountlyEvent>>(eventsFilename) ?? new List<CountlyEvent>();

            Sessions = await Storage.LoadFromFile<List<SessionEvent>>(sessionsFilename) ?? new List<SessionEvent>();

            Exceptions = JsonConvert.DeserializeObject<List<ExceptionEvent>>(Storage.GetValue<string>(exceptionsFilename, "")) ?? new List<ExceptionEvent>();

            UserDetails = await Storage.LoadFromFile<CountlyUserDetails>(userDetailsFilename) ?? new CountlyUserDetails();

            UserDetails.UserDetailsChanged += OnUserDetailsChanged;

            startTime = DateTime.Now;

            Timer = new DispatcherTimer();
            Timer.Interval = TimeSpan.FromSeconds(updateInterval);
            Timer.Tick += UpdateSession;
            Timer.Start();

            await AddSessionEvent(new BeginSession(AppKey, Device.DeviceId, sdkVersion, new Metrics(Device.OS, Device.OSVersion, Device.DeviceName, Device.Resolution, Device.Carrier, Device.AppVersion)));

            if (null != SessionStarted)
            {
                SessionStarted(null, EventArgs.Empty);
            }
        }