Beispiel #1
0
        private void Button_SelectAFSClick(object sender, RoutedEventArgs e)
        {
            var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog {
                Filter = "AFS files (*.afs)|*.afs|All files (*.*)|*.*"
            };

            if (dialog.ShowDialog() == false)
            {
                return;
            }
            if (!dialog.FileName.ToLower().EndsWith(".afs"))
            {
                MessageBox.Show("Pick an 'AFS' file", "Try Again");
                return;
            }
            var data = File.ReadAllBytes(dialog.FileName);

            if (AfsArchive.TryFromFile(data, out var afsArchive))
            {
                currentAfs = afsArchive;
                Button_ExportAFS.IsEnabled = true;
                if (ListBox_CurrentFNT.SelectedItem == null)
                {
                    return;
                }
                var currentSubtitleIndex = currentFnt.entryTable.IndexOf((TableEntry)ListBox_CurrentFNT.SelectedItem);
                if (currentSubtitleIndex == -1)
                {
                    return;
                }
                ListBox_CurrentFNT.SelectedIndex = -1;
                ListBox_CurrentFNT.SelectedIndex = currentSubtitleIndex;
            }
            ;
        }
Beispiel #2
0
 private void ExecuteChangePath()
 {
     if (Mode == "Installing")
     {
         var ofd = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
         ofd.Description            = "Select Installation Directory";
         ofd.UseDescriptionForTitle = true;
         if (ofd.ShowDialog() == true)
         {
             Location = ofd.SelectedPath;
             if (_downloadLocation == null)
             {
                 DownloadLocation = Path.Combine(Location, "downloads");
             }
         }
     }
     else
     {
         var fsd = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
         fsd.Title  = "Select a ModOrganizer modlist.txt file";
         fsd.Filter = "modlist.txt|modlist.txt";
         if (fsd.ShowDialog() == true)
         {
             Location = fsd.FileName;
             ConfigureForBuild();
         }
     }
 }
        /// <summary>
        /// Opens a file browser dialog when the button is clicked.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void BrowseButtonClick(object sender, RoutedEventArgs e)
        {
            Ookii.Dialogs.Wpf.VistaFileDialog fileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            //don't check if file exists, as dialog might be used for specifying the output filepath
            fileDialog.CheckFileExists = false;
            fileDialog.Title           = "Select File";

            bool?success = fileDialog.ShowDialog();

            if (success == true)
            {
                try
                {
                    FilePath path = new FilePath();
                    path.Init(fileDialog.FileName, Path.DataRoot);
                    Path = path;
                }
                catch (System.ArgumentException ex)
                {
                    NLog.LogManager.GetCurrentClassLogger().ErrorException("Failed to set reference to a file", ex);
                    MessageBox.Show(ex.Message, "Failed to set reference to a file", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }
        private void btnOpenFile_Click(object sender, RoutedEventArgs e)
        {
            Ookii.Dialogs.Wpf.VistaOpenFileDialog ofd = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            ofd.AddExtension     = true;
            ofd.CheckFileExists  = ofd.CheckPathExists = true;
            ofd.DefaultExt       = DefaultExt;
            ofd.FileName         = Filename;
            ofd.Filter           = Filter;
            ofd.FilterIndex      = FilterIndex;
            ofd.Multiselect      = MultiSelect;
            ofd.RestoreDirectory = true;
            ofd.Title            = Title;

            bool?Res = ofd.ShowDialog();

            if (Res.HasValue && Res.Value)
            {
                Filename    = ofd.FileName;
                Filenames   = ofd.FileNames;
                Filter      = ofd.Filter;
                FilterIndex = ofd.FilterIndex;

                TextChanged?.Invoke(this, new FileTextboxChangedEventArgs(Filename, Filenames));
            }
        }
        private void DoBrowseForTestResultsFile()
        {
            var dlg    = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            var result = dlg.ShowDialog();

            if (result == true)
            {
                TestResultsFile = dlg.FileName;
            }
        }
Beispiel #6
0
        //Primary button click
        private void PrimaryButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //Select emulator directory step
            if (StepCounter == 0)
            {
                Ookii.Dialogs.Wpf.VistaOpenFileDialog emuBrowser = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
                emuBrowser.Filter = "PCSX2 Executable | *.exe|Executable|*.exe";

                //Show dialog
                var browserResult = emuBrowser.ShowDialog();
                if (browserResult.Value == true)
                {
                    string _result = emuBrowser.FileName;

                    if (_result.ToLower().Contains("pcsx2") == false || _result.ToLower().EndsWith(".exe") == false)
                    {
                        MessageBox.Show("Invalid file.");
                        return;
                    }

                    Properties.Settings.Default.emuDir = _result;

                    BigLogo.Visibility       = Visibility.Collapsed;
                    DownloadLabel.Visibility = Visibility.Collapsed;

                    SecondaryButton.Visibility = Visibility.Visible;

                    MainLabel.Content = "PCSX2 First Time Setup";

                    Subtitle.Content    = "It is recommended to finish first time wizard to create a base configuration";
                    Subtitle.Visibility = Visibility.Visible;

                    PrimaryButton.Content = "Begin";

                    StepCounter += 1;
                    return;
                }
            }

            if (StepCounter == 1)
            {
                PrimaryButton.Visibility = Visibility.Collapsed;
                SecondaryButton.Content  = "Finish";

                MainLabel.Content = "Finish!";
                Subtitle.Content  = "Click below when finished with the wizard";

                _wizardProcess = LaunchPCSX2.CreateFirstTimeWizard();
                _wizardProcess.Start();

                StepCounter += 1;
                return;
            }
        }
        //Primary button click
        private void PrimaryButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //Select emulator directory step
            if (StepCounter == 0)
            {
                Ookii.Dialogs.Wpf.VistaOpenFileDialog emuBrowser = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
                emuBrowser.Filter = "PCSX2 Executable | *.exe|Executable|*.exe";

                //Show dialog
                var browserResult = emuBrowser.ShowDialog();
                if (browserResult.Value == true)
                {
                    string _result = emuBrowser.FileName;

                    if (_result.ToLower().Contains("pcsx2") == false || _result.ToLower().EndsWith(".exe") == false)
                    {
                        MessageBox.Show("Invalid file.");
                        return;
                    }

                    Properties.Settings.Default.emuDir = _result;
                    Properties.Settings.Default.Save();

                    //Increment Step count
                    StepCounter += 1;

                    /*
                     * Last step is for selecting the scraping API
                     * Since this process has been automated the entire
                     * step has become redundant. Thus has bee disabled
                     *
                     * This step remains until all the related UI controls
                     * Gets removed, this block serves as a reminder
                     * ~ CyberFoxHax - 11/12/2018
                     */
                    if (false)
                    {
                        //Set up next step
                        BigLogo.Visibility       = Visibility.Collapsed;
                        DownloadLabel.Visibility = Visibility.Collapsed;

                        MainLabel.Content           = "Select Boxart searching method";
                        TGDB_Description.Visibility = Visibility.Visible;

                        PrimaryButton.Content     = "Continue";
                        API_RadioPanel.Visibility = Visibility.Visible;
                        return;
                    }
                }
            }

            //Hide this page and go to Spectabis
            ((MainWindow)Application.Current.MainWindow).HideFirsttimeSetup();
        }
Beispiel #8
0
        private void DoBrowseForTestResultsFile()
        {
            var dlg = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            dlg.Multiselect = true;
            var result = dlg.ShowDialog();

            if (result == true)
            {
                this.TestResultsFile = string.Join(";", dlg.FileNames);
            }
        }
Beispiel #9
0
        private void LoadTargetsFromFile()
        {
            var openFileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            var worked         = openFileDialog.ShowDialog();

            if (worked == true)
            {
                MessageBox.Show("We loaded: " + openFileDialog.FileName);
                var iniReader = FRFactory.CreateReader(FRType.INIReader, openFileDialog.FileName);
                TargetsList = m_targetManager.GetTargetList();
                AddTarget();
            }
        }
Beispiel #10
0
        private void OpenFileExecute()
        {
            Ookii.Dialogs.Wpf.VistaOpenFileDialog ofd = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            ofd.Filter      = "Cringle Files (*.cringle)|*.cringle|All Files (*.*)|*.*";
            ofd.FilterIndex = 1;
            ofd.Multiselect = false;
            bool?result = ofd.ShowDialog();

            if (result == true)
            {
                OpenFile(ofd.FileName);
            }
        }
Beispiel #11
0
        private async void OpenDictionaryCommandExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            dialog.Filter          = "All Files (*.*)|*.*";
            dialog.CheckFileExists = true;
            var result = dialog.ShowDialog();

            if (result == true)
            {
                await OpenDictionary(dialog.FileName);
            }
        }
Beispiel #12
0
        // Package List
        private void packageListLocationButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog
            {
                InitialDirectory = Path.GetDirectoryName(Config.packageListPath)
            };

            if (dialog.ShowDialog(this).GetValueOrDefault())
            {
                packageListLocationTextbox.Text = dialog.FileName;
                packageListLocationTextbox_TextChanged(sender, null);
            }
        }
Beispiel #13
0
        private void SelReproductor_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog
            {
                AddExtension     = true,
                Filter           = "VxPlayer.exe|*.exe|VxPlayer.ink|*.ink",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
            };

            if (dialog.ShowDialog(this).GetValueOrDefault())
            {
                TxtReproductor.Text = dialog.FileName;
            }
        }
Beispiel #14
0
        private void OpenGame(object parameter)
        {
            Ookii.Dialogs.Wpf.VistaOpenFileDialog dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            //dialog.Description = "Select your workspace's root folder.";
            dialog.DefaultExt      = "ctp";
            dialog.CheckFileExists = true;
            dialog.Multiselect     = false;
            dialog.Title           = "Select a Project to Open";
            //dialog.ShowNewFolderButton = true;
            if (dialog.ShowDialog(this) == true)
            {
                //string fileName = System.IO.Path.Combine(_Workspace.RootFolder, _Workspace.ProjectName) + ".ctp";
                string fileName = dialog.FileName;
                //var settings = new XmlReaderSettings;();// { Indent = true };

                using (XmlReader reader = XmlReader.Create(fileName))
                {
                    //CTSerializer.Write(writer, _Workspace, "Workspace");
                    DataContractSerializerSettings serSettings = new DataContractSerializerSettings();
                    serSettings.PreserveObjectReferences = true;
                    DataContractSerializer serializer = new DataContractSerializer(typeof(Workspace), serSettings);
                    //serializer.WriteObject(writer, _Workspace);
                    _Workspace = serializer.ReadObject(reader) as Workspace;
                    if (_Workspace == null)
                    {
                        MessageBox.Show("The resulting workspace within the file '" + fileName + "' was invalid.");
                    }
                    reader.Close();
                }

                int i = fileName.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
                //string dir = fileName.Substring(System.IO.Path.DirectorySeparatorChar);
                //int i = fileName.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
                //dir = dir.Replace(dir, "");
                string dir = fileName.Remove(i);

                _Workspace.ProvideWorkspaceRoot(dir);
                this.Title = "Card Tricks - " + this._Workspace.ProjectName;
                ActiveCard = null;
                NotifyPropertyChanged("ActiveCard");
                NotifyPropertyChanged("Workspace");
                NotifyPropertyChanged("ObservableSets");
                NotifyPropertyChanged("ObservableDecks");
                NotifyPropertyChanged("ObservableTemplates");
                NotifyPropertyChanged("EditorPanelControls");
                NotifyPropertyChanged("TemplatesMenuList");
                NotifyPropertyChanged("HasTemplates");
                ClearDesignerWorkspace();
            }
        }
Beispiel #15
0
        private void LoadItemsFromDisk()
        {
            var openFileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            openFileDialog.AddExtension = true;
            openFileDialog.Filter       = "Easy Backup Files | *.ebf";
            openFileDialog.DefaultExt   = "ebf";
            openFileDialog.Title        = "Choose Easy Backup File";
            if (openFileDialog.ShowDialog(Application.Current.MainWindow).GetValueOrDefault())
            {
                LoadBackupTemplate(openFileDialog.FileName);
                UpdateLastUsedBackupPath(openFileDialog.FileName);
            }
        }
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog()
            {
                CheckFileExists = true,
                Filter          = "Mods|*.jar;*.zip|Tous les fichiers|*.*",
                Multiselect     = true,
                Title           = "Importer un mod"
            };

            if (dialog.ShowDialog(MainWindow.App) == true)
            {
                var progress        = new LoadingPage();
                var displayProgress = new BaseModel("Chargement...", false);
                displayProgress.Child = progress;
                displayProgress.Owner = MainWindow.App;
                Task.Factory.StartNew(() =>
                {
                    int max     = dialog.FileNames.Length;
                    int current = 0;
                    var newMods = new List <Mod>();
                    foreach (var file in dialog.FileNames)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            progress.ChangeDisplayer("Chargement de : " + Path.GetFileNameWithoutExtension(file) + "...");
                            progress.ChangeFill((float)current / max);
                        });
                        if (MainWindow.mods.FirstOrDefault((m) => m.Filename == Path.GetFileName(file)) == null)
                        {
                            File.Copy(file, Path.Combine(MainWindow.ModDir, Path.GetFileName(file)), true);
                            var mod     = MainWindow.LoadModFromFile(Path.Combine(MainWindow.ModDir, Path.GetFileName(file)));
                            mod.Enabled = true;
                            Dispatcher.Invoke(() => ListMods.Add(new ListMod(mod)));
                            MainWindow.mods.Add(mod);
                        }
                        current++;
                    }
                    ListMods.Sort((left, right) => left.linkedMod.Infos.name.CompareTo(right.linkedMod.Infos.name));
                    Dispatcher.Invoke(() =>
                    {
                        displayProgress.ForceClosing();
                    });
                });
                displayProgress.ShowDialog();
                MainWindow.mods.Sort((left, right) => left.Infos.name.CompareTo(right.Infos.name));
                updateList();
            }
        }
