Ejemplo n.º 1
0
        void _screen_GameSelected(object sender, GameSelectedEventArgs e)
        {
            String s = e.StoryFileName;

            for (int i = 0; i < LastPlayedGames.Count; i++)
            {
                if (String.IsNullOrWhiteSpace(LastPlayedGames[i]) || String.Compare(LastPlayedGames[i], s, true) == 0)
                {
                    LastPlayedGames.RemoveAt(i--);
                }
            }

            LastPlayedGames.Add(s);


            while (LastPlayedGames.Count > Properties.Settings.Default.LastPlayedGamesCount)
            {
                LastPlayedGames.RemoveAt(0);
            }

            Properties.Settings.Default.LastPlayedGames = String.Join("|", LastPlayedGames.ToArray());
            Properties.Settings.Default.Save();

            _storyFileName = e.StoryFileName;
            _blorbFile     = e.BlorbFile;

            miGameInfo.IsEnabled = (_blorbFile != null);
        }
Ejemplo n.º 2
0
        public BlorbMetadata(Frotz.Blorb.Blorb BlorbFile)
        {
            InitializeComponent();

            rtb.SizeChanged      += new SizeChangedEventHandler(rtb_SizeChanged);
            imgCover.SizeChanged += new SizeChangedEventHandler(imgCover_SizeChanged);

            _blorb = BlorbFile;

            var xml = new XmlDocument();

            xml.LoadXml(_blorb.MetaData);

            int row = 0;

            XmlNodeList nodes;

            if (BlorbFile.Pictures.Count > 0)
            {
                nodes = xml.GetElementsByTagName("coverpicture");
                if (nodes.Count > 0)
                {
                    int id = Convert.ToInt32(nodes[0].InnerText);

                    var bi = new BitmapImage();
                    bi.BeginInit();
                    var ms = new MemoryStream(BlorbFile.Pictures[id].Image);
                    bi.StreamSource = ms;
                    bi.EndInit();
                    imgCover.Source = bi;
                }
            }

            nodes = xml.GetElementsByTagName("bibliographic");
            if (nodes.Count == 1)
            {
                foreach (XmlNode node in nodes[0].ChildNodes)
                {
                    if (node.Name == "description")
                    {
                        wbInfo.NavigateToString(node.InnerXml);
                    }
                    else
                    {
                        string text = "";
                        string key  = node.Name;
                        switch (key)
                        {
                        case "title":
                        {
                            text  = "Title";
                            Title = node.InnerText;
                        }
                        break;

                        case "author":
                            text = "Author"; break;

                        case "language":
                            text = "Language"; break;

                        case "headline":
                            text = "Subtitle"; break;

                        case "firstpublished":
                            text = "First Published"; break;

                        case "genre":
                            text = "Genre"; break;

                        case "group":
                            text = "Group"; break;

                        case "series":
                            text = "Series"; break;

                        case "seriesnumber":
                            text = "Series #"; break;
                        }

                        if (text == "Language")
                        {
                            continue;                     // Temporary measure, since I don't want to see the language
                        }
                        var tr = new TableRow();
                        var tc = new TableCell(new Paragraph(new Run(text)));
                        tr.Cells.Add(tc);

                        var p = new Paragraph();
                        var r = new Run(node.InnerText);
                        p.TextAlignment = TextAlignment.Right;
                        p.Inlines.Add(r);

                        tc = new TableCell(p);
                        tr.Cells.Add(tc);

                        trg.Rows.Add(tr);

                        row++;
                    }
                }

                btnOk.Focus();
            }

            nodes = xml.GetElementsByTagName("contacts");
            if (nodes.Count > 0)
            {
                var n = nodes[0];
                if (n.FirstChild.Name == "url")
                {
                    var tr = new TableRow();
                    var tc = new TableCell(new Paragraph(new Run("More Info")));
                    tr.Cells.Add(tc);

                    var p = new Paragraph();
                    var h = new Hyperlink(new Run(n.FirstChild.InnerText))
                    {
                        Focusable  = false,
                        Foreground = Brushes.Blue,
                        IsEnabled  = true
                    };
                    p.TextAlignment = TextAlignment.Right;
                    h.MouseDown    += new MouseButtonEventHandler(h_MouseDown);
                    h.NavigateUri   = new Uri(n.FirstChild.InnerText);
                    h.ForceCursor   = true;
                    h.Cursor        = Cursors.Hand;
                    p.Inlines.Add(h);

                    tc = new TableCell(p);
                    tr.Cells.Add(tc);
                    trg.Rows.Add(tr);
                }
            }
        }
 public GameSelectedEventArgs(String StoryFileName, Frotz.Blorb.Blorb BlorbFile)
 {
     this.StoryFileName = StoryFileName;
     this.BlorbFile     = BlorbFile;
 }
