Beispiel #1
0
        private void ApplyConfig()
        {
            try
            {
                if (_view != null)
                {
                    _view.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
                    _view.MaxWidth  = SystemParameters.MaximizedPrimaryScreenWidth;

                    //_view.CategoriesColumn.Width = new GridLength(ConfigService.Instanse.CategoriesWidth);
                    _view.Width       = ConfigService.Instanse.MainWindowWidth;
                    _view.Height      = ConfigService.Instanse.MainWindowHeight;
                    _view.WindowState = ConfigService.Instanse.MainWindowState;
                    RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
                    IsShowMoreInfo = ConfigService.Instanse.MoreInfoShow;
                }
                else
                {
                    throw new Exception($" Filed '{nameof(_view)}' is null");
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                Crashes.TrackError(ex);

                MessageBoxViewModel.ShowDialog(LocalizationProvider.GetLocalizedValue(nameof(Strings.ConfigApllyError)), manager);
            }
        }
Beispiel #2
0
        public void Remove()
        {
            if (SelectedServer == null)
            {
                return;
            }


            Log.Info($"Try remove server: {SelectedServer}");

            var result = StorageRepository.GetServersList().Delete(SelectedServer.Id);

            Log.Info($"RemoveResult: {result}");
            if (!result)
            {
                //TODO: Add string
                MessageBoxViewModel.ShowDialog("RemoveErrorContent", manager);
            }

            var ind = ServerIndex -= 1;

            //if (App.Instance.KeblerControl.SelectedServer.Id == SelectedServer.Id)
            //{
            //    App.Instance.KeblerControl.Disconnect();
            //}
            _eventAggregator.PublishOnUIThreadAsync(new Messages.ServersUpdated());

            SelectedServer = null;
            GetServers();
            ServerIndex = ind;
        }
Beispiel #3
0
        public async void Save()
        {
            try
            {
                var sett = new TorrentSettings
                {
                    DownloadLimited = MXD_Bool,
                    UploadLimited   = MXU_Bool,
                    DownloadLimit   = MaxDownSp,
                    UploadLimit     = MaxUpSp,
                    SeedRatioLimit  = SeedRation,
                    SeedIdleLimit   = StopSeed,
                    IDs             = tors,
                    PeerLimit       = PeerLimit,
                    TrackerAdd      = toAdd?.Count <= 0 ? null : toAdd?.ToArray(),
                    TrackerRemove   = toRm?.Count <= 0 ? null : toRm?.ToArray(),
                };

                var resp = await _transmissionClient.TorrentSetAsync(sett, new CancellationToken());

                if (resp.Success)
                {
                    await TryCloseAsync();
                }
                else
                {
                    await MessageBoxViewModel.ShowDialog(LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.TorretPropertiesSetError)), _manager);
                }
            }
            finally
            {
                IsBusy = Visibility.Collapsed;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Rename torrent.
        /// </summary>
        public async void Rename()
        {
            if (selectedIDs.Length > 1)
            {
                await MessageBoxViewModel.ShowDialog(LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.MSG_OnlyOneTorrent)), manager);

                return;
            }

            if (selectedIDs.Length < 1)
            {
                await MessageBoxViewModel.ShowDialog(LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.MSG_SelectOneTorrent)), manager);

                return;
            }

            if (!IsConnected || SelectedTorrent is null)
            {
                return;
            }

            var selectedTorrent = SelectedTorrent;
            var dialog          = new DialogBoxViewModel(LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.MSG_InterNewName)), selectedTorrent.Name, false);

            var result = await manager.ShowDialogAsync(dialog);

            var newName = dialog.Value.ToString();

            if (result is not true || _transmissionClient is null || newName is null)
            {
                return;
            }

            var resp = await _transmissionClient.TorrentRenamePathAsync(selectedTorrent.Id, selectedTorrent.Name, newName,
                                                                        _cancelTokenSource.Token);

            resp.ParseTransmissionReponse(Log);
        }
Beispiel #5
0
        private async Task <bool> CheckResponse(TransmissionResponse resp)
        {
            if (resp.WebException != null)
            {
                //TODO: to IWindowManager manager = new WindowManager();
                var msg = resp.WebException.Status switch
                {
                    WebExceptionStatus.NameResolutionFailure =>
                    $"{LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.EX_Host))} '{SelectedServer.FullUriPath}'",
                    _ => $"{resp.WebException.Status} {Environment.NewLine} {resp.WebException?.Message}"
                };


                await MessageBoxViewModel.ShowDialog(msg, manager, LocalizationProvider.GetLocalizedValue(nameof(Resources.Strings.Error)));

                return(false);
            }

            if (resp.CustomException != null)
            {
                return(false);
            }
            return(true);
        }