Example #1
0
        private static void ModeChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            DrawerMode mode  = (DrawerMode)e.NewValue;
            DrawerView _self = d as DrawerView;

            _self.OnModeChanged(mode);
        }
Example #2
0
        private void OnModeChanged(DrawerMode mode, bool IsAnimation = false)
        {
            int time = 200;

            if (_mask == null || _translate == null)
            {
                return;
            }

            switch (mode)
            {
            case DrawerMode.Bottom:
                _mask.Height = MASK_INSTANCE;
                _mask.Width  = _container.Width;
                _mask.HorizontalAlignment    = HorizontalAlignment.Stretch;
                _mask.VerticalAlignment      = VerticalAlignment.Bottom;
                _container.VerticalAlignment = VerticalAlignment.Bottom;
                DoTranslate(0, _container.Height, time, IsAnimation);
                break;

            case DrawerMode.Left:
                _mask.Width                    = MASK_INSTANCE;
                _mask.Height                   = _container.Height;
                _mask.VerticalAlignment        = VerticalAlignment.Stretch;
                _mask.HorizontalAlignment      = HorizontalAlignment.Left;
                _container.HorizontalAlignment = HorizontalAlignment.Left;
                DoTranslate(-_container.Width, 0, time, IsAnimation);
                break;

            case DrawerMode.Right:
                _mask.Width                    = MASK_INSTANCE;
                _mask.Height                   = _container.Height;
                _mask.VerticalAlignment        = VerticalAlignment.Stretch;
                _mask.HorizontalAlignment      = HorizontalAlignment.Right;
                _container.HorizontalAlignment = HorizontalAlignment.Right;
                DoTranslate(_container.Width, 0, time, IsAnimation);
                break;

            case DrawerMode.Top:
                _mask.Height = MASK_INSTANCE;
                _mask.Width  = _cp.Width;
                _mask.HorizontalAlignment    = HorizontalAlignment.Stretch;
                _mask.VerticalAlignment      = VerticalAlignment.Top;
                _container.VerticalAlignment = VerticalAlignment.Top;
                DoTranslate(0, -_container.Height, time, IsAnimation);
                break;

            case DrawerMode.Full:
                _mask.Height = _cp.Height;
                _mask.Width  = _cp.Width;
                _mask.HorizontalAlignment = HorizontalAlignment.Stretch;
                _mask.VerticalAlignment   = VerticalAlignment.Stretch;
                DoTranslate(0, 0, time, IsAnimation);
                break;
            }
        }