Ejemplo n.º 1
0
        public override void LoadView()
        {
            // Create a view
            CGRect frame = UIScreen.MainScreen.Bounds;

            frame.Y      += 23;
            frame.Height -= 23;
            HypnosisView v = new HypnosisView(frame);

            // Set it as the view of this view controller
            this.View = v;

            // Create a segmented control
            segControl = new UISegmentedControl(new string[4] {
                "Grey", "Red", "Green", "Blue"
            });
            segControl.Frame            = new CGRect(0, 25, View.Bounds.Size.Width, 25);
            segControl.BackgroundColor  = UIColor.White;
            segControl.AutoresizingMask = (UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin);

            // Set subview tint colors
            var subViews = segControl.Subviews;

            subViews[0].TintColor = UIColor.LightGray;
            subViews[1].TintColor = UIColor.Red;
            subViews[2].TintColor = UIColor.Green;
            subViews[3].TintColor = UIColor.Blue;
            // set staring index
            segControl.SelectedSegment = 0;
            // Add it
            View.Add(segControl);



            segControl.ValueChanged += (sender, e) => {
                switch (segControl.SelectedSegment)
                {
                case 0:
                    v.CircleColor = UIColor.LightGray;
                    break;

                case 1:
                    v.CircleColor = UIColor.Red;
                    break;

                case 2:
                    v.CircleColor = UIColor.Green;
                    break;

                case 3:
                    v.CircleColor = UIColor.Blue;
                    break;

                default:
                    break;
                }
            };
        }
Ejemplo n.º 2
0
        public override void LoadView()
        {
            // Create a view
            CGRect frame = UIScreen.MainScreen.Bounds;
            frame.Y += 23;
            frame.Height -= 23;
            HypnosisView v = new HypnosisView(frame);

            // Set it as the view of this view controller
            this.View = v;

            // Create a segmented control
            segControl = new UISegmentedControl(new string[4]{"Grey","Red", "Green", "Blue"});
            segControl.Frame = new CGRect(0, 25, View.Bounds.Size.Width, 25);
            segControl.BackgroundColor = UIColor.White;
            segControl.AutoresizingMask = (UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin);

            // Set subview tint colors
            var subViews = segControl.Subviews;
            subViews[0].TintColor = UIColor.LightGray;
            subViews[1].TintColor = UIColor.Red;
            subViews[2].TintColor = UIColor.Green;
            subViews[3].TintColor = UIColor.Blue;
            // set staring index
            segControl.SelectedSegment = 0;
            // Add it
            View.Add(segControl);

            segControl.ValueChanged += (sender, e) =>  {
                switch (segControl.SelectedSegment)
                {
                    case 0:
                        v.CircleColor = UIColor.LightGray;
                        break;
                    case 1:
                        v.CircleColor = UIColor.Red;
                        break;
                    case 2:
                        v.CircleColor = UIColor.Green;
                        break;
                    case 3:
                        v.CircleColor = UIColor.Blue;
                        break;
                    default:
                        break;

                }
            };
        }
Ejemplo n.º 3
0
        public override void MotionBegan(UIEventSubtype motion, UIEvent evt)
        {
            HypnosisView view = this.View as HypnosisView;

            if (motion == UIEventSubtype.MotionShake)
            {
                Console.WriteLine("Device started shaking");
                if (view.CircleColor != UIColor.Orange)
                {
                    lastSelectedColor          = view.CircleColor;
                    lastSelectedSegmentIndex   = segControl.SelectedSegment;
                    view.CircleColor           = UIColor.Orange;
                    segControl.SelectedSegment = -1;
                }
                else
                {
                    view.CircleColor           = lastSelectedColor;
                    segControl.SelectedSegment = lastSelectedSegmentIndex;
                }
            }
        }