Example #1
0
        /// <summary>
        /// Adds a JumpTask and if needed creates the JumpList
        /// </summary>
        /// <param name="game"></param>
        public void AddTask(Game game)
        {
            try
            {
                Game g = game.Copy();
                g.Name = g.Name.Replace("fav_", "");
                // Configure a new JumpTask.
                JumpTask jumpTask1 = CreateJumpTask(g);

                // Get the JumpList from the application and update it.
                if (jumpList == null)
                    LoadJumpList();

                if (!jumpList.JumpItems.Exists(j => ((JumpTask) j).Title == g.Description))
                {
                    jumpList.JumpItems.Insert(0, jumpTask1);
                    SettingsManager.AddGameToJumpList(g.Name);
                }

                jumpList.Apply();
            }
            catch (Exception)
            {
                //No jump list, we're on XP/Vista
            }
        }
Example #2
0
        /// <summary>
        /// Creates a JumpTask
        /// </summary>
        /// <param name="game"></param>
        /// <returns></returns>
        private JumpTask CreateJumpTask(Game game)
        {
            JumpTask jumpTask1 = new JumpTask();
            jumpTask1.ApplicationPath = Settings.Default.MAME_EXE;
            jumpTask1.WorkingDirectory = Path.GetDirectoryName(Settings.Default.MAME_EXE);
            jumpTask1.Arguments = game.Name;

            string iconPath = game.IsParent
                                  ? Settings.Default.icons_directory + game.Name + ".ico"
                                  : Settings.Default.icons_directory + game.ParentSet + ".ico";
            if (!File.Exists(iconPath))
                jumpTask1.IconResourcePath = Application.ExecutablePath;
            else
                jumpTask1.IconResourcePath = iconPath;
            jumpTask1.Title = game.Description;
            jumpTask1.Description = game.Year + " " + game.Manufacturer;
            jumpTask1.CustomCategory = "Recently Played Games";

            return jumpTask1;
        }
Example #3
0
 public virtual void EndSearch()
 {
     _currentNode = null;
     _searchString = "";
 }
Example #4
0
        private IEnumerable<string> GetNodeLabels(Game node, SearchType type)
        {
            object obj = null;
            switch (type)
            {
                case SearchType.Name:
                    obj = node.Name;
                    break;
                case SearchType.Description:
                    obj = node.Description;
                    break;
                case SearchType.Driver:
                    obj = node.SourceFile;
                    break;
                case SearchType.Year:
                    obj = node.Year;
                    break;
            }

            if (obj != null)
                yield return obj.ToString().ToLowerInvariant();
        }
Example #5
0
        protected IEnumerable<string> IterateNodeLabels(Game start, SearchType type)
        {
            iterations = 0;
            _currentNode = start;
            while (_currentNode != null)
            {
                foreach (string label in GetNodeLabels(_currentNode, type))
                {
                    iterations++;
                    yield return label;
                }
                _currentNode = _currentNode.NextGame;
                if (_currentNode == null)
                    _currentNode = _gameList.FirstGame;

                if (start == _currentNode)
                    break;
            }
        }
        /// <summary>
        /// Returns what text we should draw depending on the display mode.
        /// </summary>
        /// <param name="game"></param>
        /// <returns></returns>
        private string GetRowText(Game game)
        {
            string RowText = "";
            switch (DisplayMode)
            {
                case DisplayModeEnum.Description:
                    RowText = game.Description;
                    break;
                case DisplayModeEnum.DescriptionAndYear:
                    RowText = game.Description + " " + game.Year;
                    break;
                case DisplayModeEnum.DescriptionAndManufacturer:
                    RowText = game.Description + " " + game.Manufacturer;
                    break;
                case DisplayModeEnum.DescriptionYearAndManufacturer:
                    RowText = game.Description + " " + game.Year + " " + game.Manufacturer;
                    break;
            }

            return RowText;
        }
        private void DrawRow(int row, int offset, Game game, Graphics g)
        {
            //Draw Icon
            FetchIcon(game);
            try
            {
                if (row == SelectedRow && Settings.Default.large_icon && SelectedGame != null)
                {
                    int lastrow = VerticalScroll.Maximum/RowHeight == row ? LargeIconSize.Height/2 : 0;
                    g.DrawImage(game.Icon, offset - LargeIconSize.Width/2,
                                RowHeight*row - lastrow, LargeIconSize.Width,
                                LargeIconSize.Height);
                }
                else
                    g.DrawImage(game.Icon, offset, RowHeight*row, SmallIconSize.Width,
                                SmallIconSize.Height);
            }
            catch (Exception ex)
            {
                Logger.WriteToLog(ex);
            }

            //Draw Text
            string RowText = GetRowText(game);
            RowText = ValidateRowLength(RowText, offset);

            game.RowRectangle = new Rectangle(0, RowHeight*row - RowHeight, ClientRectangle.Width,
                                              RowHeight*2);

            if (game.IsFavorite)
                g.DrawString(RowText, Font, new SolidBrush(FavoriteColor), offset + SmallIconSize.Width + 1,
                             RowHeight*row);
            else if (game.IsParent)
                g.DrawString(RowText, Font, new SolidBrush(ParentColor), offset + SmallIconSize.Width + 1,
                             RowHeight*row);
            else
            {
                g.DrawString(RowText, Font, new SolidBrush(CloneColor), offset + SmallIconSize.Width + 1,
                             RowHeight*row);
            }
        }
