コード例 #1
1
 public BroadcastModel(Configuration configuration,
     IEnumerable<IExternalYellowPages> externalYellowPagesList,
     PluginList plugins)
 {
     this.configuration = configuration;
     this.externalYellowPagesList = externalYellowPagesList;
     this.plugins = plugins;
     timer.Ticked += timer_Ticked;
 }
コード例 #2
0
 public void Put(Configuration entity)
 {
     using (var fileStream = m_externalResource.GetConfigurationOutputStream())
     {
         new XmlSerializer(typeof(Configuration)).Serialize(fileStream, entity);
     }
 }
コード例 #3
0
        public YellowPagesListViewModel(IEnumerable<IYellowPages> yellowPagesList, Configuration settings)
        {
            this.YellowPagesViewModels = yellowPagesList.Select(x => new YellowPagesViewModel(x)).ToArray();
            this.settings = settings;

            var recent = settings.SelectedYellowPages;
            SelectedYellowPages = YellowPagesViewModels.SingleOrDefault(x => x.Name == recent);
            foreach (var yp in YellowPagesViewModels)
            {
                yp.PropertyChanged += (sender, e) => OnPropertyChanged("Prefix");

                var ypSetting = settings.YellowPagesList.FirstOrDefault(x => x.Name == yp.Name);
                if (ypSetting == null)
                {
                    ypSetting = new Configuration.YellowPages() { Name = yp.Name };
                    settings.YellowPagesList.Add(ypSetting);
                }
                yp.Settings = ypSetting;
            }
        }
コード例 #4
0
        public ExternalSourceViewModel(Configuration configuration)
        {
            var removeItemCommand = new RemoveItemCommand();
            Name = new ChannelNameTextBoxWithHistoryViewModel(removeItemCommand);
            Genre = new ParameterTextBoxWithHistoryViewModel(removeItemCommand);
            Description = new ParameterTextBoxWithHistoryViewModel(removeItemCommand);
            Comment = new ParameterTextBoxWithHistoryViewModel(removeItemCommand);

            this.configuration = configuration;
            StreamUrl = configuration.StreamUrl;
            Type = configuration.Type;
            Name.History = new ObservableCollection<string>(configuration.NameHistory);
            configuration.NameHistory = Name.History;
            Genre.History = new ObservableCollection<string>(configuration.GenreHistory);
            configuration.GenreHistory = Genre.History;
            Description.History = new ObservableCollection<string>(configuration.DescriptionHistory);
            configuration.DescriptionHistory = Description.History;
            Comment.History = new ObservableCollection<string>(configuration.CommentHistory);
            configuration.CommentHistory = Comment.History;
        }
コード例 #5
0
        public BroadcastControlViewModel(MainPanelViewModel parent,
            BroadcastModel broadcastModel, Configuration configuration)
        {
            this.configuration = configuration;

            var externalSourceViewModel = parent.ExternalSourceViewModel;
            BroadcastCommand = new DelegateCommand(() =>
            {
                // 画面ロック
                IsProcessing = true;
                // ヒストリ更新
                externalSourceViewModel.UpdateHistory();
                // YP規約チェック
                var yp = parent.YellowPagesListViewModel.SelectedYellowPages;
                if (!yp.IsAccepted)
                {
                    parent.OnException(new ApplicationException("YPの規約に同意していません。" + Environment.NewLine
                        + "配信を開始するにはYPの規約を確認し、同意する必要があります。"));
                    parent.SelectedIndex = MainPanelViewModel.YellowPagesTabIndex;
                    IsProcessing = false;
                    return;
                }
                var parameter = ViewModelDxo.ToBroadcastParameter(externalSourceViewModel);
                var id = broadcastModel.BroadcastAsync(
                    yp.Model, yp.AcceptedHash, yp.Parameters.Dictionary, parameter,
                    new Progress<string>(x => parent.Feedback = x)).ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        parent.OnException(t.Exception);
                        IsProcessing = false;
                        return;
                    }
                    BroadcastingChannel = new BroadcastingChannel(parameter.Name, t.Result.Id);
                    IsProcessing = false;
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }, () =>
            {
                if (IsProcessing)
                    return false;
                if (IsBroadcasting)
                    return false;
                if (parent.SettingsViewModel.HasError)
                    return false;
                if (parent.YellowPagesListViewModel.SelectedYellowPages == null)
                    return false;
                if (externalSourceViewModel.HasError)
                    return false;
                return true;
            });

            UpdateCommand = new DelegateCommand(() =>
            {
                IsProcessing = true;
                parent.ExternalSourceViewModel.UpdateHistory();
                var yp = parent.YellowPagesListViewModel.SelectedYellowPages;
                broadcastModel.UpdateAsync(
                    yp.Model, yp.Parameters.Dictionary,
                    ViewModelDxo.ToUpdateParameter(BroadcastingChannel.Id, parent.ExternalSourceViewModel),
                    new Progress<string>(x => parent.Feedback = x))
                    .ContinueWith(t =>
                    {
                        if (t.IsFaulted)
                        {
                            parent.OnException(t.Exception);
                        }
                        IsProcessing = false;
                    }, TaskScheduler.FromCurrentSynchronizationContext());
            }, () =>
            {
                if (IsProcessing)
                    return false;
                if (!IsBroadcasting)
                    return false;
                if (parent.SettingsViewModel.HasError)
                    return false;
                if (externalSourceViewModel.HasError)
                    return false;
                return true;
            });

            StopCommand = new DelegateCommand(() =>
            {
                IsProcessing = true;
                var yp = parent.YellowPagesListViewModel.SelectedYellowPages;
                broadcastModel.StopAsync(yp.Model, yp.Parameters.Dictionary,
                    BroadcastingChannel.Name, BroadcastingChannel.Id,
                    new Progress<string>(x => parent.Feedback = x))
                    .ContinueWith(t =>
                    {
                        if (t.IsFaulted)
                        {
                            parent.OnException(t.Exception);
                            IsProcessing = false;
                            return;
                        }
                        BroadcastingChannel = null;
                        IsProcessing = false;
                    }, TaskScheduler.FromCurrentSynchronizationContext());
            }, () =>
            {
                if (IsProcessing)
                    return false;
                if (!IsBroadcasting)
                    return false;
                if (parent.SettingsViewModel.HasError)
                    return false;
                return true;
            });
        }
コード例 #6
0
 public ChannelViewModel(IEnumerable<IYellowPages> yellowPagesList, Configuration configuration)
 {
     YellowPagesListViewModel = new YellowPagesListViewModel(yellowPagesList, configuration);
     ExternalSourceViewModel = new ExternalSourceViewModel(configuration);
 }
コード例 #7
0
 public SettingsViewModel(Configuration configuration)
 {
     this.configuration = configuration;
 }