├── .gitattributes
├── .gitignore
├── MultiSourceTorrentDownloader.sln
├── MultiSourceTorrentDownloader
├── App.config
├── App.xaml
├── App.xaml.cs
├── Behaviors
│ ├── BindHtmlBehavior.cs
│ ├── CloseAutoCompleteDropDownBehavior.cs
│ ├── PersistanceBehavior.cs
│ └── TorrentInfoSizeReductionBehavior.cs
├── Common
│ ├── Command.cs
│ └── ContainerConfig.cs
├── Constants
│ ├── KickassTorrentIndexer.cs
│ ├── LeetxTorrentIndexer.cs
│ ├── RargbTorrentIndexer.cs
│ ├── SizePostfix.cs
│ └── ThePirateBayTorrentIndexer.cs
├── Converters
│ ├── BooleanToBackgroundColorConverter.cs
│ ├── MessageTypeToBackgroundConverter.cs
│ ├── MessageTypeToStatusBarVisibilityConverter.cs
│ ├── TimeFormatConverter.cs
│ └── TorrentCategoryToBooleanConverter.cs
├── Data
│ ├── DisplaySource.cs
│ ├── KickassSorting.cs
│ ├── LeetxSorting.cs
│ ├── RargbSorting.cs
│ ├── Settings.cs
│ ├── SizeEntity.cs
│ ├── SourceInformation.cs
│ ├── SourceState.cs
│ ├── SourceStateUI.cs
│ ├── SourceToProcess.cs
│ ├── TorrentEntry.cs
│ ├── TorrentPaging.cs
│ └── TorrentQueryResult.cs
├── Enums
│ ├── MessageType.cs
│ ├── Sorting.cs
│ ├── ThePirateBaySorting.cs
│ ├── TorrentCategory.cs
│ └── TorrentSource.cs
├── Extensions
│ └── ObservableCollectionForEachExtension.cs
├── Interfaces
│ ├── IAutoCompleteService.cs
│ ├── IKickassParser.cs
│ ├── IKickassSource.cs
│ ├── ILeetxParser.cs
│ ├── ILeetxSource.cs
│ ├── ILogService.cs
│ ├── IRargbParser.cs
│ ├── IRargbSource.cs
│ ├── IThePirateBayParser.cs
│ ├── IThePirateBaySource.cs
│ ├── ITorrentDataSource.cs
│ ├── ITorrentParser.cs
│ └── IUserConfiguration.cs
├── Mapping
│ ├── SortingMapper.cs
│ └── TorrentCategoryMapper.cs
├── Models
│ ├── DataModelBase.cs
│ ├── MainModel.cs
│ ├── MainModel.g.cs
│ ├── ModelBase.cs
│ ├── NotificaitonPropertyChangedExtensions.cs
│ ├── SubModels
│ │ ├── MainModelSettings.cs
│ │ └── MainModelSettings.g.cs
│ ├── TorrentInfoDialogModel.cs
│ └── TorrentInfoDialogModel.g.cs
├── MultiSourceTorrentDownloader.csproj
├── Properties
│ └── AssemblyInfo.cs
├── Services
│ ├── AutoCompleteService.cs
│ ├── KickassParser.cs
│ ├── KickassSource.cs
│ ├── LeetxParser.cs
│ ├── LeetxSource.cs
│ ├── LogService.cs
│ ├── ParserBase.cs
│ ├── RargbParser.cs
│ ├── RargbSource.cs
│ ├── SourceBase.cs
│ ├── ThePirateBayParser.cs
│ ├── ThePirateBaySource.cs
│ └── UserConfiguration.cs
├── ViewModels
│ ├── MainViewModel.cs
│ ├── TorrentInfoDialogViewModel.cs
│ └── ViewModelBase.cs
├── Views
│ ├── DrawerView.xaml
│ ├── DrawerView.xaml.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── StatusBar.xaml
│ ├── StatusBar.xaml.cs
│ ├── TorrentInfoDialogView.xaml
│ └── TorrentInfoDialogView.xaml.cs
├── app.manifest
├── icon.ico
├── packages.config
└── splash.png
├── README.md
├── TorrentSourceTemplate.zip
├── demo
├── details.png
├── launched.png
├── menu.png
└── searched.png
├── icon.ico
├── icon_big.png
├── license.txt
└── splash.png
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore App.xaml.cs which contains secrets
2 | MultiSourceTorrentDownloader/Secret.cs
3 |
4 | ## Ignore Visual Studio temporary files, build results, and
5 | ## files generated by popular Visual Studio add-ons.
6 |
7 | # User-specific files
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Build results
17 | [Dd]ebug/
18 | [Dd]ebugPublic/
19 | [Rr]elease/
20 | [Rr]eleases/
21 | x64/
22 | x86/
23 | bld/
24 | [Bb]in/
25 | [Oo]bj/
26 | [Ll]og/
27 |
28 | # Visual Studio 2015 cache/options directory
29 | .vs/
30 | .vs
31 | # Uncomment if you have tasks that create the project's static files in wwwroot
32 | #wwwroot/
33 |
34 | # MSTest test Results
35 | [Tt]est[Rr]esult*/
36 | [Bb]uild[Ll]og.*
37 |
38 | # NUNIT
39 | *.VisualState.xml
40 | TestResult.xml
41 |
42 | # Build Results of an ATL Project
43 | [Dd]ebugPS/
44 | [Rr]eleasePS/
45 | dlldata.c
46 |
47 | # DNX
48 | project.lock.json
49 | project.fragment.lock.json
50 | artifacts/
51 |
52 | *_i.c
53 | *_p.c
54 | *_i.h
55 | *.ilk
56 | *.meta
57 | *.obj
58 | *.pch
59 | *.pdb
60 | *.pgc
61 | *.pgd
62 | *.rsp
63 | *.sbr
64 | *.tlb
65 | *.tli
66 | *.tlh
67 | *.tmp
68 | *.tmp_proj
69 | *.log
70 | *.vspscc
71 | *.vssscc
72 | .builds
73 | *.pidb
74 | *.svclog
75 | *.scc
76 |
77 | # Chutzpah Test files
78 | _Chutzpah*
79 |
80 | # Visual C++ cache files
81 | ipch/
82 | *.aps
83 | *.ncb
84 | *.opendb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 | *.VC.db
89 | *.VC.VC.opendb
90 |
91 | # Visual Studio profiler
92 | *.psess
93 | *.vsp
94 | *.vspx
95 | *.sap
96 |
97 | # TFS 2012 Local Workspace
98 | $tf/
99 |
100 | # Guidance Automation Toolkit
101 | *.gpState
102 |
103 | # ReSharper is a .NET coding add-in
104 | _ReSharper*/
105 | *.[Rr]e[Ss]harper
106 | *.DotSettings.user
107 |
108 | # JustCode is a .NET coding add-in
109 | .JustCode
110 |
111 | # TeamCity is a build add-in
112 | _TeamCity*
113 |
114 | # DotCover is a Code Coverage Tool
115 | *.dotCover
116 |
117 | # NCrunch
118 | _NCrunch_*
119 | .*crunch*.local.xml
120 | nCrunchTemp_*
121 |
122 | # MightyMoose
123 | *.mm.*
124 | AutoTest.Net/
125 |
126 | # Web workbench (sass)
127 | .sass-cache/
128 |
129 | # Installshield output folder
130 | [Ee]xpress/
131 |
132 | # DocProject is a documentation generator add-in
133 | DocProject/buildhelp/
134 | DocProject/Help/*.HxT
135 | DocProject/Help/*.HxC
136 | DocProject/Help/*.hhc
137 | DocProject/Help/*.hhk
138 | DocProject/Help/*.hhp
139 | DocProject/Help/Html2
140 | DocProject/Help/html
141 |
142 | # Click-Once directory
143 | publish/
144 |
145 | # Publish Web Output
146 | *.[Pp]ublish.xml
147 | *.azurePubxml
148 | # TODO: Comment the next line if you want to checkin your web deploy settings
149 | # but database connection strings (with potential passwords) will be unencrypted
150 | #*.pubxml
151 | *.publishproj
152 |
153 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
154 | # checkin your Azure Web App publish settings, but sensitive information contained
155 | # in these scripts will be unencrypted
156 | PublishScripts/
157 |
158 | # NuGet Packages
159 | *.nupkg
160 | # The packages folder can be ignored because of Package Restore
161 | **/packages/*
162 | # except build/, which is used as an MSBuild target.
163 | !**/packages/build/
164 | # Uncomment if necessary however generally it will be regenerated when needed
165 | #!**/packages/repositories.config
166 | # NuGet v3's project.json files produces more ignoreable files
167 | *.nuget.props
168 | *.nuget.targets
169 |
170 | # Microsoft Azure Build Output
171 | csx/
172 | *.build.csdef
173 |
174 | # Microsoft Azure Emulator
175 | ecf/
176 | rcf/
177 |
178 | # Windows Store app package directories and files
179 | AppPackages/
180 | BundleArtifacts/
181 | Package.StoreAssociation.xml
182 | _pkginfo.txt
183 |
184 | # Visual Studio cache files
185 | # files ending in .cache can be ignored
186 | *.[Cc]ache
187 | # but keep track of directories ending in .cache
188 | !*.[Cc]ache/
189 |
190 | # Others
191 | ClientBin/
192 | ~$*
193 | *~
194 | *.dbmdl
195 | *.dbproj.schemaview
196 | *.jfm
197 | *.pfx
198 | *.publishsettings
199 | node_modules/
200 | orleans.codegen.cs
201 |
202 | # Since there are multiple workflows, uncomment next line to ignore bower_components
203 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
204 | #bower_components/
205 |
206 | # RIA/Silverlight projects
207 | Generated_Code/
208 |
209 | # Backup & report files from converting an old project file
210 | # to a newer Visual Studio version. Backup files are not needed,
211 | # because we have git ;-)
212 | _UpgradeReport_Files/
213 | Backup*/
214 | UpgradeLog*.XML
215 | UpgradeLog*.htm
216 |
217 | # SQL Server files
218 | *.mdf
219 | *.ldf
220 |
221 | # Business Intelligence projects
222 | *.rdl.data
223 | *.bim.layout
224 | *.bim_*.settings
225 |
226 | # Microsoft Fakes
227 | FakesAssemblies/
228 |
229 | # GhostDoc plugin setting file
230 | *.GhostDoc.xml
231 |
232 | # Node.js Tools for Visual Studio
233 | .ntvs_analysis.dat
234 |
235 | # Visual Studio 6 build log
236 | *.plg
237 |
238 | # Visual Studio 6 workspace options file
239 | *.opt
240 |
241 | # Visual Studio LightSwitch build output
242 | **/*.HTMLClient/GeneratedArtifacts
243 | **/*.DesktopClient/GeneratedArtifacts
244 | **/*.DesktopClient/ModelManifest.xml
245 | **/*.Server/GeneratedArtifacts
246 | **/*.Server/ModelManifest.xml
247 | _Pvt_Extensions
248 |
249 | # Paket dependency manager
250 | .paket/paket.exe
251 | paket-files/
252 |
253 | # FAKE - F# Make
254 | .fake/
255 |
256 | # JetBrains Rider
257 | .idea/
258 | *.sln.iml
259 |
260 | # CodeRush
261 | .cr/
262 |
263 | # Python Tools for Visual Studio (PTVS)
264 | __pycache__/
265 | *.pyc
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29503.13
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiSourceTorrentDownloader", "MultiSourceTorrentDownloader\MultiSourceTorrentDownloader.csproj", "{2483D14D-06BF-4533-8FD8-A53CCBDC8522}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x86 = Debug|x86
12 | Release|Any CPU = Release|Any CPU
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {2483D14D-06BF-4533-8FD8-A53CCBDC8522}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {2483D14D-06BF-4533-8FD8-A53CCBDC8522}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {2483D14D-06BF-4533-8FD8-A53CCBDC8522}.Debug|x86.ActiveCfg = Debug|x86
19 | {2483D14D-06BF-4533-8FD8-A53CCBDC8522}.Debug|x86.Build.0 = Debug|x86
20 | {2483D14D-06BF-4533-8FD8-A53CCBDC8522}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {2483D14D-06BF-4533-8FD8-A53CCBDC8522}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {2483D14D-06BF-4533-8FD8-A53CCBDC8522}.Release|x86.ActiveCfg = Release|x86
23 | {2483D14D-06BF-4533-8FD8-A53CCBDC8522}.Release|x86.Build.0 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {AF8DE5A1-B5E6-4206-9F69-0ABAFEED43EF}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using MultiSourceTorrentDownloader.Interfaces;
2 | using Ninject;
3 | using System.Reflection;
4 | using System.Windows;
5 |
6 | namespace MultiSourceTorrentDownloader
7 | {
8 | ///
9 | /// Interaction logic for App.xaml
10 | ///
11 | public partial class App : Application
12 | {
13 | private ILogService _logger;
14 | public App()
15 | {
16 |
17 | var kernel = new StandardKernel();
18 | kernel.Load(Assembly.GetExecutingAssembly());
19 | _logger = kernel.Get();
20 |
21 | Current.DispatcherUnhandledException += HandleDispatcherUnhandledException;
22 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24 | //Secret.SyncFususionLicenseKey is a const string containing the community license for the project.
25 | //Please replace with stringor create a file Secret.cs with a const string referring to a license.
26 | //If Secret.cs is created in same directory as App.xaml.cs, gitignore will not commit the secret.
27 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 | Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(Secret.SyncFususionLicenseKey);
30 | }
31 |
32 | private void HandleDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
33 | {
34 | _logger.Error($"Unhandled exception occured: {e.Exception.StackTrace}");
35 | Current.Shutdown();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader/Behaviors/BindHtmlBehavior.cs:
--------------------------------------------------------------------------------
1 | using CefSharp;
2 | using CefSharp.Wpf;
3 | using System.Windows;
4 | using System.Windows.Interactivity;
5 |
6 | namespace MultiSourceTorrentDownloader.Behaviors
7 | {
8 | public class BindHtmlBehavior : Behavior
9 | {
10 | private const string _dynamicImageStyle = "";
11 |
12 | public static readonly DependencyProperty HtmlProperty =
13 | DependencyProperty.Register("Html", typeof(string), typeof(BindHtmlBehavior));
14 |
15 | public string Html
16 | {
17 | get { return (string)GetValue(HtmlProperty); }
18 | set { SetValue(HtmlProperty, value); }
19 | }
20 |
21 | protected override void OnAttached()
22 | {
23 | AssociatedObject.IsBrowserInitializedChanged += IsBrowserInitializedChanged;
24 | }
25 |
26 | private void IsBrowserInitializedChanged(object sender, DependencyPropertyChangedEventArgs e)
27 | {
28 | if (AssociatedObject.IsBrowserInitialized)
29 | {
30 | var fitToScreenHtml = $"{_dynamicImageStyle}{Html ?? string.Empty}";
31 | AssociatedObject.LoadHtml(fitToScreenHtml);
32 | }
33 | }
34 |
35 | protected override void OnDetaching()
36 | {
37 | AssociatedObject.IsBrowserInitializedChanged -= IsBrowserInitializedChanged;
38 | }
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader/Behaviors/CloseAutoCompleteDropDownBehavior.cs:
--------------------------------------------------------------------------------
1 | using Syncfusion.Windows.Controls.Input;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Interactivity;
8 |
9 | namespace MultiSourceTorrentDownloader.Behaviors
10 | {
11 | public class CloseAutoCompleteDropDownBehavior : Behavior
12 | {
13 | protected override void OnAttached()
14 | {
15 | AssociatedObject.LostKeyboardFocus += OnLostFocus;
16 |
17 | base.OnAttached();
18 | }
19 |
20 | private void OnLostFocus(object sender, System.Windows.RoutedEventArgs e)
21 | {
22 | AssociatedObject.IsSuggestionOpen = false;
23 | }
24 |
25 | protected override void OnDetaching()
26 | {
27 | AssociatedObject.LostKeyboardFocus -= OnLostFocus;
28 |
29 | base.OnDetaching();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader/Behaviors/PersistanceBehavior.cs:
--------------------------------------------------------------------------------
1 | using MultiSourceTorrentDownloader.Data;
2 | using MultiSourceTorrentDownloader.Interfaces;
3 | using Ninject;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Reflection;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows;
11 | using System.Windows.Interactivity;
12 |
13 | namespace MultiSourceTorrentDownloader.Behaviors
14 | {
15 | public class PersistanceBehavior : Behavior
16 | {
17 | private IUserConfiguration _config;
18 | protected override void OnAttached()
19 | {
20 | AssociatedObject.Loaded += WindowLoaded;
21 | AssociatedObject.Closing += WindowClosing;
22 | }
23 |
24 |
25 | protected override void OnDetaching()
26 | {
27 | AssociatedObject.Loaded -= WindowLoaded;
28 | AssociatedObject.Closing -= WindowClosing;
29 | }
30 |
31 | private void WindowLoaded(object sender, RoutedEventArgs e)
32 | {
33 | var settings = GetUserSettings();
34 |
35 | if(settings.Window == null)
36 | {
37 | AssociatedObject.SizeToContent = SizeToContent.WidthAndHeight;
38 | return;
39 | }
40 |
41 | AssociatedObject.SizeToContent = SizeToContent.Manual;
42 | AssociatedObject.WindowStartupLocation = WindowStartupLocation.Manual;
43 |
44 | AssociatedObject.Width = settings.Window.Width;
45 | AssociatedObject.Height = settings.Window.Height;
46 | AssociatedObject.Left = settings.Window.PositionLeft;
47 | AssociatedObject.Top = settings.Window.PositionTop;
48 | }
49 |
50 | private Settings GetUserSettings()
51 | {
52 | var kernel = new StandardKernel();
53 | kernel.Load(Assembly.GetExecutingAssembly());
54 | _config = kernel.Get();
55 | return _config.GetConfiguration();
56 | }
57 |
58 | private void WindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
59 | {
60 | var window = new Data.Window
61 | {
62 | Width = AssociatedObject.ActualWidth,
63 | Height = AssociatedObject.ActualHeight,
64 | PositionLeft = AssociatedObject.Left,
65 | PositionTop = AssociatedObject.Top
66 | };
67 |
68 | _config.SaveSettings(window);
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader/Behaviors/TorrentInfoSizeReductionBehavior.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Interactivity;
9 |
10 | namespace MultiSourceTorrentDownloader.Behaviors
11 | {
12 | public class TorrentInfoSizeReductionBehavior : Behavior
13 | {
14 | private bool _sizeChangeInProgress = true;
15 | private const int MaxDialogHeight = 890;
16 | protected override void OnAttached()
17 | {
18 | AssociatedObject.SizeChanged += SizeChanged;
19 | }
20 |
21 | private void SizeChanged(object sender, SizeChangedEventArgs e)
22 | {
23 | _sizeChangeInProgress = !_sizeChangeInProgress;
24 | if (_sizeChangeInProgress) return;
25 |
26 | AssociatedObject.Width = AssociatedObject.ActualWidth * 0.85;
27 |
28 | var newHeight = AssociatedObject.ActualHeight * 0.9;
29 | AssociatedObject.Height = newHeight > MaxDialogHeight ? MaxDialogHeight : newHeight;
30 | }
31 |
32 | protected override void OnDetaching()
33 | {
34 | AssociatedObject.SizeChanged -= SizeChanged;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/MultiSourceTorrentDownloader/Common/Command.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace MultiSourceTorrentDownloader.Common
5 | {
6 | public class Command : ICommand
7 | {
8 | private Predicate