void UpdateDateFromModel(bool animate)
        {
            if (_picker.Date.ToDateTime().Date != Element.Date.Date)
            {
                _picker.SetDate(Element.Date.ToNSDate(), animate);
            }

            //can't use Element.Format because it won't display the correct format if the region and language are set differently
            if (String.IsNullOrWhiteSpace(Element.Format) || Element.Format.Equals("d") || Element.Format.Equals("D"))
            {
                NSDateFormatter dateFormatter = new NSDateFormatter();
                if (Element.Format?.Equals("D") == true)
                {
                    dateFormatter.DateStyle = NSDateFormatterStyle.Long;
                    var strDate = dateFormatter.StringFor(_picker.Date);
                    Control.Text = strDate;
                }
                else
                {
                    dateFormatter.DateStyle = NSDateFormatterStyle.Short;
                    var strDate = dateFormatter.StringFor(_picker.Date);
                    Control.Text = strDate;
                }
            }
            else if (Element.Format.Contains("/"))
            {
                Control.Text = Element.Date.ToString(Element.Format, CultureInfo.InvariantCulture);
            }
            else
            {
                Control.Text = Element.Date.ToString(Element.Format);
            }
        }
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell((NSString)"Cell", indexPath);

            if (indexPath.Section == 0)
            {
                if (indexPath.Row == 0)
                {
                    cell.TextLabel.Text       = "Walking";
                    cell.DetailTextLabel.Text = formatTimeInterval(activityDataManager.WalkingDuration);
                }
                else if (indexPath.Row == 1)
                {
                    cell.TextLabel.Text       = "Running";
                    cell.DetailTextLabel.Text = formatTimeInterval(activityDataManager.RunningDuration);
                }
                else if (indexPath.Row == 2)
                {
                    cell.TextLabel.Text       = "Driving";
                    cell.DetailTextLabel.Text = formatTimeInterval(activityDataManager.VehicularDuration);
                }
                else if (indexPath.Row == 3)
                {
                    cell.TextLabel.Text       = "Moving";
                    cell.DetailTextLabel.Text = formatTimeInterval(activityDataManager.MovingDuration);
                }
                else if (indexPath.Row == 4)
                {
                    cell.TextLabel.Text       = "Current activity";
                    cell.DetailTextLabel.Text = currentActivity;
                }
            }
            else if (indexPath.Section == 1)
            {
                cell.TextLabel.Text       = detailItem.IsToday ? "Live Step Counts" : "Step Counts";
                cell.DetailTextLabel.Text = (activityDataManager.StepCounts + currentSteps).ToString();
            }
            else if (indexPath.Section == 2)
            {
                var activity = activityDataManager.SignificantActivities [indexPath.Row];
                cell.TextLabel.Text = String.Format("{0} ({1} - {2})",
                                                    ActivityDataManager.ActivityTypeToString(activity.ActivityType),
                                                    dateFormatter.StringFor(activity.StartDate),
                                                    dateFormatter.StringFor(activity.EndDate));
                if (activity.ActivityType == ActivityType.Walking || activity.ActivityType == ActivityType.Running)
                {
                    cell.DetailTextLabel.Text = activity.StepCounts.ToString();
                }
                else
                {
                    cell.DetailTextLabel.Text = "n/a";
                }
            }

            return(cell);
        }
예제 #3
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad ();
     controller = this.ParentViewController as PetTabController;
     // Set all the labels with the pet's info
     this.BreedLabel.Text = "Breed: " + controller.pet.breed;
     this.ageLabel.Text = "Age: " + (controller.pet.age < 0 ? "" : controller.pet.age.ToString ());
     this.weightLabel.Text = "Weight: " + ( controller.pet.weight < 0 ? "" : controller.pet.weight + " kg");
     this.weightLabel.Text = "Weight: " + controller.pet.weight + " kg";
     NSDateFormatter format = new NSDateFormatter ();
     format.TimeStyle = NSDateFormatterStyle.None;
     format.DateStyle = NSDateFormatterStyle.Medium;
     this.birthdayLabel.Text = "Birthday: " + (controller.pet.birthday == null ? "" : format.StringFor (controller.pet.birthday));
     this.colorLabel.Text = "Color: " + controller.pet.bodyColor;
     this.eyeColorLabel.Text = "Eye Color: " + controller.pet.eyeColor;
     this.heightLabel.Text = "Height: " + (controller.pet.height < 0 ? "" : controller.pet.height + " cm");
     this.lengthLabel.Text = "Length: " + (controller.pet.length < 0 ? "" : controller.pet.length + " cm");
     if (controller.pet.identifyingMarks == null) {
         this.identifyingMarksLabel.Text = "Identifying Marks: None";
     } else {
         string marks = "Identifying Marks: ";
         for (int i = 0; i < controller.pet.identifyingMarks.Length; i++) {
             marks += controller.pet.identifyingMarks [i] + (i == controller.pet.identifyingMarks.Length - 1 ? "" : ", ");
         }// for
         this.identifyingMarksLabel.Text = marks;
     }// if-else
     this.idChipBrandLabel.Text = "ID Chip Brand: " + controller.pet.idBrand;
     this.idChipNumberLabel.Text = "ID Chip Number: " + controller.pet.idNumber;
     this.notesTextView.Text = "Notes : " + controller.pet.notes;
     this.profilePicture.Image = controller.pet.profilePicture;
     this.profilePicture.ClipsToBounds = true;
 }
        private async Task ShowTimePopup()
        {
            var dateTimeAlertController = new UIAlertController();

            var timePicker = new UIDatePicker();

            timePicker.Date = _selectedDate;
            timePicker.Mode = UIDatePickerMode.Time;
            timePicker.TranslatesAutoresizingMaskIntoConstraints = false;

            var rootView = dateTimeAlertController.View;

            rootView.AddSubview(timePicker);
            rootView.AddConstraints(timePicker.WithSameTop(rootView),
                                    timePicker.AtBottomOf(rootView, 100f),
                                    timePicker.WithSameLeft(rootView),
                                    timePicker.WithSameRight(rootView));

            dateTimeAlertController.AddAction(UIAlertAction.Create(ConstantsHelper.Ok, UIAlertActionStyle.Default, action =>
            {
                _selectedDate     = timePicker.Date;
                var timeFormatter = new NSDateFormatter {
                    DateFormat = "HH:mm"
                };
                _currentTimeField.Text = timeFormatter.StringFor(_selectedDate);
            }));
            dateTimeAlertController.AddAction(UIAlertAction.Create(ConstantsHelper.Cancel, UIAlertActionStyle.Cancel, null));
            await PresentViewControllerAsync(dateTimeAlertController, true);
        }
