public void parseObjects() { _leech = null; ProgrammeCollection _tvToday = parsedObj; ProgrammeCollection _tvNow = _tvToday.GetCurrentShows(); // 3 is added to imageheight to get some space between objects int itemHeight = 0; float fontSize = 0; if (_tvNow.Count() > 15) { itemHeight = 22; fontSize = 6F; } else if (_tvNow.Count() > 10) { itemHeight = 27; fontSize = 8F; } else if (_tvNow.Count() > 8) { itemHeight = 35; fontSize = 10F; } else { itemHeight = 35; fontSize = 10F; } custListBox = new CustomListBox(itemHeight); custListBox.WrapText = true; custListBox.BackColor = Color.White; //custListBox.ForeColor = Color.White; int imageSize = itemHeight - 3; custListBox.Width = 234; custListBox.Height = (itemHeight * _tvNow.Count()); custListBox.Location = new Point(3, 3); ImageList _channelImageList = new ImageList(); _channelImageList.ImageSize = new Size(imageSize, imageSize); int i = 0; //Populate items foreach (Programme prog in _tvNow) { int _currentPos = _tvToday.IndexOf(prog); Programme _nextShow = _tvToday[_currentPos + 1]; ListItem item1 = new ListItem(); item1.FontSize = fontSize; //item1.TextStyle = FontStyle.Regular; item1.Text = String.Format("{0:HH:mm}", prog.StartTime) + " " + prog.Caption; item1.Text += "\r\n" + String.Format("{0:HH:mm}", _nextShow.StartTime) + " " + _nextShow.Caption; _channelImageList.Images.Add(prog.ChannelImage); item1.ImageIndex = i; custListBox.Items.Add(item1); i++; } //Assign ImageList custListBox.ImageList = _channelImageList; }
private ProgrammeCollection GetProgrammes() { const String nl = "\r\n"; XMLTVParser parser; String strXMLFileContents = ""; String tvdbURI = prefs.XMLTVSourceURI; ProgrammeCollection parsedObj = new ProgrammeCollection(); string[] kanaler = prefs.ChannelList; try { Cursor.Current = Cursors.WaitCursor; for (int i = 0; i < kanaler.Length ;i++ ) { string uri = tvdbURI + kanaler[i].ToString(); string strFileName; Leecher _leech = new Leecher(uri); //LOG: String.Format("Starting download of file: {0}", uri) + nl+ nl ; _leech.GetListings(false); strFileName = _leech.PathToFile; if (strFileName.EndsWith(".xml.gz")) { //LOG: this // decompress the gziped file to string, and send content to xmltv parser GzipDecompressor gzPack = new GzipDecompressor(); strXMLFileContents = gzPack.Decompress(strFileName); } else { if (strFileName.EndsWith(".xml")) { //LOG: this //no need for decompression, read filestream into string at once... StreamReader st = new StreamReader(strFileName); strXMLFileContents = st.ReadToEnd(); } else throw new Exception("Unknow filetype. Must be XML or XML.GZ"); } //LOG: this "File downloaded: " + Path.GetFileName(strFileName) + nl + nl; parser = new XMLTVParser(strXMLFileContents); foreach (Programme oProg in parser.ParsedProgrammes) { parsedObj.Add(oProg); } } } catch (Exception downloadExcepetion) { MessageBox.Show(downloadExcepetion.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } Cursor.Current = Cursors.Default; return parsedObj; }
/// <summary> /// Initialize the downloader, and calls startThread to begin download /// </summary> private void GetListings() { string[] kanaler = prefs.ChannelListURL; try { _leech = new Leecher(kanaler); parsedObj = new ProgrammeCollection(); // Create the worker thread and start it ThreadStart starter = new ThreadStart(this.startMeUp); Thread t = new Thread(starter); t.Start(); } catch (Exception downloadExcepetion) { MessageBox.Show(downloadExcepetion.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }