예제 #1
0
        public static Task ShowDrawer(object view, string?title = null, DrawerDirection direction = DrawerDirection.Right)
        {
            if (!(view is UserControl control))
            {
                throw new Exception("Invalid view");
            }

            if (ShowingDrawer == null)
            {
                return(Task.CompletedTask);
            }

            return(ShowingDrawer.Invoke(title, control, direction));
        }
예제 #2
0
파일: ViewService.cs 프로젝트: achaacha/CM3
        public Task ShowDrawer <T>(string title, DrawerDirection direction)
        {
            UserControl view = this.CreateView <T>();

            return(this.ShowingDrawer?.Invoke(title, view, direction));
        }
예제 #3
0
        private async Task OnShowDrawer(string?title, UserControl view, DrawerDirection direction)
        {
            await Application.Current.Dispatcher.InvokeAsync(async() =>
            {
                // Close all current drawers.
                this.DrawerHost.IsLeftDrawerOpen   = false;
                this.DrawerHost.IsTopDrawerOpen    = false;
                this.DrawerHost.IsRightDrawerOpen  = false;
                this.DrawerHost.IsBottomDrawerOpen = false;

                // If this is a drawer view, bind to its events.
                if (view is IDrawer drawer)
                {
                    drawer.Close += () => this.DrawerHost.IsLeftDrawerOpen = false;
                    drawer.Close += () => this.DrawerHost.IsTopDrawerOpen = false;
                    drawer.Close += () => this.DrawerHost.IsRightDrawerOpen = false;
                    drawer.Close += () => this.DrawerHost.IsBottomDrawerOpen = false;
                }

                switch (direction)
                {
                case DrawerDirection.Left:
                    {
                        this.DrawerLeft.Content          = view;
                        this.DrawerHost.IsLeftDrawerOpen = true;
                        this.LeftTitle.Content           = title;
                        break;
                    }

                case DrawerDirection.Top:
                    {
                        this.DrawerTop.Content          = view;
                        this.DrawerHost.IsTopDrawerOpen = true;
                        break;
                    }

                case DrawerDirection.Right:
                    {
                        this.DrawerRight.Content          = view;
                        this.DrawerHost.IsRightDrawerOpen = true;
                        this.RightTitle.Content           = title;
                        break;
                    }

                case DrawerDirection.Bottom:
                    {
                        this.DrawerBottom.Content          = view;
                        this.DrawerHost.IsBottomDrawerOpen = true;
                        break;
                    }
                }

                // Wait while any of the drawer areas remain open
                while (this.DrawerHost.IsLeftDrawerOpen ||
                       this.DrawerHost.IsRightDrawerOpen ||
                       this.DrawerHost.IsBottomDrawerOpen ||
                       this.DrawerHost.IsTopDrawerOpen)
                {
                    await Task.Delay(250);
                }

                GC.Collect();
            });
        }
예제 #4
0
 public ShowDrawerAnimatedTransitioning(DrawerDirection direction, int maxX)
 {
     Direction = direction;
     MaxX      = maxX;
 }
 public ShowDrawerTransitionDelegate(DrawerDirection direction, int maxX)
 {
     Direction = direction;
     MaxX      = maxX;
 }