Beispiel #1
0
        public MainPage()
        {
            ServiceProvider.Initialize("aff9f004793a1d32d26fe2361d5fc723", "33dbf033a01d5a3be4a631b4d47950c6", Dispatcher);
            ServiceProvider.GoneOnline  += (sender, e) => IsOnline = true;
            ServiceProvider.GoneOffline += (sender, e) =>
            {
                IsOnline = false;
                ServiceProvider.ViewManager.NavigationCommands.NavigateLoginCommand.Execute(null);
            };

            ServiceProvider.ViewManager.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_OnViewManagerPropertyChanged);

            Loaded += (sender, e) =>
            {
                this.StartSwooshes();

                ServiceProvider.ViewManager.NavigationCommands.NavigateLoginCommand.Execute(null);
            };


            DeploymentManager.StartMonitor();
            DeploymentManager.ApplicationUpdated += _OnApplicationUpdated;

            _LocalApplicationCommands    = new MainWindowCommands(ServiceProvider.ViewManager);
            _SwitchFullScreenModeCommand = new RoutedCommand("SwitchFullScreenMode", typeof(MainPage));

            InitializeComponent();

            CommandBindings.Add(new CommandBinding(System.Windows.Input.NavigationCommands.BrowseBack, (sender, e) => _SafeBrowseBack(), (sender, e) => e.CanExecute = CanGoBack));
            CommandBindings.Add(new CommandBinding(System.Windows.Input.NavigationCommands.Refresh, (sender, e) => ServiceProvider.ViewManager.NavigationCommands.StartSyncCommand.Execute(null)));
            CommandBindings.Add(new CommandBinding(MediaCommands.TogglePlayPause, OnPlayCommandExecuted));
            CommandBindings.Add(new CommandBinding(MediaCommands.Play, OnPlayCommandExecuted));
            CommandBindings.Add(new CommandBinding(_SwitchFullScreenModeCommand, OnSwitchFullScreenCommand));

            RoutedCommand backNavigationKeyOverrideCommand = new RoutedCommand();

            CommandBindings.Add(
                new CommandBinding(
                    backNavigationKeyOverrideCommand,
                    (sender, e) => ((MainPage)sender)._SafeBrowseBack()));

            InputBindings.Add(new InputBinding(backNavigationKeyOverrideCommand, new KeyGesture(Key.Back)));
            InputBindings.Add(new KeyBinding(_LocalApplicationCommands.SwitchThemeCommand, new KeyGesture(Key.T, ModifierKeys.Control)));
        }
Beispiel #2
0
        public MainWindow()
        {
            ServiceProvider.Initialize(FacebookClientApplication.FacebookApiId, FacebookClientApplication.FacebookApiKey, FacebookClientApplication.BingApiKey, Environment.GetCommandLineArgs(), Dispatcher);
            ServiceProvider.GoneOnline += (sender, e) =>
            {
                IsOnline = true;
                ServiceProvider.ViewManager.Friends.CollectionChanged += _OnFriendsHasCount;
            };

            ServiceProvider.ViewManager.PropertyChanged             += _OnViewManagerPropertyChanged;
            ServiceProvider.ViewManager.ExternalNavigationRequested += _OnExternalNavigationRequested;

            Loaded += (sender, e) =>
            {
                ServiceProvider.ViewManager.NavigationCommands.NavigateLoginCommand.Execute(null);

                if (FacebookClientApplication.Current2.IsFirstRun)
                {
                    FacebookClientApplication.Current2.IsFirstRun = false;
                }
            };

            SourceInitialized += (sender, e) =>
            {
                // Defer starting the update timer until the Window is up, but not until the application is online.
                // We want to make sure that the user is able to update the app if there's a fix available for an issue that
                // was preventing them from connecting to the service.
                DeploymentManager.ApplicationUpdated      += _OnApplicationUpdated;
                DeploymentManager.ApplicationUpdateFailed += _OnApplicationUpdateFailed;
                DeploymentManager.StartMonitor();
            };

            // When the window loses focus take it as an opportunity to trim our workingset.
            Deactivated += (sender, e) => FacebookClientApplication.PerformAggressiveCleanup();

            ApplicationCommands = new MainWindowCommands(ServiceProvider.ViewManager);

            _SwitchFullScreenModeCommand = new RoutedCommand("SwitchFullScreenMode", typeof(MainWindow));

            InitializeComponent();

            _photoUploadWizard         = new PhotoUploadWizard();
            _photoUploadWizardInfoPage = new PhotoUploadInformationPage(_photoUploadWizard);
            _embeddedBrowserControl    = new EmbeddedBrowserControl();

            Rect settingsBounds = Properties.Settings.Default.MainWindowBounds;

            if (!settingsBounds.IsEmpty)
            {
                if (settingsBounds.Left == 0 && settingsBounds.Top == 0)
                {
                    WindowStartupLocation = WindowStartupLocation.CenterScreen;
                }
                else
                {
                    this.Left = settingsBounds.Left;
                    this.Top  = settingsBounds.Top;
                }
                this.Width  = settingsBounds.Width;
                this.Height = settingsBounds.Height;
            }

            CommandBindings.Add(new CommandBinding(System.Windows.Input.NavigationCommands.BrowseBack, (sender, e) => _SafeBrowseBack(), (sender, e) => e.CanExecute = CanGoBack));
            CommandBindings.Add(new CommandBinding(System.Windows.Input.NavigationCommands.Refresh, (sender, e) => ServiceProvider.ViewManager.ActionCommands.StartSyncCommand.Execute(null)));
            CommandBindings.Add(new CommandBinding(_SwitchFullScreenModeCommand, OnSwitchFullScreenCommand));

            RoutedCommand backNavigationKeyOverrideCommand = new RoutedCommand();

            CommandBindings.Add(
                new CommandBinding(
                    backNavigationKeyOverrideCommand,
                    (sender, e) => ((MainWindow)sender)._SafeBrowseBack()));

            InputBindings.Add(new InputBinding(backNavigationKeyOverrideCommand, new KeyGesture(Key.Back)));

            this.PreviewStylusSystemGesture += new StylusSystemGestureEventHandler(OnPreviewStylusSystemGesture);
            this.PreviewStylusMove          += new StylusEventHandler(OnPreviewStylusMove);

            this.SizeChanged += _OnSizeChanged;
        }