Пример #1
1
		public DateChartView ()
		{
			SFChart chart 						= new SFChart ();
			chart.Title.Text					= (NSString)"Average Sales Comparison";
			SFDateTimeAxis dateTimeAxis 		= new SFDateTimeAxis ();
			dateTimeAxis.EdgeLabelsDrawingMode  = SFChartAxisEdgeLabelsDrawingMode.Hide;
			dateTimeAxis.IntervalType 			= SFChartDateTimeIntervalType.Years;
			dateTimeAxis.Interval 				= new NSNumber(1);

			NSDateFormatter formatter			= new NSDateFormatter ();
			formatter.DateFormat				= "MM/yyyy";

			dateTimeAxis.LabelStyle.LabelFormatter	= formatter;
			dateTimeAxis.LabelRotationAngle			= -60;

			chart.PrimaryAxis 					= dateTimeAxis;
			chart.PrimaryAxis.Title.Text    	= new NSString ("Sales Across Years");

			chart.SecondaryAxis 				= new SFNumericalAxis ();
			chart.SecondaryAxis.Minimum 		= new NSNumber(0);
			chart.SecondaryAxis.Maximum 		= new NSNumber(100);
			chart.SecondaryAxis.Interval 		= new NSNumber(10);
			chart.SecondaryAxis.Title.Text 		= new NSString ("Sales Amount in Millions (USD)");

			NSNumberFormatter numberFormatter 	= new NSNumberFormatter ();
			numberFormatter.NumberStyle 		= NSNumberFormatterStyle.Currency;
			numberFormatter.MinimumFractionDigits	= 0;

			chart.SecondaryAxis.LabelStyle.LabelFormatter  = numberFormatter;

			DateTimeDataSource dataModel 	= new DateTimeDataSource ();
			chart.DataSource 				= dataModel as SFChartDataSource;
			this.control = chart;
		}
Пример #2
0
        public MultipleAxes()
        {
            SFChart        chart       = new SFChart();
            SFCategoryAxis primaryAxis = new SFCategoryAxis();

            primaryAxis.LabelPlacement = SFChartLabelPlacement.BetweenTicks;
            primaryAxis.Title.Text     = new NSString("Years");
            chart.PrimaryAxis          = primaryAxis;
            chart.SecondaryAxis        = new SFNumericalAxis()
            {
                ShowMajorGridLines = false
            };
            chart.SecondaryAxis.Title.Text = new NSString("Revenue (in millions)");
            NSNumberFormatter formatter = new NSNumberFormatter();

            formatter.PositiveFormat = "$";
            chart.SecondaryAxis.LabelStyle.LabelFormatter = formatter;
            chart.Legend.Visible = true;
            chart.Legend.ToggleSeriesVisibility = true;
            chart.Legend.ItemMargin             = new UIEdgeInsets(0, 0, 50, 20);
            MultipleAxisDataSource dataModel = new MultipleAxisDataSource();

            chart.DataSource = dataModel as SFChartDataSource;
            this.AddSubview(chart);
        }
Пример #3
0
        public MultipleAxes()
        {
            SFChart chart = new SFChart();

            chart.Title.Text     = new NSString("Mutiple Axes");
            chart.Legend.Visible = true;
            chart.Legend.ToggleSeriesVisibility = true;
            chart.Legend.DockPosition           = SFChartLegendPosition.Bottom;
            chart.Legend.IconWidth  = 14;
            chart.Legend.IconHeight = 14;

            chart.ColorModel.Palette = SFChartColorPalette.Natural;

            SFCategoryAxis primaryAxis = new SFCategoryAxis();

            primaryAxis.LabelPlacement = SFChartLabelPlacement.BetweenTicks;
            primaryAxis.Title.Text     = new NSString("Years");
            chart.PrimaryAxis          = primaryAxis;
            chart.SecondaryAxis        = new SFNumericalAxis()
            {
                ShowMajorGridLines = false
            };
            chart.SecondaryAxis.Title.Text = new NSString("Revenue (in millions)");
            NSNumberFormatter formatter = new NSNumberFormatter();

            formatter.PositiveFormat = "$";
            chart.SecondaryAxis.LabelStyle.LabelFormatter = formatter;

            ChartViewModel dataModel = new ChartViewModel();

            SFColumnSeries series = new SFColumnSeries();

            series.ItemsSource     = dataModel.MultipleAxisData;
            series.XBindingPath    = "XValue";
            series.YBindingPath    = "YValue";
            series.EnableTooltip   = true;
            series.Label           = new NSString("Revenue");
            series.EnableAnimation = true;
            chart.Series.Add(series);

            SFLineSeries series1 = new SFLineSeries();

            series1.ItemsSource   = dataModel.MultipleAxisData1;
            series1.XBindingPath  = "XValue";
            series1.YBindingPath  = "YValue";
            series1.EnableTooltip = true; series1.Label = new NSString("Customers");
            series1.YAxis         = new SFNumericalAxis()
            {
                OpposedPosition    = true,
                Minimum            = new NSNumber(0),
                Maximum            = new NSNumber(80),
                Interval           = new NSNumber(5),
                ShowMajorGridLines = false
            };
            series1.YAxis.Title.Text = new NSString("Number of Customers");
            series1.EnableAnimation  = true;
            chart.Series.Add(series1);

            this.AddSubview(chart);
        }
