예제 #1
0
        public TilesView GetTilesViewByCR(int Col, int Row)
        {
            TilesView LG = new TilesView();

            LG = (TilesView)Grilla.Children[Col * this.Dimension_R + Row];

            return(LG);
        }
예제 #2
0
        public TilesView GetTilesViewByXY(Double coordX, Double coordY)
        {
            TilesView LG = new TilesView();

            if ((coordX < Grilla.Width) && (coordX > 0) && (coordY < Grilla.Height) && (coordY > 0))
            {
                double cuadro_width  = Grilla.Width / this.Dimension_C;
                double cuadro_height = Grilla.Height / this.Dimension_R;

                int LG_C = (int)(coordX / cuadro_width);
                int LG_R = (int)(coordY / cuadro_height);

                LG = (TilesView)Grilla.Children[LG_C * this.Dimension_R + LG_R];
            }
            else
            {
                LG.Col = -1;
                LG.Row = -1;
            }
            return(LG);
        }
예제 #3
0
 public Boolean MismaUbicacion(TilesView A)
 {
     return((A.Col == this.Col) && (A.Row == this.Row));
 }
예제 #4
0
        void OnTouchEffectAction(object sender, TouchActionEventArgs args)
        {
            EventHandler <TileEventArgs> handler;

            switch (args.Type)
            {
            case TouchActionType.Pressed:
                T.Stop();
                TileView_Seleccionado = (TilesView)this.GetTilesViewByXY(args.Location.X, args.Location.Y);
                if (TileView_Seleccionado != null)
                {
                    T = new Timer(TimeSpan.FromSeconds(3), () => ClickLento_TimeOut(sender, args, "TOut "));
                    T.Start();

                    /* Esta parte genera el eveno MoveFrom */
                    TileEventArgs tArgs = new TileEventArgs(args.Id, args.Type, args.Location, args.IsInContact);
                    tArgs.Tile = TileView_Seleccionado;


                    if (EventStatus != EnumEstadoEvento.Click)
                    {
                        handler = Tile_MoveFrom;
                        if (handler != null)
                        {
                            EventStatus = EnumEstadoEvento.MoveFrom;
                            handler(this, tArgs);
                        }
                    }
                    else
                    {
                        EventStatus = EnumEstadoEvento.DobleClick;
                    }
                }

                break;

            case TouchActionType.Moved:
                if (TileView_Seleccionado != null)
                {
                    TilesView cuadro_Actual = this.GetTilesViewByXY(args.Location.X, args.Location.Y);

                    if ((cuadro_Actual.Col != -1) || (cuadro_Actual.Row != -1))
                    {
                        if ((!TileView_Seleccionado.MismaUbicacion(cuadro_Actual)) && ((EventStatus == EnumEstadoEvento.MoveTo) || (EventStatus == EnumEstadoEvento.MoveFrom)))
                        {
                            T.Stop();
                            TileEventArgs tArgs = new TileEventArgs(args.Id, args.Type, args.Location, args.IsInContact);
                            tArgs.Tile       = TileView_Seleccionado;
                            tArgs.MovioA_Col = cuadro_Actual.Col;
                            tArgs.MovioA_Row = cuadro_Actual.Row;

                            TileView_Seleccionado = cuadro_Actual;
                            EventStatus           = EnumEstadoEvento.MoveTo;

                            handler = Tile_MoveTo;
                            if (handler != null)
                            {
                                handler(this, tArgs);
                            }
                        }
                    }
                }

                break;

            case TouchActionType.Released:
                if (TileView_Seleccionado != null)
                {
                    T.Stop(); T_DC.Stop();

                    if (EventStatus == EnumEstadoEvento.MoveFrom)
                    {
                        T_DC = new Timer(TimeSpan.FromSeconds(1), () => Click_TimeOut(sender, args, "TOut "));
                        T_DC.Start();
                        EventStatus = EnumEstadoEvento.Click;
                    }

                    if (EventStatus == EnumEstadoEvento.DobleClick)
                    {
                        handler = Tile_DobleClick;
                        if (handler != null)
                        {
                            TileEventArgs tArgs = new TileEventArgs(args.Id, args.Type, args.Location, args.IsInContact);
                            tArgs.Tile = TileView_Seleccionado;

                            EventStatus = EnumEstadoEvento.Nulo;
                            handler(this, tArgs);
                        }
                    }

                    if (EventStatus == EnumEstadoEvento.MoveTo)
                    {
                        TileView_Seleccionado = null;
                        EventStatus           = EnumEstadoEvento.Nulo;
                    }
                }

                break;
            }
        }