private void number_part(StringBuilder builder)
        {
            // number_part = (unit_part level_part road_number_part / level_part sub_building_number road_number_part)
            //     unit_part = unit_type SP unit_number_part SP
            //         unit_number_part = ( / unit_prefix) ( / unit_number) ( / unit_suffix)
            //     level_part = ( / level_type SP ( / level_number_part SP))
            //         level_number_part = ( / level_prefix) ( / level_number) ( / level_suffix)
            //     sub_building_number = ( / unit_number_part "/")
            //     road_number_part = (number_first_part ("-" number_last_part) SP / lot_number_part)
            //         number_first_part = ( / number_first_prefix) number_first ( / number_first_suffix)
            //         number_last_part = ( / number_last_prefix) number_last ( / number_last_suffix)
            //         lot_number_part = ( / "LOT" SP ( / lot_number_prefix) ( / lot_number_first) ( / lot_number_suffix) SP)

            if (ComplexUnitType.HasValue())
            {
                // unit_part level_part
                builder.Append(ComplexUnitType).Append(Sp);

                if (ComplexUnitIdentifier.HasValue())
                {
                    builder.Append(ComplexUnitIdentifier).Append(Sp);
                }

                level_part(builder);
            }
            else
            {
                // level_part sub_building_number
                level_part(builder);

                if (ComplexUnitIdentifier.HasValue())
                {
                    builder.Append(ComplexUnitIdentifier).Append('/');
                }
            }

            // road_number_part
            if (StreetNumber1.HasValue())
            {
                // number_first_part ("-" number_last_part) SP
                builder.Append(StreetNumber1);

                if (StreetNumber2.HasValue())
                {
                    builder.Append('-');
                    builder.Append(StreetNumber2);
                }
            }
            else
            {
                // lot_number_part
                builder.Append("LOT");
                builder.Append(Sp);
                builder.Append(LotIdentifier);
            }
            builder.Append(Sp);
        }
Пример #2
0
        public override void SetTextSize([GeneratedEnum] ComplexUnitType unit, float size)
        {
            base.SetTextSize(unit, size);

            if (!TextSizeHelper.calculatedSize.HasValue)
            {
                TextSizeHelper.AdjustTextSizeIfRequired();
            }
        }
        /// <summary>
        /// 将[传入的单位值]与[传入的单位类型]转换为[px(像素)值]
        /// </summary>
        /// <param name="context"></param>
        /// <param name="value"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        static float ToPx(this Context context, float value, ComplexUnitType unit)
        {
            var result = TypedValue.ApplyDimension(
                unit,
                value,
                context.Resources?.DisplayMetrics);

            return(result);
        }
Пример #4
0
 public static float ConvertTextSize(Context context, ComplexUnitType unit, float size)
 {
     switch(unit)
     {
     case ComplexUnitType.Px:
         return size;
     default:
         return Utils.GetPixelsFromDP(context, size);
     }
 }
 public string[] GenerateCompletionAddresses(string locality, List <string> addresses)
 {
     addresses.Add(GenerateCompletionAddress(locality, true));
     if (SiteName.HasValue())
     {
         addresses.Add(GenerateCompletionAddress(locality, false));
     }
     if (ComplexUnitType.HasValue())
     {
         var addressWithoutUnitType = DeepCopyAttributes();
         addressWithoutUnitType.ComplexUnitType = null;
         addresses.Add(addressWithoutUnitType.GenerateCompletionAddress(locality, true));
         if (SiteName.HasValue())
         {
             addresses.Add(addressWithoutUnitType.GenerateCompletionAddress(locality, false));
         }
     }
     return(addresses.ToArray());
 }
Пример #6
0
        public Dimension(TypedValue val) : this()
        {
            if (val.Type != DataType.Dimension)
            {
                throw new ArgumentException("Wrong type: " + val.Type);
            }

            ComplexUnitType unit = (ComplexUnitType)((val.Data >> (int)ComplexUnitType.Shift) & (int)ComplexUnitType.Mask);

            switch (unit)
            {
            case ComplexUnitType.Dip:
                this.Unit = DimensionUnit.Dp;
                break;

            case ComplexUnitType.Sp:
                this.Unit = DimensionUnit.Sp;
                break;

            case ComplexUnitType.Px:
                this.Unit = DimensionUnit.Px;
                break;

            case ComplexUnitType.In:
                this.Unit = DimensionUnit.In;
                break;

            case ComplexUnitType.Mm:
                this.Unit = DimensionUnit.Mm;
                break;

            case ComplexUnitType.Pt:
                this.Unit = DimensionUnit.Pt;
                break;

            default:
                throw new Exception("Unexpected: " + (int)unit);
            }

            this.Value = TypedValue.ComplexToFloat(val.Data);
        }
 /**
  * Set the horizontal margin of the icon in the given unit (default is 16dp)
  * @param unit TypedValue
  * @param iconHorizontalMargin the margin in the given unit
  */
 public void SetIconHorizontalMargin(ComplexUnitType unit, int iconHorizontalMargin)
 {
     this._iconHorizontalMargin = (int)TypedValue.ApplyDimension(unit, iconHorizontalMargin,
                                                                 _recyclerView.Context.Resources.DisplayMetrics);
 }
 /**
  * Set the size of the text shown when swiping left
  * @param unit TypedValue (default is COMPLEX_UNIT_SP)
  * @param size the size value
  */
 public void SetSwipeLeftTextSize(ComplexUnitType unit, float size)
 {
     _mSwipeLeftTextUnit = unit;
     _mSwipeLeftTextSize = size;
 }
Пример #9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            ViewGroup listContainer = (ViewGroup)base.OnCreateView(inflater, container, savedInstanceState);

            TextView proj = new TextView(inflater.Context);

            proj.Gravity = GravityFlags.Center;

            ComplexUnitType ct = ComplexUnitType.Dip;

            proj.SetTextSize(ct, 20);
            proj.Text = _projectName;

            SwipeRefreshLayout srl = new SwipeRefreshLayout(inflater.Context);

            srl.AddView(listContainer, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            srl.LayoutParameters = (
                new ViewGroup.LayoutParams(
                    ViewGroup.LayoutParams.MatchParent,
                    ViewGroup.LayoutParams.MatchParent));


            LinearLayout ll = new LinearLayout(inflater.Context);

            ll.Orientation = Orientation.Vertical;

            LinearLayout.LayoutParams lp2 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            lp2.Gravity           = GravityFlags.Center;
            proj.LayoutParameters = lp2;


            View ruler = new View(inflater.Context);

            ruler.SetBackgroundColor(Color.Gray);

            ll.AddView(proj);
            ll.AddView(ruler,
                       new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, 2));
            ll.AddView(srl);

            _si = new ListOfProjects.Scrollinput(srl);

            srl.Refresh += async delegate
            {
                try
                {
                    await AddData(((MainActivity)Activity).Ctrl, _projectId);

                    srl.Refreshing = false;
                }
                catch (CannotReachServerException)
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                    builder.SetTitle("Unable to Connect")
                    .SetMessage("Please check your network connection and try again")
                    .SetNeutralButton("Okay", (sender, args) =>
                    {
                        builder.Dispose();
                    })
                    .SetCancelable(false);
                    AlertDialog alert = builder.Create();
                    alert.Show();
                }
                catch (StatusNotOkayException se)
                {
                    AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                    builder.SetTitle("An Error has occured")
                    .SetMessage("Error :" + se.GetMessage())
                    .SetNeutralButton("Okay", (sender, args) =>
                    {
                        builder.Dispose();
                    })
                    .SetCancelable(false);
                    AlertDialog alert = builder.Create();
                    alert.Show();
                }
                catch (Exception e)
                {
                    // For any other weird exceptions
                    AlertDialog.Builder builder = new AlertDialog.Builder(Activity);
                    builder.SetTitle("An Error has occured")
                    .SetNeutralButton("Okay", (sender, args) =>
                    {
                        builder.Dispose();
                    })
                    .SetMessage("Error :" + e.Message)
                    .SetCancelable(false);
                    AlertDialog alert = builder.Create();
                    alert.Show();
                }
            };
            return(ll);
        }
 public override void SetTextSize(ComplexUnitType unitType, float size)
 {
     base.SetTextSize(unitType, size);
     _textSize = TextSize;
 }
Пример #11
0
 public override void SetTextSize(ComplexUnitType unitType, float size)
 {
     base.SetTextSize(unitType, size);
     mTextSize = TextSize;
 }
Пример #12
0
 public override void SetTextSize(ComplexUnitType unit, float size)
 {
     _maxTextSize = size;
     base.SetTextSize (unit, size);
 }
Пример #13
0
        public void SetTextSize(ComplexUnitType unit, float size)
        {
            float dimension = TypedValue.ApplyDimension(unit, size, _resources.DisplayMetrics);

            this.SetRawTextSize(dimension);
        }
Пример #14
0
 // Calculates a screen dimension given a specified dimension in raw pixels
 internal static float CalculateScreenDimension(float pixels, ComplexUnitType screenUnitType = ComplexUnitType.Dip)
 {
     return(!DesignTime.IsDesignMode ?
            TypedValue.ApplyDimension(screenUnitType, pixels, GetDisplayMetrics()) : pixels);
 }
Пример #15
0
 public void SetTextSize(ComplexUnitType unit, float size)
 {
     _textSize = Utils.ConvertTextSize(_context, unit, size);
 }
Пример #16
0
 public void SetTextSize(ComplexUnitType unit, int size)
 {
     SetTextSize(unit, (float)size);
 }
Пример #17
0
		public override void SetTextSize (ComplexUnitType unit, float size)
		{
			base.SetTextSize(unit,size);
			mTextSize = this.TextSize;
		}
Пример #18
0
 public static int ConvertTextSize(Context context, ComplexUnitType unit, int size)
 {
     return (int)ConvertTextSize(context, unit, (float)size);
 }
Пример #19
0
 public FontSize(float value, ComplexUnitType unit)
 {
     Value = value;
     Unit  = unit;
 }
Пример #20
0
 /**
  * Set the size of the label to be shown while swiping left
  * @param unit the unit to convert from
  * @param size the size to be set
  * @return This instance of @RecyclerViewSwipeDecorator.Builder
  */
 public Builder SetSwipeLeftLabelTextSize(ComplexUnitType unit, float size)
 {
     _mDecorator.SetSwipeLeftTextSize(unit, size);
     return(this);
 }
        /// <inheritdoc cref="ToPx(Context,float, ComplexUnitType)"/>
        static int ToPxInt32(this Context context, float value, ComplexUnitType unit, NumberToInt32Format format = Format)
        {
            var result = ToPx(context, value, unit).ToInt32(format);

            return(result);
        }
Пример #22
0
 /**
  * Set the horizontal margin of the icon in the given unit (default is 16dp)
  * @param unit TypedValue
  * @param iconHorizontalMargin the margin in the given unit
  *
  * @return This instance of @RecyclerViewSwipeDecorator.Builder
  */
 public Builder SetIconHorizontalMargin(ComplexUnitType unit, int iconHorizontalMargin)
 {
     _mDecorator.SetIconHorizontalMargin(unit, iconHorizontalMargin);
     return(this);
 }
 // Calculates a screen dimension given a specified dimension in raw pixels
 internal static float CalculateScreenDimension(float pixels, ComplexUnitType screenUnitType = ComplexUnitType.Dip, Context?context = null)
 {
     return(!DesignTime.IsDesignMode ?
            TypedValue.ApplyDimension(screenUnitType, pixels, Internal.ViewExtensions.GetDisplayMetrics(context)) : pixels);
 }
 public ResultDialogBuilder SetTextSize(ComplexUnitType unit, float size)
 {
     _textView.SetTextSize(unit, size);
     return(this);
 }
Пример #25
0
        public override void SetTextSize([GeneratedEnum] ComplexUnitType unit, float size)
        {
            base.SetTextSize(unit, size);

            mTextSize = TextSize;
        }
Пример #26
0
 public static int ToSizeUnit(ComplexUnitType toUnit, int value)
 {
     return(Convert.ToInt32(TypedValue.ApplyDimension(toUnit, value, Application.Context.Resources.DisplayMetrics)));
 }
 public override void SetTextSize(ComplexUnitType unit, float size)
 {
     base.SetTextSize(unit, size);
     var fontMetrics = Paint.GetFontMetricsInt();
     _lineDecender = fontMetrics.Descent;
     if (EllipsizingLastFullyVisibleLine())
     {
         _isStale = true;
     }
 }