Пример #4
0
        public Pie()
        {
            SFChart chart = new SFChart();

            chart.Title.Text     = new NSString("Sales by Sales Person");
            chart.Legend.Visible = true;
            ChartViewModel dataModel = new ChartViewModel();

            SFPieSeries series = new SFPieSeries();

            series.StrokeColor          = UIColor.White;
            series.ItemsSource          = dataModel.PieSeriesData;
            series.XBindingPath         = "XValue";
            series.YBindingPath         = "YValue";
            series.StartAngle           = 50;
            series.EndAngle             = 410;
            series.CircularCoefficient  = 0.65f;
            series.EnableSmartLabels    = true;
            series.DataMarker.ShowLabel = true;
            NSNumberFormatter formatter = new NSNumberFormatter();

            formatter.PositiveSuffix = "%";
            series.DataMarker.LabelStyle.LabelFormatter = formatter;
            chart.Legend.IconWidth              = 14;
            chart.Legend.IconHeight             = 14;
            chart.Legend.ToggleSeriesVisibility = true;
            series.EnableAnimation              = true;
            series.GroupTo            = 25;
            series.ColorModel.Palette = SFChartColorPalette.Natural;
            chart.Series.Add(series);

            this.AddSubview(chart);
        }
Пример #5
0
    public void ObjectSame()
    {
        var a = new NSNumberFormatter();
        var b = Runtime.GetNSObject <NSNumberFormatter>(a.Handle);

        Assert.AreSame(a, b);
    }
Пример #6
0
        public StepArea()
        {
            SFChart chart = new SFChart();

            chart.ColorModel.Palette = SFChartColorPalette.Natural;

            chart.Title.Text = new NSString("Electricity Production");
            SFNumericalAxis primaryAxis = new SFNumericalAxis();

            primaryAxis.Title.Text              = new NSString("Year");
            primaryAxis.Interval                = new NSNumber(2);
            primaryAxis.EdgeLabelsDrawingMode   = SFChartAxisEdgeLabelsDrawingMode.Shift;
            primaryAxis.ShowMajorGridLines      = false;
            primaryAxis.MajorTickStyle.LineSize = 8;

            chart.PrimaryAxis = primaryAxis;
            SFNumericalAxis secondaryAxis = new SFNumericalAxis();

            secondaryAxis.Title.Text = new NSString("Production (Billion as kWh)");
            secondaryAxis.Minimum    = new NSNumber(0);
            secondaryAxis.Maximum    = new NSNumber(600);
            secondaryAxis.Interval   = new NSNumber(100);
            secondaryAxis.AxisLineStyle.LineWidth  = 0;
            secondaryAxis.MajorTickStyle.LineWidth = 0;
            NSNumberFormatter formatter = new NSNumberFormatter();

            formatter.PositiveSuffix = "B";
            secondaryAxis.LabelStyle.LabelFormatter = formatter;
            chart.SecondaryAxis = secondaryAxis;
            ChartViewModel dataModel = new ChartViewModel();

            SFStepAreaSeries series1 = new SFStepAreaSeries();

            series1.ItemsSource     = dataModel.StepAreaData1;
            series1.XBindingPath    = "XValue";
            series1.YBindingPath    = "YValue";
            series1.EnableTooltip   = true;
            series1.Label           = "Renewable";
            series1.EnableAnimation = true;
            series1.LegendIcon      = SFChartLegendIcon.Rectangle;
            chart.Series.Add(series1);

            SFStepAreaSeries series2 = new SFStepAreaSeries();

            series2.ItemsSource     = dataModel.StepAreaData2;
            series2.XBindingPath    = "XValue";
            series2.YBindingPath    = "YValue";
            series2.EnableTooltip   = true;
            series2.Label           = "Non-Renewable";
            series2.EnableAnimation = true;
            series2.LegendIcon      = SFChartLegendIcon.Rectangle;
            chart.Series.Add(series2);

            chart.Legend.Visible = true;
            chart.Legend.ToggleSeriesVisibility = true;
            chart.Legend.IconWidth    = 14;
            chart.Legend.IconHeight   = 14;
            chart.Legend.DockPosition = SFChartLegendPosition.Bottom;
            this.AddSubview(chart);
        }
Пример #7
0
    public void NumberStyle()
    {
        var numberStyle = new NSNumberFormatter().NumberStyle;

        numberStyle = NSNumberFormatterStyle.Currency;
        Assert.AreEqual(NSNumberFormatterStyle.Currency, numberStyle);
    }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            adReceived          = true;
            SeqView.Hidden      = true;
            internetView.Hidden = true;

            numberFormatter             = new NSNumberFormatter();
            numberFormatter.Locale      = NSLocale.CurrentLocale;
            numberFormatter.NumberStyle = NSNumberFormatterStyle.Decimal;

            var appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate;

            if (String.IsNullOrEmpty(appDelegate.GuestToken) == true)
            {
                this.GetGuestTokenForPrizeView();
                this.GetThisWeekPrizeDic();
            }

            if (appDelegate.RecentSeqNum > 0)
            {
                this.LabelsSetting();
                lastSeqNum = appDelegate.RecentSeqNum - 1;
                tempNum    = lastSeqNum;
                this.GetPrizeBySeqDic(lastSeqNum);
                prizeTableView.ReloadData();
                this.ConfigureView();
                this.MakeSeqCount();
            }
        }
Пример #9
0
        public Pyramid()
        {
            SFChart chart = new SFChart();

            chart.Title.Text     = new NSString("Food Comparison Chart");
            chart.Legend.Visible = true;
            ChartViewModel dataModel = new ChartViewModel();

            SFPyramidSeries series = new SFPyramidSeries();

            series.ItemsSource        = dataModel.PyramidData;
            series.XBindingPath       = "XValue";
            series.YBindingPath       = "YValue";
            series.LegendIcon         = SFChartLegendIcon.Circle;
            chart.Legend.IconWidth    = 14;
            chart.Legend.IconHeight   = 14;
            series.ColorModel.Palette = SFChartColorPalette.Natural;
            series.EnableTooltip      = true;
            chart.Series.Add(series);

            chart.Legend.ToggleSeriesVisibility = true;

            var tooltip = new SFChartTooltipBehavior();
            NSNumberFormatter formatter = new NSNumberFormatter();

            formatter.PositiveSuffix = " cal";
            tooltip.LabelFormatter   = formatter;
            chart.AddChartBehavior(tooltip);
            this.AddSubview(chart);
        }
Пример #10
0
    public void PaddingPosition()
    {
        var paddingPosition = new NSNumberFormatter().PaddingPosition;

        paddingPosition = NSNumberFormatterPadPosition.BeforePrefix;
        Assert.AreEqual(NSNumberFormatterPadPosition.BeforePrefix, paddingPosition);
    }
Пример #11
0
    public void RoundingMode()
    {
        var roundingMode = new NSNumberFormatter().RoundingMode;

        roundingMode = NSNumberFormatterRoundingMode.Down;
        Assert.AreEqual(NSNumberFormatterRoundingMode.Down, roundingMode);
    }
