コード例 #1
0
ファイル: UtilsDroid.cs プロジェクト: ammogcoder/mobile
        public static int ExtraMargin(DroidVariable widgetFunc, ScreenSize screenSize, double multiplier)
        {
            int offset = 0;

            if (widgetFunc.ViewX is Switch)
            {
                offset = (int)AutoScaleFunction.TransformSize(UtilsDroid.SWITCH_MARGIN, screenSize.Width, 3);
                if (screenSize.Width <= AutoScaleFunction.BASE_WIDTH)
                {
                    offset = SWITCH_MARGIN; // from -45, 480
                }
                //offset = -112; // (before -168) // from 1200
                //offset = -135; // from 1440
            }
            return(offset);
        }
コード例 #2
0
ファイル: DroidVariable.cs プロジェクト: ammogcoder/mobile
        public virtual void AdjustTranslation(DroidVariable location, bool isX, bool sameWidget = true)
        {
            int        offset     = 0;
            ScreenSize screenSize = UtilsDroid.GetScreenSize();

            if (isX && sameWidget && ViewX is Switch)
            {
                offset = (int)AutoScaleFunction.TransformSize(UtilsDroid.SWITCH_MARGIN, screenSize.Width, 3);
                if (screenSize.Width <= AutoScaleFunction.BASE_WIDTH)
                {
                    offset = UtilsDroid.SWITCH_MARGIN; // from -45, 480
                }
                //offset = -112; // (before -168) // from 1200
                //offset = -135; // from 1440
            }
            location.TranslationX += offset;
        }
コード例 #3
0
ファイル: DroidVariable.cs プロジェクト: ammogcoder/mobile
        public void ProcessTranslationY(DroidVariable location)
        {
            if (location.RuleY == "CENTER" && WidgetType == UIType.LABEL)
            {
                int deltaY = (int)AutoScaleFunction.TransformSize(20, UtilsDroid.GetScreenSize().Width);;
                location.TranslationY += deltaY;
            }

            if (location.TranslationY < 0 && location.LayoutRuleY == LayoutRules.AlignParentTop)
            {
                location.TranslationY = 0;
            }
            else if (location.ViewY is Spinner)
            {
                if (location.LayoutRuleY == LayoutRules.AlignParentBottom ||
                    location.LayoutRuleY == LayoutRules.Below)
                {
                    location.ExtraY        = (int)AutoScaleFunction.TransformSize(10, UtilsDroid.GetScreenSize().Width);
                    location.TranslationY -= location.ExtraY;
                }
            }
        }
コード例 #4
0
        void CreatePicker()
        {
            if (!m_init)
            {
                Forms.Init();
                SfPickerRenderer.Init();
                m_init = true;
            }

            m_picker = new SfPicker();
            ViewX    = UtilsiOS.ConvertFormsToNative(m_picker, m_rect);

            string str1 = "", str2 = "", str3 = "", str4 = "";

            Utils.Extract(m_data, ref str1, ref str2, ref str3, ref str4);
            if (!string.IsNullOrEmpty(str1))
            {
                double rowHeight = Utils.ConvertToDouble(str1);
                if (rowHeight > 0)
                {
                    rowHeight = AutoScaleFunction.TransformSize((int)rowHeight,
                                                                (int)UtilsiOS.GetScreenSize().Width);
                    m_picker.ItemHeight = rowHeight;
                }
            }

            m_picker.ShowHeader = !string.IsNullOrEmpty(str2);
            if (m_picker.ShowHeader)
            {
                m_picker.HeaderHeight = 40;
                m_picker.HeaderText   = str2;
            }
            m_picker.ShowColumnHeader = !string.IsNullOrEmpty(str3);
            if (m_picker.ShowColumnHeader)
            {
                m_picker.ColumnHeaderHeight = 40;
                m_picker.ColumnHeaderText   = str3;
            }

            m_picker.ShowFooter    = false;
            m_picker.SelectedIndex = 0;

            m_picker.PickerMode   = PickerMode.Default;
            m_picker.PickerWidth  = m_rect.Width;
            m_picker.PickerHeight = m_rect.Height;

            m_picker.BackgroundColor             = Color.Transparent;
            m_picker.HeaderBackgroundColor       = Color.Transparent;
            m_picker.ColumnHeaderBackgroundColor = Color.Transparent;
            m_picker.HeaderTextColor             = Color.Black;
            m_picker.UnSelectedItemTextColor     = Color.LightGray;
            m_picker.SelectedItemTextColor       = Color.Black;

            m_picker.SelectionChanged += (sender, e) => {
                ActionDelegate?.Invoke(WidgetName, e.NewValue.ToString());
            };

            m_picker.OnPickerItemLoaded += (sender, e) => {
                if (m_pics == null)
                {
                    return;
                }
                int row = e.Row;

                CustomRowView view = new CustomRowView(m_rect.Width);

                if (m_pics.Count > row)
                {
                    UIImageView rowPic = new UIImageView(m_pics[row]);
                    view.AddSubview(rowPic);
                }

                if (m_strings != null && m_strings.Count > row)
                {
                    UILabel rowText = new UILabel();
                    rowText.Text            = m_strings[row];
                    rowText.TextAlignment   = m_alignment;
                    rowText.BackgroundColor = m_bgColor;
                    //rowText.BackgroundColor = UIColor.Clear;
                    rowText.TextColor = m_fontColor;
                    view.AddSubview(rowText);
                }

                e.View = view.ToView();
            };

            m_picker.HeaderFontSize           = m_picker.ColumnHeaderFontSize =
                m_picker.SelectedItemFontSize = m_picker.UnSelectedItemFontSize = 15;
        }