Implemented file selection
This commit is contained in:
parent
0876caa0d0
commit
89b2744896
@ -1,5 +1,5 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace UI_WinForms.Components;
|
namespace UI_WinForms.Components;
|
||||||
|
|
||||||
@ -78,23 +78,50 @@ public partial class LoaderStart : UserControl
|
|||||||
|
|
||||||
private void buttonNew_Click(object sender, EventArgs e)
|
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
|
var dialogResult = saveDialog.ShowDialog(this);
|
||||||
LoaderStart.UpdateRecentProjectsWithPruning(string.Empty);
|
if (dialogResult != DialogResult.OK)
|
||||||
|
return;
|
||||||
|
|
||||||
// TODO: Open the project
|
var destinationFilePath = saveDialog.FileName;
|
||||||
|
LoaderStart.UpdateRecentProjectsWithPruning(destinationFilePath);
|
||||||
|
this.OpenProject(destinationFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BrowseForProject()
|
private void BrowseForProject()
|
||||||
{
|
{
|
||||||
// TODO: Browse for project
|
var openDialog = new OpenFileDialog
|
||||||
// TODO: Handle cancel event
|
{
|
||||||
|
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
|
var projectFilePath = openDialog.FileName;
|
||||||
LoaderStart.UpdateRecentProjectsWithPruning(string.Empty);
|
LoaderStart.UpdateRecentProjectsWithPruning(projectFilePath);
|
||||||
|
this.OpenProject(projectFilePath);
|
||||||
// TODO: Open the project
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenRecentProject(object? sender)
|
private void OpenRecentProject(object? sender)
|
||||||
@ -104,8 +131,13 @@ public partial class LoaderStart : UserControl
|
|||||||
|
|
||||||
var path = (item.Tag as string)!;
|
var path = (item.Tag as string)!;
|
||||||
LoaderStart.UpdateRecentProjectsWithPruning(path);
|
LoaderStart.UpdateRecentProjectsWithPruning(path);
|
||||||
|
this.OpenProject(path);
|
||||||
// TODO: Open the project
|
}
|
||||||
|
|
||||||
|
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)
|
private void contextMenuRecentProjects_Closing(object sender, ToolStripDropDownClosingEventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user