예제 #1
0
파일: GameList.cs 프로젝트: GEPWNAGE/Steel
        public List<Game> generateGameList()
        {
            List<Game> generatedList = new List<Game>();

            if(!File.Exists(Settings.Default.xmlPath)){
                return generatedList;
            }

            // parse the XML file
            XmlDocument parser = new XmlDocument();
            parser.Load(Settings.Default.xmlPath);
            foreach (XmlNode gameNode in parser.GetElementsByTagName("game")) {
                Game g = new Game();
                foreach (XmlNode game_element in gameNode.ChildNodes) {

                    List<string> exes = new List<string>();
                    if (game_element.Name == "title") {
                        g.title = game_element.InnerText;
                    }
                    if (game_element.Name == "size") {
                        g.size = game_element.InnerText;
                    }
                    if (game_element.Name == "players") {
                        g.players = game_element.InnerText;
                    }

                    if (game_element.Name == "message") {
                        g.message = game_element.InnerText.Trim();
                    }

                    if (game_element.Name == "exes") {
                        foreach (XmlNode exe in game_element.ChildNodes) {
                            Exe newExe = new Exe();
                            foreach (XmlNode exe_element in exe.ChildNodes) {

                                if (exe_element.Name == "file") {
                                    newExe.file = exe_element.InnerText;
                                }
                                if (exe_element.Name == "icon") {
                                    newExe.icon = exe_element.InnerText;
                                }
                                if (exe_element.Name == "name") {
                                    newExe.title = exe_element.InnerText;
                                }
                            }
                            g.AddExe(newExe);
                        }
                    }
                }

                // new list? Add!
                generatedList.Add(g);
            }

            return generatedList;
        }
예제 #2
0
        private void btnPlay_Click(object sender, RoutedEventArgs e)
        {
            Game g = ((FrameworkElement)sender).DataContext as Game;
            selectedGame = g;

            if (g._isInstalling)
            {
                return;
            }

            if (g._isDownloading) {
                if (g._isPaused) {
                    // resume torrent
                    g.resumeTorrent();
                }
                else {
                    // pause torrent
                    g.pauseTorrent();
                }

                return;
            }

            if (!g.installed)
            {
                g.downloadAndInstall();
                return;
            }

            if (g.exeCount > 1) {
                Button b = ((FrameworkElement)sender) as Button;

                if (b.ContextMenu == null) {
                    b.ContextMenu = new ContextMenu();
                    b.ContextMenu.Background = Brushes.DarkSlateGray;
                    b.ContextMenu.Foreground = Brushes.LightGray;

                    MenuItem m0 = new MenuItem();
                    m0.Header = g.executables[0].title;
                    m0.Click += new RoutedEventHandler(m0_Click);

                    m0.Icon = new System.Windows.Controls.Image {
                        Source = new BitmapImage(new Uri(g.icon(0))),
                        Height = 20,
                        Width = 20
                    };
                    m0.Background = Brushes.DarkSlateGray;
                    b.ContextMenu.Items.Add(m0);

                    MenuItem m1 = new MenuItem();
                    m1.Header = g.executables[1].title;
                    m1.Click += new RoutedEventHandler(m1_Click);

                    m1.Icon = new System.Windows.Controls.Image {
                        Source = new BitmapImage(new Uri(g.icon(1))),
                        Height = 20,
                        Width = 20
                    };

                    m1.Background = Brushes.DarkSlateGray;
                    b.ContextMenu.Items.Add(m1);
                }
                b.ContextMenu.PlacementTarget = b;
                b.ContextMenu.IsOpen = true;
            } else {
                this.WindowState = WindowState.Minimized;
                g.play(0);
                this.WindowState = WindowState.Normal;
            }
        }
예제 #3
0
        /*
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            Game g = ((FrameworkElement)sender).DataContext as Game;
            selectedGame = g;

            Button b = ((FrameworkElement)sender) as Button;

            if (b.ContextMenu == null) {
                b.ContextMenu = new ContextMenu();
                b.ContextMenu.Background = Brushes.DarkSlateGray;
                b.ContextMenu.Foreground = Brushes.LightGray;

                MenuItem m0 = new MenuItem();
                m0.Header = "Remove Installer";
                m0.Click += new RoutedEventHandler(RemInstall_Click);

                m0.Background = Brushes.DarkSlateGray;
                b.ContextMenu.Items.Add(m0);

                MenuItem m1 = new MenuItem();
                m1.Header = "Remove All Data";
                m1.Click += new RoutedEventHandler(RemAll_Click);

                m1.Background = Brushes.DarkSlateGray;
                b.ContextMenu.Items.Add(m1);
            }
            b.ContextMenu.PlacementTarget = b;
            b.ContextMenu.IsOpen = true;
        }*/
        private void btnUninstall_Click(object sender, RoutedEventArgs e)
        {
            Game g = ((FrameworkElement)sender).DataContext as Game;
            selectedGame = g;

            g.uninstall();
        }