Ejemplo n.º 4
0
        public BlorbMetadata(Frotz.Blorb.Blorb BlorbFile)
        {
            InitializeComponent();

            rtb.SizeChanged += new SizeChangedEventHandler(rtb_SizeChanged);
            imgCover.SizeChanged += new SizeChangedEventHandler(imgCover_SizeChanged);

            _blorb = BlorbFile;

            XmlDocument xml = new XmlDocument();
            xml.LoadXml(_blorb.MetaData);

            int row = 0;

            XmlNodeList nodes;

            if (BlorbFile.Pictures.Count > 0)
            {
                nodes = xml.GetElementsByTagName("coverpicture");
                if (nodes.Count > 0)
                {
                    int id = Convert.ToInt32(nodes[0].InnerText);

                    BitmapImage bi = new BitmapImage();
                    bi.BeginInit();
                    bi.StreamSource = new MemoryStream(BlorbFile.Pictures[id].Image);
                    bi.EndInit();
                    imgCover.Source = bi;
                }
                
            }




            nodes = xml.GetElementsByTagName("bibliographic");
            if (nodes.Count == 1)
            {
                foreach (XmlNode node in nodes[0].ChildNodes)
                {
                    if (node.Name == "description")
                    {
                        wbInfo.NavigateToString(node.InnerXml);
                    }
                    else
                    {
                        String text = "";
                        String key = node.Name;
                        switch (key)
                        {
                            case "title":
                                {
                                    text = "Title";
                                    this.Title = node.InnerText;
                                }
                                break;
                            case "author":
                                text = "Author"; break;
                            case "language":
                                text = "Language"; break;
                            case "headline":
                                text = "Subtitle"; break;
                            case "firstpublished":
                                text = "First Published"; break;
                            case "genre":
                                text = "Genre"; break;
                            case "group":
                                text = "Group"; break;
                            case "series":
                                text = "Series"; break;
                            case "seriesnumber":
                                text = "Series #"; break;
                        }

                        if (text == "Language") continue; // Temporary measure, since I don't want to see the language

                        TableRow tr = new TableRow();
                        TableCell tc = new TableCell(new Paragraph(new Run(text)));
                        tr.Cells.Add(tc);

                        Paragraph p = new Paragraph();
                        Run r = new Run(node.InnerText);
                        p.TextAlignment = TextAlignment.Right;
                        p.Inlines.Add(r);

                        tc = new TableCell(p);
                        tr.Cells.Add(tc);

                        trg.Rows.Add(tr);

                        row++;
                    }
                }

                btnOk.Focus();
            }

            nodes = xml.GetElementsByTagName("contacts");
            if (nodes.Count > 0)
            {
                var n = nodes[0];
                if (n.FirstChild.Name == "url")
                {

                    TableRow tr = new TableRow();
                    TableCell tc = new TableCell(new Paragraph(new Run("More Info")));
                    tr.Cells.Add(tc);

                    Paragraph p = new Paragraph();
                    Hyperlink h = new Hyperlink(new Run(n.FirstChild.InnerText));
                    h.Focusable = false;
                    h.Foreground = Brushes.Blue;
                    h.IsEnabled = true;
                    p.TextAlignment = TextAlignment.Right;
                    h.MouseDown += new MouseButtonEventHandler(h_MouseDown);
                    h.NavigateUri = new Uri(n.FirstChild.InnerText);
                    h.ForceCursor = true;
                    h.Cursor = Cursors.Hand;
                    p.Inlines.Add(h);

                    tc = new TableCell(p);
                    tr.Cells.Add(tc);
                    trg.Rows.Add(tr);
                }
            }
        }
Ejemplo n.º 5
0
 public GameSelectedEventArgs(String StoryFileName, Frotz.Blorb.Blorb BlorbFile)
 {
     this.StoryFileName = StoryFileName;
     this.BlorbFile = BlorbFile;
 }
Ejemplo n.º 6
0
        void _screen_GameSelected(object sender, GameSelectedEventArgs e)
        {
            String s = e.StoryFileName;

            for (int i = 0; i < LastPlayedGames.Count; i++)
            {
                if (String.IsNullOrWhiteSpace(LastPlayedGames[i]) || String.Compare(LastPlayedGames[i], s, true) == 0)
                {
                    LastPlayedGames.RemoveAt(i--);
                }
            }

            LastPlayedGames.Add(s);


            while (LastPlayedGames.Count > Properties.Settings.Default.LastPlayedGamesCount)
            {
                LastPlayedGames.RemoveAt(0);
            }

            Properties.Settings.Default.LastPlayedGames = String.Join("|", LastPlayedGames.ToArray());
            Properties.Settings.Default.Save();

            _storyFileName = e.StoryFileName;
            _blorbFile = e.BlorbFile;

            miGameInfo.IsEnabled = (_blorbFile != null);
        }