예제 #5
0
        public override UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
        {
            if (elementKind == UICollectionElementKindSectionKey.Header)
            {
                var album  = MomentAlbumList[indexPath.Section];
                var header = CollectionView.DequeueReusableSupplementaryView(elementKind, "MomentHeader", indexPath) as MomentSectionHeaderView;
                if (header != null)
                {
                    header.locationLabel.Text = album.Title;
                    if (album.Date != null)
                    {
                        var formatter = new NSDateFormatter();
                        formatter.DateStyle   = NSDateFormatterStyle.Long;
                        formatter.TimeStyle   = NSDateFormatterStyle.None;
                        header.dateLabel.Text = formatter.StringFor(album.Date);
                    }
                    else
                    {
                        header.dateLabel.Text = string.Empty;
                    }
                    return(header);
                }
                else
                {
                    throw new Exception("failed to create MomentHeader");
                }
            }
            return(null);

            //return base.GetViewForSupplementaryElement(collectionView, elementKind, indexPath);
        }
예제 #6
0
 public override string ToString()
 {
     NSDateFormatter df = new NSDateFormatter();
     df.TimeStyle = NSDateFormatterStyle.None;
     df.DateStyle = NSDateFormatterStyle.Full;
     return string.Format("NSDate:   {0}\nDateTime: {1} = {2} and {3}", df.StringFor(entryDate), EntryDate.ToLocalTime().ToLongDateString(), firstNumber, secondNumber);
 }
예제 #7
0
        private PWIInboxStyle GetInboxStyle()
        {
            PWIInboxStyle   style     = PWIInboxStyle.DefaultStyle();
            NSDateFormatter formatter = new NSDateFormatter
            {
                DateFormat = "dd.MM.yyyy"
            };

            style.DateFormatterBlock = (NSDate date, NSObject owner) => formatter.StringFor(date);
            style.AccentColor        = UIColor.Blue;
            style.BackgroundColor    = UIColor.White;
            style.BarAccentColor     = UIColor.Blue;
            style.BarBackgroundColor = UIColor.White;
            style.BarTextColor       = UIColor.Black;
            style.BarTitle           = "My title";
            style.DateColor          = UIColor.Black;
            style.TitleColor         = UIColor.Black;
            style.SeparatorColor     = UIColor.Gray;
            style.SelectionColor     = UIColor.Orange;
            style.DescriptionColor   = UIColor.Black;
            style.ListEmptyMessage   = "There is no inbox messages";
            style.ListErrorMessage   = "Some error happenned";
            style.DefaultImageIcon   = UIImage.FromBundle("Default");
            style.ListEmptyImage     = UIImage.FromBundle("Empty");
            style.ListErrorImage     = UIImage.FromBundle("Error");
            style.UnreadImage        = UIImage.FromBundle("Unread");
            style.TitleFont          = UIFont.SystemFontOfSize(20);
            style.DescriptionFont    = UIFont.SystemFontOfSize(18);
            style.DateFont           = UIFont.SystemFontOfSize(12);
            return(style);
        }
예제 #8
0
        partial void datumValueChanged(NSObject sender)
        {
            var formatter = new NSDateFormatter();

            formatter.DateFormat = "dd.MM.yyyy";
            datumValue.Text      = formatter.StringFor(datum.Date);
        }
예제 #9
0
		List<WeatherModel> addPopulationData()
		{
			List<WeatherModel> array = new List<WeatherModel>();

			NSDate now = NSDate.Now;


			string[] imagesArray = new string[] { "Cloudy.png", "Humid.png", "Rainy.png", "Warm.png", "Windy.png", "Cloudy.png", "Humid.png" };
			for (int i = 0; i < 7; i++)
			{
				int daysToAdd = i;
				NSDateComponents components = new NSDateComponents();
				components.Day = daysToAdd;

				NSCalendar gregorian =  NSCalendar.CurrentCalendar;

				NSDate newDate2 = gregorian.DateByAddingComponents(components, now, NSCalendarOptions.None);
				NSDateFormatter dateFormatter = new NSDateFormatter();
				dateFormatter.DateFormat = "EEEE, MMMM dd";

				NSDateFormatter dateFormatter1 = new NSDateFormatter();
				dateFormatter1.DateFormat = "EEEE";
				array.Add(new WeatherModel((NSString)dateFormatter.StringFor(newDate2), (NSString)imagesArray[i], (NSString)new Random().Next(10, 40).ToString(), (NSString)dateFormatter1.StringFor(newDate2)));
			}

			return array;
		}
