private void BtnBrowse_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog {
                Title  = "更改图标",
                Filter = "图标文件|*.ico;*.exe;*.dll|程序|*.exe|库|*.dll|图标|*.ico|所有文件|*.*"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                string fileName = ofd.FileName;
                txtPath.Text = fileName;
                pnlICO.Controls.Clear();
                TileIcon tileIcon = new TileIcon();
                tileIcon.LoadIcon(fileName);
                tileIcon.ShowIcon(pnlICO);
            }
        }
        //更改图标
        private void ReplaceIcon(object sender, EventArgs e)
        {
            var frm = new FormReplaceIcon(iconPath)
            {
                Icon = this.Icon
            };

            frm.ShowDialog();
            if (frm.IconIndex == -1)
            {
                return;
            }
            iconPath  = frm.IconPath;
            iconIndex = frm.IconIndex;
            Image image = new TileIcon().ToImage(iconPath, iconIndex);

            ShowMyIcon(image);
        }
        public FormReplaceIcon(string iconPath)
        {
            this.InitializeComponent();
            this.IconPath     = null;
            this.IconIndex    = -1;
            this.AcceptButton = btnOK;
            this.CancelButton = btnCancel;

            if (iconPath != null)
            {
                txtPath.Text = iconPath;
                TileIcon tileIcon = new TileIcon();
                tileIcon.LoadIcon(iconPath);
                tileIcon.ShowIcon(pnlICO);
            }
            btnBrowse.Click += BtnBrowse_Click;
            btnOK.Click     += BtnOK_Click;
            btnCancel.Click += BtnCancel_Click;
        }
Beispiel #4
0
        //更改图标
        private void ReplaceIcon(object sender, EventArgs e)
        {
            var frm = new FormReplaceIcon(iconPath)
            {
                Icon = this.Icon
            };

            frm.ShowDialog();
            if (frm.IconIndex == -1)
            {
                return;
            }
            iconPath  = frm.IconPath;
            iconIndex = frm.IconIndex;
            Image image = new TileIcon().ToImage(iconPath, iconIndex);

            if (image == null)
            {
                return;
            }
            picIconView.Image = image;
            UseIcoAsPic();
        }