Exemplo n.º 1
0
        void AddColorPickerControl()
        {
            _colorPickerViewController = new PopColorPickerViewController();

            _colorPickerViewController.CancelButton.Clicked += (object sender, EventArgs e) =>
            {
                if (!IsIpad())
                {
                    _colorPickerViewController.NavigationController.PopViewController(true);
                }
                else
                {
                    _popoverController.Dismiss(true);
                }
            };

            _colorPickerViewController.DoneButton.Clicked += (object sender, EventArgs e) =>
            {
                if (!IsIpad())
                {
                    _colorPickerViewController.NavigationController.PopViewController(true);
                }
                else
                {
                    _popoverController.Dismiss(true);
                }
                nfloat r, g, b, a;
                _colorPickerViewController.SelectedColor.GetRGBA(out r, out g, out b, out a);
                _richTextEditor.SetTextColor((int)(r * 255), (int)(g * 255), (int)(b * 255));
            };

            _richTextEditor.LaunchColorPicker = () =>
            {
                if (!IsIpad())
                {
                    this.NavigationController.PushViewController(_colorPickerViewController, true);
                }
                else
                {
                    var navController = new UINavigationController(_colorPickerViewController);

                    _popoverController = new UIPopoverController(navController);
                    _popoverController.PresentFromRect(_toolbarHolder.Frame, View, UIPopoverArrowDirection.Down, true);
                }
            };
        }
Exemplo n.º 2
0
        public override void ViewDidLoad()
        {
            colourPickerViewController = new PopColorPickerViewController();

            colourPickerViewController.CancelButton.Clicked += (object sender, EventArgs e) =>
            {
                DismissViewController(true, null);
            };

            colourPickerViewController.DoneButton.Clicked += (object sender, EventArgs e) =>
            {
                DismissViewController(true, null);
                selectedColour.Layer.BackgroundColor = colourPickerViewController.SelectedColor.CGColor;
                SelectColour(selectedColour);
            };

            ChangeColourButton.TouchUpInside += ChangeColourButtonPressed;
            Colour1.TouchUpInside            += ColourTouched;
            Colour2.TouchUpInside            += ColourTouched;
            SelectColour(Colour1);

            TouchToCanvas.canvasImg     = Canvas;
            TouchToCanvas.canvasTempImg = TempCanvas;
            BrushSlider.SetValue(8, false);
            UpdateBrushPreview();

            if (thisTask.TaskType.IdName == "DRAW_PHOTO")
            {
                var suppress = LoadBGImage();
            }

            // Add save icon
            UIBarButtonItem saveButton = new UIBarButtonItem(
                UIImage.FromBundle("SaveIcon"),
                UIBarButtonItemStyle.Plain,
                (s, e) => {
                var suppressWarning = SaveAndReturn();
            }
                );

            NavigationItem.RightBarButtonItem = saveButton;
        }
Exemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            _colorPickerViewController = new PopColorPickerViewController();

            _colorPickerViewController.CancelButton.Clicked += (object sender, EventArgs e) =>
            {
                if (UserInterfaceIdiomIsPhone)
                {
                    DismissViewController(true, null);
                }
                else
                {
                    _popoverController.Dismiss(true);
                }

                Console.WriteLine("Cancel Action 1");
            };

            _colorPickerViewController.DoneButton.Clicked += (object sender, EventArgs e) =>
            {
                if (UserInterfaceIdiomIsPhone)
                {
                    DismissViewController(true, null);
                }
                else
                {
                    _popoverController.Dismiss(true);
                }

                this.View.BackgroundColor = _colorPickerViewController.SelectedColor;
                Console.WriteLine("Done Action 1");
            };

            button1.TouchUpInside += Button1_TouchUpInside;
        }
        void KeyboardWillShow(NSNotification notification)
        {
            if (contentView != null)
            {
                InputAssistantItem.LeadingBarButtonGroups = new[] { new UIBarButtonItemGroup(_uiToolbarItems.ToArray(), null) }
            }
            ;
        }

        void StyleScrollView()
        {
            var width = this.View.Frame.Width - 44;

            if (IsIpad())
            {
                width = this.View.Frame.Width;
            }
            _toolbarScroll = new UIScrollView()
            {
                Frame = new CGRect(0, 0, width, 44)
            };
            _toolbarScroll.BackgroundColor = UIColor.Clear;
            _toolbarScroll.ShowsVerticalScrollIndicator = false;
        }

        void StyleToolbar()
        {
            _toolbar = new UIToolbar(_toolbarScroll.Frame);
            _toolbar.BackgroundColor = UIColor.Clear;
            _toolbarScroll.AddSubview(_toolbar);
            _toolbarScroll.AutoresizingMask = _toolbar.AutoresizingMask;
        }

        void AddColorPickerControl()
        {
            _colorPickerViewController = new PopColorPickerViewController();

            _colorPickerViewController.CancelButton.Clicked += (object sender, EventArgs e) =>
            {
                if (IsIpad())
                {
                    _popoverController.Dismiss(true);
                }
                else
                {
                    _colorPickerViewController.NavigationController.PopViewController(true);
                }
            };

            _colorPickerViewController.DoneButton.Clicked += (object sender, EventArgs e) =>
            {
                if (IsIpad())
                {
                    _popoverController.Dismiss(true);
                }
                else
                {
                    _colorPickerViewController.NavigationController.PopViewController(true);
                }


                nfloat r, g, b, a;
                _colorPickerViewController.SelectedColor.GetRGBA(out r, out g, out b, out a);
                _richTextEditor.SetTextColor((int)(r * 255), (int)(g * 255), (int)(b * 255));
            };

            _richTextEditor.LaunchColorPicker = () =>
            {
                if (IsIpad())
                {
                    var navController = new UINavigationController(_colorPickerViewController);

                    _popoverController = new UIPopoverController(navController);
                    _popoverController.PresentFromRect(_toolbarHolder.Frame, View, UIPopoverArrowDirection.Down, true);
                }
                else
                {
                    this.NavigationController.PushViewController(_colorPickerViewController, true);
                }
            };
        }

        void LayoutToolBarHolder()
        {
            float toolbarHeight = _uiToolbarItems.Count > 0 ? 44f : 0f;

            UIToolbar backgroundToolbar = new UIToolbar()
            {
                Frame = new CGRect(0, 0, this.View.Frame.Width, toolbarHeight)
            };

            backgroundToolbar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;

            _toolbarHolder = new UIView(new CGRect(0, this.View.Frame.Height, this.View.Frame.Width, toolbarHeight));
            _toolbarHolder.AutoresizingMask = _toolbar.AutoresizingMask;
            _toolbarHolder.AddSubview(_toolbarScroll);
            _toolbarHolder.InsertSubview(backgroundToolbar, 0);
            // Hide Keyboard
            if (!IsIpad())
            {
                // Toolbar holder used to crop and position toolbar
                UIView toolbarCropper = new UIView(new CGRect(this.View.Frame.Width - toolbarHeight, 0, 44, toolbarHeight));
                toolbarCropper.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin;
                toolbarCropper.ClipsToBounds    = true;

                // Use a toolbar so that we can tint
                UIToolbar keyboardToolbar = new UIToolbar(new CGRect(-7, -1, 44, toolbarHeight));
                toolbarCropper.AddSubview(keyboardToolbar);

                _keyboardItem = new UIBarButtonItem(UIImage.FromFile("ZSSkeyboard.png"), UIBarButtonItemStyle.Plain, delegate(object sender, EventArgs e)
                {
                    this.View.EndEditing(true);
                });

                keyboardToolbar.Items = new[] { _keyboardItem };

                _toolbarHolder.AddSubview(toolbarCropper);

                UIView line = new UIView(new CGRect(0, 0, 0.6, 44));
                line.BackgroundColor = UIColor.LightGray;
                line.Alpha           = (nfloat)0.7;
                toolbarCropper.AddSubview(line);
            }

            float toolbarWidth = _uiToolbarItems.Count == 0 ? 0.0f : ((_uiToolbarItems.Count * 39) + 50);

            _toolbar.Items             = _uiToolbarItems.ToArray();
            _toolbar.Frame             = new CGRect(0, 0, toolbarWidth, toolbarHeight);
            _toolbarScroll.ContentSize = new CGSize(_toolbar.Frame.Width, _toolbar.Frame.Height);

            if (!IsIpad())
            {
                this.View.AddSubview(_toolbarHolder);
            }
        }

        bool IsIpad()
        {
            return(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad);
        }