示例#1
0
        private void cmResize_Click(object sender, EventArgs e)
        {
            try
            {
                ListBox lbx = (((ToolStripMenuItem)sender).Owner.Tag.ToString().ToLower().Contains("banner")) ? lbxBannerTpls : lbxIconTpls;

                int selectedIndex = lbx.SelectedIndex;
                string tplName = lbx.SelectedItem.ToString().Remove(lbx.SelectedItem.ToString().IndexOf('(') - 3);

                Size oldSize;

                if (lbx == lbxBannerTpls)
                    if (string.IsNullOrEmpty(replacedBanner))
                    { oldSize = TPL.Load(bannerBin.Data[bannerBin.GetNodeIndex(tplName)]).GetTextureSize(0); }
                    else
                    { oldSize = TPL.Load(newBannerBin.Data[newBannerBin.GetNodeIndex(tplName)]).GetTextureSize(0); }
                else
                    if (string.IsNullOrEmpty(replacedIcon))
                    { oldSize = TPL.Load(iconBin.Data[iconBin.GetNodeIndex(tplName)]).GetTextureSize(0); }
                    else
                    { oldSize = TPL.Load(newIconBin.Data[newIconBin.GetNodeIndex(tplName)]).GetTextureSize(0); }

                CustomizeMii_InputBox ib = new CustomizeMii_InputBox();
                ib.Description = "Please enter a new size:";
                ib.tbInput.Size = new Size(ib.btnExit.Width, ib.tbInput.Height);
                ib.tbInput2.Visible = true;
                ib.CommonKeyMode = false;
                ib.tbInput.MaxLength = 127;
                ib.btnExit.Text = "Close";
                ib.Input = oldSize.Width.ToString();
                ib.Input2 = oldSize.Height.ToString();

                if (ib.ShowDialog() == DialogResult.OK)
                {
                    Size newSize = new Size(int.Parse(ib.Input), int.Parse(ib.Input2));
                    if (newSize == oldSize) return;

                    TPL tmpTpl;

                    if (lbx == lbxBannerTpls)
                        if (string.IsNullOrEmpty(replacedBanner))
                            tmpTpl = TPL.Load(bannerBin.Data[bannerBin.GetNodeIndex(tplName)]);
                        else
                            tmpTpl = TPL.Load(newBannerBin.Data[newBannerBin.GetNodeIndex(tplName)]);
                    else
                        if (string.IsNullOrEmpty(replacedIcon))
                            tmpTpl = TPL.Load(iconBin.Data[iconBin.GetNodeIndex(tplName)]);
                        else
                            tmpTpl = TPL.Load(newIconBin.Data[newIconBin.GetNodeIndex(tplName)]);

                    TPL_TextureFormat tplFormat = tmpTpl.GetTextureFormat(0);
                    Image newImg = resizeImage(tmpTpl.ExtractTexture(0), newSize.Width, newSize.Height);

                    tmpTpl.RemoveTexture(0);
                    tmpTpl.AddTexture(newImg, tplFormat);

                    if (lbx == lbxBannerTpls)
                        if (string.IsNullOrEmpty(replacedBanner))
                            bannerBin.ReplaceFile(bannerBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
                        else
                            newBannerBin.ReplaceFile(newBannerBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
                    else
                        if (string.IsNullOrEmpty(replacedIcon))
                            iconBin.ReplaceFile(iconBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());
                        else
                            newIconBin.ReplaceFile(newIconBin.GetNodeIndex(tplName), tmpTpl.ToByteArray());

                    addTpls();

                    try { lbx.SelectedIndex = selectedIndex; }
                    catch { }
                }
            }
            catch (Exception ex) { errorBox(ex.Message); }
        }
        private void forwarderDialogSimple()
        {
            CustomizeMii_InputBox ib = new CustomizeMii_InputBox(false);
            ib.Size = new Size(ib.Size.Width, 120);
            ib.lbInfo.Text = "Enter the application folder where the forwarder will point to (3-18 chars)";
            ib.tbInput.MaxLength = 18;
            ib.btnExit.Text = "Cancel";
            ib.cbElf.Visible = true;

            ib.tbInput.Text = simpleForwarder.AppFolder;
            ib.cbElf.Checked = simpleForwarder.ForwardToElf;

            if (ib.ShowDialog() == DialogResult.OK)
            {
                simpleForwarder.ForwardToElf = ib.cbElf.Checked;
                simpleForwarder.AppFolder = ib.Input;
                setControlText(tbDol, string.Format("Simple Forwarder: \"SD:\\apps\\{0}\\boot.{1}\"",
                    simpleForwarder.AppFolder, simpleForwarder.ForwardToElf == true ? "elf" : "dol"));
                btnBrowseDol.Text = "Clear";
            }
        }
示例#3
0
        private void cmRename_Click(object sender, EventArgs e)
        {
            try
            {
                ListBox lbx = (((ToolStripMenuItem)sender).Owner.Tag.ToString().ToLower().Contains("banner")) ? lbxBannerTpls : lbxIconTpls;

                string oldNameFull = lbx.SelectedItem.ToString();
                string oldName = lbx.SelectedItem.ToString().Remove(lbx.SelectedItem.ToString().IndexOf('(') - 3);
                CustomizeMii_InputBox ib = new CustomizeMii_InputBox();
                ib.Description = "Please enter a new name:";
                ib.Input = oldName;
                ib.CommonKeyMode = false;
                ib.tbInput.MaxLength = 127;
                ib.btnExit.Text = "Close";

                if (ib.ShowDialog() == DialogResult.OK && oldName != ib.Input && !string.IsNullOrEmpty(ib.Input))
                {
                    string newName = ib.Input;
                    if (!newName.ToLower().EndsWith(".tpl")) newName += ".tpl";

                    foreach (char thisChar in Path.GetInvalidFileNameChars())
                        if (newName.Contains(thisChar.ToString()))
                            throw new Exception(string.Format("Invalid path char \"{0}\" found in new name!", thisChar));

                    if (lbx == lbxBannerTpls)
                        if (string.IsNullOrEmpty(replacedBanner))
                            bannerBin.RenameNode(oldName, newName);
                        else
                            newBannerBin.RenameNode(oldName, newName);
                    else
                        if (string.IsNullOrEmpty(replacedIcon))
                            iconBin.RenameNode(oldName, newName);
                        else
                            newIconBin.RenameNode(oldName, newName);

                    addTpls();

                    try { lbx.SelectedItem = oldNameFull.Replace(oldName, newName); }
                    catch { }
                }
            }
            catch (Exception ex) { errorBox(ex.Message); }
        }