Ejemplo n.º 1
0
        private void OnTapGestureDected(object source, TapGestureDetector.DetectedEventArgs e)
        {
            if (e.View == baseView)
            {
                View stickerBaseView = new View()
                {
                    WidthSpecification  = 200,
                    HeightSpecification = 200
                };
                tgd.Attach(stickerBaseView);
                lpgd.Attach(stickerBaseView);
                pgd.Attach(stickerBaseView);
                baseView.Add(stickerBaseView);

                Random random = new Random();
                int    number = random.Next(1, 10);

                string path = ApplicationInfo.SharedResourcePath;
                string file = "fb_emoji_500_0" + number + ".png.gif";
                string gif  = path + file;

                ImageView stickerImageView = new ImageView(gif)
                {
                    WidthResizePolicy  = ResizePolicyType.FillToParent,
                    HeightResizePolicy = ResizePolicyType.FillToParent,
                    ReleasePolicy      = ReleasePolicyType.Never
                };
                stickerBaseView.Add(stickerImageView);
            }
        }
Ejemplo n.º 2
0
        public SwipeViewTest2Page()
        {
            InitializeComponent();

            panGestureDetector = new PanGestureDetector();
            panGestureDetector.Attach(text1View);
            panGestureDetector.Attach(text2View);
            panGestureDetector.Detected += (obj, e) =>
            {
                Vector2 velocity = e.PanGesture.Velocity;
                View    view     = e.View;
                if (view != null)
                {
                    if (e.PanGesture.State == Gesture.StateType.Started)
                    {
                        init1Position = text1View.Position;
                        init2Position = text2View.Position;
                    }
                    else if (e.PanGesture.State == Gesture.StateType.Finished || e.PanGesture.State == Gesture.StateType.Cancelled)
                    {
                        if (view.Position.X < -110)
                        {
                            var button = new Button()
                            {
                                Text = "Cancel",
                            };

                            button.Clicked += (object s, ClickedEventArgs a) =>
                            {
                                Navigator?.Pop();
                            };

                            if (view == text1View)
                            {
                                DialogPage.ShowAlertDialog("SwipeView", "SwipeItemView Invoked", button);
                            }
                            else if (view == text2View)
                            {
                                DialogPage.ShowAlertDialog("SwipeView", "SwipeItemView Command Executed", button);
                            }
                        }

                        text1View.Position = init1Position;
                        text2View.Position = init2Position;
                    }
                    else
                    {
                        if (velocity.X < 0 && view.Position.X > -140)
                        {
                            view.Position += new Position(e.PanGesture.ScreenDisplacement.X, 0, 0);
                        }
                    }
                }
            };
        }
Ejemplo n.º 3
0
        private void OnPushButtonClicked(object sender, global::System.EventArgs args)
        {
            mSlideshow = !mSlideshow;
            if (mSlideshow)
            {
                mPanGestureDetector.Detach(mContent);

                var style = mSlideshowButton.Style;
                style.Icon.ResourceUrl = new Selector <string>()
                {
                    Normal = SLIDE_SHOW_STOP_ICON, Pressed = SLIDE_SHOW_STOP_ICON_SELECTED
                };
                mSlideshowButton.ApplyStyle(style);

                mPanPosition     = new Vector2(NUIApplication.GetDefaultWindow().WindowSize.Width, NUIApplication.GetDefaultWindow().WindowSize.Width * 0.5f);
                mPanDisplacement = new Vector2(-10.0f, 0.0f);

                mViewTimer.Start();
            }
            else
            {
                mPanGestureDetector.Attach(mContent);
                var style = mSlideshowButton.Style;
                style.Icon.ResourceUrl = new Selector <string>()
                {
                    Normal = SLIDE_SHOW_START_ICON, Pressed = SLIDE_SHOW_START_ICON_SELECTED
                };
                mSlideshowButton.ApplyStyle(style);
                mViewTimer.Stop();
            }
        }
Ejemplo n.º 4
0
        public ScrollableBase() : base()
        {
            mPanGestureDetector = new PanGestureDetector();
            mPanGestureDetector.Attach(this);
            mPanGestureDetector.AddDirection(PanGestureDetector.DirectionVertical);
            mPanGestureDetector.Detected += OnPanGestureDetected;

            mTapGestureDetector = new TapGestureDetector();
            mTapGestureDetector.Attach(this);
            mTapGestureDetector.Detected += OnTapGestureDetected;


            ClippingMode = ClippingModeType.ClipToBoundingBox;

            mScrollingChild = new View();
            mScrollingChild.Name = "DefaultScrollingChild";

            //Interrupt touching when panning is started;
            mInterruptTouchingChild = new View()
            {
                Name = "InterruptTouchingChild",
                Size = new Size(Window.Instance.WindowSize),
                BackgroundColor = Color.Transparent,
            };

            mInterruptTouchingChild.TouchEvent += (object source, View.TouchEventArgs args) => {
                return true;
            };

            Layout = new ScrollableBaseCustomLayout();
        }
Ejemplo n.º 5
0
        private ImageView CreateThumb()
        {
            if (null == thumbImage)
            {
                thumbImage = new ImageView()
                {
                    WidthResizePolicy      = ResizePolicyType.Fixed,
                    HeightResizePolicy     = ResizePolicyType.Fixed,
                    ParentOrigin           = NUI.ParentOrigin.Center,
                    PivotPoint             = NUI.PivotPoint.Center,
                    PositionUsesPivotPoint = true
                };
                if (slidedTrackImage != null)
                {
                    slidedTrackImage.Add(thumbImage);
                }
                thumbImage.TouchEvent += OnTouchEventForThumb;

                panGestureDetector = new PanGestureDetector();
                panGestureDetector.Attach(thumbImage);
                panGestureDetector.Detected += OnPanGestureDetected;
            }

            return(thumbImage);
        }
Ejemplo n.º 6
0
        private void Initialize()
        {
            currentSlidedOffset     = 0;
            isFocused               = false;
            isPressed               = false;
            LayoutDirectionChanged += OnLayoutDirectionChanged;

            panGestureDetector = new PanGestureDetector();
            panGestureDetector.Attach(this);
            panGestureDetector.Detected += OnPanGestureDetected;
        }
Ejemplo n.º 7
0
        private void init(View view)
        {
            mTapGestureDetector   = new TapGestureDetector();
            mLongGestureDetector  = new LongPressGestureDetector();
            mPanGestureDetector   = new PanGestureDetector();
            mPinchGestureDetector = new PinchGestureDetector();

            mTapGestureDetector.Attach(view);
            mLongGestureDetector.Attach(view);
            mPanGestureDetector.Attach(view);
            mPinchGestureDetector.Attach(view);
        }
Ejemplo n.º 8
0
        private void Initialize()
        {
            AccessibilityHighlightable = true;

            currentSlidedOffset     = 0;
            isFocused               = false;
            isPressed               = false;
            LayoutDirectionChanged += OnLayoutDirectionChanged;

            this.TouchEvent += OnTouchEventForTrack;

            panGestureDetector = new PanGestureDetector();
            panGestureDetector.Attach(this);
            panGestureDetector.Detected += OnPanGestureDetected;
        }
Ejemplo n.º 9
0
        public PanGestureTest1Page()
        {
            InitializeComponent();

            mPanDetector = new PanGestureDetector();
            mPanDetector.Attach(imageView);

            mPanDetector.Detected += (obj, e) =>
            {
                View view = e.View;
                if (view != null)
                {
                    view.Position += new Position(e.PanGesture.ScreenDisplacement.X, e.PanGesture.ScreenDisplacement.Y, 0);
                }
            };
        }
Ejemplo n.º 10
0
        public RotarySelector()
        {
            rotarySelectorManager = new RotarySelectorManager(new Size(360, 360));
            this.Add(rotarySelectorManager.GetRotaryPagination());
            this.Add(rotarySelectorManager.GetRotaryLayerView());

            longPressDetector           = new LongPressGestureDetector();
            longPressDetector.Detected += Detector_Detected;
            longPressDetector.Attach(rotarySelectorManager.GetRotaryLayerView().GetMainText());

            panDetector = new PanGestureDetector();
            panDetector.Attach(this);
            panDetector.Detected += PanDetector_Detected;

            this.WheelEvent += RotarySelector_WheelEvent;
        }
Ejemplo n.º 11
0
        public ScrollableBase() : base()
        {
            mPanGestureDetector = new PanGestureDetector();
            mPanGestureDetector.Attach(this);
            mPanGestureDetector.AddDirection(PanGestureDetector.DirectionVertical);
            mPanGestureDetector.Detected += OnPanGestureDetected;

            mTapGestureDetector = new TapGestureDetector();
            mTapGestureDetector.Attach(this);
            mTapGestureDetector.Detected += OnTapGestureDetected;

            ClippingMode = ClippingModeType.ClipToBoundingBox;

            mScrollingChild = new View();

            Layout = new ScrollableBaseCustomLayout();
        }
Ejemplo n.º 12
0
        public FlexibleView()
        {
            mRecyclerPool = new RecycledViewPool(this);

            mRecycler = new FlexibleViewRecycler(this);
            mRecycler.SetRecycledViewPool(mRecyclerPool);

            mChildHelper = new ChildHelper(this);

            mPanGestureDetector = new PanGestureDetector();
            mPanGestureDetector.Attach(this);
            mPanGestureDetector.Detected += OnPanGestureDetected;

            mAdapteHelper = new AdapterHelper(this);

            ClippingMode = ClippingModeType.ClipToBoundingBox;
        }
        public SwipeGestureRecognizerTestPage()
        {
            InitializeComponent();

            panGestureDetector = new PanGestureDetector();

            panGestureDetector.Attach(areaView);
            panGestureDetector.Detected += (obj, e) =>
            {
                Vector2 velocity = e.PanGesture.Velocity;

                if (velocity.X > 0)
                {
                    text1.Text = "Direction : Right";
                }
                else if (velocity.X < 0)
                {
                    text1.Text = "Direction : Left";
                }
            };
        }
Ejemplo n.º 14
0
        private void Initialize()
        {
            AccessibilityHighlightable = true;

            currentSlidedOffset     = 0;
            isFocused               = false;
            isPressed               = false;
            LayoutDirectionChanged += OnLayoutDirectionChanged;

            this.TouchEvent         += OnTouchEventForTrack;
            this.GrabTouchAfterLeave = true;

            panGestureDetector = new PanGestureDetector();
            panGestureDetector.Attach(this);
            panGestureDetector.Detected += OnPanGestureDetected;

            this.Layout = new LinearLayout()
            {
                LinearOrientation = LinearLayout.Orientation.Horizontal,
            };
        }
Ejemplo n.º 15
0
        private bool OnPushButtonClicked(object sender, global::System.EventArgs args)
        {
            mSlideshow = !mSlideshow;
            if (mSlideshow)
            {
                mPanGestureDetector.Detach(mContent);

                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_STOP_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_STOP_ICON_SELECTED));
                mSlideshowButton.SelectedBackgroundVisual = selected_bg_map;

                mPanPosition     = new Vector2(Window.Instance.WindowSize.Width, Window.Instance.WindowSize.Width * 0.5f);
                mPanDisplacement = new Vector2(-10.0f, 0.0f);

                mViewTimer.Start();
            }
            else
            {
                mPanGestureDetector.Attach(mContent);

                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;

                mViewTimer.Stop();
            }
            return(true);
        }
Ejemplo n.º 16
0
        public ScrollableBase() : base()
        {
            base.Layout         = new ScrollableBaseCustomLayout();
            mPanGestureDetector = new PanGestureDetector();
            mPanGestureDetector.Attach(this);
            mPanGestureDetector.AddDirection(PanGestureDetector.DirectionVertical);
            mPanGestureDetector.Detected += OnPanGestureDetected;

            mTapGestureDetector = new TapGestureDetector();
            mTapGestureDetector.Attach(this);
            mTapGestureDetector.Detected += OnTapGestureDetected;

            ClippingMode = ClippingModeType.ClipChildren;

            //Default Scrolling child
            ContentContainer = new View()
            {
                WidthSpecification  = ScrollingDirection == Direction.Vertical ? LayoutParamPolicies.MatchParent : LayoutParamPolicies.WrapContent,
                HeightSpecification = ScrollingDirection == Direction.Vertical ? LayoutParamPolicies.WrapContent : LayoutParamPolicies.MatchParent,
                Layout = new AbsoluteLayout()
                {
                    SetPositionByLayout = false
                },
            };
            ContentContainer.Relayout     += OnScrollingChildRelayout;
            propertyNotification           = ContentContainer.AddPropertyNotification("position", PropertyCondition.Step(1.0f));
            propertyNotification.Notified += OnPropertyChanged;
            base.Add(ContentContainer);

            //Interrupt touching when panning is started
            mInterruptTouchingChild = new View()
            {
                Size            = new Size(Window.Instance.WindowSize),
                BackgroundColor = Color.Transparent,
            };
            mInterruptTouchingChild.TouchEvent += OnIterruptTouchingChildTouched;

            Scrollbar = new Scrollbar();
        }
