コード例 #1
0
        public TorrentManager(string magnetUrl, string downloadLocation)
        {
            var settings = new EngineSettings
            {
                SavePath   = downloadLocation,
                ListenPort = Port
            };

            var torrentDefaults = new TorrentSettings();
            var writer          = new DiskWriter();

            _dataAccessor = new MonotorrentDataAccessor(writer);
            _engine       = new ClientEngine(settings, writer);

            if (!Directory.Exists(downloadLocation))
            {
                Directory.CreateDirectory(downloadLocation);
            }

            var magnet = MagnetLink.Parse(magnetUrl);

            _manager              = new MonoTorrent.Client.TorrentManager(magnet, downloadLocation, torrentDefaults, downloadLocation);
            _manager.PieceHashed += async(sender, eventArgs) => await _matroskaPlayer.OnPieceHashed(sender, eventArgs);

            _manager.TorrentStateChanged += delegate(object sender, TorrentStateChangedEventArgs args) { Console.WriteLine(args.NewState); };
            _matroskaPlayer = new MatroskaPlayer(_manager, _dataAccessor);
            TorrentError   += OnError;
        }
コード例 #2
0
        public ScreenShotViewModel(VideoViewModel VideoViewModel,
                                   RecentViewModel RecentViewModel,
                                   ISystemTray SystemTray,
                                   LanguageManager Loc,
                                   Settings Settings,
                                   IRegionProvider RegionProvider,
                                   IMainWindow MainWindow,
                                   DiskWriter DiskWriter,
                                   ClipboardWriter ClipboardWriter,
                                   ImgurWriter ImgurWriter,
                                   IVideoSourcePicker SourcePicker) : base(Settings, Loc)
        {
            _videoViewModel      = VideoViewModel;
            _recentViewModel     = RecentViewModel;
            _systemTray          = SystemTray;
            _regionProvider      = RegionProvider;
            _mainWindow          = MainWindow;
            _sourcePicker        = SourcePicker;
            this.DiskWriter      = DiskWriter;
            this.ClipboardWriter = ClipboardWriter;
            this.ImgurWriter     = ImgurWriter;

            ScreenShotCommand = new DelegateCommand(() => CaptureScreenShot());

            ScreenShotActiveCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.ForegroundWindow)));

            ScreenShotDesktopCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.DesktopWindow)));

            ScreenshotRegionCommand = new DelegateCommand(async() => await ScreenshotRegion());

            ScreenshotWindowCommand = new DelegateCommand(async() => await ScreenshotWindow());

            ScreenshotScreenCommand = new DelegateCommand(async() => await ScreenshotScreen());
        }
コード例 #3
0
        public ScreenShotViewModel(LanguageManager Loc,
                                   Settings Settings,
                                   DiskWriter DiskWriter,
                                   ClipboardWriter ClipboardWriter,
                                   ImageUploadWriter ImgurWriter,
                                   ScreenShotModel ScreenShotModel,
                                   VideoSourcesViewModel VideoSourcesViewModel,
                                   IPlatformServices PlatformServices) : base(Settings, Loc)
        {
            this.DiskWriter      = DiskWriter;
            this.ClipboardWriter = ClipboardWriter;
            this.ImgurWriter     = ImgurWriter;

            ScreenShotCommand = VideoSourcesViewModel
                                .ObserveProperty(M => M.SelectedVideoSourceKind)
                                .Select(M => !(M is NoVideoSourceProvider))
                                .ToReactiveCommand()
                                .WithSubscribe(() => ScreenShotModel.CaptureScreenShot());

            async Task ScreenShotWindow(IWindow Window)
            {
                var img = ScreenShotModel.ScreenShotWindow(Window);

                await ScreenShotModel.SaveScreenShot(img);
            }

            ScreenShotActiveCommand  = new DelegateCommand(async() => await ScreenShotWindow(PlatformServices.ForegroundWindow));
            ScreenShotDesktopCommand = new DelegateCommand(async() => await ScreenShotWindow(PlatformServices.DesktopWindow));
            ScreenshotRegionCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotRegion());
            ScreenshotWindowCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotWindow());
            ScreenshotScreenCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotScreen());
        }
