Esempio n. 1
0
 private void ctrlFiles_NewItemNeeded(object sender, AdditionalFilesEventArgs e)
 {
     using (FileSelectForm form = new FileSelectForm())
     {
         form.Initialize(this.DataSourceAdapter, this.m_additionalFileViews);
         form.MultiSelect   = true;
         form.StartPosition = FormStartPosition.CenterParent;
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             IGameFileDataSource[] second = new IGameFileDataSource[] { this.GameFile };
             IGameFileDataSource[] source = form.SelectedFiles.Except <IGameFileDataSource>(second).ToArray <IGameFileDataSource>();
             if (source.Length != 0)
             {
                 e.NewItems = source.Cast <object>().ToList <object>();
                 try
                 {
                     IGameFileDataSource[] selectedFiles = new IGameFileDataSource[] { source.First <IGameFileDataSource>() };
                     this.ResetSpecificFilesSelections(selectedFiles);
                 }
                 catch (FileNotFoundException exception)
                 {
                     MessageBox.Show(this, $"The Game File {exception.FileName} is missing from the library.", "File Not Found");
                 }
                 catch (Exception exception2)
                 {
                     DoomLauncher.Util.DisplayUnexpectedException(this, exception2);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private void ctrlFiles_NewItemNeeded(object sender, AdditionalFilesEventArgs e)
        {
            using (FileSelectForm fileSelect = new FileSelectForm())
            {
                fileSelect.Initialize(m_adapter, m_additionalFileViews);
                fileSelect.MultiSelect   = true;
                fileSelect.StartPosition = FormStartPosition.CenterParent;

                if (fileSelect.ShowDialog(this) == DialogResult.OK)
                {
                    IGameFile[] selectedFiles = fileSelect.SelectedFiles.Except(new IGameFile[] { GameFile }).ToArray();

                    if (selectedFiles.Length > 0)
                    {
                        e.NewItems = selectedFiles.Cast <object>().ToList();

                        try
                        {
                            ResetSpecificFilesSelections(new IGameFile[] { selectedFiles.First() });
                        }
                        catch (FileNotFoundException ex)
                        {
                            MessageBox.Show(this, string.Format("The Game File {0} is missing from the library.", ex.FileName), "File Not Found");
                        }
                        catch (Exception ex)
                        {
                            Util.DisplayUnexpectedException(this, ex);
                        }
                    }
                }

                SetColumnConfigToMain(fileSelect.TabViews);
            }
        }
Esempio n. 3
0
        private void btnCopyFrom_Click(object sender, EventArgs e)
        {
            using (FileSelectForm fileSelect = CreateFileSelectForm()) //select the file you want to copy data from
            {
                if (fileSelect.ShowDialog(this) == DialogResult.OK)
                {
                    using (GameFileEditForm dataSelect = CreateDataSelectForm(fileSelect)) //show another GameFileEdit with checkboxes to select what fields
                    {
                        if (dataSelect.ShowDialog(this) == DialogResult.OK)
                        {
                            GameFile updateFile             = ((GameFile)EditControl.DataSource).Clone() as GameFile; //clone GameFile otherwise we are modifying the datasource the gridview is using
                            List <GameFileFieldType> fields = dataSelect.EditControl.UpdateDataSource(EditControl.DataSource);

                            foreach (var field in fields)
                            {
                                var property  = typeof(IGameFile).GetProperty(field.ToString("g"));
                                var fieldData = property.GetValue(dataSelect.EditControl.DataSource);
                                property.SetValue(updateFile, fieldData);
                            }

                            TagsChanged = dataSelect.EditControl.TagsChecked;

                            if (TagsChanged)
                            {
                                EditControl.SetDataSource(updateFile, dataSelect.EditControl.TagData);
                            }
                            else
                            {
                                EditControl.SetDataSource(updateFile, EditControl.TagData);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        private FileSelectForm CreateFileSelectForm()
        {
            FileSelectForm fileSelect = new FileSelectForm();

            fileSelect.Initialize(m_adapter, new ITabView[] { m_view });
            fileSelect.StartPosition = FormStartPosition.CenterParent;
            fileSelect.MultiSelect   = false;
            return(fileSelect);
        }
Esempio n. 5
0
        private GameFileEditForm CreateDataSelectForm(FileSelectForm fileSelect)
        {
            GameFileEditForm dataSelect = new GameFileEditForm();

            dataSelect.Text          = "Select Fields to Copy";
            dataSelect.StartPosition = FormStartPosition.CenterParent;
            var selectedFile = fileSelect.SelectedFiles[0];
            IEnumerable <ITagMapping> tagMapping = m_adapter.GetTagMappings(selectedFile.GameFileID.Value);
            var tags = from tag in m_adapter.GetTags() join map in tagMapping on tag.TagID equals map.TagID select tag;

            dataSelect.EditControl.SetDataSource(selectedFile, tags);
            dataSelect.SetSelectDataMode();
            return(dataSelect);
        }
Esempio n. 6
0
 private void ctrlFiles_NewItemNeeded(object sender, AdditionalFilesEventArgs e)
 {
     using (FileSelectForm form = new FileSelectForm())
     {
         form.Initialize(this.m_adapter, this.m_additionalFileViews);
         form.MultiSelect   = true;
         form.StartPosition = FormStartPosition.CenterParent;
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             IGameFileDataSource[] selectedFiles = form.SelectedFiles;
             if (selectedFiles.Length != 0)
             {
                 e.NewItems = selectedFiles.Cast <object>().ToList <object>();
             }
         }
     }
 }
Esempio n. 7
0
        private IGameFile HandleMultipleMetaFilesFound(IGameFile localFile, IEnumerable <IGameFile> remoteFiles)
        {
            if (remoteFiles.Count() == 1)
            {
                return(remoteFiles.First());
            }

            FillFileSize(localFile);
            IEnumerable <IGameFile> check = remoteFiles.Where(x => x.FileSizeBytes == localFile.FileSizeBytes);

            if (check.Count() == 1)
            {
                return(check.First());
            }

            FileSelectForm form = new FileSelectForm();

            form.Initialize(DataSourceAdapter, m_tabHandler.TabViews.First(x => x.Key.Equals(TabKeys.IdGamesKey)), remoteFiles);
            form.ShowSearchControl(false);
            string display = localFile.FileName;

            if (!string.IsNullOrEmpty(localFile.Title))
            {
                display = string.Format("{0}({1})", localFile.Title, localFile.FileNameNoPath);
            }
            form.SetDisplayText(string.Format("Multiple files found for {0}. Please select intended file.", display));
            form.MultiSelect   = false;
            form.StartPosition = FormStartPosition.CenterParent;

            if (form.ShowDialog() != DialogResult.Cancel)
            {
                IGameFile[] selectedFiles = form.SelectedFiles;

                if (selectedFiles.Length > 0)
                {
                    return(selectedFiles.First());
                }
            }

            return(null);
        }
Esempio n. 8
0
        private IGameFile PromptUserMainFile(IEnumerable <IGameFile> gameFiles, out bool accepted)
        {
            accepted = false;

            FileSelectForm form    = new FileSelectForm();
            ITabView       tabView = m_tabHandler.TabViews.FirstOrDefault(x => x.Key.Equals(TabKeys.LocalKey));

            form.Initialize(DataSourceAdapter, tabView, gameFiles);
            form.StartPosition = FormStartPosition.CenterParent;
            form.SetDisplayText("Please select the main file that all data will be associated with. (Screenshots, demos, save games, etc.)");
            form.MultiSelect = false;
            form.ShowSearchControl(false);

            if (form.ShowDialog(this) == DialogResult.OK && form.SelectedFiles.Length > 0)
            {
                accepted = true;
                return(form.SelectedFiles[0]);
            }

            return(gameFiles.First());
        }