//ZeroitDropshadow AddShadow = null; public void Shadow(Control control) { //System.Windows.Forms.Form form = control as System.Windows.Forms.Form; #region New Shadow Code ( Improved Performance ) if (!DesignMode) { //if (form.Location.IsEmpty) //{ // form.Location = new Point(this.Location.X - Shadows.BorderSize, this.Location.Y - Shadows.BorderSize); // //form.CenterToScreen(); //} //Check if we can use the aero shadow if ((Shadows.TypeOfShadow.Equals(ShadowType.AeroShadow) || Shadows.TypeOfShadow.Equals(ShadowType.Default)) && DwmNative.ExtendFrameIntoClientArea((System.Windows.Forms.Form)control, 0, 0, 0, 1)) { //We can! Tell windows to allow the rendering to happen on our borderless form DwmNative.AllowRenderInBorderless((System.Windows.Forms.Form)control); } //else if (Shadows.TypeOfShadow.Equals(ShadowType.Default) || Shadows.TypeOfShadow.Equals(ShadowType.FlatShadow)) //{ // //No aero for us! We must create the typical flat shadow. // new ShadowForm() // { // ShadowColor = Shadows.ShadowColor, // WindowOpacity = Shadows.WindowOpacity, // BorderSize = Shadows.BorderSize // }.Show(this); //} else if (Shadows.TypeOfShadow.Equals(ShadowType.SlowPerformer)) { Helper.ZeroitDropshadow AddShadow = new Helper.ZeroitDropshadow((System.Windows.Forms.Form)control); AddShadow.ShadowBlur = ShadowBlur; AddShadow.ShadowSpread = ShadowSpread; AddShadow.ShadowV = ShadowVertical; AddShadow.ShadowH = ShadowHorizontal; AddShadow.ShadowColor = ShadowColor; AddShadow.ActivateShadow(); //if (ActivateShadow) //{ // AddShadow.ActivateShadow(); //} } } #endregion }
/// <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(); } }