/// <summary>
        /// Create the DI container and register all classes against their interfaces
        /// </summary>
        /// <returns>The interface to the DI facade</returns>
        public IDependencyResolver Startup()
        {
            IUnityContainer container = new UnityContainer();

            container.RegisterInstance <IUnityContainer>(container, new ContainerControlledLifetimeManager());
            container.RegisterType <IDependencyResolver, UnityDI>(new ContainerControlledLifetimeManager());

            // Framework
            container.RegisterType <IDispatchOnUIThread, DispatchAdapter>(new ContainerControlledLifetimeManager());
            container.RegisterType <INavigationService, NavigationService>(new ContainerControlledLifetimeManager());
            container.RegisterType <IPlatformProperties, PlatformProperties>(new ContainerControlledLifetimeManager());

            // Services
            container.RegisterType <IBTClient, BTClient>(new ContainerControlledLifetimeManager());

            // View models
            container.RegisterType <IImagePickerViewModel, ImagePickerViewModel>();

            var injectionFacade = container.Resolve <IDependencyResolver>();

            DependencyHelper.Container = injectionFacade;

            // ensure the singleton dispatcher is created.
            DispatchHelper.Initialise(injectionFacade.Resolve <IDispatchOnUIThread>());

            return(injectionFacade);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create the DI container and register all classes against their interfaces
        /// </summary>
        private void Bootstrap()
        {
            IUnityContainer container = new UnityContainer();

            container.RegisterInstance <IUnityContainer>(container, new ContainerControlledLifetimeManager());
            container.RegisterType <IDependencyResolver, UnityDI>(new ContainerControlledLifetimeManager());

            // Initialise logging
            container.RegisterInstance <ILogger>(MainApplication.log, new ContainerControlledLifetimeManager());

            // Framework
            container.RegisterType <IDispatchOnUIThread, DispatchAdapter>(new ContainerControlledLifetimeManager());
            container.RegisterType <INavigationService, FormsNavigationService>(new ContainerControlledLifetimeManager());

            // Services
            container.RegisterType <IBTService, BTService>(new ContainerControlledLifetimeManager());

            // View models
            container.RegisterType <IPermissionsViewModel, PermissionsViewModel>();
            container.RegisterType <IMainViewModel, MainViewModel>();

            // Views
            container.RegisterType <IDialogService, DialogService>(new ContainerControlledLifetimeManager());

            var injectionFacade = container.Resolve <IDependencyResolver>();

            DependencyHelper.Container = injectionFacade;

            // ensure the singleton dispatcher is created.
            IDispatchOnUIThread dispatcher = injectionFacade.Resolve <IDispatchOnUIThread>();

            DispatchHelper.Initialise(dispatcher);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPage" /> class.
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();

            // Normaly this would be injected but for brevity
            DispatchHelper.Initialise(new UIDispatcher());
            this.DataContext = new MainViewModel();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPage"/> class
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();
            var dispatcher = new UIDispatcher();

            dispatcher.Initialize();
            DispatchHelper.Initialise(dispatcher);
            this.DataContext = new MainViewModel();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs args)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                // this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

#if NET5_0 && WINDOWS
            _window = new Window();
            _window.Activate();
#else
            _window = Windows.UI.Xaml.Window.Current;
#endif

            Frame rootFrame = _window.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // ensure the singleton dispatcher is created.
                var dispatcher = new UIDispatcher();
                dispatcher.Initialize();
                DispatchHelper.Initialise(dispatcher);

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                _window.Content = rootFrame;
            }

#if !(NET5_0 && WINDOWS)
            if (args.PrelaunchActivated == false)
#endif
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), args.Arguments);
                }
                // Ensure the current window is active
                _window.Activate();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPage" /> class.
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();

            this.dispatcher = DependencyHelper.Resolve <IDispatchOnUIThread>();
            this.dispatcher.Initialize();
            DispatchHelper.Initialise(this.dispatcher);

            this.DataContext = DependencyHelper.Resolve <IMainViewModel>();

            this.drawarea.SizeChanged += (s, e) =>
            {
                this.VM.SizeChanged(e.NewSize.Width, e.NewSize.Height);
            };
            this.Loaded += (s, e) =>
            {
                this.VM.OnViewLoaded();
            };
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPage"/> class
        /// </summary>
        public MainPage()
        {
            this.InitializeComponent();
            this.UndoCommand        = new DelegateCommandAsync(this.Undo_Templated, (o) => true);
            this.UndoInplaceCommand = new DelegateCommandAsync(this.Undo_Inplace, (o) => true);

            this.Loaded += (s, e) =>
            {
                if (Windows.UI.Xaml.Window.Current != null)
                {
                    DispatchHelper.Initialise();
                }

                this.altProgressDialog             = new AltProgressDialog();
                this.altProgressDialog.UndoCommand = this.UndoCommand;
                this.altProgressDialog.Message     = "This is where messages and and UNDO button would normally be";

                this.progressDialog.DialogSizeChanged += (d) =>
                {
                    this.dialogWidth = d;
                    this.UpdateDialogOffset();
                };
            };
        }