2

Dose any one have an idea on how to make a shadow for a c# winforms control, i know that this question was around for a long time, and there is a lot of complicated answers out there, if we can create a function that you give it a control as parameter and draw a shadow for that control,

public static void DrawShadow(Control control, Graphics g, Color shadowColor, ShadowDepth depth) //ShadowDepth is an enum
{
    switch (depth)
    {
        case ShadowDepth.z_depth_1:
            DrawShadow(control, g, shadowColor, 1); // 1px shadow
            break;
        case ShadowDepth.z_depth_2:
            DrawShadow(control, g, shadowColor, 2); // 2px shadow
            break;
        case ShadowDepth.z_depth_3:
            DrawShadow(control, g, shadowColor, 3); // 3px shadow
            break;
        case ShadowDepth.z_depth_4:
            DrawShadow(control, g, shadowColor, 4); // 4px shadow
            break;
        case ShadowDepth.z_depth_5:
            DrawShadow(control, g, shadowColor, 5); // 5px shadow
            break;
    }
}

private static void DrawShadow(Control control, Graphics g, Color shadowColor, int depth)
{

}

so that we can get result like this: shadow depth

any ideas on how can we approach that

  • 1
    possible duplicate (https://stackoverflow.com/questions/2463519/drop-shadow-in-winforms-controls) – Ryan Wilson Jul 05 '18 at 17:23
  • i already saw this answer. and many other one. the problem with this one is that the shadow is drawn around the control inside a container . he doesn't have a shadow as his own property –  Jul 05 '18 at 19:19
  • This is a possible duplicate question. [Please refer to this](https://stackoverflow.com/questions/12924296/css3-like-box-shadow-implementation-algorithm). – Willy Kimura Feb 04 '19 at 07:01
  • @WillyKimura thanks for your answer, i saw that answer, it just hack to implement shadow, he used a panel to draw shadow around the controls, what i want is a way to make the shadow as a property of he control –  Feb 05 '19 at 10:22

0 Answers0