Beispiel #1
0
        /// <summary>
        /// 插件退出
        /// </summary>
        /// <param name="behaviorType"></param>
        /// <param name="pluginName"></param>
        public void ExitPage(MenuBehaviorType behaviorType)
        {
            IRegion region = RegionManager.Regions["WinfromWrapperRegion"];

            var ActiveViews = region.ActiveViews;

            switch (behaviorType)
            {
            case MenuBehaviorType.ExitCurrentPage:
                ActiveViews.ForEach(item =>
                {
                    region.Remove(item);
                });
                break;

            case MenuBehaviorType.ExitAllPage:
                region.RemoveAll();
                break;

            case MenuBehaviorType.ExitAllExcept:
                region.Views.ForEach(item =>
                {
                    if (!ActiveViews.Contains(item))
                    {
                        region.Remove(item);
                    }
                });
                break;
            }
        }
        public void ExitPage(MenuBehaviorType behaviorType, string pageName)
        {
            switch (behaviorType)
            {
            case MenuBehaviorType.ExitCurrentPage:
                var page = OpenPageCollection.FirstOrDefault(t => t.HeaderName.Equals(pageName));
                if (page.HeaderName != "系统首页")
                {
                    OpenPageCollection.Remove(page);
                }
                break;

            case MenuBehaviorType.ExitAllPage:
                var pageList = OpenPageCollection.Where(t => t.HeaderName != "系统首页").ToList();
                if (pageList != null)
                {
                    pageList.ForEach(t =>
                    {
                        OpenPageCollection.Remove(t);
                    });
                }
                break;

            case MenuBehaviorType.ExitAllExcept:
                var pageListExcept = OpenPageCollection.Where(t => t.HeaderName != pageName && t.HeaderName != "系统首页").ToList();
                if (pageListExcept != null)
                {
                    pageListExcept.ForEach(t =>
                    {
                        OpenPageCollection.Remove(t);
                    });
                }
                break;
            }
        }
        private void ExitCommand(MenuBehaviorType type, string pageName)
        {
            var obj = this.DataContext as MainViewModel;

            if (obj == null)
            {
                return;
            }
            switch (type)
            {
            case MenuBehaviorType.ExitCurrentPage:
                obj.ExitPage(MenuBehaviorType.ExitCurrentPage, pageName);
                break;

            case MenuBehaviorType.ExitAllPage:
                obj.ExitPage(MenuBehaviorType.ExitAllPage, pageName);
                break;

            case MenuBehaviorType.ExitAllExcept:
                obj.ExitPage(MenuBehaviorType.ExitAllExcept, pageName);
                break;
            }
        }
Beispiel #4
0
        private void ExitCommand(MenuBehaviorType type)
        {
            var obj = base.DataContext as MainWindowViewModel;

            if (obj == null)
            {
                return;
            }
            switch (type)
            {
            case MenuBehaviorType.ExitCurrentPage:
                obj.ExitPage(MenuBehaviorType.ExitCurrentPage);
                break;

            case MenuBehaviorType.ExitAllPage:
                obj.ExitPage(MenuBehaviorType.ExitAllPage);
                break;

            case MenuBehaviorType.ExitAllExcept:
                obj.ExitPage(MenuBehaviorType.ExitAllExcept);
                break;
            }
        }