Пример #12
0
        public SplineRangeArea()
        {
            SFChart chart = new SFChart();

            chart.ColorModel.Palette = SFChartColorPalette.Natural;

            chart.Title.Text = new NSString("Product Price Comparison");

            SFCategoryAxis primary = new SFCategoryAxis();

            primary.EdgeLabelsDrawingMode = SFChartAxisEdgeLabelsDrawingMode.Shift;
            primary.ShowMajorGridLines    = false;
            chart.PrimaryAxis             = primary;

            chart.SecondaryAxis = new SFNumericalAxis();
            chart.SecondaryAxis.ShowMajorGridLines = false;
            chart.SecondaryAxis.ShowMinorGridLines = false;
            chart.SecondaryAxis.Minimum            = new NSNumber(5);
            chart.SecondaryAxis.Maximum            = new NSNumber(55);
            chart.SecondaryAxis.Interval           = new NSNumber(5);
            NSNumberFormatter secondaryAxisFormatter = new NSNumberFormatter();

            secondaryAxisFormatter.PositivePrefix         = "$";
            chart.SecondaryAxis.LabelStyle.LabelFormatter = secondaryAxisFormatter;

            ChartViewModel dataModel = new ChartViewModel();

            SFSplineRangeAreaSeries series1 = new SFSplineRangeAreaSeries();

            series1.ItemsSource     = dataModel.RangeAreaData;
            series1.XBindingPath    = "XValue";
            series1.High            = "High";
            series1.Low             = "Low";
            series1.EnableTooltip   = true;
            series1.Label           = "Product A";
            series1.EnableAnimation = true;
            chart.Series.Add(series1);

            SFSplineRangeAreaSeries series2 = new SFSplineRangeAreaSeries();

            series2.ItemsSource     = dataModel.RangeAreaData1;
            series2.XBindingPath    = "XValue";
            series2.High            = "High";
            series2.Low             = "Low";
            series2.EnableTooltip   = true;
            series2.Label           = "Product B";
            chart.Legend.IconHeight = 14;
            series2.EnableAnimation = true;
            chart.Series.Add(series2);

            chart.Legend.Visible                = true;
            chart.Legend.IconWidth              = 14;
            chart.Legend.IconHeight             = 14;
            chart.ColorModel.Palette            = SFChartColorPalette.Natural;
            chart.Legend.ToggleSeriesVisibility = true;
            chart.Legend.DockPosition           = SFChartLegendPosition.Bottom;

            chart.PrimaryAxis.EdgeLabelsDrawingMode = SFChartAxisEdgeLabelsDrawingMode.Shift;
            this.AddSubview(chart);
        }
Пример #13
0
    public void NewObject()
    {
        var obj = new NSNumberFormatter();

        Assert.AreNotEqual(IntPtr.Zero, obj.ClassHandle);
        Assert.AreNotEqual(IntPtr.Zero, obj.Handle);
    }
Пример #14
0
        void ConfigureDataSource()
        {
            var formatter = new NSNumberFormatter {
                GroupingSize          = 3,
                UsesGroupingSeparator = true
            };

            var snapshot = InitialSnapshot();

            dataSource = new DataSource(tableView, CellProviderHandler);
            dataSource.ApplySnapshot(snapshot, false);

            UITableViewCell CellProviderHandler(UITableView tableView, NSIndexPath indexPath, NSObject obj)
            {
                var mountain = obj as MountainsController.Mountain;

                // Get a cell of the desired kind.
                var cell = tableView.DequeueReusableCell(key);

                if (cell == null)
                {
                    cell = new UITableViewCell(UITableViewCellStyle.Subtitle, key);
                }

                cell.TextLabel.Text       = mountain.Name;
                cell.DetailTextLabel.Text = formatter.StringFromNumber(NSNumber.FromInt32(mountain.Height));

                // Return the cell.
                return(cell);
            }
        }
		public MonitoringViewController (IntPtr handle) : base (handle)
		{
			locationManger = new CLLocationManager ();
			numberFormatter = new NSNumberFormatter () {
				NumberStyle = NSNumberFormatterStyle.Decimal
			};
			uuid = Defaults.DefaultProximityUuid;
		}
Пример #16
0
 public MonitoringViewController(IntPtr handle) : base(handle)
 {
     locationManger  = new CLLocationManager();
     numberFormatter = new NSNumberFormatter()
     {
         NumberStyle = NSNumberFormatterStyle.Decimal
     };
     uuid = Defaults.DefaultProximityUuid;
 }
