コード例 #1
0
        public void DisplayNotification(StreamsInfo sInfo, int displayTime)
        {
            if (windowThread != null && windowThread.IsAlive)
                windowThread.Abort();

            windowThread = new Thread(new ThreadStart(() =>
            {
                NotificationWindow w = new NotificationWindow();

                // Try and set display monitor
                try
                {
                    var testArrayOutOfBounds = System.Windows.Forms.Screen.AllScreens[ConfigMgnr.I.DisplayMonitor];
                    w.MonitorIndex = ConfigMgnr.I.DisplayMonitor;
                }
                catch (IndexOutOfRangeException)
                {
                    w.MonitorIndex = 0;
                }

                // Check if there's valid information to display
                if (sInfo != null && sInfo.Streams != null && sInfo.Streams.Count > 0)
                    w.listDataBinding.ItemsSource = sInfo.Streams;
                else
                    w.ErrorPanel.Visibility = System.Windows.Visibility.Visible;

                w.ShowInTaskbar = false;
                w.WindowTimeOnScreen.KeyTime = new TimeSpan(0, 0, displayTime);
                w.WindowTimeOnScreen2.KeyTime = new TimeSpan(0, 0, displayTime + 2);

                w.Closed += (s, e) =>
                    System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvokeShutdown(System.Windows.Threading.DispatcherPriority.Background);

                w.Show();

                System.Windows.Threading.Dispatcher.Run();

            }));

            windowThread.SetApartmentState(ApartmentState.STA);
            windowThread.IsBackground = true;
            windowThread.Start();
        }
コード例 #2
0
        private StreamsInfo SortByTime(StreamsInfo si)
        {
            List<StreamsObj> sortedList = si.Streams.OrderByDescending(x => x.CreatedAt).ToList();

            return new StreamsInfo() { Streams = sortedList, IsSucces = true };
        }
コード例 #3
0
        /// <summary>
        /// Compares the new StreamsInfo with the current one. Invokes NotifyEvent if new entries are found.
        /// </summary>
        private void CompareInfo(StreamsInfo si)
        {
            var newstreams = new List<Channel>();
            FavouriteGroup tempgroup = null;
            FavouriteGroup returngroup = null;

            if (CurrentInfo == null)
            {
                foreach (var item in si.Streams)
                {
                    if (MiscOperations.TryGetFavourite(item.Channel.Name, out tempgroup) > 0)
                    {
                        if (returngroup == null)
                            returngroup = tempgroup;
                        else if (returngroup.Priority < tempgroup.Priority)
                            returngroup = tempgroup;
                    }
                }
                RaiseEvent(si, returngroup);
                return;
            }

            foreach (var item in si.Streams)
            {
                if (!CurrentInfo.Streams.Exists(x => x.Channel.Name.Equals(item.Channel.Name)))
                {
                    newstreams.Add(item.Channel);
                }
            }

            if (newstreams.Count > 0)
            {
                foreach (var item in newstreams)
                {
                    if (MiscOperations.TryGetFavourite(item.Name, out tempgroup) > 0)
                    {
                        if (returngroup == null)
                            returngroup = tempgroup;
                        else if (returngroup.Priority < tempgroup.Priority)
                            returngroup = tempgroup;
                    }
                }
                RaiseEvent(si, returngroup);
                return;
            }

            CurrentInfo = si;
        }
コード例 #4
0
 private void RaiseEvent(StreamsInfo si, FavouriteGroup fg)
 {
     CurrentInfo = si;
     TimeRecieved = DateTime.Now;
     if (FoundNewStreamEvent != null)
         FoundNewStreamEvent(si, fg);
 }
コード例 #5
0
        /// <summary>
        /// Updates currentInfo with the passed parameter variable
        /// </summary>
        /// <param name="si"></param>
        public void UpdateAndCompare(StreamsInfo si)
        {
            var tempSI = si;

            if (tempSI.IsSucces)
            {
                CompareInfo(tempSI);
            }
        }