Exemplo n.º 1
0
 // 隠しているとアイコンを自動開放するらしい タイル化ごとに再取得
 public void ResetIcon()
 {
     foreach (var icon in IconList)
     {
         icon.Dispose( );
     }
     IconList.Clear( );
     foreach (var c in ClientList)
     {
         Icon item = Win32dll.GetAppIcon(c.Hwnd);
         IconList.Add(item);
     }
 }
Exemplo n.º 2
0
        private bool LoadIcons()
        {
            IconList.Clear();
            SmallIcons.Images.Clear();
            var IconError = false;

            IconIndexLabel.Visible   = true;
            IconIndexTextBox.Visible = true;
            if (File.Exists(IconPathTextBox.Text))
            {
                var mIcon     = new System.Drawing.IconLib.MultiIcon();
                var IconIndex = 0;
                try
                {
                    mIcon.Load(IconPathTextBox.Text);
                    IconIndexTextBox.ReadOnly = true;
                }
                catch (Exception)
                {
                    IconError        = true;
                    _noValidate      = true;
                    OKButton.Enabled = true;
                    MessageBox.Show("There was an error loading icons from:" + Environment.NewLine + IconPathTextBox.Text + Environment.NewLine + "Icons may still be usable, but you can not select one using the icon picker.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    IconIndexTextBox.Text     = "0";
                    IconIndexTextBox.ReadOnly = false;
                }

                if (!IconError)
                {
                    _noValidate = false;
                    foreach (var sIcon in mIcon)
                    {
                        var IconKey  = IconIndex;
                        var IconItem = new ListViewItem(IconKey.ToString());
                        var fiImage  = sIcon[0];
                        foreach (var iImage in sIcon)
                        {
                            if (iImage.Icon.Width == 32)
                            {
                                switch (iImage.ColorsInPalette)
                                {
                                case 0:
                                {
                                    fiImage = iImage;
                                    break;
                                }

                                default:
                                {
                                    if (iImage.ColorsInPalette > fiImage.ColorsInPalette)
                                    {
                                        fiImage = iImage;
                                    }
                                    break;
                                }
                                }

                                if (iImage.ColorsInPalette == 0)
                                {
                                    fiImage = iImage;
                                }
                            }
                        }

                        var TheBitmap = fiImage.Icon.ToBitmap();
                        SmallIcons.Images.Add(IconKey.ToString(), TheBitmap);
                        IconItem.ImageKey = IconKey.ToString();
                        IconList.Items.Add(IconItem);
                        IconIndex++;
                    }

                    if (!_noValidate)
                    {
                        OKButton.Enabled = false;
                    }
                }
            }

            return(IconError);
        }