コード例 #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var assembly  = Assembly.GetExecutingAssembly();
            var mutexName = string.Format(CultureInfo.InvariantCulture, "Local\\{{{0}}}{{{1}}}", assembly.GetType().GUID, assembly.GetName().Name);

            _mMutex = new Mutex(true, mutexName, out bool mutexCreated);
            if (!mutexCreated)
            {
                _mMutex = null;
                Current.Shutdown();
                return;
            }

            WhatsNewDisplayService.ShowIfAppropriate();
            FirstRunDisplayService.ShowIfAppropriate();

            new MainWindow();
        }
コード例 #2
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="e">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs e)
        {
            // Set the application minimum window size
            var applicationView = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView();

            applicationView.SetPreferredMinSize(
                new Size(
                    width: 270,
                    height: 400
                    ));
            if (this.IsXBox) // Only do this on XBox, on phone the ui will be behind system app bar otherwise.
            {
                applicationView.SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseCoreWindow);
            }


            MicrosoftGraphService.Instance.AuthenticationModel = MicrosoftGraphEnums.AuthenticationModel.V2;
            MicrosoftGraphService.Instance.Initialize(SecureConstents.API,
                                                      MicrosoftGraphEnums.ServicesToInitialize.UserProfile,
                                                      new[] {
                "User.Read",
                "Files.Read",
                "Files.ReadWrite.AppFolder",
                //"profile",
                "email",
                "UserActivity.ReadWrite.CreatedByApp"
            });


            var rootFrame = Window.Current.Content as Pages.ShellPage;

            // 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 Pages.ShellPage();

                //rootFrame.NavigationFailed += OnNavigationFailed;

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

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            Shell = rootFrame;
            if (e.PrelaunchActivated == false)
            {
                if (Services.NavigationService.Frame.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
                    Services.NavigationService.Navigate <Pages.MainPage>();
                    //rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();

                Window.Current.SizeChanged += this.WindowSizeChanged;
                this.UpdateIsTouch();

                await FirstRunDisplayService.ShowIfAppropriateAsync();

                await WhatsNewDisplayService.ShowIfAppropriateAsync();
            }
        }
コード例 #3
0
        public MainPageViewModel(ICommonLogging iocCommonLogging, IEventAggregator iocEventAggregator, INavigationService iocNavigationService, FirstRunDisplayService iocFirstRunDisplayService, WhatsNewDisplayService iocWhatsNewDisplayService, DatabaseReloadDisplayService iocDatabaseReloadDisplayService, IDialogService dialogService)
            : base(iocCommonLogging, iocEventAggregator, iocNavigationService)
        {
            localWhatsNewDisplayService = iocWhatsNewDisplayService;

            localFirstRunDisplayService = iocFirstRunDisplayService;

            localDatabaseReloadDisplayService = iocDatabaseReloadDisplayService;

            _dialogService = dialogService;

            BaseEventAggregator.GetEvent <AppStartFirstRunEvent>().Subscribe(ServiceFirstRun, ThreadOption.UIThread);

            BaseEventAggregator.GetEvent <AppStartLoadDataEvent>().Subscribe(ServiceLoadData, ThreadOption.UIThread);

            BaseEventAggregator.GetEvent <AppStartReloadDatabaseEvent>().Subscribe(ServiceReloadDatabase, ThreadOption.UIThread);

            BaseEventAggregator.GetEvent <AppStartWhatsNewEvent>().Subscribe(ServiceWhatsNew, ThreadOption.UIThread);

            BaseEventAggregator.GetEvent <DataLoadCompleteEvent>().Subscribe(LoadHubPage, ThreadOption.UIThread);

            BaseEventAggregator.GetEvent <DialogBoxEvent>().Subscribe(ActionDialog, ThreadOption.UIThread);

            BaseEventAggregator.GetEvent <PageNavigateEvent>().Subscribe(OnNavigateCommandExecuted, ThreadOption.UIThread);

            BaseEventAggregator.GetEvent <PageNavigateParmsEvent>().Subscribe(OnNavigateParmsCommandExecuted, ThreadOption.UIThread);

            // Build the Menu
            NavigateCommand = new DelegateCommand <string>(OnNavigateCommandExecuted);

            MainMenuItems = new List <MainMenuItem>()

            {
                new MainMenuItem()
                {
                    Title = "Hub", Icon = CommonConstants.IconHub, TargetType = nameof(HubPage)
                },

                new MainMenuItem()
                {
                    Title = "Bookmarks", Icon = CommonConstants.IconBookMark, TargetType = nameof(BookMarkListPage)
                },

                new MainMenuItem()
                {
                    Title = "Citations", Icon = CommonConstants.IconCitation, TargetType = nameof(CitationListPage)
                },

                new MainMenuItem()
                {
                    Title = "Events", Icon = CommonConstants.IconEvents, TargetType = nameof(EventListPage)
                },

                new MainMenuItem()
                {
                    Title = "Families", Icon = CommonConstants.IconFamilies, TargetType = nameof(FamilyListPage)
                },

                new MainMenuItem()
                {
                    Title = "Media", Icon = CommonConstants.IconMedia, TargetType = nameof(MediaListPage)
                },

                new MainMenuItem()
                {
                    Title = "Notes", Icon = CommonConstants.IconNotes, TargetType = nameof(NoteListPage)
                },

                new MainMenuItem()
                {
                    Title = "People", Icon = CommonConstants.IconPeople, TargetType = nameof(PersonListPage)
                },

                new MainMenuItem()
                {
                    Title = "Places", Icon = CommonConstants.IconPlace, TargetType = nameof(PlaceListPage)
                },

                new MainMenuItem()
                {
                    Title = "Repositories", Icon = CommonConstants.IconRepository, TargetType = nameof(RepositoryListPage)
                },

                new MainMenuItem()
                {
                    Title = "Sources", Icon = CommonConstants.IconSource, TargetType = nameof(SourceListPage)
                },

                new MainMenuItem()
                {
                    Title = "Tags", Icon = CommonConstants.IconTag, TargetType = nameof(TagListPage)
                },

                //<!--
                //    new NavigationViewItemSeparator
                //    {
                //    },
                //-->

                new MainMenuItem()
                {
                    Title = "PeopleGraph", Icon = CommonConstants.IconPeopleGraph, TargetType = nameof(PeopleGraphPage)
                },

                //<!--
                //    new NavigationViewItemSeparator
                //    {
                //    },
                //-->

                new MainMenuItem()
                {
                    Title = "Search", Icon = CommonConstants.IconSearch, TargetType = nameof(SearchPage)
                },

                new MainMenuItem()
                {
                    Title = "Choose data file", Icon = CommonConstants.IconChooseDataFile, TargetType = nameof(FileInputHandlerPage)
                },

                new MainMenuItem()
                {
                    Title = "Settings", Icon = CommonConstants.IconSettings, TargetType = nameof(SettingsPage)
                },

                new MainMenuItem()
                {
                    Title = "About", Icon = CommonConstants.IconAbout, TargetType = nameof(AboutPage)
                },
            };
        }
コード例 #4
0
        private static async Task StartupAsync()
        {
            await ThemeSelectorService.SetRequestedThemeAsync();

            await FirstRunDisplayService.ShowIfAppropriateAsync();
        }