Пример #1
0
        public static void Test_DownloadManagerClient_01()
        {
            Trace.WriteLine("Test_DownloadManagerClient_01");
            //string address = "http://localhost:8019/WCFDownloadManager";
            string address = "http://localhost:8019/DownloadManagerService";

            Trace.WriteLine("address : \"{0}\"", address);
            Trace.WriteLine("ContractDescription contractDescription = ContractDescription.GetContract(typeof(IDownloadManagerService))");
            ContractDescription contractDescription = ContractDescription.GetContract(typeof(IDownloadManagerService));
            WSHttpBinding       binding             = new WSHttpBinding();

            Trace.WriteLine("EndpointAddress endpointAddress = new EndpointAddress(new Uri(address))");
            EndpointAddress endpointAddress = new EndpointAddress(new Uri(address));

            Trace.WriteLine("ServiceEndpoint endpoint = new ServiceEndpoint(contractDescription, binding, endpointAddress)");
            ServiceEndpoint endpoint = new ServiceEndpoint(contractDescription, binding, endpointAddress);

            Trace.WriteLine("ChannelFactory<IDownloadManagerService> channelFactory = new ChannelFactory<IDownloadManagerService>(endpoint)");
            ChannelFactory <IDownloadManagerService> channelFactory = new ChannelFactory <IDownloadManagerService>(endpoint);

            Trace.WriteLine("IDownloadManagerService service = channelFactory.CreateChannel()");
            IDownloadManagerService service = channelFactory.CreateChannel();
            int nb = service.GetDownloadCount();

            Trace.WriteLine("service.GetDownloadCount() : {0}", nb);
            Trace.WriteLine("channelFactory.Close()");
            channelFactory.Close();
        }
        public AudioListItemViewModel(
            IPlayerService playerService,
            IEventAggregator eventAggregator,
            IDownloadManagerService downloadService,
            AudioCommandsProxy commandProxy)
        {
            Contract.Requires(playerService != null);
            Contract.Requires(eventAggregator != null);
            Contract.Requires(commandProxy != null);
            Contract.Requires(downloadService != null);

            this.playerService   = playerService;
            this.eventAggregator = eventAggregator;
            this.commandProxy    = commandProxy;
            this.downloadService = downloadService;

            State            = PlayState.Stop;
            DownloadProgress = 0;

            SwitchLyricsStateCommand = new DelegateCommand(this.SwitchLyricsState);
            PlayCommand        = new DelegateCommand(this.Play);
            ChangeStateCommand = new DelegateCommand(this.ChangeState);
            AddCommand         = new DelegateCommand(async() => await this.Add());
            DeleteCommand      = new DelegateCommand(async() => await this.Delete());
            RestoreCommand     = new DelegateCommand(async() => await this.Restore());
            DownloadCommand    = new DelegateCommand(this.StartDownload);

            this.eventAggregator.GetEvent <AudioSelectedEvent>().Subscribe(
                audio =>
            {
                State = PlayState.Stop;
                Deattach();
            }, ThreadOption.UIThread, false, audio => audio != this && State != PlayState.Stop);
        }
Пример #3
0
 private void InitClient()
 {
     //Trace.WriteLine("create client service WCFDownloadManager");
     ContractDescription contractDescription = ContractDescription.GetContract(typeof(IDownloadManagerService));
     WSHttpBinding binding = new WSHttpBinding();
     EndpointAddress endpointAddress = new EndpointAddress(new Uri(_address));
     ServiceEndpoint endpoint = new ServiceEndpoint(contractDescription, binding, endpointAddress);
     _channelFactory = new ChannelFactory<IDownloadManagerService>(endpoint);
     _service = _channelFactory.CreateChannel();
 }
Пример #4
0
        private void InitClient()
        {
            //Trace.WriteLine("create client service WCFDownloadManager");
            ContractDescription contractDescription = ContractDescription.GetContract(typeof(IDownloadManagerService));
            WSHttpBinding       binding             = new WSHttpBinding();
            EndpointAddress     endpointAddress     = new EndpointAddress(new Uri(_address));
            ServiceEndpoint     endpoint            = new ServiceEndpoint(contractDescription, binding, endpointAddress);

            _channelFactory = new ChannelFactory <IDownloadManagerService>(endpoint);
            _service        = _channelFactory.CreateChannel();
        }
 public DownloadManagerViewModel(IDownloadManagerService downloadService)
 {
     DownloadService = downloadService;
     RemoveCompeltedItemsCommand = new DelegateCommand(DownloadService.RemoveCompletedItems);
 }
 public DownloadManagerViewModel(IDownloadManagerService downloadService)
 {
     DownloadService             = downloadService;
     RemoveCompeltedItemsCommand = new DelegateCommand(DownloadService.RemoveCompletedItems);
 }
Пример #7
0
        public AudioListItemViewModel(
            IPlayerService playerService,
            IEventAggregator eventAggregator,
            IDownloadManagerService downloadService,
            AudioCommandsProxy commandProxy)
        {
            Contract.Requires(playerService != null);
            Contract.Requires(eventAggregator != null);
            Contract.Requires(commandProxy != null);
            Contract.Requires(downloadService != null);

            this.playerService = playerService;
            this.eventAggregator = eventAggregator;
            this.commandProxy = commandProxy;
            this.downloadService = downloadService;

            State = PlayState.Stop;
            DownloadProgress = 0;

            SwitchLyricsStateCommand = new DelegateCommand(this.SwitchLyricsState);
            PlayCommand = new DelegateCommand(this.Play);
            ChangeStateCommand = new DelegateCommand(this.ChangeState);
            AddCommand = new DelegateCommand(async () => await this.Add());
            DeleteCommand = new DelegateCommand(async () => await this.Delete());
            RestoreCommand = new DelegateCommand(async () => await this.Restore());
            DownloadCommand = new DelegateCommand(this.StartDownload);

            this.eventAggregator.GetEvent<AudioSelectedEvent>().Subscribe(
                audio =>
                {
                    State = PlayState.Stop;
                    Deattach();
                }, ThreadOption.UIThread, false, audio => audio != this && State != PlayState.Stop);
        }
Пример #8
0
        public MainWindow()
        {
            Button AddButton(string text, string tooltip, MouseEvent action)
            {
                var button = new Button
                {
                    Text    = text,
                    Tooltip = tooltip,
                    Dock    = DockStyle.Left
                };

                button.MouseClick += action;
                _menuBar.Content.Controls.Add(button);
                return(button);
            }

            loading    = true;
            pkgManager = Localizer.Kernel.Get <IPackageManageService>();
            sourcePackageLoadServiceService = Localizer.Kernel.Get <SourcePackageLoad <DataModel.Default.Package> >();
            packedPackageLoadServiceService = Localizer.Kernel.Get <PackedPackageLoad <DataModel.Default.Package> >();
            packageExportService            = Localizer.Kernel.Get <IPackageExportService>();
            packageSaveService       = Localizer.Kernel.Get <IPackageSaveService>();
            packageUpdateService     = Localizer.Kernel.Get <IPackageUpdateService>();
            fileLoadService          = Localizer.Kernel.Get <IFileLoadService>();
            fileSaveService          = Localizer.Kernel.Get <IFileSaveService>();
            packageBrowserService    = Localizer.Kernel.Get <IPackageBrowserService>();
            downloadManagerService   = Localizer.Kernel.Get <IDownloadManagerService>();
            pkgManager.PackageGroups = new ObservableCollection <IPackageGroup>();
            Size          = new Point(800, 340);
            Position      = new Point(40, 200);
            Titlebar.Text = _("PackageManage");
            Titlebar.Button.MouseClick += (sender, args) => Visible = false;
            Resizable = true;

            _menuBar = new Panel
            {
                Dock = DockStyle.Top,
                Size = new Point(0, 30)
            };
            Controls.Add(_menuBar);

            AddButton(_("Reload"), _("ReloadDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    LoadPackages();
                }
            });

            var refreshBtn = AddButton(_("RefreshOnline"), _("RefreshOnlineDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    RefreshOnlinePackages(sender);
                }
            });

            AddButton(_("OpenFolder"), _("OpenFolderDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    Process.Start($"file://{Path.Combine(Environment.CurrentDirectory, "Localizer")}");
                }
            });

            AddButton(_("Export"), _("ExportDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    Export(false);
                }
            });

            AddButton(_("ExportWithTranslation"), _("ExportWithTranslationDesc"), (sender, args) =>
            {
                if (args.Button == 0)
                {
                    Export(true);
                }
            });

            _split = new SplitContainer
            {
                Margin = new Margin(0, 10, 0, 0),
                Dock   = DockStyle.Fill
            };
            _split.SplitButton.Style    = "button";
            _split.SplitFrame1.AutoSize = AutoSize.Horizontal;
            _split.SplitFrame2.AutoSize = AutoSize.Horizontal;
            Controls.Add(_split);
            _split.SplitFrame1.Controls.Add(_modList);
            _modList.SelectedItemChanged += (sender, value) => RefreshPkgList();
            _split.SplitFrame2.Controls.Add(_pkgList);
            RefreshModList();
            LoadPackages().ContinueWith(_ => RefreshOnlinePackages(refreshBtn));
        }