예제 #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}";
             }
         }
     };
 }
예제 #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);
                }
            };
        }
 public ChangeIconMenuItem(ITsiIconItem item) : base(AppString.Menu.ChangeIcon)
 {
     this.Click += (sender, e) =>
     {
         string iconPath  = item.IconPath;
         int    iconIndex = item.IconIndex;
         using (Icon icon = ChangeIcon(ref iconPath, ref iconIndex))
         {
             if (icon == null)
             {
                 return;
             }
             item.IconPath     = iconPath;
             item.IconIndex    = iconIndex;
             item.IconLocation = $"{iconPath},{iconIndex}";
             item.Image        = icon.ToBitmap();
         }
     };
 }