123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using LYFZ.WinAPI;
- namespace LYFZ.ComponentLibrary
- {
-
-
-
- public partial class BaseShadowForm : BaseMotherForm
- {
- ShadowLayer layer = null;
- bool _isShadow = true;
-
-
-
- [DescriptionAttribute("是否开启四边阴影"), CategoryAttribute("自定义窗体属性"), DefaultValueAttribute(typeof(bool), "true")]
- public bool IsShadow
- {
- get { return _isShadow; }
- set { _isShadow = value; }
- }
- Rectangle _layerRel = new Rectangle(5,5,10,12);
-
-
-
- [DescriptionAttribute("在开启阴影效果时设置阴影位置和大小"), CategoryAttribute("自定义窗体属性")]
- public Rectangle LayerRel
- {
- get { return _layerRel; }
- set { _layerRel = value; }
- }
- public BaseShadowForm()
- {
- InitializeComponent();
- }
-
- protected override void OnVisibleChanged(EventArgs e)
- {
- if (Visible)
- {
-
- if (!DesignMode)
- {
-
-
- }
-
- if (!DesignMode && (layer == null ||layer.IsDisposed))
- {
- if (IsShadow)
- {
- layer = new ShadowLayer(this);
- layer.Difference_X = LayerRel.X;
- layer.Difference_Y = LayerRel.Y;
- layer.Difference_Width = LayerRel.Width;
- layer.Difference_Height = LayerRel.Height;
- if (this.IsReion && this.Width == 780 && this.Height == 580)
- {
- layer.Difference_X = 19;
- layer.Difference_Y = 27;
- layer.Difference_Width = 38;
- layer.Difference_Height = 46;
- layer.SetInit();
- }
- try
- {
- layer.Show(this);
- }
- catch { }
- }
- }
- base.OnVisibleChanged(e);
- }
- else
- {
- base.OnVisibleChanged(e);
-
- }
- }
-
- protected override void OnClosing(CancelEventArgs e)
- {
- base.OnClosing(e);
- try
- {
-
- if (layer != null && !layer.IsDisposed)
- {
- layer.Close();
- layer.Dispose();
- layer = null;
- }
- }
- catch { }
-
-
- }
- }
- }
|