Example #8
0
 public PropertiesView(Game game)
 {
     InitializeComponent();
     _game = game;
 }
Example #9
0
        private Game GetNodeParent(Game node)
        {
            if (node == null)
                return null;

            if (node.IsFavorite)
                return node;

            return !node.IsParent && Games.ContainsKey(node.ParentSet) ? Games[node.ParentSet] : node;
        }
Example #10
0
        /// <summary>
        /// Caches the icon from disk when drawing the game row for the first time
        /// </summary>
        /// <param name="game"></param>
        private void FetchIcon(Game game)
        {
            if (game.Icon == null || (!game.Working && !game.HasOverlay && Settings.Default.non_working_overlay))
            {
                if (File.Exists(game.IconPath))
                {
                    try
                    {
                        game.Icon = new Icon(game.IconPath).ToBitmap();

                        if (!game.Working && Settings.Default.non_working_overlay)
                            DrawNonWorkingOverlay(game);

                    }
                    catch (Exception ex)
                    {
                        Logger.WriteToLog(ex);
                        if (game.Working)
                            game.Icon = game.IsParent ? _defaultIcon : _defaultCloneIcon;
                        else
                        {
                            game.Icon = _defaultNonWorkingIcon;
                            game.HasOverlay = true;
                        }
                    }

                }
                else
                {
                    try
                    {

                        if (game.IsParent)
                        {
                            if (game.Working)
                                game.Icon = _defaultIcon;
                            else
                            {
                                game.Icon = _defaultNonWorkingIcon;
                                game.HasOverlay = true;
                            }
                        }
                        else
                        {
                            if (game.Working && File.Exists(Path.Combine(Settings.Default.icons_directory, game.ParentSet + ".ico")))
                            {
                                game.Icon =
                                    new Icon(Path.Combine(Settings.Default.icons_directory, game.ParentSet + ".ico")).
                                        ToBitmap();

                                //if (!game.Working && Settings.Default.non_working_overlay)
                                //      DrawNonWorkingOverlay(game);

                            }
                            else
                                if (game.Working)
                                    game.Icon = _defaultCloneIcon;
                                else
                                {
                                    game.Icon = _defaultNonWorkingIcon;
                                    game.HasOverlay = true;
                                }

                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteToLog(ex);
                        if (game.Working)
                            game.Icon = game.IsParent ? _defaultIcon : _defaultCloneIcon;
                        else
                            game.Icon = _defaultNonWorkingIcon;
                    }
                }
            }
            else
            {
                if (!game.Working && game.HasOverlay && !Settings.Default.non_working_overlay)
                {
                    game.Icon = null;
                    game.HasOverlay = false;
                    FetchIcon(game);
                }
            }
        }
Example #11
0
 private void DrawNonWorkingOverlay(Game game)
 {
     Graphics g = Graphics.FromImage(game.Icon);
     g.DrawImageUnscaled(Properties.Resources.nonworkingoverlay,16,16);
     game.HasOverlay = true;
 }
Example #12
0
        /// <summary>
        /// Adds or removes games to the favorites, this has to refresh the list.
        /// </summary>
        /// <param name="game"></param>
        public void AddRemoveFavorites(Game game)
        {
            if (game == null)
                return;

            if (game.IsFavorite)
            {
                //remove game from favorites file
                string[] favs = new string[1];
                try
                {
                    if (File.Exists(Settings.Default.favorites_ini))
                        favs = File.ReadAllLines(Settings.Default.favorites_ini);
                }
                catch (Exception ex)
                {
                    Logger.WriteToLog(ex);
                }

                string name = game.Name.Replace("fav_", "");

                try
                {
                    List<string> favList = favs.ToList();
                    favList.Remove(name);
                    favList.Sort();
                    File.WriteAllLines(Settings.Default.favorites_ini, favList, Encoding.ASCII);
                }
                catch (Exception ex)
                {
                    Logger.WriteToLog(ex);
                }
                SelectedGame = SelectedGame.NextGame;
                if (FavoritesMode != FavoritesMode.Games)
                    Filter = _filter;
            }
            else //Add game to favorites
            {
                //check that no favorite exists
                if (!Games.ContainsKey("fav_" + game.Name))
                {
                    string[] favs = new string[1];

                    try
                    {
                        if (File.Exists(Settings.Default.favorites_ini))
                            favs = File.ReadAllLines(Settings.Default.favorites_ini);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteToLog(ex);
                    }

                    try
                    {
                        List<string> favList = favs.ToList();
                        favList.Add(game.Name);
                        favList.Sort();
                        File.WriteAllLines(Settings.Default.favorites_ini, favList, Encoding.ASCII);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteToLog(ex);
                    }

                    if (FavoritesMode != FavoritesMode.Games)
                        Filter = _filter;
                }
            }
        }