예제 #1
0
        public static void ShowView(iOSVariable view, bool showIt, bool tabChange)
        {
            bool explicitlyHidden = m_hiddenViews.Contains(view);

            if (explicitlyHidden && tabChange)
            {
                return;
            }

            /*UIView uiview = view.ViewX;
             * if (uiview == null) {
             * uiview = AppDelegate.GetCurrentView();
             * }
             * uiview.Hidden = !showIt;*/
            view.ShowHide(showIt);

            if (tabChange)
            {
                return;
            }
            if (!showIt && !explicitlyHidden)
            {
                m_hiddenViews.Add(view);
            }
            else if (showIt && explicitlyHidden)
            {
                m_hiddenViews.Remove(view);
            }
        }
예제 #2
0
        public static void SetValues(iOSVariable widgetFunc, string valueStr)
        {
            if (string.IsNullOrWhiteSpace(valueStr))
            {
                return;
            }
            widgetFunc.InitValue = new Variable(valueStr);

            // currValue:minValue:maxValue:step

            double minValue = 0, maxValue = 1, currValue = 0, step = 1.0;

            string[] vals = valueStr.Split(new char[] { ',', ':' });
            Double.TryParse(vals[0].Trim(), out currValue);

            if (vals.Length > 1)
            {
                Double.TryParse(vals[1].Trim(), out minValue);
                if (vals.Length > 2)
                {
                    Double.TryParse(vals[2].Trim(), out maxValue);
                }
                if (vals.Length > 3)
                {
                    Double.TryParse(vals[3].Trim(), out step);
                }
            }
            else
            {
                minValue = maxValue = currValue;
            }

            if (widgetFunc.ViewX is UISwitch)
            {
                ((UISwitch)widgetFunc.ViewX).On = (int)currValue == 1;
            }
            else if (widgetFunc.ViewX is UISlider)
            {
                ((UISlider)widgetFunc.ViewX).MinValue = (float)minValue;
                ((UISlider)widgetFunc.ViewX).MaxValue = (float)maxValue;
                ((UISlider)widgetFunc.ViewX).Value    = (float)currValue;
            }
            else if (widgetFunc.ViewX is UISegmentedControl)
            {
                UISegmentedControl seg = widgetFunc.ViewX as UISegmentedControl;
                for (int i = 0; i < vals.Length; i++)
                {
                    seg.InsertSegment(vals[i], i, false);
                }
                seg.SelectedSegment = 0;
            }
            else
            {
                widgetFunc.CurrVal = currValue;
                widgetFunc.MinVal  = minValue;
                widgetFunc.MaxVal  = maxValue;
                widgetFunc.Step    = step;
            }
        }
예제 #3
0
 public void RemoveView(iOSVariable view)
 {
     if (view == null)
     {
         return;
     }
     view.ViewY?.RemoveFromSuperview();
     view.ViewX?.RemoveFromSuperview();
     m_views.Remove(view);
 }
예제 #4
0
 public static void AddView(iOSVariable view)
 {
     if (m_activeTab == null)
     {
         m_nonTabViews.Add(view);
         return;
     }
     m_activeTab.AddView(view);
     m_view2Tab[view] = m_activeTab;
 }
예제 #5
0
        public UIView GetParentView()
        {
            iOSVariable parent = ParentView as iOSVariable;

            if (parent != null)
            {
                return(parent.ViewX);
            }
            return(AppDelegate.GetCurrentView());
        }
예제 #6
0
        public static void RemoveView(iOSVariable view)
        {
            iOSTab tab;

            if (m_view2Tab.TryGetValue(view, out tab))
            {
                tab.RemoveView(view);
            }
            else
            {
                RemoveNonTabView(view);
            }
        }
