/*
         * 返回上一页
         *
         * 2.淡出完成,开始淡入
         */
        private void fadeOut_Completed(DControl ctl, Boolean isBack, int pageSwitchType)
        {
            PageTemplate pt = new PageTemplate(pageTemplate1.mainFrame, ctl.linkToPageId, true, isBack, pageSwitchType, pageTemplate1.screen, pageTemplate1.mqServer);

            pageTemplate1.mainFrame.NavigationService.Navigate(pt);
            FrameUtil.RemoveBackEntry(pageTemplate1.mainFrame);
        }
        /*
         * 进入新页面
         *
         * 2.淡出完成,开始淡入
         */
        private void fadeOut_Completed(DControl ctl, CFrameTag cFrameTag)
        {
            PageTemplate pageTemplate = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, true, ctl.isTransparentDialog, pageTemplate1.screen, pageTemplate1.mqServer);

            cFrameTag.currCFrame.NavigationService.Navigate(pageTemplate);
            FrameUtil.RemoveBackEntry(cFrameTag.currCFrame);
        }
 public PageTemplate(Frame mainFrame, Int32 pageId, MqServer mqServer)
 {
     InitializeComponent();
     this.mainFrame = mainFrame;
     App.localStorage.currPageId = pageId;
     this.mqServer = mqServer;
     FrameUtil.RemoveBackEntry(mainFrame);
     initControl(pageId);
     Unloaded += PageTemplate_UnLoaded;
 }
 /*
  * 释放内存
  */
 private void Window_Unloaded(object sender, RoutedEventArgs e)
 {
     Console.WriteLine("PreviewWindow:Window_Unloaded");
     FrameUtil.RemoveBackEntry(pageTemplate.mainFrame);
     pageTemplate = null;
     mainFrame    = null;
     Loaded      -= Window_Loaded;
     Unloaded    -= Window_Unloaded;
     this.mqServer.sendMsgEvent -= Client_ReceiveMsgEvent;
     clearMusic();
     mainGrid.Children.Clear();
     GC.Collect();
 }
 public PageTemplate(Frame mainFrame, Int32 pageId, Boolean isTransparentDialog, MqServer mqServer)
 {
     InitializeComponent();
     this.mainFrame = mainFrame;
     FrameUtil.RemoveBackEntry(mainFrame);
     Background = Brushes.Transparent;
     if (!isTransparentDialog)
     {
         showDefaultBackgroundInCFrameDialog = true;
     }
     this.mqServer = mqServer;
     initControl(pageId);
     Unloaded += PageTemplate_UnLoaded;
 }
