コード例 #1
0
        private static List <Hadith> GetAllHadithFromFile(string filename)
        {
            XmlReader reader = XmlReader.Create(filename);
            Hadith    hadith = new Hadith();

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "book")
                {
                    reader.Read();
                    hadith.Book = "Sahih Bukhari: " + reader.Value;
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "narrator")
                {
                    reader.Read();
                    hadith.Narrator = reader.Value;
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "content")
                {
                    reader.Read();
                    hadith.Content = reader.Value;
                }

                // When we have all the info for this hadith, load it into ahadith list and reset current hadith
                if (hadith.Book != null && hadith.Content != null && hadith.Narrator != null)
                {
                    ahadith.Add(hadith);
                    hadith = new Hadith();
                }
            }
            return(ahadith);
        }
コード例 #2
0
        private void MainFlipView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // Update the Heading TextBlock with Book/Chapter/etc information
            Hadith currentHadith = ahadith[MainFlipView.SelectedIndex];

            headingTextBlock.Text = currentHadith.Book;
        }
コード例 #3
0
        private static void UpdateLiveTile()
        {
            // Get random hadith
            int    hadithIndex = (new Random()).Next() % ahadith.Count;
            Hadith hadith      = ahadith[hadithIndex];

            // Create wide tile
            XmlDocument tileXml          = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text04);
            XmlNodeList tileXmlTextNodes = tileXml.GetElementsByTagName("text");

            tileXmlTextNodes[0].InnerText = hadith.Content;

            // Create square tile
            XmlDocument squareTileXml      = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text02);
            XmlNodeList squareXmlTextNodes = tileXml.GetElementsByTagName("text");

            squareXmlTextNodes[0].InnerText = hadith.Content;

            // Combine wide and square into one XML
            IXmlNode node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true);

            tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node);

            // Send notification
            TileNotification notification = new TileNotification(tileXml);

            notification.ExpirationTime = DateTimeOffset.UtcNow.AddDays(1);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
        }
コード例 #4
0
        private static List<Hadith> GetAllHadithFromFile(string filename)
        {
            XmlReader reader = XmlReader.Create(filename);
            Hadith hadith = new Hadith();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "book")
                {
                    reader.Read();
                    hadith.Book = "Sahih Bukhari: " + reader.Value;
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "narrator")
                {
                    reader.Read();
                    hadith.Narrator = reader.Value;
                }
                else if (reader.NodeType == XmlNodeType.Element && reader.Name == "content")
                {
                    reader.Read();
                    hadith.Content = reader.Value;
                }

                // When we have all the info for this hadith, load it into ahadith list and reset current hadith
                if (hadith.Book != null && hadith.Content != null && hadith.Narrator != null)
                {
                    ahadith.Add(hadith);
                    hadith = new Hadith();
                }
            }
            return ahadith;
        }