Beispiel #17
0
        private void ChooseFile()
        {
            var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            dialog.Multiselect  = true;
            dialog.ShowReadOnly = true;
            dialog.Title        = "Choose a file";
            if (dialog.ShowDialog(Application.Current.MainWindow).GetValueOrDefault())
            {
                foreach (string fileName in dialog.FileNames)
                {
                    AddPath(fileName);
                }
            }
        }
Beispiel #18
0
        private void OnOpenClick(object sender, RoutedEventArgs e)
        {
            var fileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog {
                Filter = "markdown files (*.md)|*.md"
            };

            if (fileDialog.ShowDialog(this) == true)
            {
                try
                {
                    this.viewModel.Source = new Uri(fileDialog.FileName, UriKind.Absolute);
                }
                catch (Exception ex)
                {
                    this.viewModel.TableOfContents = ex.Message;
                }
            }
        }
Beispiel #19
0
        private void DefaultExperiment_Click(object sender, RoutedEventArgs e)
        {
            Ookii.Dialogs.Wpf.VistaFileDialog fileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            fileDialog.CheckFileExists = true;
            fileDialog.Title           = "Select a experiment";
            fileDialog.AddExtension    = true;
            fileDialog.DefaultExt      = ".teml";
            fileDialog.Filter          = "Experimental Graph Files|*.teml";

            bool?success = fileDialog.ShowDialog();

            if (success.HasValue && success.Value)
            {
                var s  = (Button)sender;
                var vm = s.DataContext as SettingsViewModel;
                vm.DefaultExperiment = fileDialog.FileName;
            }
        }
Beispiel #20
0
        private static string GetBenchmarkFilePathDialog()
        {
            var fileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            fileDialog.Title           = "Select benchmark file path";
            fileDialog.CheckFileExists = false;
            fileDialog.AddExtension    = true;
            fileDialog.DefaultExt      = ".tbml";
            fileDialog.Filter          = "Benchmark Files|*.tbml";

            string filePath = null;
            bool?  success  = fileDialog.ShowDialog();

            if (success.HasValue && success.Value)
            {
                filePath = fileDialog.FileName;
            }
            return(filePath);
        }
Beispiel #21
0
        private void LoadModsFromSave(object sender, RoutedEventArgs e)
        {
            var dir = Directory.Exists(XmlFileReaderUtility.directory) ? XmlFileReaderUtility.directory : string.Empty;

            Ookii.Dialogs.Wpf.VistaOpenFileDialog dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog
            {
                Filter           = "yoursavefile.rws (*.rws)|*.rws",
                InitialDirectory = dir
            };
            if (dialog.ShowDialog() == true)
            {
                var list = XmlFileReaderUtility.ReadModsFromSaveFile(dialog.FileName);

                if (list.Any())
                {
                    LoadModsFromList(list);
                }
            }
        }
Beispiel #22
0
        private void Button_ReplaceADXClick(object sender, RoutedEventArgs e)
        {
            if (currentAfs == null)
            {
                return;
            }
            var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            if (dialog.ShowDialog() == false)
            {
                return;
            }
            if (dialog.FileName != "")
            {
                var newData = File.ReadAllBytes(dialog.FileName);
                currentAfs.Files[int.Parse(TextBox_AudioID.Text)].Data = newData;
                return;
            }
            MessageBox.Show("Failed");
        }
Beispiel #23
0
        //Change boxart
        private void ChangeArt_Button(object sender, RoutedEventArgs e)
        {
            Ookii.Dialogs.Wpf.VistaOpenFileDialog artBrowser = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            artBrowser.Filter = "JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png";
            artBrowser.Title  = "Browse to a new boxart image";

            var browserResult = artBrowser.ShowDialog();

            if (browserResult == true)
            {
                string _file = artBrowser.FileName;
                string _game = Header_title.Text;

                //Url files don't get filtered, so let's just not break the game profile and stop, if
                //selected file is indeed a url file
                if (_file.Contains(".url"))
                {
                    Console.WriteLine("File was URL, returning.");
                    return;
                }

                //Replace the boxart image
                //refreshTile(null);
                GameSettings_Header.Source = null;
                File.Copy(_file, BaseDirectory + @"\resources\configs\" + _game + @"\art.jpg", true);

                //Reload the image in header
                var artSource = new System.Windows.Media.Imaging.BitmapImage();
                artSource.BeginInit();
                artSource.CacheOption    = System.Windows.Media.Imaging.BitmapCacheOption.None;
                artSource.UriCachePolicy = new RequestCachePolicy(RequestCacheLevel.BypassCache);
                artSource.CreateOptions  = System.Windows.Media.Imaging.BitmapCreateOptions.IgnoreImageCache;

                artSource.CacheOption = System.Windows.Media.Imaging.BitmapCacheOption.OnLoad;
                artSource.UriSource   = new Uri(BaseDirectory + @"\resources\configs\" + _game + @"\art.jpg");
                artSource.EndInit();
                GameSettings_Header.Source = artSource;

                refreshTile(_game);
            }
        }
Beispiel #24
0
        public static SelectedFile SelectFile()
        {
            var filePicker = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            var response = filePicker.ShowDialog();

            if (response == null || response == false)
            {
                // Cancelled by user
                return(null);
            }

            // Return the file
            Stream file = filePicker.OpenFile();

            return(new SelectedFile
            {
                FileContents = file,
                FileName = filePicker.FileName
            });
        }
Beispiel #25
0
        public string OpenFileDialog(string fileName = null, FileType fileType = FileType.Any)
        {
            string filters;

            switch (fileType)
            {
            case FileType.Word:
                filters = "Документы Microsoft Word|*.doc;*.docx";
                break;

            case FileType.Xml:
                filters = $"Файлы проекта|*.{Constants.ExtName}";
                break;

            default:
                filters = "Все файлы| *.*";
                break;
            }

            var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog
            {
                CheckFileExists  = true,
                ShowReadOnly     = true,
                RestoreDirectory = true,
                DereferenceLinks = true,
                Filter           = filters
            };

            if (string.IsNullOrEmpty(fileName))
            {
                dialog.InitialDirectory = Path.GetDirectoryName(fileName);
                dialog.FileName         = Path.GetFileName(fileName);
            }
            else
            {
                // todo set default initial path
            }

            return(dialog.ShowDialog().GetValueOrDefault() ? dialog.FileName : null);
        }
Beispiel #26
0
        private void OpenFileSelectDialog()
        {
            if (!Directory.Exists(textBox.Content.ToString()))
            {
                textBox.Content = string.Empty;
            }

            Ookii.Dialogs.Wpf.VistaOpenFileDialog dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog
            {
                Filter           = "RimWorld.exe (*.exe)|*.exe",
                InitialDirectory = textBox.Content.ToString()
            };
            if (dialog.ShowDialog() == true)
            {
                textBox.Content = dialog.FileName;
                TryLoadFolder(Path.GetDirectoryName(dialog.FileName));
            }
            else
            {
                Application.Current.Shutdown();
            }
        }
        private void selectDevFileButton_Click(object sender, RoutedEventArgs e)
        {
            Ookii.Dialogs.Wpf.VistaOpenFileDialog fbd = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            fbd.Multiselect = false;
            fbd.Title       = "Select Dev-File-Template";

            /* if (File.Exists(Settings.Default.DevFile))
             * { fbd.FileName = Settings.Default.DevFile; }
             * else { fbd.FileName = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); }
             *
             * fbd.Filter = "DICOM files (*.dcm)|*.dcm|All Files (*.*)|*.*";
             *
             * if (fbd.ShowDialog() == true)
             * {
             *   try
             *   {
             *       var dcm = EvilDICOM.Core.DICOMObject.Read(fbd.FileName);
             *       if (dcm.FindFirst(TagHelper.Modality).DData.ToString() == "RTDOSE")
             *       {
             *           selectedDevFileTextBox.Text = fbd.FileName;
             *           Settings.Default.DevFile = fbd.FileName;
             *           ShowLogMsg("new Dev-File-Template: " + fbd.FileName);
             *           selectDevFileButton.Background = System.Windows.Media.Brushes.LawnGreen;
             *       }
             *       else
             *       {
             *           MessageBox.Show("The selected DICOM file does not have the required 'RTDOSE' modality.", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             *           //ChangeDummyTemplateButton.Background = System.Windows.Media.Brushes.PaleVioletRed;
             *       }
             *   }
             *   catch
             *   {
             *       MessageBox.Show("DICOM reading failed", "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
             *       //ChangeDummyTemplateButton.Background = System.Windows.Media.Brushes.PaleVioletRed;
             *   }
             * }*/
        }
 private void DoBrowseForTestResultsFile()
 {
     var dlg = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
     dlg.Multiselect = true;
     var result = dlg.ShowDialog();
     if (result == true) this.TestResultsFile = string.Join(";", dlg.FileNames);
 }
 private void menuOpenProject_Click(object sender, RoutedEventArgs e)
 {
     var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog()
     {
         AddExtension = true,
         CheckFileExists = true,
         DefaultExt = ProjectManifest.PROJECT_MANIFEST_EXTENSION,
         Filter = $"{ProjectManifest.PROJECT_MANIFEST_EXTENSION}|*{ProjectManifest.PROJECT_MANIFEST_EXTENSION}",
         Multiselect = false,
         ValidateNames = true,
     };
     var result = dialog.ShowDialog();
     if (result.Value)
         LoadProject(dialog.FileName);
 }
Beispiel #30
0
        private void InitCommands()
        {
            this._loadResumeDataCommand = new RelayCommand(() =>
            {
                var dialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
                dialog.Title = "Please select one resume.dat file to open";
                dialog.Filter = "All Files|*.*";
                dialog.CheckFileExists = true;
                dialog.ShowDialog();
                this.OpenResume(dialog.FileName);
            });

            this._treeviewSelectionChangedCommand = new RelayCommand<RoutedPropertyChangedEventArgs<object>>((args) =>
            {
                if (args.NewValue != null)
                {
                    if (args.NewValue is TreeViewItem)
                    {
                        this.UpdateItems("All");
                        return;
                    }
                    var patt = new Regex(@"(.*) \(\d+\)$");
                    this.UpdateItems(patt.Match(args.NewValue.ToString()).Groups[1].Value);
                }
            });

            this._createLabelsCommand = new RelayCommand(CreateLabels);

            this._resetCommand = new RelayCommand(() =>
            {
                if (this._resume != null)
                {
                    this._resumeItems = this._resume.ResumeItems;
                    this.UpdateLables();
                    this.UpdateItems("All");
                }
            });

            this._saveCommand = new RelayCommand(() =>
            {
                if (this._resumeItems == null)
                {
                    return;
                }
                string backpath = this._resume.Backup();
                if (backpath != null)
                {
                    this._resume.Save(this._resumeItems);
                    MessageBox.Show("Save compolete, the original file has been backup to " + backpath, "ResumeEditor", MessageBoxButton.OK, MessageBoxImage.None);
                }
                else
                {
                    throw new Exception("Cannot backup resume.dat, the change has not been saved.");
                }
            });

            this._filterCommand = new RelayCommand(FilterList);

            this._openExplorerCommand = new RelayCommand<object>((dg) =>
            {
                var datagrid = (DataGrid)dg;
                if (datagrid.SelectedItem != null)
                {
                    var item = (ResumeItem)datagrid.SelectedItem;
                    Process.Start("explorer.exe", item.Path);
                }
            });

            this._selectUTorrentChangedCommand = new RelayCommand(() => OpenResume(this._selectedResume));
        }
Beispiel #31
0
 private void DoBrowseForTestResultsFile()
 {
     var dlg = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
     var result = dlg.ShowDialog();
     if (result == true) this.TestResultsFile = dlg.FileName;
 }
        private void DefaultExperiment_Click(object sender, RoutedEventArgs e)
        {
            Ookii.Dialogs.Wpf.VistaFileDialog fileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            fileDialog.CheckFileExists = true;
            fileDialog.Title = "Select a experiment";
            fileDialog.AddExtension = true;
            fileDialog.DefaultExt = ".teml";
            fileDialog.Filter = "Experimental Graph Files|*.teml";

            bool? success = fileDialog.ShowDialog();
            if (success.HasValue && success.Value)
            {
                var s = (Button)sender;
                var vm = s.DataContext as SettingsViewModel;
                vm.DefaultExperiment = fileDialog.FileName;
            }
        }
Beispiel #33
0
        public void LoadPbp()
        {
            if (IsBusy)
            {
                MessageBox.Show(Window, "An operation is in progress. Please wait for the current operation to complete.", "PSXPackager",
                                MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            var openFileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            openFileDialog.Filter = "PBP Files|*.pbp|All files|*.*";
            var result = openFileDialog.ShowDialog();

            if (!result.GetValueOrDefault(false))
            {
                return;
            }

            var path = openFileDialog.FileName;

            try
            {
                using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    var pbpReader = new PbpReader(stream);

                    var discs = pbpReader.Discs.Select((d, i) =>
                    {
                        var game = _gameDb.GetEntryByScannerID(d.DiscID);

                        var disc = new Disc()
                        {
                            Index           = i,
                            Title           = game.GameName,
                            Size            = d.IsoSize,
                            GameID          = d.DiscID,
                            IsRemoveEnabled = true,
                            IsLoadEnabled   = true,
                            IsSaveAsEnabled = true,
                            IsEmpty         = false,
                            SourceUrl       = $"//pbp/disc{i}/{path}"
                        };

                        disc.RemoveCommand = new RelayCommand((o) => Remove(disc));

                        return(disc);
                    }).ToList();


                    var dummyDiscs = DummyDisc(discs.Count, 5 - discs.Count);

                    Model.Discs = discs.Concat(dummyDiscs).ToList();


                    void LoadResource(ResourceType type, ResourceModel model)
                    {
                        if (pbpReader.TryGetResourceStream(type, stream, out var resourceStream))
                        {
                            model.Icon            = GetBitmapImage(resourceStream);
                            model.IsLoadEnabled   = true;
                            model.IsSaveAsEnabled = true;
                            model.IsRemoveEnabled = true;
                            model.SourceUrl       = $"//pbp/{type.ToString().ToLower()}/{path}";
                        }
                    }


                    LoadResource(ResourceType.ICON0, Model.Icon0);
                    LoadResource(ResourceType.ICON1, Model.Icon1);
                    LoadResource(ResourceType.PIC0, Model.Pic0);
                    LoadResource(ResourceType.PIC1, Model.Pic1);

                    Model.IsNew = false;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(Window, e.Message, "PSXPackager", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
        /// <summary>
        /// Opens a file browser dialog when the button is clicked.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void BrowseButtonClick(object sender, RoutedEventArgs e)
        {
            Ookii.Dialogs.Wpf.VistaFileDialog fileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
            
            //don't check if file exists, as dialog might be used for specifying the output filepath
            fileDialog.CheckFileExists = false;
            fileDialog.Title = "Select File";

            bool? success = fileDialog.ShowDialog();
            if (success == true)
            {
                try
                {
                    FilePath path = new FilePath();
                    path.Init(fileDialog.FileName, Path.DataRoot);
                    Path = path;
                }
                catch (System.ArgumentException ex)
                {
                    NLog.LogManager.GetCurrentClassLogger().ErrorException("Failed to set reference to a file", ex);
                    MessageBox.Show(ex.Message, "Failed to set reference to a file", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }
        private void ConvertMultiToSingleBin_OnClick(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();

            openFileDialog.Filter      = "Supported files|*.bin;*.cue|All files|*.*";
            openFileDialog.Multiselect = true;
            var openResult = openFileDialog.ShowDialog();

            if (!openResult.GetValueOrDefault(false))
            {
                return;
            }

            var saveFileDialog = new Ookii.Dialogs.Wpf.VistaSaveFileDialog();

            saveFileDialog.Filter       = "Supported files|*.bin;";
            saveFileDialog.DefaultExt   = ".bin";
            saveFileDialog.AddExtension = true;
            var saveResult = saveFileDialog.ShowDialog();

            if (!saveResult.GetValueOrDefault(false))
            {
                return;
            }

            bool   generatedCue = false;
            string tempFile     = "";

            var trackRegex = new Regex("Track (\\d+)");

            if (openFileDialog.FileNames.Length > 1)
            {
                if (!openFileDialog.FileNames.All(f =>
                {
                    var match = trackRegex.Match(f);
                    return(Path.GetExtension(f).ToLower() == ".bin" &&
                           match.Success &&
                           int.TryParse(match.Groups[1].Value, out var dummy));
                }))
                {
                    MessageBox.Show(Window, "Please multi-select only .bins ending in (Track #)",
                                    "PSXPackager",
                                    MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                var cueFile = new CueFile();

                var index = 1;
                foreach (var fileName in openFileDialog.FileNames.OrderBy(f => int.Parse(trackRegex.Match(f).Groups[1].Value)))
                {
                    cueFile.FileEntries.Add(new CueFileEntry()
                    {
                        FileName = fileName,
                        FileType = "BINARY",
                        Tracks   = index == 1
                            ? new List <CueTrack>()
                        {
                            new CueTrack()
                            {
                                DataType = CueTrackType.Data,
                                Number   = index,
                                Indexes  = new List <CueIndex>()
                                {
                                    new CueIndex()
                                    {
                                        Number = 1, Position = new IndexPosition(0, 0, 0)
                                    }
                                }
                            }
                        }
                            : new List <CueTrack>()
                        {
                            new CueTrack()
                            {
                                DataType = CueTrackType.Audio,
                                Number   = index,
                                Indexes  = new List <CueIndex>()
                                {
                                    new CueIndex()
                                    {
                                        Number = 0, Position = new IndexPosition(0, 0, 0)
                                    },
                                    new CueIndex()
                                    {
                                        Number = 1, Position = new IndexPosition(0, 2, 0)
                                    }
                                }
                            }
                        }
                    });
                    index++;
                }

                tempFile = Path.GetTempFileName() + ".cue";

                CueFileWriter.Write(cueFile, tempFile);

                generatedCue = true;
            }
            else if (Path.GetExtension(openFileDialog.FileName).ToLower() == ".cue")
            {
                tempFile = openFileDialog.FileName;
            }
            else
            {
                MessageBox.Show(Window, "Please select the CUE file, or if you do not have a CUE file, multi-select all the .bins ending in (Track #)",
                                "PSXPackager",
                                MessageBoxButton.OK, MessageBoxImage.Information);
            }

            var folder     = Path.GetDirectoryName(Path.GetFullPath(saveFileDialog.FileName));
            var filename   = Path.GetFileName(saveFileDialog.FileName);
            var processing = new Popstation.Processing(null, null, null);

            var(binfile, cuefile) = processing.ProcessCue(tempFile, Path.GetTempPath());

            var cueFileName = Path.GetFileNameWithoutExtension(filename) + ".cue";
            var outputPath  = Path.Combine(folder, saveFileDialog.FileName);

            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }

            File.Move(binfile, outputPath);

            if (generatedCue)
            {
                var updatedCueFile = CueFileReader.Read(cuefile);
                var fileEntry      = updatedCueFile.FileEntries.First();
                fileEntry.FileName = filename;
                CueFileWriter.Write(updatedCueFile, Path.Combine(folder, cueFileName));
            }

            MessageBox.Show(Window, $"Merged .bins to {outputPath}", "PSXPackager",
                            MessageBoxButton.OK, MessageBoxImage.Information);
        }
        //Primary button click
        private void PrimaryButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            //Select emulator directory step
            if (StepCounter == 0)
            {
                Ookii.Dialogs.Wpf.VistaOpenFileDialog emuBrowser = new Ookii.Dialogs.Wpf.VistaOpenFileDialog();
                emuBrowser.Filter = "PCSX2 Executable | *.exe|Executable|*.exe";

                //Show dialog
                var browserResult = emuBrowser.ShowDialog();
                if (browserResult.Value == true)
                {
                    string _result = emuBrowser.FileName;

                    if (_result.ToLower().Contains("pcsx2") == false || _result.ToLower().EndsWith(".exe") == false)
                    {
                        MessageBox.Show("Invalid file.");
                        return;
                    }

                    //Save selected path, *don't* remove pcsx2.exe from string
                    Properties.Settings.Default.emuDir = _result;
                    Properties.Settings.Default.Save();

                    //Increment Step count
                    StepCounter = +1;

                    //Set up next step
                    BigLogo.Visibility       = Visibility.Collapsed;
                    DownloadLabel.Visibility = Visibility.Collapsed;

                    MainLabel.Content           = "Select Boxart searching method";
                    TGDB_Description.Visibility = Visibility.Visible;

                    PrimaryButton.Content     = "Continue";
                    API_RadioPanel.Visibility = Visibility.Visible;

                    return;
                }
            }

            //Select API step
            if (StepCounter == 1)
            {
                //If Giantbomb is selected, check if API key is entered
                if (GB_Radio.IsChecked == true)
                {
                    if (ApiBox.Text.Length != 40)
                    {
                        MessageBox.Show("API Key not valid lenght");
                        return;
                    }


                    //Save settings
                    Properties.Settings.Default.artDB            = "GiantBomb";
                    Properties.Settings.Default.APIKey_GiantBomb = ApiBox.Text;
                    Properties.Settings.Default.Save();
                }
                else if (TGDB_Radio.IsChecked == true)
                {
                    //Save settings
                    Properties.Settings.Default.artDB = "TheGamesDB";
                    Properties.Settings.Default.Save();
                }
            }

            //Hide this page and go to Spectabis
            ((MainWindow)Application.Current.MainWindow).HideFirsttimeSetup();
        }