Пример #17
0
        public static string FormatCurrency(this decimal amount, string currencyCode)
        {
            NSNumberFormatter formatter = new NSNumberFormatter();

            formatter.NumberStyle  = NSNumberFormatterStyle.Currency;
            formatter.CurrencyCode = currencyCode;

            return(formatter.StringFromNumber((NSNumber)(double)amount));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            #region InputValueController

            lbl_inputController.StringValue =
                @"Min, Max and Number are binded to InputValueController fields. InputValueController can change " +
                @"increment field in NSSteper. Min, Max and Increment can be changed dinamicly, you can input " +
                @"what you want but those NSTextFields accept only integer";

            InputController = new InputValueController(tf,
                                                       (number) => _viewModel.MyProperty = number, () => _viewModel.MyProperty,
                                                       0, 200, stp);

            InputController.Number = _viewModel.MyProperty;

            #endregion

            #region Formatter

            lbl_formatter.StringValue =
                @"Min, Max and Increment NSTextFields accepts only integer. " +
                @"NSNumberFormatter created programaticly";

            var numberFormatter = new NSNumberFormatter();
            numberFormatter.NumberStyle = NSNumberFormatterStyle.None;

            tf_min.Formatter       = numberFormatter;
            tf_max.Formatter       = numberFormatter;
            tf_increment.Formatter = numberFormatter;

            #endregion

            #region Delegate

            lbl_delegate.StringValue =
                @"For this NSTextFiled was created my own delegate, " +
                @"change text or press Esc, Enter key and you will se how it work";

            var dlg = new TextFieldDelegate();
            dlg.PressedEscKey += (sender, e) =>
                                 _alertWindow.ShowAlert("Alert", "In NSTextField you pressed Esc key", "OK");

            dlg.PressedEnterKey += (sender, e) =>
                                   _alertWindow.ShowAlert("Alert", "In NSTextField you pressed Enter key", "OK");

            dlg.TextChanged += (sender, e) => {
                var textField = (NSTextField)sender;
                TfText = textField.StringValue;
            };


            tf_delegate.Delegate = dlg;

            #endregion
        }
Пример #19
0
        NSNumberFormatter NumericFormatter()
        {
            if (!numericFormatter)
            {
                numericFormatter = NSNumberFormatter.TheNew();
                numericFormatter.SetFormatterBehavior(NSNumberFormatterBehaviorDefault);
            }

            return(numericFormatter);
        }
Пример #20
0
        private string CalculateBottomInset()
        {
            nfloat   bottomInset  = additionalInset + safeAreaInsets.Bottom;
            NSNumber bottomNumber = new NSNumber(bottomInset);

            var numberFormatter = new NSNumberFormatter();

            numberFormatter.Locale = new NSLocale("en-US");
            return(numberFormatter.StringFromNumber(bottomNumber));
        }
Пример #21
0
 public static string LocalizedPrice(this SKProduct product)
 {
     using (NSNumberFormatter numberFormatter = new NSNumberFormatter())
     {
         numberFormatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4;
         numberFormatter.NumberStyle       = NSNumberFormatterStyle.Currency;
         numberFormatter.Locale            = product.PriceLocale;
         return(numberFormatter.StringFromNumber(product.Price).ToString());
     }
 }
Пример #22
0
        public NSAttributedString AttributedTextForFraction(float frag)
        {
            var formatter = new NSNumberFormatter();

            formatter.MaximumFractionDigits = DisplayValueMaximumFractionDigits;
            formatter.MaximumIntegerDigits  = DisplayValueMaximumIntegerDigits;
            var str = formatter.StringFromNumber(frag * Math.Abs(To - From) + From) ?? "";

            return(new NSAttributedString(str));
        }
 /// <remarks>
 /// Use Apple's sample code for formatting a SKProduct price
 /// https://developer.apple.com/library/ios/#DOCUMENTATION/StoreKit/Reference/SKProduct_Reference/Reference/Reference.html#//apple_ref/occ/instp/SKProduct/priceLocale
 /// Objective-C version:
 ///    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
 ///    [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
 ///    [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
 ///    [numberFormatter setLocale:product.priceLocale];
 ///    NSString *formattedString = [numberFormatter stringFromNumber:product.price];
 /// </remarks>
 public static string LocalizedPrice(this SKProduct product)
 {
     var formatter = new NSNumberFormatter ();
     formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4;
     formatter.NumberStyle = NSNumberFormatterStyle.Currency;
     formatter.Locale = product.PriceLocale;
     var formattedString = formatter.StringFromNumber(product.Price);
     Console.WriteLine(" ** formatter.StringFromNumber("+product.Price+") = " + formattedString + " for locale " + product.PriceLocale.LocaleIdentifier);
     return formattedString;
 }
		public ConfigurationViewController (IntPtr handle) : base (handle)
		{
			var peripheralDelegate = new PeripheralManagerDelegate ();
			peripheralManager = new CBPeripheralManager (peripheralDelegate, DispatchQueue.DefaultGlobalQueue);
			numberFormatter = new NSNumberFormatter () {
				NumberStyle = NSNumberFormatterStyle.Decimal
			};
			uuid = Defaults.DefaultProximityUuid;
			power = Defaults.DefaultPower;
		}
