private async void projectBtn_Click(object sender, RoutedEventArgs e) { rootPage = ((App)App.Current)._MainWindowHandle; if (rootPage.ProjectionViewPageControl == null) { double CropPanelHeight = clippingPanel.Height; double CropPanelWidth = clippingPanel.Width; double offsetX = clippingGrid.ColumnDefinitions[0].Width.Value - paddingX; double offsetY = clippingGrid.RowDefinitions[0].Height.Value - paddingY; double ImageWidth = image.ActualWidth; // First, create a new, blank view var thisDispatcher = Window.Current.Dispatcher; await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // ViewLifetimeControl is a wrapper to make sure the view is closed only // when the app is done with it rootPage.ProjectionViewPageControl = ViewLifetimeControl.CreateForCurrentView(); // Assemble some data necessary for the new page var initData = new ProjectionViewPageInitializationData(); initData.MainDispatcher = thisDispatcher; initData.ProjectionViewPageControl = rootPage.ProjectionViewPageControl; initData.MainViewId = thisViewId; initData.page = typeof(PictureEditorProject); PageNavigateParam param = new PageNavigateParam(); param.MainViewId = thisViewId; switch (stage) { case GLOABOALSTAGE.EDITPAGE_CROP: param.stage = GLOABOALSTAGE.EDITPAGE_CROP; CropStateParam cropParam = new CropStateParam(); cropParam.PicInfo = info; cropParam.CropPanelHeight = CropPanelHeight; cropParam.CropPanelWidth = CropPanelWidth; cropParam.offsetX = offsetX; cropParam.offsetY = offsetY; cropParam.ImageWidth = ImageWidth; param.stageParam = cropParam; break; case GLOABOALSTAGE.EDITPAGE_ROTATE: param.stage = GLOABOALSTAGE.EDITPAGE_ROTATE; RotateStateParam rotateParam = new RotateStateParam(); rotateParam.PicInfo = info; rotateParam.UserRotation = m_userRotation; param.stageParam = rotateParam; break; case GLOABOALSTAGE.EDITPAGE_INK: param.stage = GLOABOALSTAGE.EDITPAGE_INK; InkStateParam inkParam = new InkStateParam(); inkParam.PicInfo = info; param.stageParam = inkParam; //foreach (var item in strokes) //{ // ((App)App.Current).Strokes.Add(item.Clone()); //} //((App)App.Current).SyncStrokeEx(strokeMapping, false); inkTimer = new DispatcherTimer(); inkTimer.Tick += InkTimer_Tick; inkTimer.Interval = new TimeSpan(0, 0, 2); inkTimer.Start(); break; case GLOABOALSTAGE.EDITPAGE_TEXT: param.stage = GLOABOALSTAGE.EDITPAGE_TEXT; TextStateParam textParam = new TextStateParam(); textParam.PicInfo = info; param.stageParam = textParam; break; } initData.naviParam = param; // Display the page in the view. Note that the view will not become visible // until "StartProjectingAsync" is called var rootFrame = new Frame(); rootFrame.Navigate(typeof(HomeProject), initData); Window.Current.Content = rootFrame; Window.Current.Activate(); }); try { // Start/StopViewInUse are used to signal that the app is interacting with the // view, so it shouldn't be closed yet, even if the user loses access to it rootPage.ProjectionViewPageControl.StartViewInUse(); // Show the view on a second display (if available) or on the primary display Rect pickerLocation = new Rect(470.0, 0.0, 200.0, 300.0); bool projected = await ProjectionManager.RequestStartProjectingAsync(rootPage.ProjectionViewPageControl.Id, thisViewId, pickerLocation, Windows.UI.Popups.Placement.Above); if (projected) { ((App)App.Current).projectedFlag = true; rootPage.ProjectionViewPageControl.StopViewInUse(); if (stage != GLOABOALSTAGE.EDITPAGE_INK) { projectControlPanel.Visibility = Visibility.Visible; editorGrid.Visibility = Visibility.Collapsed; if (monitorTimer == null) { monitorTimer = new DispatcherTimer(); monitorTimer.Interval = new TimeSpan(0, 0, 2); monitorTimer.Tick += MonitorTimer_Tick; monitorTimer.Start(); } else { monitorTimer.Start(); } } } } catch (InvalidOperationException) { } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter != null) { var param = e.Parameter; if (param.ToString().Equals((typeof(PictureListInfo)).ToString())) { PictureListInfo info = param as PictureListInfo; image.Source = info.picture; filePath = info.picturePath; this.info = info; } else if (param.ToString().Equals((typeof(PageNavigateParam)).ToString())) { isProjected = true; PageNavigateParam projectParam = param as PageNavigateParam; mainViewId = projectParam.MainViewId; //thisViewControl = projectParam.ProjectionViewPageControl; //mainDispatcher = projectParam.MainDispatcher; //thisViewControl.Released += ThisViewControl_Released; GLOABOALSTAGE stageProjected = projectParam.stage; if(stageProjected != GLOABOALSTAGE.EDITPAGE_INK) { monitorTimer = new DispatcherTimer(); monitorTimer.Interval = new TimeSpan(0, 0, 2); monitorTimer.Tick += MonitorTimer_Tick; monitorTimer.Start(); } switch (stageProjected) { case GLOABOALSTAGE.EDITPAGE_CROP: cropParam = projectParam.stageParam as CropStateParam; this.info = cropParam.PicInfo; filePath = info.picturePath; break; case GLOABOALSTAGE.EDITPAGE_ROTATE: RotateStateParam rotateParam = projectParam.stageParam as RotateStateParam; this.info = rotateParam.PicInfo; filePath = info.picturePath; stage = GLOABOALSTAGE.EDITPAGE_ROTATE; m_userRotation = rotateParam.UserRotation; break; case GLOABOALSTAGE.EDITPAGE_INK: InkStateParam inkParam = projectParam.stageParam as InkStateParam; this.info = inkParam.PicInfo; filePath = info.picturePath; stage = GLOABOALSTAGE.EDITPAGE_INK; //((App)App.Current).SyncStrokeEx(strokeMapping, true); ink.Visibility = Visibility.Visible; break; case GLOABOALSTAGE.EDITPAGE_TEXT: TextStateParam textParam = projectParam.stageParam as TextStateParam; this.info = textParam.PicInfo; filePath = info.picturePath; stage = GLOABOALSTAGE.EDITPAGE_TEXT; break; } } } }