예제 #10
0
        public override string ToString()
        {
            NSDateFormatter df = new NSDateFormatter();

            df.TimeStyle = NSDateFormatterStyle.None;
            df.DateStyle = NSDateFormatterStyle.Full;
            return(string.Format("NSDate:   {0}\nDateTime: {1} = {2} and {3}", df.StringFor(entryDate), EntryDate.ToLocalTime().ToLongDateString(), firstNumber, secondNumber));
        }
예제 #11
0
 public string GetLocaleShortTime(DateTime?time)
 {
     using (var df = new NSDateFormatter())
     {
         df.Locale    = NSLocale.CurrentLocale;
         df.TimeStyle = NSDateFormatterStyle.Short;
         return(df.StringFor((NSDate)time));
     }
 }
예제 #12
0
 public BNRMapPoint(string title, CLLocationCoordinate2D coord)
 {
     _title = title;
     this.coord = coord;
     NSDateFormatter dateFormatter = new NSDateFormatter();
     dateFormatter.DateStyle = NSDateFormatterStyle.Medium;
     dateFormatter.TimeStyle = NSDateFormatterStyle.Short;
     _subtitle = "Created: " + dateFormatter.StringFor(NSDate.Now);
 }
예제 #13
0
        public BNRMapPoint(string title, CLLocationCoordinate2D coord)
        {
            _title     = title;
            this.coord = coord;
            NSDateFormatter dateFormatter = new NSDateFormatter();

            dateFormatter.DateStyle = NSDateFormatterStyle.Medium;
            dateFormatter.TimeStyle = NSDateFormatterStyle.Short;
            _subtitle = "Created: " + dateFormatter.StringFor(NSDate.Now);
        }
예제 #14
0
        public static void UpdateDate(this MauiDatePicker platformDatePicker, IDatePicker datePicker, UIDatePicker?picker)
        {
            if (picker != null && picker.Date.ToDateTime().Date != datePicker.Date.Date)
            {
                picker.SetDate(datePicker.Date.ToNSDate(), false);
            }

            string format = datePicker.Format ?? string.Empty;

            // Can't use VirtualView.Format because it won't display the correct format if the region and language are set differently
            if (picker != null && string.IsNullOrWhiteSpace(format) || format.Equals("d", StringComparison.OrdinalIgnoreCase))
            {
                NSDateFormatter dateFormatter = new NSDateFormatter
                {
                    TimeZone = NSTimeZone.FromGMT(0)
                };

                if (format.Equals("D", StringComparison.Ordinal) == true)
                {
                    dateFormatter.DateStyle = NSDateFormatterStyle.Long;
                    var strDate = dateFormatter.StringFor(picker?.Date);
                    platformDatePicker.Text = strDate;
                }
                else
                {
                    dateFormatter.DateStyle = NSDateFormatterStyle.Short;
                    var strDate = dateFormatter.StringFor(picker?.Date);
                    platformDatePicker.Text = strDate;
                }
            }
            else if (format.Contains('/', StringComparison.Ordinal))
            {
                platformDatePicker.Text = datePicker.Date.ToString(format, CultureInfo.InvariantCulture);
            }
            else
            {
                platformDatePicker.Text = datePicker.Date.ToString(format);
            }

            platformDatePicker.UpdateCharacterSpacing(datePicker);
        }
예제 #15
0
        public void setCurrentTime()
        {
            NSDate          now        = (NSDate)DateTime.Now;
            NSDateFormatter dateFormat = new NSDateFormatter();

            dateFormat.TimeStyle = NSDateFormatterStyle.Medium;

            lblTime.Text = dateFormat.StringFor(now);

            //SpinTimeLabel();
            BounceTimeLabel();
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			dateFormatter = new NSDateFormatter ();

			calendar = new XuniCalendar();
			calendar.HeaderBackgroundColor = UIColor.White;
			calendar.Hidden = true;
			calendar.SelectionChanged+=(object sender, SelectionChangedEventArgs e) => 
			{
				dateFormatter.DateFormat = "M/d/yyyy";
				dateLabel.Text = "The date " + dateFormatter.StringFor(e.SelectedDates.StartDate) + " was selected.";
				calendar.Hidden = true;
				if (calendar.Hidden == true) {
						this.View.BackgroundColor = UIColor.White;
						this.NavigationController.NavigationBar.BarTintColor = UIColor.White;
				}

			};

			pickBtn = new UIButton(UIButtonType.System);
			pickBtn.SetTitle("Pick a date", UIControlState.Normal);
			pickBtn.TouchUpInside+=(object sender, EventArgs e) => 
			{
				calendar.Hidden = !calendar.Hidden;
				if (calendar.Hidden == false) {
					this.View.BackgroundColor = UIColor.Gray;
					this.NavigationController.NavigationBar.BarTintColor = UIColor.LightGray;
				}
				else
				{
					this.View.BackgroundColor = UIColor.White;
					this.NavigationController.NavigationBar.BarTintColor = UIColor.White;
				}
			};

			dateLabel = new UILabel();
			dateLabel.Text = "";

			view = new UIView();
			view.BackgroundColor  = UIColor.White;
			view.UserInteractionEnabled = true;
			view.Layer.CornerRadius = 4;

			this.View.Add(pickBtn);
			this.View.Add(dateLabel);
			this.View.Add(view);
			this.View.Add(calendar);


		}
