Пример #1
0
        //! Open dialog to open a save file for import.
        private void BtnLoadLottery_Click(object sender, RoutedEventArgs e)
        {
            var openfileDialog = new OpenFileDialog()
            {
                Filter           = "Velvet Pearl Lottery Files (*.vplf)|*.vplf",
                FileName         = "Velvet Pearl lottery",
                DefaultExt       = "vplf",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
            };

            var result = openfileDialog.ShowDialog();

            if (result == null || !result.Value)
            {
                return;
            }

            var filestream      = openfileDialog.OpenFile();
            var importedLottery = InitiateImport(filestream);

            filestream.Close();
            if (importedLottery == null)
            {
                return;
            }

            var mainWindow = new WndMain(true, openfileDialog.FileName)
            {
                Owner = this, LotteryModel = importedLottery
            };

            mainWindow.Show();
            mainWindow.Owner = null;
            this.Close();
        }
Пример #2
0
        /*!
         *  \brief ButtonClick event handler for creating a new lottery.
         *
         *  This function opens a new main window for the new lottery and then
         *  the dialog window for creating the new lottery, in which the user
         *  will input the required data.
         *
         *  Once the two new windows have been created and enabled, the
         *  function closes its own welcoming window.
         *
         *  \param sender Object that triggered the ButtonClick event.
         *  \para e Event information.
         */
        private void BtwNewLottery_Click(object sender, RoutedEventArgs e)
        {
            var mainWindow = new WndMain(true)
            {
                Owner = this
            };

            mainWindow.Show();
            mainWindow.Owner = null;
            Hide();
            mainWindow.OpenNewLotteryWindow();
            Close();
        }
Пример #3
0
        /*!
         *  \brief Check if a load-file name is stored and parse it if so.
         *
         *  This function, run upon the welcome window being loaded, checks the
         *  application's dynamic memory for a filename on a lottery save file
         *  the application was started with (e.g. by double-clicking a save file).
         *
         *  If such a file is found, it is parsed and the application shows the main
         *  lottery window, assuming no parse error occured.
         */
        private void WelcomeWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (!SkipUpdateCheck)
            {
                CheckForUpdates();
                if (UpdateProcess != null && UpdateProcess.UpdateAvailable && !UpdateWasCancelled)
                {
                    // Close the application since the update installer has been opened.
                    Close();
                    return;
                }
            }

            if (Application.Current.Properties["LoadfileName"] == null)
            {
                return;
            }

            var     filename = Application.Current.Properties["LoadfileName"].ToString();
            Lottery importedLottery;

            try {
                Stream filestream = new FileStream(filename, FileMode.Open);
                importedLottery = InitiateImport(filestream);
            }
            catch (Exception ex) {
                WndDialogMessage.Show(this, "An unexpected error occured during loading of the save file:\n" + ex.Message,
                                      "Unexpected Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (importedLottery == null)
            {
                return;
            }

            var mainWindow = new WndMain(true, filename)
            {
                Owner = this, LotteryModel = importedLottery
            };

            mainWindow.Show();
            mainWindow.Owner = null;
            Close();
        }