Beispiel #1
0
        /// <summary>
        /// Open app startup with use file parameter
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            //Setup files and language
            Config.FileName = UtilsApp.GetDocsPath() + Config.FileName;
            App.ViewModel.LoadSetup();
            App.ViewModel.LoadLanguage();
            //Init setup values
            App.ViewModel.InitSetup();

            var mainWindow = new MainWindow();

            mainWindow.Show();

            //If argument exists
            if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null)
            {
                if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null &&
                    AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Count() > 0)
                {
                    String arg = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0];
                    if (!String.IsNullOrEmpty(arg))
                    {
                        App.ViewModel.FilterMsg = arg;
                        await mainWindow.OpenFileFromArg(arg);

                        App.ViewModel.FilterMsg = String.Empty;
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Event Open existing file from menu left
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void buttonAbrir_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.Filter           = "Comic Database File (.cdb)|*.cdb";
            openFileDialog.InitialDirectory = UtilsApp.GetDocsPath();
            System.Windows.Forms.DialogResult res = openFileDialog.ShowDialog();
            string path = openFileDialog.FileName;

            if (!String.IsNullOrEmpty(path) && res == System.Windows.Forms.DialogResult.OK)
            {
                await Task.Run(() =>
                {
                    App.ViewModel.IsWorking = true;
                    App.ViewModel.OpenFileDialog(path);
                    App.ViewModel.IsWorking = false;
                });
            }
        }