private bool OnToggleButtonClicked(object sender, global::System.EventArgs args) { mContent.Remove(mCurrentEffect); if (mCurrentEffect == mCubeWaveEffect) { mCurrentEffect = mCubeCrossEffect; mTitle.Text = APPLICATION_TITLE_CROSS; } else if (mCurrentEffect == mCubeCrossEffect) { mCurrentEffect = mCubeFoldEffect; mTitle.Text = APPLICATION_TITLE_FOLD; } else { mCurrentEffect = mCubeWaveEffect; mTitle.Text = APPLICATION_TITLE_WAVE; } mContent.Add(mCurrentEffect); // Set the current image to cube transition effect // only need to set at beginning or change from another effect mCurrentEffect.SetCurrentTexture(mCurrentTexture); return(true); }
private void OnFoldClicked(object sender, global::System.EventArgs args) { mContent.Remove(mCurrentEffect); mCurrentEffect = mCubeFoldEffect; mTitle.Text = APPLICATION_TITLE_FOLD; mContent.Add(mCurrentEffect); // Set the current image to cube transition effect // only need to set at beginning or change from another effect mCurrentEffect.SetCurrentTexture(mCurrentTexture); }
public void Activate() { // tool bar tool_bar = new View(); tool_bar.BackgroundColor = Color.White; tool_bar.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, 100); tool_bar.PositionUsesPivotPoint = true; tool_bar.ParentOrigin = ParentOrigin.TopLeft; tool_bar.PivotPoint = PivotPoint.TopLeft; NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(tool_bar); NUIApplication.GetDefaultWindow().GetDefaultLayer().RaiseToTop(); // title of tool bar mTitle = new TextLabel(); mTitle.Text = APPLICATION_TITLE_WAVE; mTitle.FontFamily = "SamsungOne 400"; mTitle.PointSize = 20; mTitle.Position2D = new Position2D(400, 42); mTitle.ParentOrigin = ParentOrigin.TopLeft; mTitle.PositionUsesPivotPoint = true; mTitle.PivotPoint = PivotPoint.TopLeft; tool_bar.Add(mTitle); // push button of tool bar var style = new ButtonStyle(); style.Icon.ResourceUrl = new Selector <string>() { Normal = SLIDE_SHOW_START_ICON, Pressed = SLIDE_SHOW_START_ICON_SELECTED }; style.Position = new Position(800, 32); style.ParentOrigin = ParentOrigin.TopLeft; style.PivotPoint = PivotPoint.TopLeft; style.Size = new Size(58, 58); mSlideshowButton = new Button(style); mSlideshowButton.Clicked += OnPushButtonClicked; mSlideshowButton.RaiseToTop(); tool_bar.Add(mSlideshowButton); // toggle button of tool bar radiosParent = new View(); radiosParent.Size = new Size(200, 40); radiosParent.Position = new Position(900, 42); var layout = new LinearLayout(); layout.LinearOrientation = LinearLayout.Orientation.Horizontal; layout.CellPadding = new Size(30, 30); radiosParent.Layout = layout; tool_bar.Add(radiosParent); toggle = new RadioButtonGroup(); for (int i = 0; i < 3; i++) { radios[i] = new RadioButton(); radios[i].Size = new Size(37, 34); toggle.Add(radios[i]); radiosParent.Add(radios[i]); } var radioStyle = radios[0].Style; radioStyle.Icon.BackgroundImage = new Selector <string>() { Normal = EFFECT_WAVE_IMAGE, Selected = EFFECT_WAVE_IMAGE_SELECTED }; radios[0].ApplyStyle(radioStyle); radioStyle = radios[1].Style; radioStyle.Icon.BackgroundImage = new Selector <string>() { Normal = EFFECT_CROSS_IMAGE, Selected = EFFECT_CROSS_IMAGE_SELECTED }; radios[1].ApplyStyle(radioStyle); radioStyle = radios[2].Style; radioStyle.Icon.BackgroundImage = new Selector <string>() { Normal = EFFECT_FOLD_IMAGE, Selected = EFFECT_FOLD_IMAGE_SELECTED }; radios[2].ApplyStyle(radioStyle); radios[0].SelectedChanged += OnWaveClicked; radios[1].SelectedChanged += OnCrossClicked; radios[2].SelectedChanged += OnFoldClicked; radios[0].IsSelected = true; // load image mCurrentTexture = LoadStageFillingTexture(IMAGES[mIndex]); // content layer is 3D. content_layer = new Layer(); content_layer.Behavior = Layer.LayerBehavior.Layer3D; NUIApplication.GetDefaultWindow().AddLayer(content_layer); //use small cubes mCubeWaveEffect = new CubeTransitionWaveEffect(NUM_ROWS_WAVE, NUM_COLUMNS_WAVE); mCubeWaveEffect.SetTransitionDuration(ANIMATION_DURATION_WAVE); mCubeWaveEffect.SetCubeDisplacement(CUBE_DISPLACEMENT_WAVE); mCubeWaveEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeWaveEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeWaveEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeWaveEffect.PivotPoint = PivotPoint.TopLeft; mCubeWaveEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeWaveEffect.SetCurrentTexture(mCurrentTexture); // use big cubes mCubeCrossEffect = new CubeTransitionCrossEffect(NUM_ROWS_CROSS, NUM_COLUMNS_CROSS); mCubeCrossEffect.SetTransitionDuration(ANIMATION_DURATION_CROSS); mCubeCrossEffect.SetCubeDisplacement(CUBE_DISPLACEMENT_CROSS); mCubeCrossEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeCrossEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeCrossEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeCrossEffect.PivotPoint = PivotPoint.TopLeft; mCubeCrossEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeCrossEffect.SetCurrentTexture(mCurrentTexture); mCubeFoldEffect = new CubeTransitionFoldEffect(NUM_ROWS_FOLD, NUM_COLUMNS_FOLD); mCubeFoldEffect.SetTransitionDuration(ANIMATION_DURATION_FOLD); mCubeFoldEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeFoldEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeFoldEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeFoldEffect.PivotPoint = PivotPoint.TopLeft; mCubeFoldEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeFoldEffect.SetCurrentTexture(mCurrentTexture); mViewTimer = new Timer(VIEWINGTIME); mViewTimer.Tick += OnTimerTick; // content mCurrentEffect = mCubeWaveEffect; mContent = new View(); mContent.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mContent.ParentOrigin = ParentOrigin.TopLeft; mContent.PositionUsesPivotPoint = true; mContent.PivotPoint = PivotPoint.TopLeft; mContent.Add(mCurrentEffect); content_layer.Add(mContent); mPanGestureDetector = new PanGestureDetector(); mPanGestureDetector.Detected += OnPanGesture; mPanGestureDetector.Attach(mContent); }
public void Deactivate() { if (mTitle) { tool_bar.Remove(mTitle); mTitle.Dispose(); mTitle = null; } if (mSlideshowButton) { tool_bar.Remove(mSlideshowButton); mSlideshowButton.Clicked -= OnPushButtonClicked; mSlideshowButton.Dispose(); mSlideshowButton = null; } if (radiosParent) { for (int i = 0; i < 3; i++) { if (radios[i]) { if (0 == i) { radios[0].SelectedChanged -= OnWaveClicked; } if (1 == i) { radios[1].SelectedChanged -= OnCrossClicked; } if (2 == i) { radios[2].SelectedChanged -= OnFoldClicked; } radiosParent.Remove(radios[i]); radios[i].Dispose(); radios[i] = null; } } tool_bar.Remove(radiosParent); radiosParent.Dispose(); radiosParent = null; } if (tool_bar) { NUIApplication.GetDefaultWindow().GetDefaultLayer().Remove(tool_bar); tool_bar.Dispose(); tool_bar = null; } if (mCubeWaveEffect) { mCubeWaveEffect.TransitionCompleted -= OnCubeEffectCompleted; mCubeWaveEffect.Dispose(); mCubeWaveEffect = null; } if (mCubeCrossEffect) { mCubeCrossEffect.TransitionCompleted -= OnCubeEffectCompleted; mCubeCrossEffect.Dispose(); mCubeCrossEffect = null; } if (mCubeFoldEffect) { mCubeFoldEffect.TransitionCompleted -= OnCubeEffectCompleted; mCubeFoldEffect.Dispose(); mCubeFoldEffect = null; } if (mPanGestureDetector) { mPanGestureDetector.Detected -= OnPanGesture; mPanGestureDetector.Dispose(); mPanGestureDetector = null; } if (null != mViewTimer) { mViewTimer.Stop(); mViewTimer.Tick -= OnTimerTick; mViewTimer.Dispose(); mViewTimer = null; } if (null != mCurrentEffect) { mCurrentEffect.StopTransition(); mContent.Remove(mCurrentEffect); mCurrentEffect.Dispose(); mCurrentEffect = null; } if (mContent) { content_layer.Remove(mContent); mContent.Dispose(); mContent = null; } if (content_layer) { NUIApplication.GetDefaultWindow().RemoveLayer(content_layer); content_layer.Dispose(); content_layer = null; } }
public void Activate() { // tool bar tool_bar = new View(); tool_bar.BackgroundColor = Color.White; tool_bar.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, 100); tool_bar.PositionUsesPivotPoint = true; tool_bar.ParentOrigin = ParentOrigin.TopLeft; tool_bar.PivotPoint = PivotPoint.TopLeft; NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(tool_bar); NUIApplication.GetDefaultWindow().GetDefaultLayer().RaiseToTop(); // title of tool bar mTitle = new TextLabel(); mTitle.Text = APPLICATION_TITLE_WAVE; mTitle.FontFamily = "SamsungOne 400"; mTitle.PointSize = 20; mTitle.Position2D = new Position2D(400, 42); mTitle.ParentOrigin = ParentOrigin.TopLeft; mTitle.PositionUsesPivotPoint = true; mTitle.PivotPoint = PivotPoint.TopLeft; tool_bar.Add(mTitle); // push button of tool bar mSlideshowButton = new PushButton(); PropertyMap unselected_bg_map = new PropertyMap(); unselected_bg_map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); unselected_bg_map.Add(ImageVisualProperty.URL, new PropertyValue(SLIDE_SHOW_START_ICON)); mSlideshowButton.UnselectedBackgroundVisual = unselected_bg_map; PropertyMap selected_bg_map = new PropertyMap(); selected_bg_map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Image)); selected_bg_map.Add(ImageVisualProperty.URL, new PropertyValue(SLIDE_SHOW_START_ICON_SELECTED)); mSlideshowButton.SelectedBackgroundVisual = selected_bg_map; mSlideshowButton.ParentOrigin = ParentOrigin.TopLeft; mSlideshowButton.PivotPoint = PivotPoint.TopLeft; mSlideshowButton.Position2D = new Position2D(800, 32); mSlideshowButton.Clicked += OnPushButtonClicked; mSlideshowButton.RaiseToTop(); tool_bar.Add(mSlideshowButton); // toggle button of tool bar toggle_button = new ToggleButton(); PropertyArray array = new PropertyArray(); array.Add(new PropertyValue(EFFECT_WAVE_IMAGE)); array.Add(new PropertyValue(EFFECT_CROSS_IMAGE)); array.Add(new PropertyValue(EFFECT_FOLD_IMAGE)); toggle_button.StateVisuals = array; toggle_button.ParentOrigin = ParentOrigin.TopLeft; toggle_button.PivotPoint = PivotPoint.TopLeft; toggle_button.CellHorizontalAlignment = HorizontalAlignmentType.Right; toggle_button.Position2D = new Position2D(900, 42); toggle_button.Clicked += OnToggleButtonClicked; tool_bar.Add(toggle_button); // load image mCurrentTexture = LoadStageFillingTexture(IMAGES[mIndex]); // content layer is 3D. content_layer = new Layer(); content_layer.Behavior = Layer.LayerBehavior.Layer3D; NUIApplication.GetDefaultWindow().AddLayer(content_layer); //use small cubes mCubeWaveEffect = new CubeTransitionWaveEffect(NUM_ROWS_WAVE, NUM_COLUMNS_WAVE); mCubeWaveEffect.SetTransitionDuration(ANIMATION_DURATION_WAVE); mCubeWaveEffect.SetCubeDisplacement(CUBE_DISPLACEMENT_WAVE); mCubeWaveEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeWaveEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeWaveEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeWaveEffect.PivotPoint = PivotPoint.TopLeft; mCubeWaveEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeWaveEffect.SetCurrentTexture(mCurrentTexture); // use big cubes mCubeCrossEffect = new CubeTransitionCrossEffect(NUM_ROWS_CROSS, NUM_COLUMNS_CROSS); mCubeCrossEffect.SetTransitionDuration(ANIMATION_DURATION_CROSS); mCubeCrossEffect.SetCubeDisplacement(CUBE_DISPLACEMENT_CROSS); mCubeCrossEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeCrossEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeCrossEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeCrossEffect.PivotPoint = PivotPoint.TopLeft; mCubeCrossEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeCrossEffect.SetCurrentTexture(mCurrentTexture); mCubeFoldEffect = new CubeTransitionFoldEffect(NUM_ROWS_FOLD, NUM_COLUMNS_FOLD); mCubeFoldEffect.SetTransitionDuration(ANIMATION_DURATION_FOLD); mCubeFoldEffect.TransitionCompleted += OnCubeEffectCompleted; mCubeFoldEffect.Position2D = new Position2D(0, tool_bar.Size2D.Height); mCubeFoldEffect.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mCubeFoldEffect.PivotPoint = PivotPoint.TopLeft; mCubeFoldEffect.ParentOrigin = ParentOrigin.TopLeft; mCubeFoldEffect.SetCurrentTexture(mCurrentTexture); mViewTimer = new Timer(VIEWINGTIME); mViewTimer.Tick += OnTimerTick; // content mCurrentEffect = mCubeWaveEffect; mContent = new View(); mContent.Size2D = new Size2D(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Height - tool_bar.Size2D.Height); mContent.ParentOrigin = ParentOrigin.TopLeft; mContent.PositionUsesPivotPoint = true; mContent.PivotPoint = PivotPoint.TopLeft; mContent.Add(mCurrentEffect); content_layer.Add(mContent); mPanGestureDetector = new PanGestureDetector(); mPanGestureDetector.Detected += OnPanGesture; mPanGestureDetector.Attach(mContent); }
public void Deactivate() { if (mTitle) { tool_bar.Remove(mTitle); mTitle.Dispose(); mTitle = null; } if (mSlideshowButton) { tool_bar.Remove(mSlideshowButton); mSlideshowButton.Clicked -= OnPushButtonClicked; mSlideshowButton.Dispose(); mSlideshowButton = null; } if (toggle_button) { tool_bar.Remove(toggle_button); toggle_button.Clicked -= OnToggleButtonClicked; toggle_button.Dispose(); toggle_button = null; } if (tool_bar) { NUIApplication.GetDefaultWindow().GetDefaultLayer().Remove(tool_bar); tool_bar.Dispose(); tool_bar = null; } if (mCubeWaveEffect) { mCubeWaveEffect.TransitionCompleted -= OnCubeEffectCompleted; mCubeWaveEffect.Dispose(); mCubeWaveEffect = null; } if (mCubeCrossEffect) { mCubeCrossEffect.TransitionCompleted -= OnCubeEffectCompleted; mCubeCrossEffect.Dispose(); mCubeCrossEffect = null; } if (mCubeFoldEffect) { mCubeFoldEffect.TransitionCompleted -= OnCubeEffectCompleted; mCubeFoldEffect.Dispose(); mCubeFoldEffect = null; } if (mPanGestureDetector) { mPanGestureDetector.Detected -= OnPanGesture; mPanGestureDetector.Dispose(); mPanGestureDetector = null; } if (null != mViewTimer) { mViewTimer.Stop(); mViewTimer.Tick -= OnTimerTick; mViewTimer.Dispose(); mViewTimer = null; } if (null != mCurrentEffect) { mCurrentEffect.StopTransition(); mContent.Remove(mCurrentEffect); mCurrentEffect.Dispose(); mCurrentEffect = null; } if (mContent) { content_layer.Remove(mContent); mContent.Dispose(); mContent = null; } if (content_layer) { NUIApplication.GetDefaultWindow().RemoveLayer(content_layer); content_layer.Dispose(); content_layer = null; } }