void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.Launcher = ((GameLauncher.MainWindow)(target));
                return;

            case 2:
                this.MainGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 3:
                this.AddNewGame = ((System.Windows.Controls.Button)(target));

            #line 18 "..\..\MainWindow.xaml"
                this.AddNewGame.Click += new System.Windows.RoutedEventHandler(this.NewGameButton_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.LaumcherWindow = ((GameLauncher.MainWindow)(target));
     return;
     case 2:
     this.browser = ((System.Windows.Controls.WebBrowser)(target));
     return;
     case 3:
     this.VersionLabel = ((System.Windows.Controls.Label)(target));
     return;
     case 4:
     this.LaunchGameBtn = ((System.Windows.Controls.Button)(target));
     
     #line 26 "..\..\..\MainWindow.xaml"
     this.LaunchGameBtn.Click += new System.Windows.RoutedEventHandler(this.LaunchGameBtn_Click);
     
     #line default
     #line hidden
     return;
     case 5:
     this.LaunchSiteBtn = ((System.Windows.Controls.Button)(target));
     
     #line 27 "..\..\..\MainWindow.xaml"
     this.LaunchSiteBtn.Click += new System.Windows.RoutedEventHandler(this.LaunchSiteBtn_Click);
     
     #line default
     #line hidden
     return;
     case 6:
     this.gameNameLabel = ((System.Windows.Controls.Label)(target));
     return;
     }
     this._contentLoaded = true;
 }
Exemple #3
0
        /// <summary>
        /// Called when the application starts.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            // Check to see if the config file exists.
            // If not, we'll create a folder selection dialog.
            // If it does, we'll continue normally.
            if (!Configuration.Instance.Exists)
            {
                var dialog = new CommonOpenFileDialog
                {
                    Title                     = "Select game directory",
                    IsFolderPicker            = true,
                    InitialDirectory          = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                    AddToMostRecentlyUsedList = false,
                    AllowNonFileSystemItems   = false,
                    DefaultDirectory          = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                    EnsureFileExists          = false,
                    EnsurePathExists          = false,
                    EnsureReadOnly            = false,
                    EnsureValidNames          = true,
                    Multiselect               = false,
                    ShowPlacesList            = false,
                };

                if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
                {
                    if (File.Exists(Path.Combine(dialog.FileName, "nfsw.exe")))
                    {
                        MessageBox.Show("Selected folder already contains Need for Speed: World.", "Error", MessageBoxButton.OK);
                        Current.Shutdown(-1);
                        return;
                    }

                    Configuration.Instance.Create(dialog.FileName);

                    var mainWindow = new MainWindow();
                    Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                    Current.MainWindow   = mainWindow;
                    mainWindow.Show();
                }
                else
                {
                    MessageBox.Show("Please restart the launcher. You must select a folder.", "Error", MessageBoxButton.OK);
                    Current.Shutdown(-1);
                }
            }
            else
            {
                if (Process.GetProcessesByName("nfsw.exe").Length >= 1)
                {
                    MessageBox.Show("An instance of NFSW is already running.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Current.Shutdown(-1);
                    return;
                }

                var mainWindow = new MainWindow();
                Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                Current.MainWindow   = mainWindow;
                mainWindow.Show();
                mainWindow.Activate();
            }
        }