Exemple #1
0
 public ChangeIconMenuItem(ITsiIconItem item) : base(AppString.Menu.ChangeIcon)
 {
     this.Click += (sender, e) =>
     {
         using (IconDialog dlg = new IconDialog())
         {
             dlg.IconPath  = item.IconPath;
             dlg.IconIndex = item.IconIndex;
             if (dlg.ShowDialog() != DialogResult.OK)
             {
                 return;
             }
             using (Icon icon = ResourceIcon.GetIcon(dlg.IconPath, dlg.IconIndex))
             {
                 Image image = icon?.ToBitmap();
                 if (image == null)
                 {
                     return;
                 }
                 item.Image        = image;
                 item.IconPath     = dlg.IconPath;
                 item.IconIndex    = dlg.IconIndex;
                 item.IconLocation = $"{dlg.IconPath},{dlg.IconIndex}";
             }
         }
     };
 }
Exemple #2
0
        public ChangeIconMenuItem(ITsiIconItem item) : base(AppString.Menu.ChangeIcon)
        {
            this.Click += (sender, e) =>
            {
                using (IconDialog dlg = new IconDialog())
                {
                    dlg.IconPath  = item.IconPath;
                    dlg.IconIndex = item.IconIndex;
                    if (dlg.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    item.IconPath     = dlg.IconPath;
                    item.IconIndex    = dlg.IconIndex;
                    item.IconLocation = $"{dlg.IconPath},{dlg.IconIndex}";
                    using (Icon icon = ResourceIcon.GetIcon(dlg.IconPath, dlg.IconIndex))
                    {
                        item.Image = icon.ToBitmap();
                    }
                }
            };
            MyListItem listItem = (MyListItem)item;

            listItem.Disposed         += (sender, e) => item.ItemIcon?.Dispose();
            listItem.ImageDoubleClick += (sender, e) =>
            {
                if (this.Enabled)
                {
                    this.OnClick(null);
                }
            };
        }
Exemple #3
0
        private void BtnOpenIcon_Click(object sender, EventArgs e)
        {
            var dlg = new IconDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                imgIco = ImageFormator.GetIconImage(dlg.FileName, dlg.IconIndex);
                imgPvw = PixelFormator.PixelIcon(imgIco, 1, 512);
                picPvw.Refresh();
                chkPixel.Enabled   = true;
                btnSaveIco.Enabled = true;
            }
        }
 public static Icon ChangeIcon(ref string iconPath, ref int iconIndex)
 {
     using (IconDialog dlg = new IconDialog {
         IconPath = iconPath, IconIndex = iconIndex
     })
     {
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             return(null);
         }
         iconPath  = dlg.IconPath;
         iconIndex = dlg.IconIndex;
     }
     return(ResourceIcon.GetIcon(iconPath, iconIndex));
 }
 private void SelectIcon()
 {
     using (IconDialog dlg = new IconDialog())
     {
         dlg.IconPath  = this.ItemIconPath;
         dlg.IconIndex = this.ItemIconIndex;
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         ItemIconPath  = dlg.IconPath;
         ItemIconIndex = dlg.IconIndex;
         picIcon.Image = ResourceIcon.GetIcon(ItemIconPath, ItemIconIndex).ToBitmap();
     }
 }
 private void SelectIcon()
 {
     using (IconDialog dlg = new IconDialog())
     {
         dlg.IconPath  = this.ItemIconPath;
         dlg.IconIndex = this.ItemIconIndex;
         if (dlg.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         using (Icon icon = ResourceIcon.GetIcon(dlg.IconPath, dlg.IconIndex))
         {
             Image image = icon?.ToBitmap();
             if (image == null)
             {
                 return;
             }
             picIcon.Image      = image;
             this.ItemIconPath  = dlg.IconPath;
             this.ItemIconIndex = dlg.IconIndex;
         }
     }
 }