Пример #1
0
        public void QueueTransfer()
        {
            _actualDiskSize = _source.GetMeasuredGameSize(Application.AppId);
            if (_target.GetFreeSpace() < _actualDiskSize)
            {
                Task.Run(() =>
                {
                    System.Threading.Thread.Sleep(1000);    //TODO this is a little lazy, replace this if I get a proper scheduler.
                    string message = string.Format("The destination only has {0} free, {1} is {2}.\nThe transfer cannot be completed.",
                                                   Utils.FileUtils.GetReadableFileSize(_target.GetFreeSpace()),
                                                   Utils.FileUtils.GetReadableFileSize(_actualDiskSize),
                                                   Application.GameName);
                    Utils.Logging.Logger.Error(message);
                    System.Windows.MessageBox.Show(message, "Insufficient Disk Space", System.Windows.MessageBoxButton.OK,
                                                   System.Windows.MessageBoxImage.Exclamation, System.Windows.MessageBoxResult.OK);
                });
            }
            //else if (_target.HasApp(Application.AppId))
            //{

            //}
            else if (_target.HasGameDir(Application.InstallDir) && _actualDiskSize > 0)
            {
                Task.Run(() =>
                {
                    //Don't show the dialog immediately after the mouse button gets released, that's just asking for trouble.
                    System.Threading.Thread.Sleep(1000);    //TODO this is a little lazy, replace this if I get a proper scheduler.
                    var result = System.Windows.MessageBox.Show(string.Format("A directory already exists at the transfer destination {0}.\nHow would you like to handle it?\n\nYes = Backup the directory, then delete it upon successful copy.\nNo = Backup the directory, then open it upon a successful copy, and I will decide what to do.\nCancel = Just abort the transfer.\n\n", Application.InstallDir),
                                                                "Directory Already Exists", System.Windows.MessageBoxButton.YesNoCancel, System.Windows.MessageBoxImage.Exclamation, System.Windows.MessageBoxResult.Cancel);
                    switch (result)
                    {
                    case System.Windows.MessageBoxResult.Yes:
                        _desiredBackupBehavior = BackupDisposalProcedure.BackupThenDelete;
                        TransferManager.Instance.AddTransfer(this);
                        break;

                    case System.Windows.MessageBoxResult.No:
                        _desiredBackupBehavior = BackupDisposalProcedure.BackupThenOpen;
                        TransferManager.Instance.AddTransfer(this);
                        break;

                    default:
                    case System.Windows.MessageBoxResult.Cancel:
                        (_target as Steam.SteamLibrary)?.OpenGameDir(Application.InstallDir, true, true);
                        break;
                    }
                });
            }
            else
            {
                TransferManager.Instance.AddTransfer(this);
            }
        }