示例#6
0
        /*
         * 单击页面树,显示当前页面内容
         */
        private void StorageVideo_TreeView_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (e.Source.GetType().Name != "TreeViewItem")
            {
                e.Handled = true;
                return;
            }

            try
            {
                TreeViewItem treeViewItem = (TreeViewItem)e.Source;
                Object       tag          = treeViewItem.Tag;
                if (tag != null)
                {
                    Int32         folderId      = Int32.Parse(tag.ToString());
                    VideoItemPage videoItemPage = new VideoItemPage(folderId);
                    mainFrame.Navigate(videoItemPage);
                    FrameUtil.RemoveBackEntry(mainFrame);
                }
                else
                {
                    MessageBox.Show("没有tag:" + treeViewItem.Header.ToString());
                }
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("页面不能为空");
            }
            catch (ArgumentException)
            {
                MessageBox.Show("页面地址异常");
            }
            catch (UriFormatException)
            {
                MessageBox.Show("页面地址格式化异常");
            }
            catch (Exception e4)
            {
                MessageBox.Show("找不到此页面" + e4.Message.ToString() + e4.StackTrace);
            }
        }
        /*
         *  标准进入页面
         */
        public PageTemplate(Frame mainFrame, Int32 pageId, Boolean isMoveIn, System.Windows.Forms.Screen screen, MqServer mqServer)
        {
            InitializeComponent();
            this.mainFrame = mainFrame;
            this.screen    = screen;
            this.mqServer  = mqServer;
            FrameUtil.RemoveBackEntry(mainFrame);
            CFrameTag cFrameTag = (CFrameTag)mainFrame.Tag;

            if (cFrameTag.parentFrame != null)
            {
                Background = Brushes.Transparent;
                showDefaultBackgroundInCFrameDialog = true;
            }
            initControl(pageId);
            Unloaded += PageTemplate_UnLoaded;

            if (isMoveIn)
            {
                Loaded += moveIn;
            }
        }
        /*
         * 1.3 跳转到指定的页面,并伴随页面切换效果
         */
        private void linkToPageWithPageSwitchType(DControl ctl)
        {
            //1.如果显示位置不是 最顶层,则直接显示(无页面切换效果)
            CFrameTag cFrameTag = getCFrameTag(ctl.showInWhichCFrame);
            //2.如果是当前页面
            DPage linkToDPage = dPageBll.get(ctl.linkToPageId);

            if (linkToDPage == null)
            {
                return;
            }
            if (linkToDPage.pageSwitchType <= 0)
            {
                linkToDPage.pageSwitchType = 1;
            }

            //滚动条回到开始
            if (cFrameTag.parentFrame != null)
            {
                object parent = cFrameTag.currCFrame.Parent;
                if (parent is ScrollViewer)
                {
                    ScrollViewer sv = (ScrollViewer)parent;
                    sv.ScrollToVerticalOffset(0);
                    sv.ScrollToHorizontalOffset(0);
                }
            }

            //1.直接进入
            if (linkToDPage.pageSwitchType == 1)
            {
                //  cFrameTag.currCFrame.Background = Brushes.White;
                PageTemplate page1 = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, false, pageTemplate1.screen, pageTemplate1.mqServer);
                cFrameTag.currCFrame.NavigationService.Navigate(page1);
                return;
            }
            //2.淡出淡入
            if (linkToDPage.pageSwitchType == 2)
            {
                PageTemplate pt = (PageTemplate)cFrameTag.currCFrame.Content;
                cFrameTag.currCFrame.Background = Brushes.White;
                pt.RenderTransformOrigin        = new System.Windows.Point(0.5, 0.5);
                TransformGroup group = new TransformGroup();
                pt.RenderTransform = group;

                DoubleAnimation da = new DoubleAnimation(1.0, 0, new Duration(TimeSpan.FromMilliseconds(400)));
                da.BeginTime = TimeSpan.FromMilliseconds(0);
                IEasingFunction easingFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseIn
                };
                da.EasingFunction = easingFunction;
                da.Completed     += (sender1, e1) => fadeOut_Completed(ctl, cFrameTag);
                pt.BeginAnimation(UIElement.OpacityProperty, da);

                return;
            }

            //3.右侧移入
            if (linkToDPage.pageSwitchType == 3)
            {
                PageTemplate pt        = (PageTemplate)cFrameTag.currCFrame.Content;
                string       shotImage = ShotUtil.shot(pt);
                cFrameTag.currCFrame.Background = new ImageBrush
                {
                    ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage)
                };
                PageTemplate page = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, true, pageTemplate1.screen, pageTemplate1.mqServer);
                cFrameTag.currCFrame.NavigationService.Navigate(page);
                FrameUtil.RemoveBackEntry(cFrameTag.currCFrame);
                return;
            }

            //4.右侧拉伸
            if (linkToDPage.pageSwitchType == 4)
            {
                PageTemplate pt        = (PageTemplate)cFrameTag.currCFrame.Content;
                string       shotImage = ShotUtil.shot(pt);
                cFrameTag.currCFrame.Background = new ImageBrush
                {
                    ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage)
                };
                PageTemplate page = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, true, pageTemplate1.screen, pageTemplate1.mqServer);
                cFrameTag.currCFrame.NavigationService.Navigate(page);
                FrameUtil.RemoveBackEntry(cFrameTag.currCFrame);
                return;
            }

            //5.中心放大
            if (linkToDPage.pageSwitchType == 5)
            {
                PageTemplate pt        = (PageTemplate)cFrameTag.currCFrame.Content;
                string       shotImage = ShotUtil.shot(pt);
                cFrameTag.currCFrame.Background = new ImageBrush
                {
                    ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + shotImage)
                };
                PageTemplate page = new PageTemplate(cFrameTag.currCFrame, ctl.linkToPageId, true, pageTemplate1.screen, pageTemplate1.mqServer);
                cFrameTag.currCFrame.NavigationService.Navigate(page);
                FrameUtil.RemoveBackEntry(cFrameTag.currCFrame);
                return;
            }
        }