Inheritance: ICommand
Ejemplo n.º 1
0
        public UpdaterViewModel(IEnumerable<VersionDescription> versionInfo)
        {
            this.versionInfo = versionInfo;

              download = new Command(
            () => Process.Start(versionInfo.First().Link.ToString()));
        }
Ejemplo n.º 2
0
 public OutputListenerViewModel(SettingViewModel owner, OutputListener model)
 {
   this.owner = owner;
   if (model.LocalEndPoint.Address.Equals(System.Net.IPAddress.Any)) {
     address = "IPv4 Any";
   }
   else if (model.LocalEndPoint.Address.Equals(System.Net.IPAddress.IPv6Any)) {
     address = "IPv6 Any";
   }
   else {
     address = model.LocalEndPoint.Address.ToString();
   }
   port    = model.LocalEndPoint.Port;
   globalRelay     = (model.GlobalOutputAccepts & OutputStreamType.Relay)!=0;
   globalPlay      = (model.GlobalOutputAccepts & OutputStreamType.Play)!=0;
   globalInterface = (model.GlobalOutputAccepts & OutputStreamType.Interface)!=0;
   globalAuthRequired = model.GlobalAuthorizationRequired;
   localRelay      = (model.LocalOutputAccepts & OutputStreamType.Relay)!=0;
   localPlay       = (model.LocalOutputAccepts & OutputStreamType.Play)!=0;
   localInterface  = (model.LocalOutputAccepts & OutputStreamType.Interface)!=0;
   localAuthRequired = model.LocalAuthorizationRequired;
   authId       = model.AuthenticationKey!=null ? model.AuthenticationKey.Id : null;
   authPassword = model.AuthenticationKey!=null ? model.AuthenticationKey.Password : null;
   isOpen = null;
   RegenerateAuthKey = new Command(DoRegenerateAuthKey);
 }
        internal YellowPagesEditViewModel(PeerCast peerCast)
        {
            protocols = peerCast.YellowPageFactories
            .Select(factory => new YellowPageFactoryItem(factory)).ToArray();
              add = new Command(() =>
              {
            if (String.IsNullOrEmpty(Name)
            || SelectedProtocol == null)
              return;
            var factory = SelectedProtocol.Factory;
            var protocol = factory.Protocol;
            if (String.IsNullOrEmpty(protocol))
              return;

            Uri uri;
            var md = Regex.Match(Address, @"\A([^:/]+)(:(\d+))?\Z");
            if (md.Success &&
              Uri.CheckHostName(md.Groups[1].Value) != UriHostNameType.Unknown &&
              Uri.TryCreate(protocol + "://" + Address, UriKind.Absolute, out uri) &&
              factory.CheckURI(uri))
            {
            }
            else if (Uri.TryCreate(Address, UriKind.Absolute, out uri) &&
              factory.CheckURI(uri))
            {
            }
            else
            {
              return;
            }

            peerCast.AddYellowPage(protocol, Name, uri);
              });
        }
Ejemplo n.º 4
0
        public UpdaterViewModel(VersionDescription versionInfo)
        {
            this.versionInfo = versionInfo;

              download = new Command(
            () => Process.Start(versionInfo.Link.ToString()));
        }
Ejemplo n.º 5
0
 public RelayTreeViewModel(PeerCast peerCast)
 {
   this.peerCast = peerCast;
   this.RelayTree = new RelayTreeNodeViewModel[0];
   refresh = new Command(
     () => Update(this.channel),
     () => channel!=null);
 }
 public ConnectionListViewModel()
 {
   this.Connections = new ObservableCollection<ChannelConnectionViewModel>();
   this.Close = new Command(
     () => selectedConnection.Disconnect(),
     () => selectedConnection!=null && selectedConnection.IsDisconnectable);
   this.Reconnect = new Command(
     () => selectedConnection.Reconnect(),
     () => selectedConnection != null && selectedConnection.IsReconnectable);
 }
        public ConnectionListViewModel(PeerCast peerCast)
        {
            this.peerCast = peerCast;

              close = new Command(
            () => connection.Disconnect(),
            () => connection != null && connection.IsDisconnectable);
              reconnect = new Command(
            () => connection.Reconnect(),
            () => connection != null && connection.IsReconnectable);
        }