예제 #17
0
        void ShowLastAccessed()
        {
            NSObject lastAccessed = NSUserDefaults.StandardUserDefaults["LastAccessed"];

            if (lastAccessed != null)
            {
                NSDateFormatter df = new NSDateFormatter();
                df.DateStyle = NSDateFormatterStyle.Full;

                var alert = new UIAlertView("Last Accessed", df.StringFor(lastAccessed), null, "OK");
                alert.Show();
            }
        }
 void ShowLastAccessed ()
 {
     NSObject lastAccessed = NSUserDefaults.StandardUserDefaults["LastAccessed"];
     
     if(lastAccessed != null)
     {
         NSDateFormatter df = new NSDateFormatter();
         df.DateStyle = NSDateFormatterStyle.Full;
         
         var alert = new UIAlertView("Last Accessed", df.StringFor(lastAccessed), null, "OK");
         alert.Show ();
     }
 }
예제 #19
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            dateFormatter = new NSDateFormatter();

            calendar = new XuniCalendar();
            calendar.HeaderBackgroundColor = UIColor.White;
            calendar.Hidden            = true;
            calendar.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
            {
                dateFormatter.DateFormat = "M/d/yyyy";
                dateLabel.Text           = "The date " + dateFormatter.StringFor(e.SelectedDates.StartDate) + " was selected.";
                calendar.Hidden          = true;
                if (calendar.Hidden == true)
                {
                    this.View.BackgroundColor = UIColor.White;
                    this.NavigationController.NavigationBar.BarTintColor = UIColor.White;
                }
            };

            pickBtn = new UIButton(UIButtonType.System);
            pickBtn.SetTitle("Pick a date", UIControlState.Normal);
            pickBtn.TouchUpInside += (object sender, EventArgs e) =>
            {
                calendar.Hidden = !calendar.Hidden;
                if (calendar.Hidden == false)
                {
                    this.View.BackgroundColor = UIColor.Gray;
                    this.NavigationController.NavigationBar.BarTintColor = UIColor.LightGray;
                }
                else
                {
                    this.View.BackgroundColor = UIColor.White;
                    this.NavigationController.NavigationBar.BarTintColor = UIColor.White;
                }
            };

            dateLabel      = new UILabel();
            dateLabel.Text = "";

            view = new UIView();
            view.BackgroundColor        = UIColor.White;
            view.UserInteractionEnabled = true;
            view.Layer.CornerRadius     = 4;

            this.View.Add(pickBtn);
            this.View.Add(dateLabel);
            this.View.Add(view);
            this.View.Add(calendar);
        }
예제 #20
0
        /// <summary>
        /// Log the file transfer progress.
        /// </summary>
        private void LogProgress(WCSessionFileTransfer fileTransfer)
        {
            DispatchQueue.MainQueue.DispatchAsync(() =>
            {
                var dateFormatter = new NSDateFormatter {
                    TimeStyle = NSDateFormatterStyle.Medium
                };
                var timeString = dateFormatter.StringFor(new NSDate());
                var fileName   = fileTransfer.File.FileUrl.LastPathComponent;

                var progress = fileTransfer.Progress.LocalizedDescription ?? "No progress";
                this.Log($"- {fileName}: {progress} at {timeString}");
            });
        }
        public void setCurrentTime()
        {
            NSDate          now        = DateTime.Now;
            NSDateFormatter dateFormat = new NSDateFormatter();

            dateFormat.TimeStyle = NSDateFormatterStyle.Medium;

            lblTime.Text = dateFormat.StringFor(now);

            // Will spin the time label (lblTime)
            //SpinTimeLabel();
            // Will "bounce" the time label (lblTime) while fading it in and out.
            BounceTimeLabel();
        }
예제 #22
0
파일: MUtils.cs 프로젝트: borain89vn/demo2
		public static string nsDateToString (NSDate date, string format)
		{
			string strDate = "";
			NSLocale gbLocale = NSLocale.FromLocaleIdentifier ("en_GB");
			NSDateFormatter dateFormatter = new NSDateFormatter ();
			dateFormatter.DateFormat = format;
			dateFormatter.Locale = gbLocale;
			try {
				strDate = dateFormatter.StringFor (date).ToUpper ();
			} catch (Exception ex) {
				Console.Out.WriteLine (ex.Message);
			}
			 
			return strDate;
		}
        public string DateToString(NSDate date, double value, NChartValueAxis axis)
        {
            // Perform date to string conversion. Let's perform it by the following rule:
            // - if tick interval is more than one day, show localized string "Day Month Year";
            // - otherwise show time string "Month.Day.Year Hours:Minutes".
            NSDateFormatter formatter = new NSDateFormatter();

            if (value >= 86400.0)
            {
                formatter.DateFormat = "d MMM YYYY";
            }
            else
            {
                formatter.DateFormat = "MM.dd.YYYY HH:mm";
            }
            return(formatter.StringFor(date));
        }
예제 #24
0
        /// <summary>
        /// 位置情報のログを送信します。
        /// </summary>
        /// <param name="location">CLLocation</param>
        /// <param name="type">位置情報の取得種別</param>
        /// <param name="isEnter">侵入か?</param>
        private void AddLocationLog(CLLocation location, string type, bool?isEnter = null)
        {
            var adapter = new DbAdapter_iOS();

            var formatter = new NSDateFormatter();

            formatter.DateFormat = "yyyy/MM/dd HH:mm:ss";
            formatter.TimeZone   = NSTimeZone.SystemTimeZone;
            var dateString   = formatter.StringFor(location.Timestamp);
            var detailString = $"{dateString},iOS,{location.Coordinate.Latitude},{location.Coordinate.Longitude},{location.VerticalAccuracy}";

            if (isEnter.HasValue)
            {
                detailString += $",{(isEnter.Value ? "侵入" : "退出")}";
            }

            adapter.AddDeviceLog($"位置情報取得:{dateString},精度:{location.VerticalAccuracy},種別:{type}", detailString);
        }
        private void SaveChanges(object sender, EventArgs args)
        {
            var dateFormatter = new NSDateFormatter {
                DateFormat = "dd/MM/yyyy HH:mm:ss"
            };
            var dateString = dateFormatter.StringFor(_selectedDate);
            var result     = DateTime.TryParse(dateString, out var dateTime);

            var model = new ToDoModel
            {
                Id          = _toDoId,
                Status      = _selectedStatus,
                WhenHappens = dateTime,
                Description = _descriptionEditor.Text
            };

            _repository.Save(model);
            NavigationController.PopViewController(true);
        }
예제 #26
0
        public ItextPageEvents(ReportType reportType)
        {
            switch (reportType)
            {
            case ReportType.Pass:
                headerText = "Inspection Report";
                break;

            case ReportType.Fail:
                headerText = "Failed Inspection Report";
                break;

            case ReportType.PhotoLog:
                headerText = "Inspection Photo Log";
                NSDate          InspectionDate = NSDate.Now;
                NSDateFormatter dateformatter  = new NSDateFormatter();
                dateformatter.DateFormat = @"MM/dd/yyyy";
                text = dateformatter.StringFor(InspectionDate);
                break;
            }
        }
        public static string ToString(
            this DateTimeOffset dateTimeOffset,
            CultureInfo cultureInfo,
            NSDateFormatterStyle dateStyle,
            NSDateFormatterStyle timeStyle
            )
        {
            if (cultureInfo == null)
            {
                throw new ArgumentNullException(nameof(cultureInfo));
            }

            var dateFormatter = new NSDateFormatter
            {
                DateStyle         = dateStyle,
                TimeStyle         = timeStyle,
                FormattingContext = NSFormattingContext.Standalone,
                Locale            = cultureInfo.ToLocale()
            };

            return(dateFormatter.StringFor(dateTimeOffset.ToNsDate()));
        }
예제 #28
0
        public void Cancel(Command command)
        {
            var commandStatus = new CommandStatus(command, Phrase.Canceled)
            {
                TimedColor = TimedColor
            };

            this.Cancel();

            var dateFormatter = new NSDateFormatter {
                TimeStyle = NSDateFormatterStyle.Medium
            };

            if (commandStatus.TimedColor != null)
            {
                commandStatus.TimedColor.TimeStamp = dateFormatter.StringFor(new NSDate());
            }

            DispatchQueue.MainQueue.DispatchAsync(() =>
            {
                NSNotificationCenter.DefaultCenter.PostNotificationName(NotificationName.DataDidFlow, commandStatus);
            });
        }
예제 #29
0
        /// <summary>
        /// Generate a dictionary containing a time stamp and a random color data.
        /// </summary>
        private static NSDictionary <NSString, NSObject> GetTimedColor()
        {
            var random = new Random();
            var red    = (float)random.NextDouble();
            var green  = (float)random.NextDouble();
            var blue   = (float)random.NextDouble();

            var randomColor = UIColor.FromRGBA(red, green, blue, 1f);

            var data = NSKeyedArchiver.ArchivedDataWithRootObject(randomColor, false, out NSError error);

            if (data == null || error != null)
            {
                throw new Exception("Failed to archive a UIColor!");
            }

            var dateFormatter = new NSDateFormatter {
                TimeStyle = NSDateFormatterStyle.Medium
            };
            var timeString = dateFormatter.StringFor(new NSDate());

            return(NSDictionary <NSString, NSObject> .FromObjectsAndKeys(new NSObject[] { new NSString(timeString), data },
                                                                         new NSString[] { PayloadKey.TimeStamp, PayloadKey.ColorData }));
        }
예제 #30
0
        /// <summary>
        /// Updates the view.
        /// </summary>
        private void UpdateView()
        {
            lblOwnerName.Text          = InspectionResult.HouseOwnerName;
            leftlblInspectionDate.Text = InspectionResult.inspectionDateTime.ToString();
            //lblPathWay.Text = InspectionResult.Pathway.ToString();
            lblInspectionType.Text = InspectionResult.InspectionType;
            lblAddress1.Text       = InspectionResult.InspectionAddress1;
            string address = !string.IsNullOrEmpty(InspectionResult.InspectionAddress2) ? InspectionResult.InspectionAddress2 + "," + InspectionResult.City + " " + InspectionResult.Pincode : InspectionResult.City + " " + InspectionResult.Pincode;

            lblAddress2.Text      = address.Trim();
            lblPhoneNumber.Text   = InspectionResult.PhoneNo;
            lblInspectorName.Text = InspectionResult.RepresentativeName;
            //lblInspectionDate.Text =InspectionResult.inspectionDateTime!=null? InspectionResult.inspectionDateTime.Date.ToString ("dd MMM yyyy"):DateTime.Today.Date.ToString ("dd MMMMM yyyy");
            //			lblInspectionDate.Text=DateTime.Today.Date.ToString ("MM/dd/yyyy");

            NSDate          todayDate     = NSDate.Now;
            NSDateFormatter dateFormatter = new NSDateFormatter();

            dateFormatter.DateFormat = @"MM/dd/yyyy";
            lblInspectionDate.Text   = dateFormatter.StringFor(todayDate);

            //			lblInspectionDate.TextAlignment = UITextAlignment.Right;
            lblFailMessage.Text = "";
        }
