示例#1
0
 private bool MeetsRequirements(Viewer user)
 {
     if (needsFollow)
     {
         if (!user.isFollowing())
         {
             return(false);
         }
     }
     if (subscriberLuck == 10)
     {
         if (!user.isSubscribed())
         {
             return(false);
         }
     }
     return(true);
 }
        public WindowViewerChat(MainWindow window, Viewer viewer)
        {
            // Set fields
            this.window = window;
            this.viewer = viewer;

            // Init Window and set datacontext to this
            // for databinding to the attached Viewer
            InitializeComponent();
            DataContext = this;

            // Init IrcMessage collection and enable sync between threads
            colViewerMessages = new ObservableCollection <IrcMessage>();
            BindingOperations.EnableCollectionSynchronization(colViewerMessages, colLock);

            // Rather than copying all messages just collect the selected viewers
            // messages to save system resources in case of huge global chat history.
            var viewerMessages = MainWindow.colChatMessages.Where(
                TwitchChatMessage => TwitchChatMessage.Author == viewer.UserName);

            foreach (IrcMessage message in viewerMessages)
            {
                colViewerMessages.Add(message);
            }

            // Set item source for the listView and apply filter
            listViewChat.ItemsSource = colViewerMessages;

            // TODO quick and dirty isFollowing / isSub test
            cbFollowing.IsChecked  = viewer.isFollowing();
            cbSubscribed.IsChecked = viewer.isSubscribed();
            using (WebClient wc = new WebClient())
            {
                BitmapImage logo = new BitmapImage();
                logo.BeginInit();
                logo.StreamSource = wc.OpenRead(Utils.GetClient().GetMyChannel().Logo);
                logo.CacheOption  = BitmapCacheOption.OnLoad;
                logo.EndInit();
                image.Source = logo;
            }
        }