Beispiel #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);
                 }
             }
         }
     }
 }
Beispiel #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);
            }
        }
Beispiel #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            object item = SelectedItem;

            if (item != null)
            {
                int index = dgvAdditionalFiles.SelectedRows[0].Index;
                AdditionalFilesEventArgs cancelEvent = new AdditionalFilesEventArgs(item);
                ItemRemoving?.Invoke(this, cancelEvent);

                if (!cancelEvent.Cancel)
                {
                    m_files.Remove(item);
                    Rebind();

                    if (dgvAdditionalFiles.Rows.Count > 0)
                    {
                        if (index >= dgvAdditionalFiles.Rows.Count)
                        {
                            index = dgvAdditionalFiles.Rows.Count - 1;
                        }
                        dgvAdditionalFiles.Rows[index].Selected = true;
                    }

                    ItemRemoved?.Invoke(this, new AdditionalFilesEventArgs(item));
                }
            }
        }
Beispiel #4
0
 private void CtrlFiles_ItemRemoving(object sender, AdditionalFilesEventArgs e)
 {
     if (e.Item.Equals(this.GameFile))
     {
         MessageBox.Show(this, $"Cannot remove {this.GameFile.FileName}. This is the file you will be launching!", "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         e.Cancel = true;
     }
 }
Beispiel #5
0
 private void dgvAdditionalFiles_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     if (this.CellFormatting != null)
     {
         AdditionalFilesEventArgs args = new AdditionalFilesEventArgs(this.dgvAdditionalFiles.Rows[e.RowIndex].DataBoundItem, (string)e.Value);
         this.CellFormatting(this, args);
         e.Value = args.DisplayText;
     }
 }
Beispiel #6
0
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            AdditionalFilesEventArgs args = new AdditionalFilesEventArgs(null);

            if (this.NewItemNeeded != null)
            {
                this.NewItemNeeded(this, args);
            }
            if (args.NewItems != null)
            {
                this.m_files.AddRange(args.NewItems);
                this.Rebind();
            }
        }
Beispiel #7
0
        private void ctrlFiles_CellFormatting(object sender, AdditionalFilesEventArgs e)
        {
            IGameFileDataSource   item          = e.Item as IGameFileDataSource;
            IGameFileDataSource   selectedIWad  = this.SelectedIWad;
            ISourcePortDataSource selectedValue = this.cmbSourcePorts.SelectedValue as ISourcePortDataSource;

            if (this.m_iwadAdditionalFiles.Contains(item))
            {
                e.DisplayText = $"{item.FileName} ({selectedIWad.FileName})";
            }
            if (this.m_sourcePortAdditionalFiles.Contains(item))
            {
                e.DisplayText = $"{item.FileName} ({selectedValue.Name})";
            }
        }
Beispiel #8
0
        private void ctrlFiles_CellFormatting(object sender, AdditionalFilesEventArgs e)
        {
            IGameFile   gameFile = e.Item as IGameFile;
            IGameFile   iwad     = SelectedIWad;
            ISourcePort port     = cmbSourcePorts.SelectedValue as ISourcePort;

            if (m_handler.IsIWadFile(gameFile))
            {
                e.DisplayText = string.Format("{0} ({1})", gameFile.FileName, Util.RemoveExtension(iwad.FileName));
            }
            if (m_handler.IsSourcePortFile(gameFile))
            {
                e.DisplayText = string.Format("{0} ({1})", gameFile.FileName, port.Name);
            }
        }
Beispiel #9
0
        private void ctrlFiles_CellFormatting(object sender, AdditionalFilesEventArgs e)
        {
            IGameFile       gameFile = e.Item as IGameFile;
            IGameFile       iwad     = SelectedIWad;
            ISourcePortData port     = SelectedSourcePort;

            if (iwad != null && m_handler.IsIWadFile(gameFile))
            {
                e.DisplayText = string.Format("{0} ({1})", gameFile.FileName, Path.GetFileNameWithoutExtension(iwad.FileName));
            }
            if (port != null && m_handler.IsSourcePortFile(gameFile))
            {
                e.DisplayText = string.Format("{0} ({1})", gameFile.FileName, port.Name);
            }
        }
Beispiel #10
0
 private void CtrlFiles_ItemRemoving(object sender, AdditionalFilesEventArgs e)
 {
     if (e.Item.Equals(GameFile))
     {
         MessageBox.Show(this, string.Format("Cannot remove {0}. This is the file you will be launching!", GameFile.FileName),
                         "Cannot Remove", MessageBoxButtons.OK, MessageBoxIcon.Error);
         e.Cancel = true;
     }
     else
     {
         if (SpecificFiles != null)
         {
             SpecificFiles = SpecificFiles.Except(GetSupportedFiles((IGameFile)e.Item)).ToArray();
         }
     }
 }
Beispiel #11
0
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            AdditionalFilesEventArgs args = new AdditionalFilesEventArgs(null);

            NewItemNeeded?.Invoke(this, args);

            if (args.NewItems != null)
            {
                m_files.AddRange(args.NewItems);
                Rebind();
                if (dgvAdditionalFiles.Rows.Count > 0)
                {
                    dgvAdditionalFiles.Rows[dgvAdditionalFiles.Rows.Count - 1].Selected = true;
                }
            }
        }
Beispiel #12
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>();
             }
         }
     }
 }
Beispiel #13
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            object selectedItem = this.SelectedItem;

            if (selectedItem != null)
            {
                AdditionalFilesEventArgs args = new AdditionalFilesEventArgs(selectedItem);
                if (this.ItemRemoving != null)
                {
                    this.ItemRemoving(this, args);
                }
                if (!args.Cancel)
                {
                    this.m_files.Remove(selectedItem);
                    this.Rebind();
                    if (this.ItemRemoved != null)
                    {
                        this.ItemRemoved(this, new AdditionalFilesEventArgs(selectedItem));
                    }
                }
            }
        }
Beispiel #14
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            object item = SelectedItem;

            if (item != null)
            {
                AdditionalFilesEventArgs cancelEvent = new AdditionalFilesEventArgs(item);
                if (ItemRemoving != null)
                {
                    ItemRemoving(this, cancelEvent);
                }

                if (!cancelEvent.Cancel)
                {
                    m_files.Remove(item);
                    Rebind();
                    if (ItemRemoved != null)
                    {
                        ItemRemoved(this, new AdditionalFilesEventArgs(item));
                    }
                }
            }
        }