Ejemplo n.º 8
0
        public BroadcastViewModel(PeerCast peerCast)
        {
            this.peerCast = peerCast;
              contentTypes = peerCast.ContentReaderFactories
            .Select(reader => new ContentReaderItem(reader)).ToArray();

              yellowPages = new YellowPageItem[] { new YellowPageItem("掲載なし", null) }
            .Concat(peerCast.YellowPages.Select(yp => new YellowPageItem(yp))).ToArray();
              if (contentTypes.Length > 0) contentType = contentTypes[0];

              start = new Command(OnBroadcast,
            () => CanBroadcast(StreamSource, ContentReaderFactory, channelName));
        }
Ejemplo n.º 9
0
        public BroadcastViewModel(PeerCast peerCast)
        {
            this.peerCast = peerCast;
              this.uiSettings = new UISettingsViewModel(PeerCastApplication.Current.Settings);
              start = new Command(OnBroadcast, () => CanBroadcast(StreamSource, ContentType, channelName));
              contentTypes = peerCast.ContentReaderFactories.ToArray();

              yellowPages = Enumerable.Repeat(new KeyValuePair<string,IYellowPageClient>("掲載なし", null),1)
            .Concat(peerCast.YellowPages.Select(yp => new KeyValuePair<string,IYellowPageClient>(yp.Name, yp)));
              if (contentTypes.Length > 0) contentType = contentTypes[0];

              this.SelectedSourceStream = SourceStreams.FirstOrDefault();
        }
Ejemplo n.º 10
0
        internal ListenerEditViewModel(PeerCast peerCast)
        {
            Address = "IPv4 Any";
              Port = 7144;
              LocalRelay = true;
              LocalPlay = true;
              LocalInterface = true;
              GlobalRelay = true;
              GlobalAuthRequired = true;
              var key = AuthenticationKey.Generate();
              AuthId       = key.Id;
              AuthPassword = key.Password;
              RegenerateAuthKey = new Command(() => {
            key = AuthenticationKey.Generate();
            AuthId       = key.Id;
            AuthPassword = key.Password;
              });

              add = new Command(() =>
              {
            IPAddress address;
            try
            {
              address = ToIPAddress(Address);
            }
            catch (FormatException)
            {
              return;
            }
            var localAccepts = ToOutputStreamType(
              LocalRelay, LocalPlay, LocalInterface);
            var glocalAccepts = ToOutputStreamType(
              GlobalRelay, GlobalPlay, GlobalInterface);
            try
            {
              var listener = peerCast.StartListen(
            new IPEndPoint(address, Port), localAccepts, glocalAccepts);
              listener.LocalAuthorizationRequired = LocalAuthRequired;
              listener.GlobalAuthorizationRequired = GlobalAuthRequired;
              listener.AuthenticationKey = new AuthenticationKey(AuthId, AuthPassword);
            }
            catch (SocketException)
            {
            }
              });
        }
        internal SettingsDialog(PeerCastApplication app)
        {
            var viewmodel = new SettingViewModel(app);

            this.viewModel   = viewmodel;
            this.DataContext = viewmodel;
            OKCommand        = new Commons.Command(() => {
                viewModel.Apply();
                this.Close();
            }, () => errorControls.Count == 0);
            CancelCommand = new Commons.Command(() => {
                this.Close();
            });
            ApplyCommand = new Commons.Command(() => {
                viewModel.Apply();
            }, () => viewModel.IsModified && errorControls.Count == 0);
            viewModel.PropertyChanged += ViewModel_PropertyChanged;
            InitializeComponent();
        }
Ejemplo n.º 12
0
        public ChannelInfoViewModel()
        {
            update = new Command(() =>
            {
              var info = new AtomCollection(channel.ChannelInfo.Extra);
              info.SetChanInfoGenre(genre);
              info.SetChanInfoDesc(description);
              info.SetChanInfoURL(contactUrl);
              info.SetChanInfoComment(comment);
              channel.ChannelInfo = new ChannelInfo(info);

              var track = new AtomCollection(channel.ChannelTrack.Extra);
              track.SetChanTrackAlbum(trackAlbum);
              track.SetChanTrackCreator(trackArtist);
              track.SetChanTrackTitle(trackTitle);
              track.SetChanTrackGenre(trackGenre);
              track.SetChanTrackURL(trackUrl);
              channel.ChannelTrack = new ChannelTrack(track);
              IsModified = false;
            },
            () => channel!=null && IsTracker && IsModified);
        }
