mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Move show msgbox to view
This commit is contained in:
parent
bfb29e384d
commit
cca10ca5a0
2 changed files with 16 additions and 21 deletions
|
|
@ -30,15 +30,15 @@ namespace Flow.Launcher.Plugin.Program
|
|||
private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var status = ViewModel.AddOrUpdate();
|
||||
if (status == null)
|
||||
bool modified = status.Item1;
|
||||
string msg = status.Item2;
|
||||
if (modified == false && msg != null)
|
||||
{
|
||||
return; // Invalid
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogResult = status ?? false;
|
||||
Close();
|
||||
MessageBox.Show(msg); // Invalid
|
||||
return;
|
||||
}
|
||||
DialogResult = modified;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,42 +80,37 @@ namespace Flow.Launcher.Plugin.Program.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public bool? AddProgramSource()
|
||||
public (bool, string) AddProgramSource()
|
||||
{
|
||||
if (!Directory.Exists(Location))
|
||||
{
|
||||
System.Windows.MessageBox.Show(API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
|
||||
return null;
|
||||
return (false, API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
|
||||
}
|
||||
else if (DuplicateSource(Location))
|
||||
{
|
||||
System.Windows.MessageBox.Show(API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source"));
|
||||
return null;
|
||||
return (false, API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source"));
|
||||
}
|
||||
else
|
||||
{
|
||||
var source = new ProgramSource(Location, Enabled);
|
||||
Settings.ProgramSources.Insert(0, source);
|
||||
ProgramSetting.ProgramSettingDisplayList.Add(source);
|
||||
return true;
|
||||
return (true, null);
|
||||
}
|
||||
}
|
||||
|
||||
public bool? UpdateProgramSource()
|
||||
public (bool, string) UpdateProgramSource()
|
||||
{
|
||||
// Separate checks to avoid changing UniqueIdentifier of UWP when changing Enabled
|
||||
if (LocationModified)
|
||||
{
|
||||
if (!Directory.Exists(Location))
|
||||
{
|
||||
System.Windows.MessageBox.Show(API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
|
||||
return null;
|
||||
return (false, API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
|
||||
}
|
||||
else if (DuplicateSource(Location))
|
||||
{
|
||||
// No need to check win32 or uwp, just override them
|
||||
System.Windows.MessageBox.Show(API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source"));
|
||||
return null;
|
||||
return (false, API.GetTranslation("flowlauncher_plugin_program_duplicate_program_source"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -126,10 +121,10 @@ namespace Flow.Launcher.Plugin.Program.ViewModels
|
|||
{
|
||||
Source.Enabled = Enabled;
|
||||
}
|
||||
return StatusModified || LocationModified;
|
||||
return (StatusModified || LocationModified, null);
|
||||
}
|
||||
|
||||
public bool? AddOrUpdate()
|
||||
public (bool, string) AddOrUpdate()
|
||||
{
|
||||
if (Source == null)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue