Example #1
0
        public void DateLocalizedStringFromDateComponents()
        {
            RequiresIos8();

            string formattedString = NSDateComponentsFormatter.LocalizedStringFromDateComponents(NowComponents, NSDateComponentsFormatterUnitsStyle.Full);

            TestFormattedString(formattedString, "LocalizedStringFromDateComponents");
        }
Example #2
0
        public static string FormatDuration(double duration)
        {
            var durationFormatter = new NSDateComponentsFormatter
            {
                UnitsStyle             = NSDateComponentsFormatterUnitsStyle.Positional,
                ZeroFormattingBehavior = NSDateComponentsFormatterZeroFormattingBehavior.Pad,
                AllowedUnits           = NSCalendarUnit.Second | NSCalendarUnit.Minute | NSCalendarUnit.Hour,
            };

            return(durationFormatter.StringFromTimeInterval(duration) ?? string.Empty);
        }
        private static NSDateComponentsFormatter GetDurationFormatter()
        {
            var formatter = new NSDateComponentsFormatter
            {
                UnitsStyle             = NSDateComponentsFormatterUnitsStyle.Positional,
                AllowedUnits           = NSCalendarUnit.Minute | NSCalendarUnit.Second,
                ZeroFormattingBehavior = NSDateComponentsFormatterZeroFormattingBehavior.Pad
            };

            return(formatter);
        }
Example #4
0
        void RequiresIos8()
        {
            TestRuntime.AssertXcodeVersion(6, 0);

            if (dateComponentsFormatter == null)
            {
                dateComponentsFormatter = new NSDateComponentsFormatter();
            }
            if (energyFormatter == null)
            {
                energyFormatter = new NSEnergyFormatter();
            }
        }
        void RequiresIos8()
        {
            TestRuntime.AssertXcodeVersion(6, 0);
            TestRuntime.AssertSystemVersion(ApplePlatform.MacOSX, 10, 10, throwIfOtherPlatform: false);

            if (dateComponentsFormatter == null)
            {
                dateComponentsFormatter = new NSDateComponentsFormatter();
            }
            if (energyFormatter == null)
            {
                energyFormatter = new NSEnergyFormatter();
            }
        }
Example #6
0
        void RequiresIos8()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(8, 0))
            {
                Assert.Inconclusive("Requires iOS8+");
            }

            if (dateComponentsFormatter == null)
            {
                dateComponentsFormatter = new NSDateComponentsFormatter();
            }
            if (energyFormatter == null)
            {
                energyFormatter = new NSEnergyFormatter();
            }
        }
Example #7
0
        public VideoAssetCell(IntPtr handle) : base(handle)
        {
            _durationFormatter = GetDurationFormatter();

            _durationLabel = new UILabel(CGRect.Empty);
            _gradientView  = new UIImageView(CGRect.Empty);
            _iconView      = new UIImageView(CGRect.Empty);

            _gradientView.Hidden = true;

            _iconView.TintColor   = UIColor.White;
            _iconView.ContentMode = UIViewContentMode.Center;

            _durationLabel.TextColor = UIColor.White;

            _durationLabel.Font          = UIFont.SystemFontOfSize(12, UIFontWeight.Semibold);
            _durationLabel.TextAlignment = UITextAlignment.Right;

            ContentView.AddSubview(_gradientView);
            ContentView.AddSubview(_durationLabel);
            ContentView.AddSubview(_iconView);
        }
Example #8
0
        public static string ShowInputBoxEx(string title, string informativeText, string defaultValue, string placeholder = "", int width = 0, NSFormatter textFormatter = null)
        {
            NSAlert alert = new NSAlert();

            alert.AddButton("OK");
            alert.AddButton("Cancel");

            if (!string.IsNullOrEmpty(title))
            {
                alert.MessageText = title;
            }

            if (!string.IsNullOrEmpty(informativeText))
            {
                alert.InformativeText = informativeText;
            }

            CGRect textFieldRect;

            if (width <= 0)
            {
                width = 300;
            }
            textFieldRect = new CGRect(0, 0, width, 36);

            CustomTextField tf = new CustomTextField(textFieldRect);

            tf.Alignment = NSTextAlignment.Center;
            tf.Font      = NSFont.SystemFontOfSize(16);

            var dc = new NSDateComponentsFormatter();

            dc.UnitsStyle   = NSDateComponentsFormatterUnitsStyle.Full;
            dc.AllowedUnits = NSCalendarUnit.Minute;

            if (textFormatter != null)
            {
                tf.Formatter = textFormatter;
            }

            if (!string.IsNullOrEmpty(defaultValue))
            {
                tf.StringValue = defaultValue;
            }
            if (!string.IsNullOrEmpty(placeholder))
            {
                tf.PlaceholderString = placeholder;
            }

            alert.AccessoryView = tf;
            alert.Window.InitialFirstResponder = tf;


            nint result = alert.RunModal();

            if (result == (int)NSAlertButtonReturn.First)
            {
                return(tf.StringValue);
            }

            return(null);
        }