Ejemplo n.º 13
0
 public OutputListenerViewModel(SettingViewModel owner, int new_port)
 {
   this.owner = owner;
   address = "IPv4 Any";
   port    = new_port;
   globalRelay     = true;
   globalPlay      = false;
   globalInterface = false;
   globalAuthRequired = true;
   localRelay      = true;
   localPlay       = true;
   localInterface  = true;
   localAuthRequired = false;
   var authkey = AuthenticationKey.Generate();
   authId       = authkey.Id;
   authPassword = authkey.Password;
   isOpen = null;
   RegenerateAuthKey = new Command(DoRegenerateAuthKey);
 }
Ejemplo n.º 14
0
        internal ChannelListViewModel(PeerCast peerCast)
        {
            this.peerCast = peerCast;
              connections = new ConnectionListViewModel(peerCast);
              relayTree = new RelayTreeViewModel(peerCast);

              play = new Command(() =>
              {
            if (peerCast.OutputListeners.Count <= 0)
              return;

            var channel = Channel.Channel;
            var channel_id = channel.ChannelID;
            var ext = (channel.ChannelInfo.ContentType == "WMV" ||
                    channel.ChannelInfo.ContentType == "WMA" ||
                    channel.ChannelInfo.ContentType == "ASX") ? ".asx" : ".m3u";
            var endpoint = peerCast.OutputListeners[0].LocalEndPoint;
            string pls;
            if (endpoint.Address.Equals(System.Net.IPAddress.Any))
            {
              pls = String.Format("http://localhost:{0}/pls/{1}{2}", endpoint.Port, channel_id.ToString("N"), ext);
            }
            else
            {
              pls = String.Format("http://{0}/pls/{1}{2}", endpoint.ToString(), channel_id.ToString("N"), ext);
            }
            System.Diagnostics.Process.Start(pls);
              },
            () => IsChannelSelected);
              close = new Command(
            () => peerCast.CloseChannel(Channel.Channel),
            () => IsChannelSelected);
              bump = new Command(
            () => Channel.Channel.Reconnect(),
            () => IsChannelSelected);
              openContactUrl = new Command(() =>
              {
            var url = Channel.Channel.ChannelInfo.URL;
            Uri uri;
            if (!String.IsNullOrEmpty(url) && Uri.TryCreate(url, UriKind.Absolute, out uri))
            {
              Process.Start(uri.ToString());
            }
              },
            () => IsChannelSelected);
              copyStreamUrl = new Command(() =>
              {
            var channel_id = Channel.Channel.ChannelID;
            var endpoint = peerCast.OutputListeners[0].LocalEndPoint;
            var ext = Channel.Channel.ChannelInfo.ContentExtension;
            string url;
            if (endpoint.Address.Equals(System.Net.IPAddress.Any))
            {
              url = String.Format("http://localhost:{0}/stream/{1}{2}", endpoint.Port, channel_id.ToString("N"), ext);
            }
            else
            {
              url = String.Format("http://{0}/pls/{1}{2}", endpoint.ToString(), channel_id.ToString("N"), ext);
            }
            Clipboard.SetText(url);
              },
            () => IsChannelSelected && peerCast.OutputListeners.Count > 0);
              copyContactUrl = new Command(() =>
              {
            var url = Channel.Channel.ChannelInfo.URL;
            Uri uri;
            if (!String.IsNullOrEmpty(url) && Uri.TryCreate(url, UriKind.Absolute, out uri))
            {
              Clipboard.SetText(uri.ToString());
            }
              },
            () => IsChannelSelected);
        }
Ejemplo n.º 15
0
 public OutputListenerViewModel(OutputListener model)
 {
     this.model = model;
       RegenerateAuthKey = new Command(DoRegenerateAuthKey);
 }