Ejemplo n.º 1
0
        private void UpdateShadow(MetroFormShadowType newShadowType)
        {
            if (DesignMode || !IsHandleCreated || IsDisposed)
            {
                return;
            }

            if (newShadowType == MetroFormShadowType.Default && !TryGetThemeProperty("ShadowType", out newShadowType))
            {
                newShadowType = MetroDefaults.FormShadowType;
            }

            if (_currentShadowType == newShadowType)
            {
                return;
            }

            if (_currentShadowType == MetroFormShadowType.SystemDropShadow)
            {
                SetCsDropShadow(false);
            }
            else if (_shadowForm != null)
            {
                if (!_shadowForm.IsDisposed)
                {
                    _shadowForm.Dispose();
                }
                _shadowForm = null;
            }

            switch (newShadowType)
            {
            case MetroFormShadowType.Flat:
                _shadowForm = new MetroFlatDropShadow(this);
                break;

            case MetroFormShadowType.DropShadow:
                _shadowForm = new MetroRealisticDropShadow(this);
                break;

            case MetroFormShadowType.SystemAeroShadow:
                _shadowForm = new MetroAeroDropShadow(this);
                break;

            case MetroFormShadowType.SystemDropShadow:
                SetCsDropShadow(true);
                break;
            }

            _currentShadowType = newShadowType;
        }
Ejemplo n.º 2
0
        private void UpdateShadow(MetroFormShadowType newShadowType)
        {
            if (DesignMode || !IsHandleCreated || IsDisposed) return;

            if (newShadowType == MetroFormShadowType.Default && !TryGetThemeProperty("ShadowType", out newShadowType))
                newShadowType = MetroDefaults.FormShadowType;

            if (_currentShadowType == newShadowType) return;

            if (_currentShadowType == MetroFormShadowType.SystemDropShadow)
            {
                SetCsDropShadow(false);
            }
            else if (_shadowForm != null)
            {
                if(!_shadowForm.IsDisposed) _shadowForm.Dispose();
                _shadowForm = null;
            }

            switch (newShadowType)
            {
                case MetroFormShadowType.Flat:
                    _shadowForm = new MetroFlatDropShadow(this);
                    break;

                case MetroFormShadowType.DropShadow:
                    _shadowForm = new MetroRealisticDropShadow(this);
                    break;

                case MetroFormShadowType.SystemAeroShadow:
                    _shadowForm = new MetroAeroDropShadow(this);
                    break;

                case MetroFormShadowType.SystemDropShadow:
                    SetCsDropShadow(true);
                    break;
            }

            _currentShadowType = newShadowType;
        }