Ejemplo n.º 1
0
        public Bitmap GetIcon(string itemName)
        {
            var container = new IconContatiner(Width, Height);
            var resource  = Properties.Resources.ResourceManager.GetObject(itemName) as Bitmap;

            if (resource == null)
            {
                Logger.Error("Cant Find Resource for: {0}", itemName);
                return(CreateErrorIcon(container));
            }

            container.DrawImage(Type, resource, new IconContatiner.Padding(Padding, Padding * 2));
            if (BorderWidth > 0)
            {
                if (Type == IconType.Circle)
                {
                    container.Graphics.DrawEllipse(new Pen(BorderColor, BorderWidth), Padding, Padding,
                                                   Width - Padding * 2, Height - Padding * 2);
                }
                else
                {
                    container.Graphics.DrawRectangle(new Pen(BorderColor, BorderWidth), Padding, Padding,
                                                     Width - Padding * 2, Height - Padding * 2);
                }
            }

            return(container.Icon);
        }
Ejemplo n.º 2
0
 private Bitmap CreateErrorIcon(IconContatiner container)
 {
     if (Type == IconType.Circle)
     {
         var bitmap = new Bitmap(128, 128);
         var g      = Graphics.FromImage(bitmap);
         g.DrawLine(Pens.Red, Padding, Padding, 128 - Padding, 128 - Padding);
         g.DrawLine(Pens.Red, Padding, 128, 128 - Padding, Padding);
         g.Save();
         container.DrawImage(IconType.Circle, bitmap, new IconContatiner.Padding(Padding, Padding * 2), false);
         container.Graphics.DrawEllipse(new Pen(BorderColor, BorderWidth), Padding, Padding, Width - Padding * 2,
                                        Height - Padding * 2);
     }
     else
     {
         container.Graphics.DrawLine(Pens.Red, new Point(0, 0), new Point(Width, Height));
         container.Graphics.DrawLine(Pens.Red, new Point(0, Height), new Point(Width, 0));
         container.Graphics.DrawRectangle(new Pen(BorderColor, BorderWidth), Padding, Padding, Width - Padding * 2,
                                          Height - Padding * 2);
     }
     container.Save();
     return(container.Icon);
 }
Ejemplo n.º 3
0
 private Bitmap CreateErrorIcon(IconContatiner container)
 {
     if (Type == IconType.Circle)
     {
         var bitmap = new Bitmap(128, 128);
         var g = Graphics.FromImage(bitmap);
         g.DrawLine(Pens.Red, Padding, Padding, 128 - Padding, 128 - Padding);
         g.DrawLine(Pens.Red, Padding, 128, 128 - Padding, Padding);
         g.Save();
         container.DrawImage(IconType.Circle, bitmap, new IconContatiner.Padding(Padding, Padding * 2), false);
         container.Graphics.DrawEllipse(new Pen(BorderColor, BorderWidth), Padding, Padding, Width - Padding * 2,
             Height - Padding * 2);
     }
     else
     {
         container.Graphics.DrawLine(Pens.Red, new Point(0, 0), new Point(Width, Height));
         container.Graphics.DrawLine(Pens.Red, new Point(0, Height), new Point(Width, 0));
         container.Graphics.DrawRectangle(new Pen(BorderColor, BorderWidth), Padding, Padding, Width - Padding * 2,
             Height - Padding * 2);
     }
     container.Save();
     return container.Icon;
 }
Ejemplo n.º 4
0
        public Bitmap GetIcon(string itemName)
        {
            var container = new IconContatiner(Width, Height);
            var resource = Properties.Resources.ResourceManager.GetObject(itemName) as Bitmap;

            if (resource == null)
            {
                Logger.Error("Cant Find Resource for: {0}", itemName);
                return CreateErrorIcon(container);
            }

            container.DrawImage(Type, resource, new IconContatiner.Padding(Padding, Padding*2));
            if (BorderWidth > 0)
                if (Type == IconType.Circle)
                    container.Graphics.DrawEllipse(new Pen(BorderColor, BorderWidth), Padding, Padding,
                        Width - Padding*2, Height - Padding*2);
                else
                    container.Graphics.DrawRectangle(new Pen(BorderColor, BorderWidth), Padding, Padding,
                        Width - Padding*2, Height - Padding*2);

            return container.Icon;
        }