Esempio n. 1
0
        internal void CreateWheelLetters(MainActivity mainActivity, bool IsShuffling)
        {
            if (!IsShuffling)
            {
                _lstFoundWordsSoFar.Clear();
            }
            this.RemoveAllViews();

            fDidLayout = false;
            this._lstLtrWheelLetterLayouts.Clear();
            //            this.LayoutParameters = layoutParametersWheel;
            foreach (var ltr in mainActivity._wordCont.InitialWord.OrderBy(p => mainActivity._Random.NextDouble()))
            {
                var wheelLetter = new LtrWheelLetterLayout(mainActivity, ltr);

                this._lstLtrWheelLetterLayouts.Add(wheelLetter);
                this.AddView(wheelLetter);
            }
        }
Esempio n. 2
0
        private LtrWheelLetterLayout GetLetterFromTouch(TouchEventArgs e)
        {
            LtrWheelLetterLayout ltrWheelLetterLayout = null;

            if (_mainActivity._btnNew.Enabled) // if we're not calculating the next board
            {
                int[] locg = new int[2];
                this.GetLocationInWindow(locg);
                var X = (int)e.Event.RawX; // - locg[0];
                var Y = (int)e.Event.RawY; // - locg[1];
                foreach (var ltr in _lstLtrWheelLetterLayouts)
                {
                    if (IsPointInsideView(X, Y, ltr))
                    {
                        ltrWheelLetterLayout = ltr;
                        break;
                    }
                }
            }
            return(ltrWheelLetterLayout);
        }
Esempio n. 3
0
        private bool IsPointInsideView(float x, float y, LtrWheelLetterLayout view)
        {
            var location = new int[2];

            view.GetLocationOnScreen(location);
            int viewX = location[0];
            int viewY = location[1];

            this.GetLocationOnScreen(location);
            x -= location[0];
            y -= location[1];

            Rect rect = new Rect();

            view.GetHitRect(rect);
            //            rect = new Rect(viewX, viewY, viewX + view.Width, viewY + view.Height);

            if (_lstSelected.Count == 0)
            {// for 1st letter, allow a larger rect
             //                rect.Left -= 50; rect.Right += 50; rect.Bottom += 50; rect.Top -= 50;
            }
            var isin = rect.Contains((int)x, (int)y);

            //            isin = false;
            //var margx = (view.LayoutParameters as RelativeLayout.LayoutParams)?.LeftMargin;
            //var margy = (view.LayoutParameters as RelativeLayout.LayoutParams)?.TopMargin;

            ////this._mainActivity._txtWordSoFar.Text = $"view={view.textView.Text} rect={rect}  ({viewX},{viewY}) ({margx}, {margy})  ({view.Width},{view.Height})";
            ////point is inside view bounds
            //// xxz ({x}, {y}) {viewX},{viewY})  rect = {rect.Left},{ rect.Top}) ({rect.Right},{rect.Bottom})
            //if (x > viewX && x < (viewX + view.Width))
            //{
            //    if (y > viewY && y < viewY + view.Height)
            //    {
            //        return true;
            //    }
            //}
            return(isin);
        }