-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
539 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using PinCab.Utils.Extensions; | ||
using PinCab.Utils.Models; | ||
using PinCab.Utils.Utils; | ||
using PinCab.Utils.ViewModels; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace PinCab.Configurator | ||
{ | ||
public partial class RenameGameForm : Form | ||
{ | ||
private FrontEndManager _manager { get; set; } | ||
private FrontEndGameViewModel _setting { get; set; } | ||
private string _newName { get; set; } | ||
public RenameGameForm(FrontEndGameViewModel setting, string newName, FrontEndManager manager) | ||
{ | ||
InitializeComponent(); | ||
_manager = manager; | ||
_setting = setting; | ||
_newName = newName; | ||
LoadData(); | ||
} | ||
|
||
private void LoadData() | ||
{ | ||
lblCurrentName.Text = _setting.FileName; | ||
lblNewName.Text = _newName; | ||
|
||
if (!string.IsNullOrEmpty(_setting.FullPathToB2s)) | ||
chkFilesToRename.Items.Add(_setting.FullPathToB2s, true); | ||
if (!string.IsNullOrEmpty(_setting.FullPathToTable)) | ||
chkFilesToRename.Items.Add(_setting.FullPathToTable, true); | ||
foreach(var file in _setting.MediaItems) | ||
{ | ||
chkFilesToRename.Items.Add(file.MediaFullPath, true); | ||
} | ||
chkSelectAll.Checked = true; | ||
} | ||
|
||
private void btnSave_Click(object sender, EventArgs e) | ||
{ | ||
var oldName = _setting.FileName; | ||
_setting.FileName = _newName; | ||
|
||
//Rename all the selected files | ||
for (int i = 0; i < chkFilesToRename.Items.Count; i++) | ||
{ | ||
if (chkFilesToRename.GetItemChecked(i)) | ||
{ | ||
var fileToRename = chkFilesToRename.Items[i].ToString(); | ||
var fileInfo = new FileInfo(fileToRename); | ||
var newFilePath = $"{fileInfo.DirectoryName}\\{_newName}{fileInfo.Extension}"; | ||
File.Move(fileToRename, newFilePath); | ||
} | ||
} | ||
|
||
//Save the database | ||
_manager.SaveGame(_setting, oldName); | ||
//Refresh the model as they may not have selected all files to rename. In this case | ||
//what happens is that some of the media audit statuses disappear | ||
_manager.RefreshGameModel(_setting, _manager.GetPinballXSystemByDatabaseFile(_setting.DatabaseFile)); | ||
|
||
Close(); | ||
} | ||
|
||
private void button1_Click(object sender, EventArgs e) | ||
{ | ||
Close(); | ||
} | ||
|
||
private void lstFiles_SelectedIndexChanged(object sender, EventArgs e) | ||
{ | ||
DialogResult = DialogResult.OK; | ||
Close(); | ||
} | ||
|
||
private void chkSelectAll_CheckedChanged(object sender, EventArgs e) | ||
{ | ||
for(int i = 0; i < chkFilesToRename.Items.Count; i++) | ||
{ | ||
chkFilesToRename.SetItemChecked(i, chkSelectAll.Checked); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.