Exemplo n.º 1
0
        public DesktopIcon(float x, float y, string loc, string name, string iconPath, int iconIndex, DesktopManager sender)
        {
            specifiedIcon = true;
            icoPath       = iconPath;
            icoIndex      = iconIndex;

            this.loc   = loc;
            this.x     = x;
            this.y     = y;
            this.name  = name;
            this.lastx = x;
            this.lasty = y;
            target     = new PointF(x, y);

            Icon ic = Win32.GetIconFromDLL(iconPath, iconIndex);

            if (ic.Width != ICON_SIZE &&
                ic.Height != ICON_SIZE)
            {
                Bitmap bm      = ic.ToBitmap();
                Bitmap toPaste = (Bitmap)bm.Clone();
                bm.Dispose();
                bm = new Bitmap(toPaste, new Size(ICON_SIZE, ICON_SIZE));
                Graphics  gr = Graphics.FromImage(bm);
                Rectangle r  = new Rectangle(new Point(0, 0), new Size(ICON_SIZE, ICON_SIZE));
                Rectangle sr = new Rectangle(new Point(shadowOffset, shadowOffset), new Size(ICON_SIZE, ICON_SIZE));
                gr.Clear(Color.FromArgb(0, 0, 0, 0));

                using (Bitmap shadow = DropShadow.CreateShadow(toPaste, shadowSize, shadowOpacity))
                    gr.DrawImage(shadow, sr);

                gr.DrawImage(toPaste, r);
                ic.Dispose();

                image = bm;

                toPaste.Dispose();
                gr.Dispose();
            }
            else
            {
                this.image = ic.ToBitmap();
                ic.Dispose();
            }
            IEnumerable <DesktopIcon> enu = sender.icons.Where(el => el != null);

            if (enu.Count() == 0)
            {
                ID = 1;
            }
            else
            {
                ID = enu.OrderByDescending(el => el.ID).First().ID + 1;
            }
        }
Exemplo n.º 2
0
        public DesktopIcon(float x, float y, string loc, DesktopManager sender)
        {
            this.loc    = loc;
            this.x      = x;
            this.y      = y;
            this.lastx  = x;
            this.lasty  = y;
            this.target = new PointF(x, y);

            name = Path.GetFileNameWithoutExtension(loc);
            Icon ic = Icon.ExtractAssociatedIcon(loc);

            if (ic.Width != ICON_SIZE &&
                ic.Height != ICON_SIZE)
            {
                Bitmap bm      = ic.ToBitmap();
                Bitmap toPaste = (Bitmap)bm.Clone();
                bm.Dispose();
                bm = new Bitmap(toPaste, new Size(ICON_SIZE, ICON_SIZE));
                Graphics  gr = Graphics.FromImage(bm);
                Rectangle r  = new Rectangle(new Point(0, 0), new Size(ICON_SIZE, ICON_SIZE));
                gr.Clear(Color.FromArgb(0, 0, 0, 0));

                using (Bitmap shadow = DropShadow.CreateShadow(toPaste, shadowSize, shadowOpacity))
                    gr.DrawImage(shadow, r);

                gr.DrawImage(toPaste, r);
                ic.Dispose();

                image = bm;

                toPaste.Dispose();
                gr.Dispose();
            }
            else
            {
                this.image = ic.ToBitmap();
                ic.Dispose();
            }

            IEnumerable <DesktopIcon> enu = sender.icons.Where(el => el != null);

            if (enu.Count() == 0)
            {
                ID = 1;
            }
            else
            {
                ID = enu.OrderByDescending(el => el.ID).First().ID + 1;
            }
        }