예제 #7
0
        public static UIView GetView(string viewName, ParsingScript script)
        {
            if (viewName.Equals("root", StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }
            ParserFunction func = ParserFunction.GetFunction(viewName);

            Utils.CheckNotNull(viewName, func);
            Variable    viewValue = func.GetValue(script);
            iOSVariable viewVar   = viewValue as iOSVariable;

            return(viewVar.ViewX);
        }
예제 #8
0
        /*public void CreateComplexView(CGRect rect, string extras, string config)
         * {
         * if (WidgetType == UIType.STEPPER) {
         *  if (ViewX != null && ViewX.Subviews.Length > 1) {
         *    // Already created: just move it.
         *    ViewX.Frame = rect;
         *    return;
         *  }
         *  CreateStepper(rect, extras);
         * } else if (WidgetType == UIType.COMBOBOX) {
         *  if (ViewX != null) {
         *    // Already created: just move it.
         *    ViewX.Frame = rect;
         *    return;
         *  }
         *  CreateCombobox(rect, config);
         * }
         * m_allComplex.Add(this);
         * }*/

        static void ResetCombos()
        {
            for (int i = 0; i < m_allComplex.Count; i++)
            {
                iOSVariable complex = m_allComplex[i];
                if (complex.m_picker != null)
                {
                    complex.m_picker.Hidden = true;
                }
                if (complex.m_button2 != null)
                {
                    complex.m_button2.Hidden = true;
                }
            }
        }
예제 #9
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);
 }
예제 #10
0
 public void AddView(iOSVariable view)
 {
     m_views.Add(view);
 }
예제 #11
0
 public static void RemoveNonTabView(iOSVariable view)
 {
     view.ViewY?.RemoveFromSuperview();
     view.ViewX?.RemoveFromSuperview();
     m_nonTabViews.Remove(view);
 }
예제 #12
0
        public static int String2Position(string param, UIView referenceView,
                                          iOSVariable location, CGSize parentSize, bool isX)
        {
            bool useRoot = referenceView == null;

            int refX      = useRoot ? 0 : (int)referenceView.Frame.Location.X;
            int refY      = useRoot ? 0 : (int)referenceView.Frame.Location.Y;
            int refWidth  = useRoot ? (int)parentSize.Width : (int)referenceView.Frame.Size.Width;
            int refHeight = useRoot ? (int)parentSize.Height : (int)referenceView.Frame.Size.Height;

            int parentWidth  = (int)parentSize.Width;
            int parentHeight = (int)parentSize.Height;

            int widgetWidth  = (int)location.Width;
            int widgetHeight = (int)location.Height;

            switch (param)
            {
            case "ALIGN_LEFT":     // X
                return(useRoot ? 0 :
                       refX);

            case "LEFT":     // X
                return(useRoot ? 0 :
                       refX - widgetWidth);

            case "ALIGN_RIGHT":     // X
                return(useRoot ? parentWidth - widgetWidth :
                       refX + refWidth - widgetWidth);

            case "RIGHT":     // X
                return(useRoot ? parentWidth - widgetWidth :
                       refX + refWidth);

            case "ALIGN_PARENT_TOP":
            case "ALIGN_TOP":     // Y
                return(useRoot ? ROOT_TOP_MIN :
                       refY);

            case "TOP":
                return(useRoot ? ROOT_TOP_MIN :
                       refY - widgetHeight);

            case "ALIGN_PARENT_BOTTOM":
            case "ALIGN_BOTTOM":
                int offset1 = useRoot ? parentHeight - widgetHeight :
                              refY + refHeight - widgetHeight;
                // if there is a tabbar, move the bottom part up:
                if (useRoot && !isX)
                {
                    offset1 -= iOSApp.GetVerticalOffset();
                }
                return(offset1);

            case "BOTTOM":
                int offset2 = useRoot ? parentHeight - widgetHeight :
                              refY + refHeight;
                // if there is a tabbar, move the bottom part up:
                if (useRoot && !isX)
                {
                    offset2 -= iOSApp.GetVerticalOffset();
                }
                return(offset2);

            case "CENTER":
                if (useRoot)
                {
                    return(isX ? (parentWidth - widgetWidth) / 2 :
                           (parentHeight - widgetHeight) / 2);
                }
                else
                {
                    return(isX ? refX + (refWidth - widgetWidth) / 2 :
                           refY + (refHeight - widgetHeight) / 2);
                }

            default:
                return(0);
            }
        }
예제 #13
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);
        }
예제 #14
0
        public override Variable Clone()
        {
            iOSVariable newVar = (iOSVariable)this.MemberwiseClone();

            return(newVar);
        }