Example #1
0
        /// <summary>
        /// Method to handle what occurs when TouchEffect is active
        /// </summary>
        /// <param name="args"></param>
        /// <param name="itemIcon"></param>
        /// <param name="currentStorageName"></param>
        /// <param name="item"></param>
        /// <param name="grid"></param>
        public static void OnScreenTouch(TouchActionEventArgs args, ItemLayout itemIcon, string currentStorageName, Action <string, ItemLayout, int> updateShelf)
        {
            var itemStorage = ContentManager.GetSelectedStorage(currentStorageName);

            itemIcon.TranslationY += args.Location.Y; itemIcon.TranslationX += args.Location.X;
            if (args.Type == TouchActionEventArgs.TouchActionType.Entered)
            {
                // re-adding the item to be at the front layer
                var pUnplacedGrid = GridManager.GetGrid(ContentManager.pUnplacedGridName);
                var index         = pUnplacedGrid.Children.IndexOf(itemIcon);
                GridManager.AddGridItemAtPosition(pUnplacedGrid, new List <View>()
                {
                    itemIcon
                }, new Vector2D <int>(index % 4, (int)(index / 4)));
            }
            if (args.Type == TouchActionEventArgs.TouchActionType.Released)
            {
                itemIcon.TranslationX = 0;
                itemIcon.TranslationY = 0;
            }


            if (args.IsInContact)
            {
                foreach (StorageCell cell in itemStorage.GetGridCells())
                {
                    cell.GetButton().RemoveEffect(typeof(ImageTint));
                }
                args.ContactView[0].AddEffect(new ImageTint()
                {
                    tint = ContentManager.button_tint_color, ImagePath = ContentManager.buttonTintImage
                });
                if (args.Type == TouchActionEventArgs.TouchActionType.Released)
                {
                    args.ContactView[0].RemoveEffect(typeof(ImageTint));

                    itemIcon.SetStoragePointer(ContentManager.GetStorageView);
                    updateShelf(currentStorageName, itemIcon, args.ContactIndex[0]);
                }
            }
            else if (args.ContactView != null)
            {
                args.ContactView[0].ToggleEffects(new ImageTint()
                {
                    tint = Color.FromRgba(100, 30, 30, 70), ImagePath = ContentManager.buttonTintImage
                }, null);
            }
        }
Example #2
0
 public void OnTouchAction(Element element, TouchActionEventArgs args)
 {
     OnTouchEvent?.Invoke(element, args);
 }