Files
bodyshop-uploader/BodyshopUploader/ViewModels/MainViewModel.commands.cs
2022-12-15 17:01:21 -08:00

345 lines
10 KiB
C#

using System;
using System.Windows;
using System.Windows.Input;
namespace BodyshopPartner.ViewModels
{
public partial class MainViewModel : BaseViewModel
{
private ICommand _testCommand;
public ICommand TestCommand
{
get
{
if (_testCommand == null)
{
_testCommand = new RelayCommand(
p => true,
async p =>
{
// Utils.OEConnection.SendToOEConnection();
await Utils.PPGMixData.PushDataToPPG();
});
}
return _testCommand;
}
}
private ICommand _openMainWindowCommand;
public ICommand OpenMainWindowCommand
{
get
{
if (_openMainWindowCommand == null)
{
_openMainWindowCommand = new RelayCommand(
p => true,
p =>
{
App.Current.MainWindow.Show();
// ((Window)p).Show();
}
);
}
return _openMainWindowCommand;
}
}
private ICommand _addMonitoringPathCommand;
public ICommand AddMonitoringPathCommand
{
get
{
if (_addMonitoringPathCommand == null)
{
_addMonitoringPathCommand = new RelayCommand(
p => true,
p => AddFolderMonitoringPath()
);
}
return _addMonitoringPathCommand;
}
}
private ICommand _removeMonitoringPathCommand;
public ICommand RemoveMonitoringPathCommand
{
get
{
if (_removeMonitoringPathCommand == null)
{
_removeMonitoringPathCommand = new RelayCommand(
p => true,
p =>
{
RemoveFolderMonitoringPath(p as Models.Monitor);
}
);
}
return _removeMonitoringPathCommand;
}
}
private ICommand _removeAllMonitoringPathCommand;
public ICommand RemoveAllMonitoringPathCommand
{
get
{
if (_removeAllMonitoringPathCommand == null)
{
_removeAllMonitoringPathCommand = new RelayCommand(
p => true,
p =>
{
RemoveAllFolderMonitors();
}
);
}
return _removeAllMonitoringPathCommand;
}
}
private ICommand _startFolderMonitorsCommand;
public ICommand StartFolderMonitorsCommand
{
get
{
if (_startFolderMonitorsCommand == null)
{
_startFolderMonitorsCommand = new RelayCommand(
p => MonitoringPaths.Count > 0 && ActiveShop != null,
p => StartAllFolderMonitors()
);
}
return _startFolderMonitorsCommand;
}
}
private ICommand _restartMonitoringPathCommand;
public ICommand RestartMonitoringPathCommand
{
get
{
if (_restartMonitoringPathCommand == null)
{
_restartMonitoringPathCommand = new RelayCommand(
p => true,
p => ((Models.Monitor)p).StartMonitor()
);
}
return _restartMonitoringPathCommand;
}
}
private ICommand _stopFolderMonitorsCommand;
public ICommand StopFolderMonitorsCommand
{
get
{
if (_stopFolderMonitorsCommand == null)
{
_stopFolderMonitorsCommand = new RelayCommand(
p => MonitoringPaths.Count > 0,
p => StopAllFolderMonitors()
);
}
return _stopFolderMonitorsCommand;
}
}
private ICommand _browseForQbFolderCommand;
public ICommand BrowseForQbFolderCommand
{
get
{
if (_browseForQbFolderCommand == null)
{
_browseForQbFolderCommand = new RelayCommand(
p => true,
p => BrowseForQbFolder()
);
}
return _browseForQbFolderCommand;
}
}
private ICommand _browseForEmsFolderCommand;
public ICommand BrowseForEmsFolderCommand
{
get
{
if (_browseForEmsFolderCommand == null)
{
_browseForEmsFolderCommand = new RelayCommand(
p => true,
p => BrowseForEmsFolder()
);
}
return _browseForEmsFolderCommand;
}
}
private ICommand _browseForPaintScalePathCommand;
public ICommand BrowseForPaintScalePathCommand
{
get
{
if (_browseForPaintScalePathCommand == null)
{
_browseForPaintScalePathCommand = new RelayCommand(
p => true,
p => BrowseForPaintScalePath()
);
}
return _browseForPaintScalePathCommand;
}
}
private ICommand _browseForPaintScaleImportPathCommand;
public ICommand BrowseForPaintScaleImportPathCommand
{
get
{
if (_browseForPaintScaleImportPathCommand == null)
{
_browseForPaintScaleImportPathCommand = new RelayCommand(
p => true,
p => BrowseForPaintScaleImportPath()
);
}
return _browseForPaintScaleImportPathCommand;
}
}
private ICommand _configurePaintScaleCommand;
public ICommand ConfigurePaintScaleCommand
{
get
{
if (_configurePaintScaleCommand == null)
{
_configurePaintScaleCommand = new RelayCommand(
p => true,
p => ConfigurePaintScale()
);
}
return _configurePaintScaleCommand;
}
}
private ICommand _browseForArmsPathPathCommand;
public ICommand BrowseForArmsPathPathCommand
{
get
{
if (_browseForArmsPathPathCommand == null)
{
_browseForArmsPathPathCommand = new RelayCommand(
p => true,
p => BrowseForArmsPath()
);
}
return _browseForArmsPathPathCommand;
}
}
private ICommand _configureArmsExportCommand;
public ICommand ConfigureArmsExportCommand
{
get
{
if (_configureArmsExportCommand == null)
{
_configureArmsExportCommand = new RelayCommand(
p => true,
p => Utils.ScheduledTaskConfig.RegisterArms()
); ;
}
return _configureArmsExportCommand;
}
}
private ICommand _installUpdatesCommand;
public ICommand InstallUpdatesCommand
{
get
{
if (_installUpdatesCommand == null)
{
_installUpdatesCommand = new RelayCommand(
p => UpdateAvailable,
async p =>
{
await InstallUpdates();
});
}
return _installUpdatesCommand;
}
}
private ICommand _quitCommand;
public ICommand QuitCommand
{
get
{
if (_quitCommand == null)
{
_quitCommand = new RelayCommand(
p => true,
p =>
{
Properties.Settings.Default.Save(); App.Current.Shutdown(0);
});
}
return _quitCommand;
}
}
private ICommand _logoutCommand;
public ICommand LogoutCommand
{
get
{
if (_logoutCommand == null)
{
_logoutCommand = new RelayCommand(
p => true,
p =>
{
Logout();
});
}
return _logoutCommand;
}
}
private ICommand _startWithWindowsCommand;
public ICommand StartWithWindowsCommand
{
get
{
if (_startWithWindowsCommand == null)
{
_startWithWindowsCommand = new RelayCommand(
p => true,
p =>
{
Utils.UpdateHandler.ToggleStartWithWindows((bool)(p));
});
}
return _startWithWindowsCommand;
}
}
}
}