예제 #31
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			Current = this;

			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			// make the window visible
			window.MakeKeyAndVisible ();
			
			// create our nav controller
			navController = new UINavigationController ();

			// create our home controller based on the device
			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) {
				homeViewController = new Tasky.Screens.iPhone.Home.controller_iPhone();
			} else {
//				homeViewController = new Hello_UniversalViewController ("Hello_UniversalViewController_iPad", null);
			}
			
			// Styling
			UINavigationBar.Appearance.TintColor = UIColor.FromRGB (38, 117 ,255); // nice blue
			UITextAttributes ta = new UITextAttributes();
			ta.Font = UIFont.FromName ("AmericanTypewriter-Bold", 0f);
			UINavigationBar.Appearance.SetTitleTextAttributes(ta);
			ta.Font = UIFont.FromName ("AmericanTypewriter", 0f);
			UIBarButtonItem.Appearance.SetTitleTextAttributes(ta, UIControlState.Normal);
			

			var sqliteFilename = "TaskDB.db3";
			// we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
			// (they don't want non-user-generated data in Documents)
			string documentsPath = Environment.GetFolderPath (Environment.SpecialFolder.Personal); // Documents folder
			string libraryPath = Path.Combine (documentsPath, "../Library/"); // Library folder
            var path = Path.Combine(libraryPath, sqliteFilename);
			conn = new Tasky.DL.SQLite.Connection(path);
			TaskMgr = new TodoManager(conn);


			// push the view controller onto the nav controller and show the window
			navController.PushViewController(homeViewController, false);
			window.RootViewController = navController;
			window.MakeKeyAndVisible ();


			//
			// https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html
			NSDateFormatter df = new NSDateFormatter ();

			df.DateStyle = NSDateFormatterStyle.Full;
			df.TimeStyle = NSDateFormatterStyle.Short;
			Debug.WriteLine ("tz: " + NSTimeZone.LocalTimeZone);

var date = NSDate.Now;

df.DateStyle = NSDateFormatterStyle.Full;
df.TimeStyle = NSDateFormatterStyle.Long;
Debug.WriteLine ("Full,Long: " + df.StringFor(date));

df.DateStyle = NSDateFormatterStyle.Short;
df.TimeStyle = NSDateFormatterStyle.Short;
Debug.WriteLine ("Short,Short: " + df.StringFor(date));

df.DateStyle = NSDateFormatterStyle.Medium;
df.TimeStyle = NSDateFormatterStyle.None;
Debug.WriteLine ("Medium,None: " + df.StringFor(date));
			return true;
		}