Пример #25
0
        public RangeColumn()
        {
            SFChart chart = new SFChart();

            chart.ColorModel.Palette = SFChartColorPalette.Natural;

            chart.Title.Text = new NSString("Temperature Variation");
            chart.Title.Font = UIFont.SystemFontOfSize(13);
            SFCategoryAxis primary = new SFCategoryAxis();

            primary.LabelPlacement     = SFChartLabelPlacement.BetweenTicks;
            primary.ShowMajorGridLines = false;
            chart.PrimaryAxis          = primary;
            chart.SecondaryAxis        = new SFNumericalAxis();
            chart.SecondaryAxis.AxisLineStyle.LineWidth = 0;
            chart.SecondaryAxis.MajorTickStyle.LineSize = 0;
            chart.SecondaryAxis.Interval = new NSNumber(5);
            NSNumberFormatter formatter = new NSNumberFormatter();

            formatter.PositiveSuffix = "°C";
            chart.SecondaryAxis.LabelStyle.LabelFormatter = formatter;
            ChartViewModel dataModel = new ChartViewModel();

            SFRangeColumnSeries series1 = new SFRangeColumnSeries();

            series1.ItemsSource     = dataModel.RangeColumnData1;
            series1.XBindingPath    = "XValue";
            series1.High            = "High";
            series1.Low             = "Low";
            series1.EnableTooltip   = true;
            series1.Label           = "India";
            series1.EnableAnimation = true;
            series1.LegendIcon      = SFChartLegendIcon.SeriesType;
            chart.Series.Add(series1);

            SFRangeColumnSeries series2 = new SFRangeColumnSeries();

            series2.ItemsSource     = dataModel.RangeColumnData2;
            series2.XBindingPath    = "XValue";
            series2.High            = "High";
            series2.Low             = "Low";
            series2.EnableTooltip   = true;
            series2.Label           = "Germany";
            series2.EnableAnimation = true;
            series2.LegendIcon      = SFChartLegendIcon.SeriesType;
            chart.Series.Add(series2);

            chart.Legend.Visible                = true;
            chart.Legend.IconWidth              = 14;
            chart.Legend.IconHeight             = 14;
            chart.Legend.ToggleSeriesVisibility = true;
            chart.Legend.DockPosition           = SFChartLegendPosition.Bottom;

            this.AddSubview(chart);
        }
Пример #26
0
        void snippet2()
        {
            // >> chart-pie-format-cs
            series.LabelDisplayMode = TKChartPieSeriesLabelDisplayMode.Inside;

            var numberFormatter = new NSNumberFormatter();

            numberFormatter.NumberStyle            = NSNumberFormatterStyle.SpellOut;
            series.Style.PointLabelStyle.Formatter = numberFormatter;
            // << chart-pie-format-cs
        }
Пример #27
0
        public static string LocalizedPrice(this SKProduct product)
        {
            var formatter = new NSNumberFormatter();

            formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4;
            formatter.NumberStyle       = NSNumberFormatterStyle.Currency;
            formatter.Locale            = product.PriceLocale;
            var formattedString = formatter.StringFromNumber(product.Price);

            return(formattedString);
        }
 private void displayTimerResults()
 {
     UIApplication.SharedApplication.IdleTimerDisabled = false;
     NSDate endTime = new NSDate();
     double interval = endTime.SecondsSinceReferenceDate - startTime.SecondsSinceReferenceDate;
     NSNumber timeNumber = new NSNumber(interval);
     NSNumberFormatter formatter = new NSNumberFormatter();
     formatter.MaximumFractionDigits = 5;
     string formattedTime = formatter.StringFromNumber(timeNumber);
     this.timeLabel.Text = formattedTime;
 }
		public static string LocalizedPrice (this SKProduct product)
		{
			var formatter = new NSNumberFormatter {
				FormatterBehavior = NSNumberFormatterBehavior.Version_10_4,
				NumberStyle = NSNumberFormatterStyle.Currency,
				Locale = product.PriceLocale,
			};

			string formattedString = formatter.StringFromNumber (product.Price);
			return formattedString;
		}
        /// <remarks>
        /// Use Apple's sample code for formatting a SKProduct price
        /// https://developer.apple.com/library/ios/#DOCUMENTATION/StoreKit/Reference/SKProduct_Reference/Reference/Reference.html#//apple_ref/occ/instp/SKProduct/priceLocale
        /// Objective-C version:
        ///    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
        ///    [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
        ///    [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
        ///    [numberFormatter setLocale:product.priceLocale];
        ///    NSString *formattedString = [numberFormatter stringFromNumber:product.price];
        /// </remarks>
        public static string LocalizedPrice(this SKProduct product)
        {
            var formatter = new NSNumberFormatter();

            formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4;
            formatter.NumberStyle       = NSNumberFormatterStyle.Currency;
            formatter.Locale            = product.PriceLocale;
            var formattedString = formatter.StringFromNumber(product.Price);

            Console.WriteLine(" ** formatter.StringFromNumber(" + product.Price + ") = " + formattedString + " for locale " + product.PriceLocale.LocaleIdentifier);
            return(formattedString);
        }
