Implemented file selection
This commit is contained in:
parent
0876caa0d0
commit
89b2744896
@ -1,5 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace UI_WinForms.Components;
|
||||
|
||||
@ -78,23 +78,50 @@ public partial class LoaderStart : UserControl
|
||||
|
||||
private void buttonNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
// TODO: Browse for new project's location
|
||||
var saveDialog = new SaveFileDialog
|
||||
{
|
||||
AddExtension = true,
|
||||
CheckPathExists = true,
|
||||
CheckFileExists = false,
|
||||
CreatePrompt = false,
|
||||
OverwritePrompt = true,
|
||||
DereferenceLinks = true,
|
||||
DefaultExt = ".i18nc",
|
||||
Filter = "I18N Commander Files (*.i18nc)|*.i18nc",
|
||||
RestoreDirectory = true,
|
||||
Title = "Create a new I18N Commander file",
|
||||
};
|
||||
|
||||
// TODO: Apply new project's path
|
||||
LoaderStart.UpdateRecentProjectsWithPruning(string.Empty);
|
||||
var dialogResult = saveDialog.ShowDialog(this);
|
||||
if (dialogResult != DialogResult.OK)
|
||||
return;
|
||||
|
||||
// TODO: Open the project
|
||||
var destinationFilePath = saveDialog.FileName;
|
||||
LoaderStart.UpdateRecentProjectsWithPruning(destinationFilePath);
|
||||
this.OpenProject(destinationFilePath);
|
||||
}
|
||||
|
||||
private void BrowseForProject()
|
||||
{
|
||||
// TODO: Browse for project
|
||||
// TODO: Handle cancel event
|
||||
var openDialog = new OpenFileDialog
|
||||
{
|
||||
AddExtension = true,
|
||||
CheckPathExists = true,
|
||||
CheckFileExists = true,
|
||||
DereferenceLinks = true,
|
||||
DefaultExt = ".i18nc",
|
||||
Filter = "I18N Commander Files (*.i18nc)|*.i18nc",
|
||||
Multiselect = false,
|
||||
RestoreDirectory = true,
|
||||
Title = "Open an I18N Commander file",
|
||||
};
|
||||
var dialogResult = openDialog.ShowDialog(this);
|
||||
if (dialogResult != DialogResult.OK)
|
||||
return;
|
||||
|
||||
// TODO: Apply chosen project's path
|
||||
LoaderStart.UpdateRecentProjectsWithPruning(string.Empty);
|
||||
|
||||
// TODO: Open the project
|
||||
var projectFilePath = openDialog.FileName;
|
||||
LoaderStart.UpdateRecentProjectsWithPruning(projectFilePath);
|
||||
this.OpenProject(projectFilePath);
|
||||
}
|
||||
|
||||
private void OpenRecentProject(object? sender)
|
||||
@ -104,8 +131,13 @@ public partial class LoaderStart : UserControl
|
||||
|
||||
var path = (item.Tag as string)!;
|
||||
LoaderStart.UpdateRecentProjectsWithPruning(path);
|
||||
|
||||
// TODO: Open the project
|
||||
this.OpenProject(path);
|
||||
}
|
||||
|
||||
private void OpenProject(string path)
|
||||
{
|
||||
// Hint: the project file might or might not exist (new project vs. recent project)
|
||||
this.LoadProject?.Invoke(this, path);
|
||||
}
|
||||
|
||||
private void contextMenuRecentProjects_Closing(object sender, ToolStripDropDownClosingEventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user