예제 #32
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            Current = this;

            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);

            // make the window visible
            window.MakeKeyAndVisible();

            // create our nav controller
            navController = new UINavigationController();

            // create our home controller based on the device
            if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
            {
                homeViewController = new Tasky.Screens.iPhone.Home.controller_iPhone();
            }
            else
            {
//				homeViewController = new Hello_UniversalViewController ("Hello_UniversalViewController_iPad", null);
            }

            // Styling
            UINavigationBar.Appearance.TintColor = UIColor.FromRGB(38, 117, 255);              // nice blue
            UITextAttributes ta = new UITextAttributes();

            ta.Font = UIFont.FromName("AmericanTypewriter-Bold", 0f);
            UINavigationBar.Appearance.SetTitleTextAttributes(ta);
            ta.Font = UIFont.FromName("AmericanTypewriter", 0f);
            UIBarButtonItem.Appearance.SetTitleTextAttributes(ta, UIControlState.Normal);


            var sqliteFilename = "TaskDB.db3";
            // we need to put in /Library/ on iOS5.1 to meet Apple's iCloud terms
            // (they don't want non-user-generated data in Documents)
            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
            string libraryPath   = Path.Combine(documentsPath, "../Library/");                    // Library folder
            var    path          = Path.Combine(libraryPath, sqliteFilename);

            conn    = new Tasky.DL.SQLite.Connection(path);
            TaskMgr = new TaskManager(conn);


            // push the view controller onto the nav controller and show the window
            navController.PushViewController(homeViewController, false);
            window.RootViewController = navController;
            window.MakeKeyAndVisible();


            //
            // https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html
            NSDateFormatter df = new NSDateFormatter();

            df.DateStyle = NSDateFormatterStyle.Full;
            df.TimeStyle = NSDateFormatterStyle.Short;
            Debug.WriteLine("tz: " + NSTimeZone.LocalTimeZone);

            var date = NSDate.Now;

            df.DateStyle = NSDateFormatterStyle.Full;
            df.TimeStyle = NSDateFormatterStyle.Long;
            Debug.WriteLine("Full,Long: " + df.StringFor(date));

            df.DateStyle = NSDateFormatterStyle.Short;
            df.TimeStyle = NSDateFormatterStyle.Short;
            Debug.WriteLine("Short,Short: " + df.StringFor(date));

            df.DateStyle = NSDateFormatterStyle.Medium;
            df.TimeStyle = NSDateFormatterStyle.None;
            Debug.WriteLine("Medium,None: " + df.StringFor(date));
            return(true);
        }
 public override void DatePickerDialogDidSelectDate(NSDate date)
 {
     TextField.Text = DateFormater.StringFor(date);
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Title = _toDoId == 0 ?
                    NSBundle.MainBundle.GetLocalizedString(ConstantsHelper.NewToDo, ConstantsHelper.NewToDo)
                : NSBundle.MainBundle.GetLocalizedString(ConstantsHelper.EditToDo, ConstantsHelper.EditToDo);

            View.BackgroundColor = UIColor.White;

            var addButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, SaveChanges)
            {
                AccessibilityLabel = ConstantsHelper.ConfirmButtonAccessibilityLabel
            };

            NavigationItem.RightBarButtonItem = addButton;

            _selectedDate = NSDate.Now;

            _dateLabel      = new UILabel();
            _dateLabel.Text = "Date:";
            _dateLabel.Font = UIFont.SystemFontOfSize(16);
            _dateLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            _currentDateField = new UITextField();
            _currentDateField.Layer.BorderColor      = UIColor.LightGray.CGColor;
            _currentDateField.Layer.BorderWidth      = 0.5f;
            _currentDateField.Layer.CornerRadius     = 5f;
            _currentDateField.UserInteractionEnabled = true;
            _currentDateField.TextAlignment          = UITextAlignment.Center;

            var dateFormatter = new NSDateFormatter {
                DateFormat = "dd/MM/yyyy"
            };

            _currentDateField.Text = dateFormatter.StringFor(_selectedDate);
            _currentDateField.Font = UIFont.SystemFontOfSize(16);
            _currentDateField.TranslatesAutoresizingMaskIntoConstraints = false;

            _timeLabel      = new UILabel();
            _timeLabel.Text = "Time:";
            _timeLabel.Font = UIFont.SystemFontOfSize(16);
            _timeLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            var timeFormatter = new NSDateFormatter {
                DateFormat = "HH:mm"
            };

            _currentTimeField = new UITextField();
            _currentTimeField.Layer.BorderColor      = UIColor.LightGray.CGColor;
            _currentTimeField.Layer.BorderWidth      = 0.5f;
            _currentTimeField.Layer.CornerRadius     = 5f;
            _currentTimeField.UserInteractionEnabled = true;
            _currentTimeField.TextAlignment          = UITextAlignment.Center;
            _currentTimeField.Text = timeFormatter.StringFor(_selectedDate);
            _currentTimeField.Font = UIFont.SystemFontOfSize(16);
            _currentTimeField.TranslatesAutoresizingMaskIntoConstraints = false;

            _statusLabel      = new UILabel();
            _statusLabel.Text = "Status:";
            _statusLabel.Font = UIFont.SystemFontOfSize(16);
            _statusLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            _statusField = new UITextField();
            _statusField.Layer.BorderColor      = UIColor.LightGray.CGColor;
            _statusField.Layer.BorderWidth      = 0.5f;
            _statusField.Layer.CornerRadius     = 5f;
            _statusField.UserInteractionEnabled = true;
            _statusField.TextAlignment          = UITextAlignment.Center;
            _statusField.Text = "Active";
            _statusField.TranslatesAutoresizingMaskIntoConstraints = false;

            _descriptionLabel      = new UILabel();
            _descriptionLabel.Text = "Description:";
            _descriptionLabel.Font = UIFont.SystemFontOfSize(16);
            _descriptionLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            _descriptionEditor      = new UITextView();
            _descriptionEditor.Text = "Test to-do";
            _descriptionEditor.Font = UIFont.SystemFontOfSize(16);
            _descriptionEditor.TranslatesAutoresizingMaskIntoConstraints = false;

            _statusGestureRecognizer = new UITapGestureRecognizer(async() => { await ShowStatusPopup(); })
            {
                NumberOfTapsRequired = 1
            };
            _currentDateGestureRecognizer = new UITapGestureRecognizer(async() => { await ShowDatePopup(); })
            {
                NumberOfTapsRequired = 1
            };
            _currentTimeGestureRecognizer = new UITapGestureRecognizer(async() => { await ShowTimePopup(); })
            {
                NumberOfTapsRequired = 1
            };

            View.AddSubviews(_dateLabel,
                             _currentDateField,
                             _timeLabel,
                             _currentTimeField,
                             _statusLabel,
                             _statusField,
                             _descriptionLabel,
                             _descriptionEditor);

            View.AddConstraints(_dateLabel.AtLeftOf(View, 10f),
                                _dateLabel.AtTopOf(View, 80f),
                                _dateLabel.Width().EqualTo(100f),
                                _dateLabel.Height().EqualTo(30f),
                                _currentDateField.WithSameCenterY(_dateLabel),
                                _currentDateField.ToRightOf(_dateLabel),
                                _currentDateField.Width().EqualTo(200f),
                                _currentDateField.Height().EqualTo(30f),
                                _timeLabel.Below(_dateLabel, 10f),
                                _timeLabel.WithSameLeft(_dateLabel),
                                _timeLabel.Width().EqualTo(100f),
                                _timeLabel.Height().EqualTo(30f),
                                _currentTimeField.WithSameCenterY(_timeLabel),
                                _currentTimeField.ToRightOf(_timeLabel),
                                _currentTimeField.Width().EqualTo(200f),
                                _currentTimeField.Height().EqualTo(30f),
                                _statusLabel.Below(_timeLabel, 10f),
                                _statusLabel.WithSameLeft(_timeLabel),
                                _statusLabel.Width().EqualTo(100f),
                                _statusLabel.Height().EqualTo(30f),
                                _statusField.WithSameCenterY(_statusLabel),
                                _statusField.ToRightOf(_statusLabel),
                                _statusField.Width().EqualTo(200f),
                                _statusField.Height().EqualTo(30f),
                                _descriptionLabel.Below(_statusLabel, 10f),
                                _descriptionLabel.WithSameLeft(_statusLabel),
                                _descriptionLabel.Width().EqualTo(100f),
                                _descriptionLabel.Height().EqualTo(30f),
                                _descriptionEditor.Below(_descriptionLabel, 10f),
                                _descriptionEditor.WithSameLeft(_descriptionLabel),
                                _descriptionEditor.Width().EqualTo(View.Bounds.Width - 20f),
                                _descriptionEditor.Height().EqualTo(500f));
        }
예제 #35
0
        public void setCurrentTime()
        {
            NSDate now = (NSDate)DateTime.Now;
            NSDateFormatter dateFormat = new NSDateFormatter();
            dateFormat.TimeStyle = NSDateFormatterStyle.Medium;

            lblTime.Text = dateFormat.StringFor(now);

            //SpinTimeLabel();
            BounceTimeLabel();
        }
