protected override System.Windows.Forms.ContextMenuStrip CreateMenu()
        {
            var mainMenu = new ContextMenuStrip();
            var itemExt  = new ToolStripMenuItem
            {
                Text  = "VPK Shell Ext..",
                Image = TextureTool.ResizeTex(Properties.Resources.VPK_ICON_CONTEXT.ToBitmap(), new System.Drawing.Size(mainMenu.Height - 2, mainMenu.Height - 2))
            };

            #region show settings
            var settingsMenu = new ToolStripMenuItem
            {
                Text  = "Settings",
                Image = TextureTool.ResizeTex(Properties.Resources.VPK_ICON_CONTEXT.ToBitmap(), new System.Drawing.Size(mainMenu.Height - 2, mainMenu.Height - 2))
            };
            var paramMenu = new ToolStripMenuItem
            {
                Text  = "Show param.sfo Info",
                Image = TextureTool.ResizeTex(Properties.Resources.VPK_ICON_CONTEXT.ToBitmap(), new System.Drawing.Size(mainMenu.Height - 2, mainMenu.Height - 2))
            };

            settingsMenu.Click += (sender, args) => showSettingsWindow();
            paramMenu.Click    += (sender, args) => showParamWindow();
            itemExt.DropDownItems.Add(settingsMenu);
            itemExt.DropDownItems.Add(paramMenu);
            #endregion
            mainMenu.Items.Add(itemExt);
            return(mainMenu);
        }
        protected override Icon GetIcon(bool smallIcon, uint iconSize)
        {
            Bitmap m_icon = null;

            if (m_icon == null)
            {
                try
                {
                    if (File.Exists(Path.Combine(SelectedItemPath, @"sce_sys\icon0.png")) &&
                        File.Exists(Path.Combine(SelectedItemPath, @"sce_sys\param.sfo")))
                    {
                        m_icon = TextureTool.GetBitmapFromFile(Path.Combine(SelectedItemPath, @"sce_sys\icon0.png"));
                        if (m_icon == null)
                        {
                            Properties.Resources.VPK_ICON0.ToBitmap();
                        }
                        m_icon = TextureTool.MergeTex(m_icon,
                                                      Properties.Resources.VPK_SIG_FOLDER,
                                                      new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                      new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                      m_icon.Width,
                                                      m_icon.Height);
                        GC.Collect();
                        return(Icon.FromHandle(TextureTool.ResizeTex(m_icon, new Size((int)iconSize, (int)iconSize)).GetHicon()));
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch
                {
                    //m_icon = Properties.Resources.VPK_ICON0.ToBitmap();
                    Logger.Log(this.ToString(), string.Format("Cant'load icon from {0}", SelectedItemPath));
                    return(null);
                }
            }
            return(null);
        }
Exemplo n.º 3
0
        protected override Icon GetIcon(bool smallIcon, uint iconSize)
        {
            Bitmap m_icon = null;

            if (m_icon == null)
            {
                try
                {
                    VPKLoader loader = new VPKLoader();
                    loader.LoadVPK(SelectedItemPath);
                    if (loader.isVitaVPK)
                    {
                        m_icon = loader.Icon;
                        if (m_icon == null)
                        {
                            Properties.Resources.VPK_ICON0.ToBitmap();
                        }

                        switch (loader.Type)
                        {
                        case VPKType.Normal_VPK:
                            m_icon = TextureTool.MergeTex(m_icon,
                                                          Properties.Resources.VPK_SIG_NORMAL,
                                                          new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                          new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                          m_icon.Width,
                                                          m_icon.Height);
                            break;

                        case VPKType.Vitamin_VPK:
                            m_icon = TextureTool.MergeTex(m_icon,
                                                          Properties.Resources.VPK_SIG_VITAMIN,
                                                          new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                          new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                          m_icon.Width,
                                                          m_icon.Height);
                            break;

                        case VPKType.Mai_VPK:
                            m_icon = TextureTool.MergeTex(m_icon,
                                                          Properties.Resources.VPK_SIG_MAI,
                                                          new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                          new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                          m_icon.Width,
                                                          m_icon.Height);
                            break;

                        case VPKType.Danger_VPK:
                            m_icon = TextureTool.MergeTex(m_icon,
                                                          Properties.Resources.VPK_SIG_DANGER,
                                                          new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                          new Rectangle((int)(m_icon.Width * 0), 0, (int)(m_icon.Width * 1), (int)(m_icon.Height * 1)),
                                                          m_icon.Width,
                                                          m_icon.Height);
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch
                {
                    //m_icon = Properties.Resources.VPK_ICON0.ToBitmap();
                    Logger.Log(this.ToString(), string.Format("Cant'load vpk from {0}", SelectedItemPath));
                    return(null);
                }
            }
            GC.Collect();
            return(Icon.FromHandle(TextureTool.ResizeTex(m_icon, new Size((int)iconSize, (int)iconSize)).GetHicon()));
        }