Пример #31
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            seqArray                    = new ArrayList();
            adReceived                  = true;
            this.loginView.Hidden       = false;
            numberFormatter             = new NSNumberFormatter();
            numberFormatter.Locale      = NSLocale.CurrentLocale;
            numberFormatter.NumberStyle = NSNumberFormatterStyle.Decimal;
            this.seqView.Hidden         = true;
        }
Пример #32
0
        public ConfigurationViewController(IntPtr handle) : base(handle)
        {
            var peripheralDelegate = new PeripheralManagerDelegate();

            peripheralManager = new CBPeripheralManager(peripheralDelegate, DispatchQueue.DefaultGlobalQueue);
            numberFormatter   = new NSNumberFormatter()
            {
                NumberStyle = NSNumberFormatterStyle.Decimal
            };
            uuid  = Defaults.DefaultProximityUuid;
            power = Defaults.DefaultPower;
        }
Пример #33
0
        NSNumberFormatter FractionFormatter()
        {
            if (!fractionFormatter)
            {
                fractionFormatter = NSNumberFormatter.TheNew();
                fractionFormatter.SetNumberStyle(NSNumberFormatterDecimalStyle);
                fractionFormatter.SetFormatterBehavior(NSNumberFormatterBehaviorDefault);
                fractionFormatter.SetDecimalSeparator(".");
                fractionFormatter.SetUsesGroupingSeparator(false);
            }

            return(fractionFormatter);
        }
Пример #34
0
        private static string LocalizedPrice(SKProduct product)
        {
            var formatter = new NSNumberFormatter
            {
                FormatterBehavior = NSNumberFormatterBehavior.Version_10_4,
                NumberStyle       = NSNumberFormatterStyle.Currency,
                Locale            = product.PriceLocale,
            };

            string formattedString = formatter.StringFromNumber(product.Price);

            return(formattedString);
        }
Пример #35
0
        public override id init()
        {
            this = base.init();
            if (this != null)
            {
                _dateFormatter           = new NSDateFormatter();
                _dateFormatter.dateStyle = NSDateFormatterStyle.NSDateFormatterMediumStyle;
                _dateFormatter.timeStyle = NSDateFormatterStyle.NSDateFormatterMediumStyle;

                _decimalFormatter             = new NSNumberFormatter();
                _decimalFormatter.numberStyle = NSNumberFormatterStyle.NSNumberFormatterDecimalStyle;
            }
            return(this);
        }
Пример #36
0
        public void Update(Person person)
        {
            if (person == null)
            {
                throw new ArgumentNullException("person");
            }

            _photo.Image = person.Photo;
            UpdatePhotoConstraint();

            _ageValueLabel.Text           = NSNumberFormatter.LocalizedStringFromNumbernumberStyle(NSNumber.FromInt32(person.Age), NSNumberFormatterStyle.Decimal);
            _hobbiesValueLabel.Text       = person.Hobbies;
            _elevatorPitchValueLabel.Text = person.ElevatorPitch;
        }
		public override async void ViewWillAppear (bool animated)
		{
			base.ViewWillAppear (animated);
			if (HKHealthStore.IsHealthDataAvailable) {

				var success = await HealthStore.RequestAuthorizationToShareAsync (DataTypesToWrite, DataTypesToRead);

				if (!success.Item1) {
					Console.WriteLine ("You didn't allow HealthKit to access these read/write data types. " +
					"In your app, try to handle this error gracefully when a user decides not to provide access. " +
					"If you're using a simulator, try it on a device.");
					return;
				}

				numberFormatter = new NSNumberFormatter ();

				UpdateUsersAge ();
				UpdateUsersHeight ();
				UpdateUsersWeight ();
			}
		}
 public static string LocalizedPrice(this SKProduct product)
 {
     var formatter = new NSNumberFormatter();
     formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4;
     formatter.NumberStyle = NSNumberFormatterStyle.Currency;
     formatter.Locale = product.PriceLocale;
     return formatter.StringFromNumber(product.Price);
 }
