//ZeroitDropshadow AddShadow = null; public void Shadow(Control control) { ZeroitDropshadow AddShadow = new ZeroitDropshadow((System.Windows.Forms.Form)control); AddShadow.ShadowBlur = ShadowBlur; AddShadow.ShadowSpread = ShadowSpread; AddShadow.ShadowV = ShadowVertical; AddShadow.ShadowH = ShadowHorizontal; AddShadow.ShadowColor = ShadowColor; if (ActivateShadow) { AddShadow.ActivateShadow(); } }
/// <summary> /// Handles the Load event of the ResizableForm control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void ResizableForm_Load(object sender, EventArgs e) { switch (ShadowKind) { case ShadowNature.Custom: #region Old Show Code ( Has Performance Issues ) if (!DesignMode) { ZeroitDropshadow AddShadow = new ZeroitDropshadow(this); #region New Idea AddShadow.DrawShadow = true; AddShadow.ShadowBlur = CustomShadow.ShadowBlur; AddShadow.ShadowSpread = CustomShadow.ShadowSpread; AddShadow.ShadowV = CustomShadow.ShadowV; AddShadow.ShadowH = CustomShadow.ShadowH; AddShadow.ShadowColor = Color.FromArgb(CustomShadow.ShadowOpacity, CustomShadow.ShadowColor); AddShadow.ShadowOpacity = CustomShadow.ShadowOpacity; AddShadow.ActivateShadow(); #endregion } #endregion break; case ShadowNature.Native: #region New Shadow Code ( Improved Performance ) if (!DesignMode) { if (Location.IsEmpty) { CenterToScreen(); } //Check if we can use the aero shadow if ((NativeShadow.ShadowType.Equals(ShadowType.AeroShadow) || NativeShadow.ShadowType.Equals(ShadowType.Default)) && DwmNative.ExtendFrameIntoClientArea(this, 0, 0, 0, 1)) { //We can! Tell windows to allow the rendering to happen on our borderless form DwmNative.AllowRenderInBorderless(this); } else if (NativeShadow.ShadowType.Equals(ShadowType.Default) || NativeShadow.ShadowType.Equals(ShadowType.FlatShadow)) { //No aero for us! We must create the typical flat shadow. new ShadowForm() { ShadowColor = NativeShadow.ShadowColor, WindowOpacity = NativeShadow.WindowOpacity, BorderSize = NativeShadow.BorderSize }.Show(this); } } #endregion break; case ShadowNature.None: break; default: throw new ArgumentOutOfRangeException(); } }