コード例 #4
0
ファイル: DiskManager.cs プロジェクト: dnetguru/monotorrent
        internal DiskManager(EngineSettings settings, IPieceWriter writer = null)
        {
            ReadLimiter = new RateLimiter();
            ReadMonitor = new SpeedMonitor();
            ReadQueue   = new Queue <BufferedIO> ();

            WriteLimiter = new RateLimiter();
            WriteMonitor = new SpeedMonitor();
            WriteQueue   = new Queue <BufferedIO> ();

            UpdateTimer = ValueStopwatch.StartNew();

            Settings = settings ?? throw new ArgumentNullException(nameof(settings));

            // If we pass in an IPieceWriter it should be used  *instead* of these.
            // However we still create these so the properties are non-null.
            DiskWriter = new DiskWriter(settings.MaximumOpenFiles)
            {
                ReadMonitor  = ReadMonitor,
                WriteMonitor = WriteMonitor,
            };
            MemoryWriter = new MemoryWriter(DiskWriter, settings.DiskCacheBytes);

            Writer = writer ?? MemoryWriter;
        }
コード例 #5
0
        public ScreenShotViewModel(LanguageManager loc,
                                   Settings settings,
                                   DiskWriter diskWriter,
                                   ClipboardWriter clipboardWriter,
                                   ImageUploadWriter imgurWriter,
                                   ScreenShotModel screenShotModel,
                                   VideoSourcesViewModel videoSourcesViewModel,
                                   IPlatformServices platformServices) : base(settings, loc)
        {
            DiskWriter      = diskWriter;
            ClipboardWriter = clipboardWriter;
            ImgurWriter     = imgurWriter;

            ScreenShotCommand = videoSourcesViewModel
                                .ObserveProperty(sourcesViewModel => sourcesViewModel.SelectedVideoSourceKind)
                                .Select(videoSourceProvider => !(videoSourceProvider is NoVideoSourceProvider))
                                .ToReactiveCommand()
                                .WithSubscribe(() => screenShotModel.CaptureScreenShot());

            async Task ScreenShotWindow(IWindow window)
            {
                var img = screenShotModel.ScreenShotWindow(window);

                await screenShotModel.SaveScreenShot(img);
            }

            ScreenShotActiveCommand  = new DelegateCommand(async() => await ScreenShotWindow(platformServices.ForegroundWindow));
            ScreenShotDesktopCommand = new DelegateCommand(async() => await ScreenShotWindow(platformServices.DesktopWindow));
            ScreenshotRegionCommand  = new DelegateCommand(async() => await screenShotModel.ScreenshotRegion());
            ScreenshotWindowCommand  = new DelegateCommand(async() => await screenShotModel.ScreenshotWindow());
            ScreenshotScreenCommand  = new DelegateCommand(async() => await screenShotModel.ScreenshotScreen());
        }
コード例 #6
0
        public ScreenShotViewModel(LanguageManager Loc,
                                   Settings Settings,
                                   DiskWriter DiskWriter,
                                   ClipboardWriter ClipboardWriter,
                                   ImageUploadWriter ImgurWriter,
                                   ScreenShotModel ScreenShotModel,
                                   VideoSourcesViewModel VideoSourcesViewModel) : base(Settings, Loc)
        {
            this.DiskWriter      = DiskWriter;
            this.ClipboardWriter = ClipboardWriter;
            this.ImgurWriter     = ImgurWriter;

            ScreenShotCommand = VideoSourcesViewModel
                                .ObserveProperty(M => M.SelectedVideoSourceKind)
                                .Select(M => !(M is NoVideoSourceProvider))
                                .ToReactiveCommand()
                                .WithSubscribe(() => ScreenShotModel.CaptureScreenShot());

            ScreenShotActiveCommand  = new DelegateCommand(async() => await ScreenShotModel.SaveScreenShot(ScreenShotModel.ScreenShotWindow(Window.ForegroundWindow)));
            ScreenShotDesktopCommand = new DelegateCommand(async() => await ScreenShotModel.SaveScreenShot(ScreenShotModel.ScreenShotWindow(Window.DesktopWindow)));
            ScreenshotRegionCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotRegion());
            ScreenshotWindowCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotWindow());
            ScreenshotScreenCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotScreen());

            ScreenShotImageFormats = ScreenShotModel.ScreenShotImageFormats;

            SelectedScreenShotImageFormat = ScreenShotModel
                                            .ToReactivePropertyAsSynchronized(M => M.SelectedScreenShotImageFormat);
        }
