mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed validation of inputs in create project dialog
This commit is contained in:
parent
1e6ba1375f
commit
bedc107bb1
@ -21,5 +21,23 @@ namespace RainmeterStudio.Core.Utils
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Validates a file name
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Name of file</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsFileNameValid(string name)
|
||||||
|
{
|
||||||
|
// No name is not a valid name
|
||||||
|
if (String.IsNullOrEmpty(name))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Check for invalid characters
|
||||||
|
if (Path.GetInvalidFileNameChars().Intersect(name).Any())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,9 +113,7 @@ namespace RainmeterStudio.UI.Dialogs
|
|||||||
|
|
||||||
// Populate controls
|
// Populate controls
|
||||||
listTemplates.ItemsSource = projectController.ProjectTemplates.OrderBy(x => x.DisplayText);
|
listTemplates.ItemsSource = projectController.ProjectTemplates.OrderBy(x => x.DisplayText);
|
||||||
|
|
||||||
textLocation.ItemsSource = GetRecentLocations().OrderBy(x => x);
|
textLocation.ItemsSource = GetRecentLocations().OrderBy(x => x);
|
||||||
|
|
||||||
textLocation.Text = GetLocation();
|
textLocation.Text = GetLocation();
|
||||||
|
|
||||||
Validate();
|
Validate();
|
||||||
@ -146,6 +144,8 @@ namespace RainmeterStudio.UI.Dialogs
|
|||||||
{
|
{
|
||||||
bool res = true;
|
bool res = true;
|
||||||
res &= (listTemplates.SelectedItem != null);
|
res &= (listTemplates.SelectedItem != null);
|
||||||
|
res &= PathHelper.IsFileNameValid(textName.Text);
|
||||||
|
res &= PathHelper.IsPathValid(textLocation.Text);
|
||||||
|
|
||||||
buttonCreate.IsEnabled = res;
|
buttonCreate.IsEnabled = res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user