Пример #39
0
 public static string SymbolForLocale(NSLocale locale)
 {
     NSNumberFormatter formatter = new NSNumberFormatter ();
     formatter.NumberStyle = NSNumberFormatterStyle.Currency;
     formatter.Locale = locale;
     return formatter.CurrencySymbol;
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            Title = "Shipping Rates";

            // Setup both operations to run
            var shopOperation = new GetShopOperation (client);
            shopOperation.DidReceiveShop += (op, shop) => {
                currencyFormatter = new NSNumberFormatter ();
                currencyFormatter.NumberStyle = NSNumberFormatterStyle.Currency;
                currencyFormatter.CurrencyCode = shop.Currency;
            };
            shopOperation.FailedToReceiveShop += (op, error) => {
                Console.WriteLine ("Failed to retrieve shop: {0}", error);
            };
            NSOperationQueue.MainQueue.AddOperation (shopOperation);

            var shippingOperation = new GetShippingRatesOperation (client, checkout);
            shippingOperation.DidReceiveShippingRates += (op, rates) => {
                shippingRates = rates;
            };
            shippingOperation.FailedToReceiveShippingRates += (op, error) => {
                Console.WriteLine ("Failed to retrieve shipping rates: {0}", error);
            };
            NSOperationQueue.MainQueue.AddOperation (shippingOperation);

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;

            // Ensure both operations are completed before we reload the table view
            var blockOperation = NSBlockOperation.Create (() => {
                UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
                TableView.ReloadData ();
            });
            blockOperation.AddDependency (shopOperation);
            blockOperation.AddDependency (shippingOperation);
            NSOperationQueue.MainQueue.AddOperation (blockOperation);

            allOperations = new NSOperation[] {
                blockOperation,
                shopOperation,
                shippingOperation
            };
        }
Пример #41
0
 /// <summary>
 /// Returns the currency symbol for the Current Locale
 /// </summary>
 public static string LocalCurrencySymbol()
 {
     NSNumberFormatter formatter = new NSNumberFormatter ();
     formatter.NumberStyle = NSNumberFormatterStyle.Currency;
     formatter.Locale = NSLocale.CurrentLocale;
     return formatter.CurrencySymbol;
 }
Пример #42
0
        public override string ToString()
        {
            NSNumberFormatter formatter = new NSNumberFormatter ();
            formatter.NumberStyle = NSNumberFormatterStyle.Decimal;
            formatter.Locale = NSLocale.CurrentLocale;
            formatter.MaximumFractionDigits = 2;

            string currencySymbol = ExchangeRates.SymbolForCurrencyCode(this.CurrencyCode);
            if (string.IsNullOrWhiteSpace(currencySymbol))
                currencySymbol = this.CurrencyCode;
            string formattedNumber = formatter.StringFromNumber (new NSNumber((double)(this.Value)));

            return String.Format("{0}{1}", currencySymbol, formattedNumber);
        }
Пример #43
0
            public string GetLocalizedPrice()
            {
                if (this.details == null)
                    return null;

                var formatter = new NSNumberFormatter();
                formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4;  
                formatter.NumberStyle = NSNumberFormatterStyle.Currency;
                formatter.Locale = this.details.PriceLocale;

                return formatter.StringFromNumber(this.details.Price);
            }
Пример #44
0
 private string LocalizedPrice(SKProduct product)
 {
     var formatter = new NSNumberFormatter();
     formatter.FormatterBehavior = NSNumberFormatterBehavior.Version_10_4;
     formatter.NumberStyle = NSNumberFormatterStyle.Currency;
     formatter.Locale = product.PriceLocale;
     var formattedString = formatter.StringFromNumber(product.Price);
     return formattedString;
 }