コード例 #7
0
        public ScreenShotViewModel(LanguageManager Loc,
                                   Settings Settings,
                                   DiskWriter DiskWriter,
                                   ClipboardWriter ClipboardWriter,
                                   ImageUploadWriter ImgurWriter,
                                   ScreenShotModel ScreenShotModel,
                                   VideoSourcesViewModel VideoSourcesViewModel,
                                   WebcamModel WebcamModel,
                                   IPlatformServices PlatformServices) : base(Settings, Loc)
        {
            this.DiskWriter      = DiskWriter;
            this.ClipboardWriter = ClipboardWriter;
            this.ImgurWriter     = ImgurWriter;

            ScreenShotCommand = new[]
            {
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is NoVideoSourceProvider),
                VideoSourcesViewModel
                .ObserveProperty(M => M.SelectedVideoSourceKind)
                .Select(M => M is WebcamSourceProvider),
                WebcamModel
                .ObserveProperty(M => M.SelectedCam)
                .Select(M => M is NoWebcamItem)
            }
            .CombineLatest(M =>
            {
                var noVideo    = M[0];
                var webcamMode = M[1];
                var noWebcam   = M[2];

                if (webcamMode)
                {
                    return(!noWebcam);
                }

                return(!noVideo);
            })
            .ToReactiveCommand()
            .WithSubscribe(M => ScreenShotModel.CaptureScreenShot());

            async Task ScreenShotWindow(IWindow Window)
            {
                var img = ScreenShotModel.ScreenShotWindow(Window);

                await ScreenShotModel.SaveScreenShot(img);
            }

            ScreenShotActiveCommand  = new DelegateCommand(async() => await ScreenShotWindow(PlatformServices.ForegroundWindow));
            ScreenShotDesktopCommand = new DelegateCommand(async() => await ScreenShotWindow(PlatformServices.DesktopWindow));
            ScreenshotRegionCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotRegion());
            ScreenshotWindowCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotWindow());
            ScreenshotScreenCommand  = new DelegateCommand(async() => await ScreenShotModel.ScreenshotScreen());
        }
コード例 #8
0
ファイル: UserController.cs プロジェクト: mceman2/SoftHouse
 public ActionResult Post(User[] user)
 {
     try
     {
         DiskWriter.Write(JsonConvert.SerializeObject(user));
         return(Ok());
     }
     catch
     {
         throw new Exception("Problem with request!");
     }
 }
コード例 #9
0
        public ScreenShotViewModel(VideoSourcesViewModel VideoSourcesViewModel,
                                   ISystemTray SystemTray,
                                   LanguageManager Loc,
                                   Settings Settings,
                                   IRegionProvider RegionProvider,
                                   IMainWindow MainWindow,
                                   DiskWriter DiskWriter,
                                   ClipboardWriter ClipboardWriter,
                                   ImageUploadWriter ImgurWriter,
                                   IVideoSourcePicker SourcePicker,
                                   IAudioPlayer AudioPlayer,
                                   IEnumerable <IImageWriterItem> ImageWriters) : base(Settings, Loc)
        {
            _videoSourcesViewModel = VideoSourcesViewModel;
            _systemTray            = SystemTray;
            _regionProvider        = RegionProvider;
            _mainWindow            = MainWindow;
            _sourcePicker          = SourcePicker;
            _audioPlayer           = AudioPlayer;
            this.DiskWriter        = DiskWriter;
            this.ClipboardWriter   = ClipboardWriter;
            this.ImgurWriter       = ImgurWriter;

            AvailableImageWriters = ImageWriters.ToList();

            if (!AvailableImageWriters.Any(M => M.Active))
            {
                AvailableImageWriters[0].Active = true;
            }

            ScreenShotCommand        = new DelegateCommand(() => CaptureScreenShot());
            ScreenShotActiveCommand  = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.ForegroundWindow)));
            ScreenShotDesktopCommand = new DelegateCommand(async() => await SaveScreenShot(ScreenShotWindow(Window.DesktopWindow)));
            ScreenshotRegionCommand  = new DelegateCommand(async() => await ScreenshotRegion());
            ScreenshotWindowCommand  = new DelegateCommand(async() => await ScreenshotWindow());
            ScreenshotScreenCommand  = new DelegateCommand(async() => await ScreenshotScreen());
        }