예제 #36
0
        /*
         * This is the main delegate method Anyline uses to report its results
         */
        void IAnylineOCRModuleDelegate.DidFindResult(AnylineOCRModuleView anylineOCRModuleView, ALOCRResult result)
        {
            StopAnyline();
            if (_drivingLicenseResultView != null)
            {
                View.BringSubviewToFront(_drivingLicenseResultView);
            }

            string[] comps = result.Result.ToString().Split('|');

            string name        = comps[0];
            string birthdateID = comps[1];

            string[] nameComps = name.Split(' ');

            switch (nameComps.Length)
            {
            case 0:
                break;

            case 1:
                _drivingLicenseResultView.Surname.Text    = nameComps[0];
                _drivingLicenseResultView.Surname2.Text   = "";
                _drivingLicenseResultView.GivenNames.Text = "";
                break;

            case 2:
                _drivingLicenseResultView.Surname.Text    = nameComps[0];
                _drivingLicenseResultView.Surname2.Text   = "";
                _drivingLicenseResultView.GivenNames.Text = nameComps[1];
                break;

            case 3:
                _drivingLicenseResultView.Surname.Text    = nameComps[0];
                _drivingLicenseResultView.Surname2.Text   = nameComps[1];
                _drivingLicenseResultView.GivenNames.Text = nameComps[2];
                break;

            default:
                break;
            }

            string[] birthdateIDComps = birthdateID.Split(' ');

            string birthday = birthdateIDComps[0];

            NSDateFormatter formatter = new NSDateFormatter();

            formatter.DateFormat = @"ddMMyyyy";

            NSDate date = formatter.Parse(birthday);

            if (date == null)
            {
                formatter.DateFormat = @"yyyyMMdd";
                date = formatter.Parse(birthday);
            }

            formatter.DateFormat = @"yyyy-MM-dd";
            _drivingLicenseResultView.Birthdate.Text = formatter.StringFor(date);
            _drivingLicenseResultView.IDNumber.Text  = birthdateIDComps[1];

            // Present the information to the user
            _drivingLicenseResultView?.AnimateFadeIn(View);
        }
        private PWIInboxStyle GetNativeStyle(PushwooshInboxStyle style)
        {
            PWIInboxStyle nativeStyle = PWIInboxStyle.DefaultStyle();

            if (style.AccentColor != Color.Default)
            {
                nativeStyle.AccentColor = GetUIColor(style.AccentColor);
            }
            if (style.BackgroundColor != Color.Default)
            {
                nativeStyle.BackgroundColor = GetUIColor(style.BackgroundColor);
            }
            if (style.BarAccentColor != Color.Default)
            {
                nativeStyle.BarAccentColor = GetUIColor(style.BarAccentColor);
            }
            if (style.BarBackgroundColor != Color.Default)
            {
                nativeStyle.BarBackgroundColor = GetUIColor(style.BarBackgroundColor);
            }
            if (style.BarTextColor != Color.Default)
            {
                nativeStyle.BarTextColor = GetUIColor(style.BarTextColor);
            }
            if (!string.IsNullOrEmpty(style.BarTitle))
            {
                nativeStyle.BarTitle = style.BarTitle;
            }
            if (style.DateColor != Color.Default)
            {
                nativeStyle.DateColor = GetUIColor(style.DateColor);
            }
            if (!string.IsNullOrEmpty(style.DateFormat))
            {
                NSDateFormatter formatter = new NSDateFormatter
                {
                    DateFormat = style.DateFormat
                };
                nativeStyle.DateFormatterBlock = (NSDate date, NSObject owner) => formatter.StringFor(date);
            }
            if (!string.IsNullOrEmpty(style.DefaultImageName))
            {
                nativeStyle.DefaultImageIcon = GetUIImage(style.DefaultImageName);
            }

            if (style.DescriptionColor != Color.Default)
            {
                nativeStyle.DescriptionColor = GetUIColor(style.DescriptionColor);
            }

            if (!string.IsNullOrEmpty(style.ListEmptyImageName))
            {
                nativeStyle.ListEmptyImage = GetUIImage(style.ListEmptyImageName);
            }

            if (!string.IsNullOrEmpty(style.ListEmptyMessage))
            {
                nativeStyle.ListEmptyMessage = style.ListEmptyMessage;
            }

            if (!string.IsNullOrEmpty(style.ListErrorImageName))
            {
                nativeStyle.ListErrorImage = GetUIImage(style.ListErrorImageName);
            }

            if (!string.IsNullOrEmpty(style.ListErrorMessage))
            {
                nativeStyle.ListErrorMessage = style.ListErrorMessage;
            }

            if (style.SeparatorColor != Color.Default)
            {
                nativeStyle.SeparatorColor = GetUIColor(style.SeparatorColor);
            }

            if (style.TitleColor != Color.Default)
            {
                nativeStyle.TitleColor = GetUIColor(style.TitleColor);
            }
            if (style.TitleTextSize > 0)
            {
                nativeStyle.TitleFont = UIFont.SystemFontOfSize(style.TitleTextSize);
            }
            if (style.DateTextSize > 0)
            {
                nativeStyle.DateFont = UIFont.SystemFontOfSize(style.DateTextSize);
            }
            if (style.DescriptionTextSize > 0)
            {
                nativeStyle.DescriptionFont = UIFont.SystemFontOfSize(style.DescriptionTextSize);
            }
            return(nativeStyle);
        }
예제 #38
0
 protected override string Convert(DateTime value, Type targetType, object parameter, CultureInfo culture)
 {
     return(_dateFormatter.StringFor((NSDate)value));
 }