Ejemplo n.º 17
0
        public CircularRecycler()
        {
            PivotPoint             = Tizen.NUI.PivotPoint.Center;
            PositionUsesPivotPoint = true;

            containerView = new View()
            {
                WidthSpecification  = LayoutParamPolicies.WrapContent,
                HeightSpecification = 360,
            };
            this.Add(containerView);

            panDetector = new PanGestureDetector();
            panDetector.Attach(this);
            panDetector.Detected += PanDetector_Detected;

            layoutManager = new DefaultLayoutManager();

            viewHolderList = new List <ViewHolder>();

            CreateLastPage();
        }
Ejemplo n.º 18
0
        private void InitializeMainScreen()
        {
            FrameWidth  = Window.Instance.WindowSize.Width;
            FrameHeight = Window.Instance.WindowSize.Height;

            var layout = new LinearLayout();

            layout.LinearOrientation = LinearLayout.Orientation.Vertical;
            View mainScreen = new View()
            {
                Layout              = layout,
                Name                = "MainScreen",
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                Background          = CreateGradientVisual(new Vector4(0.0f, 0.0f, 1.0f, 1.0f)).OutputVisualMap,
            };

            Window.Instance.Add(mainScreen);
            Window.Instance.KeyEvent += WindowKeyEvent;

            SetupCategoryItems();
            InitializeCategoryStack();
            InitializeTitleStack();
            InitializeContent();

            Window.Instance.Add(contentArea);
            contentArea.PositionY = FrameHeight;
            Window.Instance.Add(categoryStack);
            Window.Instance.Add(titleStack);

            tapGestureDetector = new TapGestureDetector();
            tapGestureDetector.Attach(mainScreen);
            tapGestureDetector.Detected += OnTapGestureDetected;

            panGestureDetector = new PanGestureDetector();
            panGestureDetector.Attach(mainScreen);
            panGestureDetector.Detected += OnPanGestureDetected;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the RefreshLayout class.
        /// </summary>
        public RefreshLayout()
        {
            _overlayArea = new View
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };
            Add(_overlayArea);

            _refreshIcon = new RefreshIcon
            {
                Opacity = 0
            };
            _overlayArea.Add(_refreshIcon);

            _panGestureDetector = new PanGestureDetector();
            _panGestureDetector.Attach(this);
            _panGestureDetector.Detected += OnDetected;

            LayoutUpdated += OnLayout;

            _refreshState = RefreshState.Idle;
        }
