Exemplo n.º 1
0
        void AddSwipeDelete()
        {
            UIButton rightSwipeViewText = new UIButton();

            rightSwipeViewText.SetTitle("Delete", UIControlState.Normal);
            rightSwipeViewText.SetTitleColor(UIColor.White, UIControlState.Normal);
            rightSwipeViewText.VerticalAlignment = UIControlContentVerticalAlignment.Center;
            rightSwipeViewText.BackgroundColor   = UIColor.FromRGB(220, 89, 95);
            rightSwipeViewText.TouchDown        += (sender, e) => {
                m_model.RemovePoint(m_rowIndex);
            };

            UIButton rightSwipeViewButton = new UIButton();

            rightSwipeViewButton.SetImage(UtilsiOS.LoadImage("Delete"), UIControlState.Normal);
            rightSwipeViewButton.BackgroundColor     = UIColor.FromRGB(220, 89, 95);
            rightSwipeViewButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            rightSwipeViewButton.TouchDown          += (sender, e) => {
                m_model.RemovePoint(m_rowIndex);
            };

            CustomSwipeView rightSwipeView = new CustomSwipeView();

            rightSwipeView.AddSubview(rightSwipeViewButton);
            rightSwipeView.AddSubview(rightSwipeViewText);

            m_grid.RightSwipeView = rightSwipeView;
        }
Exemplo n.º 2
0
        public virtual bool SetFontColor(string colorStr)
        {
            if (ViewX == null)
            {
                return(false);
            }

            UIColor color = UtilsiOS.String2Color(colorStr);

            if (ViewX is UIButton)
            {
                UIButton button = (UIButton)ViewX;
                button.SetTitleColor(color, UIControlState.Normal);
            }
            else if (ViewX is UILabel)
            {
                ((UILabel)ViewX).TextColor = color;
            }
            else if (ViewX is UITextField)
            {
                ((UITextField)ViewX).TextColor = color;
            }
            else if (ViewX is UITextView)
            {
                ((UITextView)ViewX).TextColor = color;
            }
            else
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        public bool AddAppointment(string subject, string startStr, string endStr, string colorStr,
                                   string dateFormat)
        {
            if (m_calendar == null)
            {
                return(false);
            }
            SFAppointment appointment = new SFAppointment();

            appointment.Subject = (NSString)subject;
            DateTime dt = DateTime.ParseExact(startStr, dateFormat, null);

            appointment.StartTime = (NSDate)DateTime.SpecifyKind(dt, DateTimeKind.Local);
            dt = DateTime.ParseExact(endStr, dateFormat, null);
            appointment.EndTime = (NSDate)DateTime.SpecifyKind(dt, DateTimeKind.Local);
            appointment.AppointmentBackground = UtilsiOS.String2Color(colorStr);

            var appointments = m_calendar.Appointments;

            if (appointments == null)
            {
                appointments = new NSMutableArray();
            }
            appointments.Add(appointment);
            m_calendar.Appointments = appointments;

            return(true);
        }
Exemplo n.º 4
0
        public static void ShowToast(String message, UIColor fgColor = null,
                                     UIColor bgColor = null,
                                     double duration = 10.0f,
                                     float width     = 320, float height = 60)
        {
            if (fgColor == null)
            {
                fgColor = UIColor.White;
            }
            if (bgColor == null)
            {
                bgColor = UIColor.Gray;
            }

            width = (float)iOSApp.AdjustSize(width);

            CGSize screen = UtilsiOS.GetScreenSize();
            var    size   = new CGSize(width, height);
            var    x      = (screen.Width - size.Width) / 2.0;
            var    y      = screen.Height - size.Height - 120 * WidthMultiplier();

            var point = new CGPoint(x, y);

            UIView view = AppDelegate.GetCurrentView();

            ShowToast(message, fgColor, bgColor, view, point, size, duration);
        }
Exemplo n.º 5
0
        public virtual void AddText(string text, string colorStr, double alpha = 1.0)
        {
            if (!(m_viewX is UITextView))
            {
                return;
            }
            var textView = m_viewX as UITextView;
            NSMutableAttributedString attrText = new NSMutableAttributedString(textView.AttributedText);

            var atts = new UIStringAttributes();

            atts.ForegroundColor = UtilsiOS.String2Color(colorStr, alpha);
            var attrTextAdd = new NSAttributedString(text, atts);

            //attributedString.BeginEditing();
            //attributedString.AddAttribute(UIStringAttributeKey.ForegroundColor, atts.ForegroundColor, new NSRange(0, 10));
            //attributedString.AddAttribute(UIStringAttributeKey.Font, UIFont.GetPreferredFontForTextStyle(UIFontTextStyle.Headline), new NSRange(0, 10));
            //attributedString.EndEditing();

            if (attrText.Length > 0)
            {
                attrText.Append(new NSAttributedString("\n"));
            }
            attrText.Append(attrTextAdd);
            textView.AttributedText = attrText;
        }
Exemplo n.º 6
0
        public static void GetAdSize(string arg, ref int width, ref int height)
        {
            AdSize adSize = GetAdSize(arg);

            width  = (int)adSize.Size.Width;
            height = (int)adSize.Size.Height;

            if (width == 0 || height == 0)
            {
                var screenSize = UtilsiOS.GetScreenSize();
                width = (int)screenSize.Width;
                if (screenSize.Height <= 400)
                {
                    height = 16;
                }
                else if (screenSize.Height <= 720)
                {
                    height = 25;
                }
                else
                {
                    height = 45;
                }
            }
        }
Exemplo n.º 7
0
 public CGSize GetParentSize()
 {
     if (ParentView != null)
     {
         return(new CGSize(ParentView.Width, ParentView.Height));
     }
     return(UtilsiOS.GetScreenSize());
 }
Exemplo n.º 8
0
        public static UIImage CreateComboboxImage(CGRect rect)
        {
            UIImage comboImage = UtilsiOS.ImageOfSize("combobox", new CGSize(rect.Height, rect.Height));

            UIImage img = UtilsiOS.AddMarge(comboImage, new CGSize(rect.Width, rect.Height));

            return(img);
        }
Exemplo n.º 9
0
 static int GetMinBottomOffset()
 {
     if (Instance.m_selectedTab < 0)
     {
         return(UtilsiOS.IsiPhoneX() ? UtilsiOS.ROOT_BOTTOM_MIN_X : 0);
     }
     return(UtilsiOS.ROOT_BOTTOM_MIN);
 }
Exemplo n.º 10
0
        public virtual void AddData(List <string> data, string varName, string title, string extra)
        {
            if (ViewX is UIPickerView)
            {
                UIPickerView pickerView = ViewX as UIPickerView;

                TypePickerViewModel model = pickerView.Model as TypePickerViewModel;
                if (model == null)
                {
                    model = new TypePickerViewModel(AppDelegate.GetCurrentController());
                }
                model.Data = data;

                if (!string.IsNullOrWhiteSpace(title))
                {
                    model.RowSelected += (row) => {
                        UIVariable.GetAction(title, varName, row.ToString());
                    };
                }
                if (!string.IsNullOrWhiteSpace(extra))
                {
                    var al = UtilsiOS.GetAlignment(extra);
                    model.Alignment = al.Item2;
                }

                model.SetSize((int)pickerView.Bounds.Width, (int)pickerView.Bounds.Height / 4);
                pickerView.Model = model;
            }
            else if (ViewX is UITableView)
            {
                UITableView tableView = ViewX as UITableView;

                TableViewSource source = tableView.Source as TableViewSource;
                if (source == null)
                {
                    source = new TableViewSource();
                }
                source.Data      = data;
                tableView.Source = source;
                tableView.ReloadData();
            }
            else if (m_picker != null)
            {
                TypePickerViewModel model = m_picker.Model as TypePickerViewModel;
                model.Data = data;

                if (!string.IsNullOrEmpty(extra))
                {
                    Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al =
                        UtilsiOS.GetAlignment(extra);
                    model.Alignment = al.Item2;
                }
                m_picker.Model = model;

                SetText(data[0], extra, true /* triggered */);
            }
        }
Exemplo n.º 11
0
        public static bool IsiPhoneX()
        {
            CGSize screen = UtilsiOS.GetNativeScreenSize();

            return(screen.Height == 2688 || screen.Height == 2436 ||
                   screen.Height == 1792);
            // XS: 2436x1125 XS max: 2688x1242 XR: 1792x828
            // 8: 1334x750, 8 Plus: 1920x1080, SE,5: 1136x640, 4s: 960x640
        }
Exemplo n.º 12
0
        public static Stream ImageToStream(string imagePath)
        {
            var image = UtilsiOS.LoadImage(imagePath);

            Byte[] byteArray = null;
            using (var imageData = image.AsPNG()) {
                byteArray = new Byte[imageData.Length];
                Marshal.Copy(imageData.Bytes, byteArray, 0, Convert.ToInt32(imageData.Length));
            }
            var pngImageStream = new MemoryStream(byteArray);

            return(pngImageStream);
        }
Exemplo n.º 13
0
        public override bool SetFontColor(string colorStr)
        {
            UIColor color = UtilsiOS.String2Color(colorStr);

            m_fontColor = color;

            if (m_picker != null)
            {
                m_picker.HeaderTextColor         = color.ToColor();
                m_picker.ColumnHeaderTextColor   = color.ToColor();
                m_picker.UnSelectedItemTextColor = color.ToColor();
                m_picker.SelectedItemTextColor   = color.ToColor();
            }
            else if (m_chart != null && m_chart.Title != null)
            {
                m_chart.Title.TextColor = color;
            }
            else if (m_stepper != null)
            {
                m_stepper.TextColor         = color;
                m_stepper.BorderColor       = color;
                m_stepper.UpdownButtonColor = color;

                var settingsUp = m_stepper.IncrementButtonSettings;
                settingsUp.ButtonFontColor        = color;
                m_stepper.IncrementButtonSettings = settingsUp;
                var settingsDown = m_stepper.DecrementButtonSettings;
                settingsDown.ButtonFontColor      = color;
                m_stepper.DecrementButtonSettings = settingsDown;
            }
            else if (m_barcode != null)
            {
                m_barcode.TextColor = color;
            }
            else if (m_digitalGauge != null)
            {
                //m_digitalGauge.DimmedSegmentAlpha = 30;
                m_digitalGauge.DimmedSegmentColor = color;
                m_digitalGauge.CharacterColor     = color;
            }
            else if (m_circularGauge != null && m_circularGauge.Headers.Count > 0)
            {
                m_circularGauge.Headers[0].TextColor = color;
            }
            else
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 14
0
        public override bool SetBackgroundColor(string colorStr, double alpha = 1.0)
        {
            var color = UtilsiOS.String2Color(colorStr, alpha);

            m_bgColor = color;

            if (m_picker != null)
            {
                m_picker.BackgroundColor = color.ToColor();
            }
            else if (m_chart != null)
            {
                m_chart.BackgroundColor = color;
            }
            else if (m_stepper != null)
            {
                m_stepper.BackgroundColor = color;
            }
            else if (m_grid != null)
            {
                m_grid.BackgroundColor = color;
            }
            else if (m_barcode != null)
            {
                m_barcode.BackgroundColor = color;
            }
            else if (m_digitalGauge != null)
            {
                m_digitalGauge.BackgroundColor = color;
            }
            else if (m_circularGauge != null)
            {
                m_circularGauge.BackgroundColor = color;
                m_circularScale.BackgroundColor = color;
                //m_needlePointer.BackgroundColor = color;
                //m_rangePointer1.BackgroundColor = color;
                //m_rangePointer2.BackgroundColor = color;
            }
            else if (m_busyIndicator != null)
            {
                m_busyIndicator.BackgroundColor = color;
            }
            else
            {
                ViewX.BackgroundColor = color;
            }

            return(true);
        }
Exemplo n.º 15
0
        public static UIImage ImageOfSize(string imageName, CGSize destinationSize)
        {
            UIImage img = UtilsiOS.LoadImage(imageName);

            UIGraphics.BeginImageContext(destinationSize);

            CGRect newRect = new CGRect(0, 0, destinationSize.Width, destinationSize.Height);

            img.Draw(newRect);
            UIImage newImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(newImage);
        }
Exemplo n.º 16
0
        public static UIImage AddMarge(UIImage img, CGSize destinationSize)
        {
            var delta = destinationSize.Width - img.Size.Width;

            if (delta <= 0)
            {
                return(img);
            }
            var height = img.Size.Height;
            var width  = img.Size.Width;

            UIImage transpImg = UtilsiOS.ImageOfSize("transparent", new CGSize(delta, height));
            UIImage newImage  = UtilsiOS.MergeImages(transpImg, img);

            return(newImage);
        }
Exemplo n.º 17
0
        public virtual bool AlignText(string alignment)
        {
            if (string.IsNullOrEmpty(alignment))
            {
                return(false);
            }
            alignment = alignment.ToLower();

            Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al = UtilsiOS.GetAlignment(alignment);

            if (WidgetType == UIType.COMBOBOX)
            {
                SetComboboxAlignment(al.Item2);
            }
            else if (ViewX is UIButton)
            {
                ((UIButton)ViewX).HorizontalAlignment = al.Item1;
            }
            else if (ViewX is UILabel)
            {
                ((UILabel)ViewX).TextAlignment = al.Item2;
            }
            else if (ViewX is UITextField)
            {
                ((UITextField)ViewX).TextAlignment = al.Item2;
            }
            else if (ViewX is UITextView)
            {
                ((UITextView)ViewX).TextAlignment = al.Item2;
            }
            else if (ViewX is UIPickerView)
            {
                UIPickerView        picker = ViewX as UIPickerView;
                TypePickerViewModel model  = picker.Model as TypePickerViewModel;
                if (model != null)
                {
                    model.Alignment = al.Item2;
                }
            }
            else
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 18
0
        public static void AddTab(string text, string selectedImageName, string notSelectedImageName = null)
        {
            var selImage = UtilsiOS.LoadImage(selectedImageName);

            if (selImage == null)
            {
                throw new ArgumentException("Image [" + selectedImageName + "] not found.");
            }
            selImage = selImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);

            UIViewController tab = new UIViewController();

            tab.Title = text;
            tab.TabBarItem.SelectedImage = selImage;
            tab.TabBarItem.Image         = selImage;

            if (notSelectedImageName != null)
            {
                var image = UtilsiOS.LoadImage(notSelectedImageName);
                if (image == null)
                {
                    throw new ArgumentException("Image [" + notSelectedImageName + "] not found.");
                }
                image = image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal);
                tab.TabBarItem.Image = image;
            }

            List <UIViewController> controllers = Instance.ViewControllers == null ?
                                                  new List <UIViewController>() :
                                                  new List <UIViewController>(Instance.ViewControllers);

            controllers.Add(tab);
            Instance.ViewControllers = controllers.ToArray();

            m_activeTab = new iOSTab(tab, text);
            m_tabs.Add(m_activeTab);
            if (controllers.Count == 1)
            {
                // Lift the tabbar back up:
                Instance.OffsetTabBar();
            }

            m_allTabs[text] = m_tabs.Count - 1;
            SelectTab(m_tabs.Count - 1);
        }
Exemplo n.º 19
0
        public static double AdjustSize(double size)
        {
            double newSize = size;

            if (UtilsiOS.IsiPhoneXR())
            {
                newSize = size / 1.1f;
            }
            else if (UtilsiOS.IsiPhoneX())
            {
                newSize = size / 1.5f;
            }
            else if (UtilsiOS.IsiPhonePlus())
            {
                newSize = size / 1.3f;
            }
            return(newSize);
        }
Exemplo n.º 20
0
        public static int GetVerticalOffset()
        {
            int offset = GetMinBottomOffset();

            if (iOSApp.CurrentOffset == 0)
            {
                return(offset);
            }
            offset += (int)(iOSApp.CurrentOffset * 0.8);

            // Special dealing with iPhone X:
            if (UtilsiOS.IsiPhoneX())
            {
                offset += 6;
            }
            if (IsLandscape)
            {
                offset -= 2;
            }

            return(offset);
        }
Exemplo n.º 21
0
        public virtual bool SetBackgroundColor(string colorStr, double alpha = 1.0)
        {
            if (ViewX == null)
            {
                return(false);
            }
            if (colorStr.Equals("transparent", StringComparison.OrdinalIgnoreCase))
            {
                ViewX.Opaque = true;
                alpha        = 0.0;
            }
            else
            {
                ViewX.Opaque = false;
            }

            var color = UtilsiOS.String2Color(colorStr, alpha);

            ViewX.BackgroundColor = color;

            return(true);
        }
Exemplo n.º 22
0
 public static void AdjustSizes(string widgetType, iOSVariable location,
                                string text, ref int width, ref int height)
 {
     if (widgetType == "Picker")
     {
         height = (int)(height * COMBOBOX_EXTENTION);
         //location.TranslationY += COMBOBOX_Y_MARGIN;
     }
     else if (widgetType == "AdMobBanner")
     {
         //AdMob.GetAdSize(text, ref width, ref height);
     }
     if (widgetType == "TypePicker" || widgetType == "Picker")
     {
         int screenWidth = (int)UtilsiOS.GetRealScreenWidth();
         if (screenWidth <= AutoScaleFunction.BASE_WIDTH)
         {
             // Check Combo height for smaller iPhones
             height = Math.Max(height, MAX_COMBO_HEIGHT_SMALL);
         }
     }
     location.SetSize(width, height);
 }
Exemplo n.º 23
0
        void AddSwipeEdit()
        {
            UIButton leftSwipeViewText = new UIButton();

            leftSwipeViewText.SetTitle("Edit", UIControlState.Normal);
            leftSwipeViewText.SetTitleColor(UIColor.White, UIControlState.Normal);
            leftSwipeViewText.VerticalAlignment = UIControlContentVerticalAlignment.Center;
            leftSwipeViewText.BackgroundColor   = UIColor.FromRGB(0, 158, 218);
            leftSwipeViewText.TouchDown        += EditDataGrid;

            UIButton leftSwipeViewButton = new UIButton();

            leftSwipeViewButton.SetImage(UtilsiOS.LoadImage("Edit"), UIControlState.Normal);
            leftSwipeViewButton.BackgroundColor = UIColor.FromRGB(0, 158, 218);
            leftSwipeViewButton.TouchDown      += EditDataGrid;

            CustomSwipeView leftSwipeView = new CustomSwipeView();

            leftSwipeView.AddSubview(leftSwipeViewButton);
            leftSwipeView.AddSubview(leftSwipeViewText);

            m_grid.LeftSwipeView = leftSwipeView;
        }
Exemplo n.º 24
0
        public void CreateCombobox(CGRect rect, string argument)
        {
            UIView parent = GetParentView();

            WidgetType = UIVariable.UIType.COMBOBOX;

            UIView mainView   = AppDelegate.GetCurrentView();
            int    mainHeight = (int)mainView.Frame.Size.Height;
            int    mainWidth  = (int)mainView.Frame.Size.Width;

            int pickerHeight = Math.Min(mainHeight / 3, 320);
            int pickerWidth  = Math.Min(mainWidth, 640);
            int pickerY      = mainHeight - pickerHeight + 20;

            m_picker  = new UIPickerView();
            m_button  = new UIButton();
            m_button2 = new UIButton();

            m_button.Frame = rect;

            m_picker.Frame  = new CGRect(0, pickerY, pickerWidth, pickerHeight);
            m_button2.Frame = new CGRect(0, pickerY - 20, pickerWidth, 40);

            string alignment = "", color1 = "", color2 = "", closeLabel = "";

            Utils.Extract(argument, ref alignment, ref color1, ref color2, ref closeLabel);
            m_alignment = alignment;
            Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al =
                UtilsiOS.GetAlignment(alignment);

            m_viewY       = new UIView();
            m_viewY.Frame = new CGRect(0, 0, mainWidth, mainHeight);

            TypePickerViewModel model = new TypePickerViewModel(AppDelegate.GetCurrentController());

            /*model.RowSelected += (row) => {
             * string text = model.SelectedText;
             * SetText(text, alignment, true);
             * ActionDelegate?.Invoke(WidgetName, text);
             *
             * m_viewY.RemoveFromSuperview();
             * };*/
            m_picker.ShowSelectionIndicator = true;
            m_picker.Hidden = true;
            m_picker.Model  = model;

            if (!string.IsNullOrEmpty(color1))
            {
                m_viewY.BackgroundColor = UtilsiOS.String2Color(color1);
                if (string.IsNullOrEmpty(color2))
                {
                    color2 = color1;
                }
                m_picker.BackgroundColor = UtilsiOS.String2Color(color2);
            }

            //m_button.SetTitle(extraLabel, UIControlState.Normal);
            m_button.BackgroundColor = UIColor.Clear;
            m_button.SetTitleColor(UIColor.Black, UIControlState.Normal);
            m_button.Hidden             = false;
            m_button.Layer.BorderWidth  = 1;
            m_button.Layer.CornerRadius = 4;
            m_button.Layer.BorderColor  = UIColor.LightGray.CGColor;
            UIImage img = UtilsiOS.CreateComboboxImage(rect);

            m_button.SetBackgroundImage(img, UIControlState.Normal);
            m_button.ImageView.ClipsToBounds = true;
            m_button.ContentMode             = UIViewContentMode.Right;
            m_button.HorizontalAlignment     = al.Item1;
            m_button.TouchUpInside          += (sender, e) => {
                ResetCombos();
                m_button2.Hidden = false;
                m_picker.Hidden  = false;

                model = m_picker.Model as TypePickerViewModel;

                string text = GetText();
                int    row  = model.StringToRow(text);
                model.Selected(m_picker, (int)row, 0);
                mainView.BecomeFirstResponder();
                mainView.AddSubview(m_viewY);
            };

            if (string.IsNullOrEmpty(closeLabel))
            {
                closeLabel = "X";
            }
            m_button2.SetTitle(closeLabel + "\t", UIControlState.Normal);
            m_button2.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
            m_button2.BackgroundColor     = UIColor.FromRGB(100, 100, 100);
            m_button2.SetTitleColor(UIColor.White, UIControlState.Normal);
            m_button2.Hidden         = true;
            m_button2.TouchUpInside += (sender, e) => {
                m_button2.Hidden = true;
                m_picker.Hidden  = true;
                string text = model.SelectedText;
                SetText(text, alignment, true /* triggered */);
                ActionDelegate?.Invoke(WidgetName, text);

                m_viewY.RemoveFromSuperview();
                mainView.BecomeFirstResponder();
            };

            mainView.AddSubview(m_button);

            m_viewY.AddSubview(m_picker);
            m_viewY.AddSubview(m_button2);

            m_viewX     = m_button;
            m_viewX.Tag = ++m_currentTag;
        }
Exemplo n.º 25
0
        public static bool IsiPhoneX()
        {
            CGSize screen = UtilsiOS.GetNativeScreenSize();

            return(screen.Width == 1125);
        }
Exemplo n.º 26
0
        public virtual bool SetValue(string arg1, string arg2 = "")
        {
            double val = Utils.ConvertToDouble(arg1);

            CurrVal = val;
            if (m_viewY is UIStepper)
            {
                UIStepper stepper = m_viewY as UIStepper;
                stepper.Value = val;
                UIView[] subviews = m_viewX.Subviews;
                foreach (UIView view in subviews)
                {
                    if (view is UILabel)
                    {
                        UILabel label = view as UILabel;
                        label.Text = CurrVal.ToString();
                    }
                }
            }
            else if (WidgetType == UIType.COMBOBOX)
            {
                switch (arg1)
                {
                case "alignment":
                    Tuple <UIControlContentHorizontalAlignment, UITextAlignment> al =
                        UtilsiOS.GetAlignment(arg2);
                    m_button.HorizontalAlignment = al.Item1;
                    break;

                case "backgroundcolorpicker":
                    m_picker.BackgroundColor = UtilsiOS.String2Color(arg2);
                    break;

                case "backgroundcolorbutton2":
                    m_button2.BackgroundColor = UtilsiOS.String2Color(arg2);
                    break;

                case "fontcolor2":
                    m_button2.SetTitleColor(UtilsiOS.String2Color(arg2), UIControlState.Normal);
                    break;

                case "text2":
                    m_button2.SetTitle(arg2 + "\t", UIControlState.Normal);
                    break;
                }
                if (string.IsNullOrEmpty(arg1) || arg1 == "value")
                {
                    SetComboboxText("", (int)val);
                }
            }
            else if (m_viewX is UISwitch)
            {
                ((UISwitch)m_viewX).On = (int)val == 1;
            }
            else if (m_viewX is UISlider)
            {
                ((UISlider)m_viewX).Value = (float)val;
            }
            else if (m_viewX is UIStepper)
            {
                ((UIStepper)m_viewX).Value = (float)val;
            }
            else if (m_viewX is UIPickerView)
            {
                UIPickerView picker = m_viewX as UIPickerView;
                picker.Select((int)val, 0, true);
                TypePickerViewModel model = picker.Model as TypePickerViewModel;
                model?.Selected(picker, (int)val, 0);
            }
            else if (m_viewX is UISegmentedControl)
            {
                ((UISegmentedControl)m_viewX).SelectedSegment = (nint)val;
            }
            else
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 27
0
        public void CreateStepper(CGRect rect, string extraLabel)
        {
            UIView parent = GetParentView();

            WidgetType = UIVariable.UIType.STEPPER;
            UILabel label = null;

            int stepperX  = (int)(10 * UtilsiOS.WidthMultiplier());
            int stepperY  = (int)(4 * UtilsiOS.WidthMultiplier());
            int labelSize = (int)rect.Height;

            CGRect    stepRect = new CGRect(stepperX, stepperY, rect.Width, rect.Height);
            UIStepper stepper  = new UIStepper(stepRect);

            m_viewX = new UIView(rect);

            if (!string.IsNullOrWhiteSpace(extraLabel))
            {
                extraLabel = extraLabel.ToLower();
                nfloat labelWidth  = rect.Width - stepper.Bounds.Width;
                nfloat labelHeight = stepper.Bounds.Height;
                if (extraLabel.EndsWith("left"))
                {
                    stepperX = 0;
                    CGRect labelRect = new CGRect(stepperX, stepperY, labelWidth, labelHeight);
                    label = new UILabel(labelRect);
                    label.TextAlignment = UITextAlignment.Left;
                    stepRect            = new CGRect(stepperX + labelWidth, stepperY, stepper.Bounds.Width, stepper.Bounds.Height);
                    stepper             = new UIStepper(stepRect);
                }
                else
                {
                    CGRect labelRect = new CGRect(stepperX + stepper.Bounds.Width, stepperY, labelWidth, labelHeight);
                    label = new UILabel(labelRect);
                    label.TextAlignment = UITextAlignment.Right;
                }
                label.Text          = CurrVal.ToString();
                label.TextAlignment = UITextAlignment.Center;
                //label.SizeToFit();
                m_viewX.AddSubview(label);
            }
            // "5:3:50:1"
            double curr = 0, min = 0, max = 0, step = 0;

            Utils.Extract(extraLabel, ref curr, ref min, ref max, ref step);
            CurrVal = curr;
            MinVal  = min;
            MaxVal  = max;
            Step    = step;

            stepper.MinimumValue = (float)MinVal;
            stepper.MaximumValue = (float)MaxVal;
            stepper.Value        = (float)CurrVal;
            stepper.StepValue    = (float)Step;

            m_viewX.AddSubview(stepper);
            //m_viewY = stepper;

            stepper.ValueChanged += (sender, e) => {
                CurrVal = stepper.Value;
                if (label != null)
                {
                    label.Text = CurrVal.ToString();
                }
                ActionDelegate?.Invoke(WidgetName, CurrVal.ToString());
            };
        }
Exemplo n.º 28
0
        public virtual iOSVariable GetWidget(string widgetType, string widgetName, string initArg, CGRect rect)
        {
            UIVariable.UIType type       = UIVariable.UIType.NONE;
            iOSVariable       widgetFunc = null;
            UIView            widget     = null;

            switch (widgetType)
            {
            case "View":
                type   = UIVariable.UIType.VIEW;
                widget = new UIView(rect);
                break;

            case "Button":
                type   = UIVariable.UIType.BUTTON;
                widget = new UIButton(rect);
                //widget = new UIButton(UIButtonType.System);
                ((UIButton)widget).SetTitleColor(UIColor.Black, UIControlState.Normal);
                ((UIButton)widget).SetTitle(initArg, UIControlState.Normal);
                AddBorderFunction.AddBorder(widget);
                break;

            case "Label":
                type   = UIVariable.UIType.LABEL;
                widget = new UILabel(rect);
                ((UILabel)widget).TextColor = UIColor.Black;
                ((UILabel)widget).Text      = initArg;
                break;

            case "TextEdit":
                type   = UIVariable.UIType.TEXT_FIELD;
                widget = new UITextField(rect);
                ((UITextField)widget).TextColor   = UIColor.Black;
                ((UITextField)widget).Placeholder = initArg;
                MakeBottomBorder(widget, (int)rect.Width, (int)rect.Height);
                break;

            case "TextEditView":
                type   = UIVariable.UIType.TEXT_VIEW;
                widget = new UITextView(rect);
                ((UITextView)widget).TextColor = UIColor.Black;
                AddBorderFunction.AddBorder(widget);
                break;

            case "TextView":
                type   = UIVariable.UIType.TEXT_VIEW;
                widget = new UITextView(rect);
                ((UITextView)widget).TextColor = UIColor.Black;
                ((UITextView)widget).Editable  = false;
                AddBorderFunction.AddBorder(widget);
                break;

            case "ImageView":
                type   = UIVariable.UIType.IMAGE_VIEW;
                widget = new UIImageView(rect);
                if (!string.IsNullOrWhiteSpace(initArg))
                {
                    UIImage img = UtilsiOS.LoadImage(initArg);
                    ((UIImageView)widget).Image = img;
                }
                break;

            case "Combobox":
                type       = UIVariable.UIType.COMBOBOX;
                widgetFunc = new iOSVariable(type, widgetName, widget);
                widgetFunc.CreateCombobox(rect, initArg);
                break;

            case "TypePicker":
                type   = UIVariable.UIType.PICKER_VIEW;
                widget = new UIPickerView(rect);
                ((UIPickerView)widget).AutosizesSubviews = true;
                break;

            case "Picker":
                type   = UIVariable.UIType.PICKER_IMAGES;
                widget = new UIPickerView(rect);
                ((UIPickerView)widget).AutosizesSubviews = true;
                break;

            case "ListView":
                type   = UIVariable.UIType.LIST_VIEW;
                widget = new UITableView(rect);
                ((UITableView)widget).AutosizesSubviews = true;
                ((UITableView)widget).AutoresizingMask  = UIViewAutoresizing.FlexibleBottomMargin;
                ((UITableView)widget).BackgroundColor   = UIColor.Clear;
                break;

            case "Switch":
                type   = UIVariable.UIType.SWITCH;
                widget = new UISwitch(rect);
                break;

            case "Slider":
                type   = UIVariable.UIType.SLIDER;
                widget = new UISlider(rect);
                break;

            case "Stepper":
                type       = UIVariable.UIType.STEPPER;
                widgetFunc = new iOSVariable(type, widgetName, widget);
                widgetFunc.CreateStepper(rect, initArg);
                break;

            case "SegmentedControl":
                type   = UIVariable.UIType.SEGMENTED;
                widget = new UISegmentedControl(rect);
                break;
                //default:
                //  type = UIVariable.UIType.VIEW;
                //  widget = new UIView(rect);
                //  break;
            }
            SetOptionsFunction.SetMultiline(widget);

            if (widgetFunc == null)
            {
                widgetFunc = new iOSVariable(type, widgetName, widget);
            }
            //iOSVariable widgetFunc = new iOSVariable(type, widgetName, widget);
            SetValues(widgetFunc, initArg);

            return(widgetFunc);
        }
Exemplo n.º 29
0
        public static bool IsiPhoneXR()
        {
            CGSize screen = UtilsiOS.GetNativeScreenSize();

            return(screen.Height == 1792);
        }
Exemplo n.º 30
0
        public static void SetBgColor(string colorStr, double alpha = 1.0)
        {
            var color = UtilsiOS.String2Color(colorStr, alpha);

            m_view.BackgroundColor = color;
        }