Ejemplo n.º 20
0
        public WearableGallery()
        {
            extraItemIdx = EXTRA_ITEM_COUNT;

            PivotPoint             = Tizen.NUI.PivotPoint.Center;
            PositionUsesPivotPoint = true;

            containerView = new View()
            {
                WidthSpecification  = LayoutParamPolicies.WrapContent,
                HeightSpecification = 360,
                BackgroundColor     = new Color(1, 0, 0, 0.3f),
            };
            this.Add(containerView);

            panDetector = new PanGestureDetector();
            panDetector.Attach(this);
            panDetector.Detected += PanDetector_Detected;

            layoutManager = new DefaultLayoutManager();

            viewHolderList = new List <ViewHolder>();
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
        public SwipeViewTest1Page()
        {
            InitializeComponent();

            swipeCount = 0;

            imageView.Scale = imageView.Scale * new Vector3(1.2f, 1.2f, 1.0f);

            initPosition = imageView.Position;

            ContentView.Padding = new Extents(20, 20, 20, 20);

            panGestureDetector = new PanGestureDetector();
            panGestureDetector.Attach(imageView);
            panGestureDetector.Detected += (obj, e) =>
            {
                Vector2 velocity = e.PanGesture.Velocity;
                if (e.PanGesture.State == Gesture.StateType.Started)
                {
                    if (velocity.X != 0)
                    {
                        swipeDirection = Direction.Horizontal;
                        if (velocity.X > 0)
                        {
                            image1.Size = new Size(100, 100);
                        }
                        else
                        {
                            image2.Size = new Size(100, 100);
                        }
                    }
                    else if (velocity.Y != 0)
                    {
                        swipeDirection = Direction.Vertical;

                        swipeCount++;
                        if ((swipeCount % 2) > 0)
                        {
                            imageView.BorderlineWidth = 5f;
                            imageView.BorderlineColor = Color.Green;
                        }
                        else
                        {
                            imageView.BorderlineWidth = 0f;
                        }

                        text2.Text = "Item";
                        text3.Text = "Item";
                    }
                }
                else if (e.PanGesture.State == Gesture.StateType.Continuing)
                {
                    if (swipeDirection == Direction.Vertical && imageView.Position.Y < 70 && imageView.Position.Y > -70)
                    {
                        imageView.Position += new Position(0, e.PanGesture.ScreenDisplacement.Y, 0);
                    }
                    else if (swipeDirection == Direction.Horizontal && imageView.Position.X < 70 && imageView.Position.X > -70)
                    {
                        imageView.Position += new Position(e.PanGesture.ScreenDisplacement.X, 0, 0);
                    }
                }
                else if (e.PanGesture.State == Gesture.StateType.Finished || e.PanGesture.State == Gesture.StateType.Cancelled)
                {
                    imageView.Position = initPosition;

                    image1.Size = new Size(0, 0);
                    image2.Size = new Size(0, 0);

                    text2.Text = "";
                    text3.Text = "";
                }
            };
        }
Ejemplo n.º 23
0
        public void Activate()
        {
            Window.Instance.BackgroundColor = Color.Black;
            // tool bar
            tool_bar = new View();
            tool_bar.BackgroundColor        = Color.White;
            tool_bar.Size2D                 = new Size2D(Window.Instance.WindowSize.Width, 100);
            tool_bar.PositionUsesPivotPoint = true;
            tool_bar.ParentOrigin           = ParentOrigin.TopLeft;
            tool_bar.PivotPoint             = PivotPoint.TopLeft;

            Window.Instance.GetDefaultLayer().Add(tool_bar);
            Window.Instance.GetDefaultLayer().RaiseToTop();

            // title of tool bar
            mTitle                        = new TextLabel();
            mTitle.Text                   = APPLICATION_TITLE_WAVE;
            mTitle.FontFamily             = "SamsungOneUI 400C";
            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;
            Window.Instance.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(Window.Instance.WindowSize.Width, Window.Instance.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(Window.Instance.WindowSize.Width, Window.Instance.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(Window.Instance.WindowSize.Width, Window.Instance.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(Window.Instance.WindowSize.Width, Window.Instance.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);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Override to create the required scene
        /// </summary>
        protected override void OnCreate()
        {
            base.OnCreate();

            Window window = NUIApplication.GetDefaultWindow();

            window.BackgroundColor = Color.White;

            View root = new View()
            {
                Size   = new Size(window.WindowSize),
                Layout = new LinearLayout()
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical
                },
            };

            window.Add(root);

            container = new View()
            {
                Weight              = 0,
                Layout              = new AbsoluteLayout(),
                WidthSpecification  = window.WindowSize.Width,
                HeightSpecification = window.WindowSize.Width,
                ClippingMode        = ClippingModeType.ClipToBoundingBox,
            };
            root.Add(container);

            ImageView backgroundImage = new ImageView()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                ResourceUrl         = "./res/background_image.jpg",
                Opacity             = 0.1f,
            };

            container.Add(backgroundImage);

            clippingMaskView = new ClippingMaskView("./res/background_image.jpg", "./res/mask_image.png")
            {
                Size = new Size(150, 150),
                PositionUsesPivotPoint = true,
                Position = new Position(container.Size.Width / 2.0f, container.Size.Height / 2.0f),
            };
            container.Add(clippingMaskView);

            float positionX  = (clippingMaskView.Position.X - clippingMaskView.Size.Width / 2.0f) / container.Size.Width;
            float positionY  = (clippingMaskView.Position.Y - clippingMaskView.Size.Height / 2.0f) / container.Size.Height;
            float sizeWidth  = clippingMaskView.Size.Width / container.Size.Width;
            float sizeHeight = clippingMaskView.Size.Height / container.Size.Height;

            clippingMaskView.BackgroundImage.PixelArea = new Vector4(positionX, positionY, sizeWidth, sizeHeight);

            detector = new PanGestureDetector();
            detector.Attach(container);
            detector.Detected += (object source, PanGestureDetector.DetectedEventArgs args) =>
            {
                clippingMaskView.Position = new Position(args.PanGesture.Position);
                positionX  = (clippingMaskView.Position.X - clippingMaskView.Size.Width / 2.0f) / container.Size.Width;
                positionY  = (clippingMaskView.Position.Y - clippingMaskView.Size.Height / 2.0f) / container.Size.Height;
                sizeWidth  = clippingMaskView.Size.Width / container.Size.Width;
                sizeHeight = clippingMaskView.Size.Height / container.Size.Height;

                clippingMaskView.BackgroundImage.PixelArea = new Vector4(positionX, positionY, sizeWidth, sizeHeight);
            };

            View controlPannel = new View()
            {
                WidthSpecification  = window.WindowSize.Width,
                HeightSpecification = window.WindowSize.Height - window.WindowSize.Width,
                Layout          = new AbsoluteLayout(),
                BackgroundColor = new Color("#0A0A0A"),
            };

            foreach (PannelButton.Direction type in Enum.GetValues(typeof(PannelButton.Direction)))
            {
                PannelButton button = new PannelButton()
                {
                    Size         = new Size(60, 60),
                    CornerRadius = 30,
                    Type         = type,
                };

                button.Style.BackgroundColor = new ColorSelector()
                {
                    Pressed = new Color("#A3A3A3"),
                    Normal  = Color.White,
                };

                button.ClickEvent += (object source, Button.ClickEventArgs args) =>
                {
                    Position newPosition = CalculatePositionByDirection(type);

                    positionX  = (newPosition.X - clippingMaskView.Size.Width / 2.0f) / container.Size.Width;
                    positionY  = (newPosition.Y - clippingMaskView.Size.Height / 2.0f) / container.Size.Height;
                    sizeWidth  = clippingMaskView.Size.Width / container.Size.Width;
                    sizeHeight = clippingMaskView.Size.Height / container.Size.Height;

                    Animation moveAnimation = new Animation(150);
                    moveAnimation.AnimateTo(clippingMaskView, "position", newPosition);
                    moveAnimation.AnimateTo(clippingMaskView.BackgroundImage, "pixelArea", new Vector4(positionX, positionY, sizeWidth, sizeHeight));
                    moveAnimation.Play();
                };

                controlPannel.Add(button);
            }

            root.Add(controlPannel);

            // Respond to key events
            window.KeyEvent += OnKeyEvent;
        }
Ejemplo n.º 25
0
        public override void Create()
        {
            windowWidth = LayoutingExample.GetWindow().WindowSize.Width;

            view                        = new View();
            view.Name                   = "MainLinearLayout";
            view.ParentOrigin           = ParentOrigin.Center;
            view.PivotPoint             = PivotPoint.Center;
            view.PositionUsesPivotPoint = true;
            view.WidthSpecification     = LayoutParamPolicies.MatchParent;
            view.HeightSpecification    = LayoutParamPolicies.MatchParent;

            var layout = new LinearLayout();

            layout.LinearAlignment = LinearLayout.Alignment.Center;
            view.Layout            = layout;
            view.LayoutDirection   = ViewLayoutDirectionType.LTR;

            // Add child image-views to the created view
            var index = 0;

            foreach (String image in TestImages.s_images)
            {
                // Set a delayed custom transition for each Image View so each moves into place after it's
                // adjacent sibbling.
                TransitionComponents easeInOutSineDelayed = new TransitionComponents();
                easeInOutSineDelayed.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
                easeInOutSineDelayed.Delay         = ITEM_MOVE_DURATION * index;
                easeInOutSineDelayed.Duration      = ITEM_MOVE_DURATION * TestImages.s_images.Length;

                ImageView imageView = LayoutingExample.CreateChildImageView(image, new Size2D(80, 80));

                // Override LayoutChanged transition so different for each ImageView in the Linear layout.
                // In this case each moves with a increasing delay.
                imageView.LayoutTransition = new LayoutTransition(TransitionCondition.LayoutChanged,
                                                                  AnimatableProperties.Position,
                                                                  0.0,
                                                                  easeInOutSineDelayed);

                imageView.LayoutTransition = new LayoutTransition(TransitionCondition.ChangeOnRemove,
                                                                  AnimatableProperties.Position,
                                                                  0.0,
                                                                  easeInOutSineDelayed);

                view.Add(imageView);
                index++;
            }

            LayoutingExample.GetWindow().Add(view);

            InitializePanControl();
            LayoutingExample.GetWindow().Add(panControl);

            panGestureDetector = new PanGestureDetector();
            panGestureDetector.Attach(panControl);
            panGestureDetector.Detected += OnPanGestureDetected;

            instructionsLabel = new TextLabel(instructions)
            {
                Position2D = new Position2D(10, (int)(LayoutingExample.GetWindow().WindowSize.Height *0.90f)),
                MultiLine  = true,
            };
            LayoutingExample.GetWindow().Add(instructionsLabel);
        }