예제 #1
0
            public TableSource()
            {
                laborViewModel = ServiceContainer.Resolve <LaborViewModel>();

                typeCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                typeCell.TextLabel.Text = "Type";
                typeCell.AccessoryView  = type = new LaborTypeTextField(new RectangleF(0, 0, 200, 36))
                {
                    TextAlignment     = UITextAlignment.Right,
                    VerticalAlignment = UIControlContentVerticalAlignment.Center,
                    BackgroundColor   = UIColor.Clear,
                };
                typeCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                type.EditingDidEnd     += (sender, e) => {
                    laborViewModel.SelectedLabor.Type = type.LaborType;
                };

                hoursCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                hoursCell.TextLabel.Text = "Hours";
                hoursCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                hoursCell.AccessoryView  = hours = new HoursField(new RectangleF(0, 0, 200, 44));
                hours.ValueChanged      += (sender, e) => laborViewModel.SelectedLabor.Hours = TimeSpan.FromHours(hours.Value);

                descriptionCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                descriptionCell.AccessoryView = description = new PlaceholderTextView(new RectangleF(0, 0, 470, 400))
                {
                    BackgroundColor = UIColor.Clear,
                    TextColor       = Theme.BlueTextColor,
                    Placeholder     = "Please enter notes here",
                };
                descriptionCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                description.SetDidChangeNotification(d => {
                    if (description.Text != description.Placeholder)
                    {
                        laborViewModel.SelectedLabor.Description = d.Text;
                    }
                    else
                    {
                        laborViewModel.SelectedLabor.Description = string.Empty;
                    }
                });
            }
			public TableSource ()
			{
				laborViewModel = ServiceContainer.Resolve<LaborViewModel>();

				typeCell = new UITableViewCell (UITableViewCellStyle.Default, null);
				typeCell.TextLabel.Text = "Type";
				typeCell.AccessoryView = type = new LaborTypeTextField (new CGRect(0, 0, 200, 36))
				{
					TextAlignment = UITextAlignment.Right,
					VerticalAlignment = UIControlContentVerticalAlignment.Center,
					BackgroundColor = UIColor.Clear,
				};
				typeCell.SelectionStyle = UITableViewCellSelectionStyle.None;
				type.EditingDidEnd += (sender, e) => {
					laborViewModel.SelectedLabor.Type = type.LaborType;
				};

				hoursCell = new UITableViewCell (UITableViewCellStyle.Default, null);
				hoursCell.TextLabel.Text = "Hours";
				hoursCell.SelectionStyle = UITableViewCellSelectionStyle.None;
				hoursCell.AccessoryView = hours = new HoursField(new CGRect(0, 0, 200, 44));
				hours.ValueChanged += (sender, e) => laborViewModel.SelectedLabor.Hours = TimeSpan.FromHours (hours.Value);

				descriptionCell = new UITableViewCell (UITableViewCellStyle.Default, null);
				descriptionCell.AccessoryView = description = new PlaceholderTextView(new CGRect(0, 0, Theme.IsiOS7 ? 515 : 470, 400))
				{
					BackgroundColor = UIColor.Clear,
					TextColor = Theme.BlueTextColor,
					Placeholder = "Please enter notes here",
				};
				descriptionCell.SelectionStyle = UITableViewCellSelectionStyle.None;
				description.SetDidChangeNotification (d => {
					if (description.Text != description.Placeholder) {
						laborViewModel.SelectedLabor.Description = d.Text;
					} else {
						laborViewModel.SelectedLabor.Description = string.Empty;
					}
				});
			}
            public TableSource()
            {
                expenseViewModel = ServiceContainer.Resolve<ExpenseViewModel>();

                categoryCell = new UITableViewCell (UITableViewCellStyle.Default, null);
                categoryCell.TextLabel.Text = "Category";
                categoryCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                categoryCell.AccessoryView = category = new UILabel (new CGRect(0f, 0f, 200f, 36f)) {
                    TextAlignment = UITextAlignment.Right,
                    BackgroundColor = UIColor.Clear,
                };

                costCell = new UITableViewCell (UITableViewCellStyle.Default, null);
                costCell.TextLabel.Text = "Cost";
                costCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                costCell.AccessoryView = cost = new UITextField(new CGRect (0f, 0f, 200f, 36f))
                {
                    VerticalAlignment = UIControlContentVerticalAlignment.Center,
                    TextAlignment = UITextAlignment.Right,
                };
                cost.SetDidChangeNotification (c =>
                {
                    string text = c.Text.Replace ("$", string.Empty);
                    decimal value;
                    expenseViewModel.SelectedExpense.Cost = decimal.TryParse (text, out value) ? Math.Abs (value) : 0;
                });

                descriptionCell = new UITableViewCell (UITableViewCellStyle.Default, null) {
                    SelectionStyle = UITableViewCellSelectionStyle.None
                };
                descriptionCell.AccessoryView = description = new PlaceholderTextView (new CGRect (0f, 0f, Theme.IsiOS7 ? 515f : 470f, 90f)) {
                    BackgroundColor = UIColor.Clear,
                    Placeholder = "Please enter notes here",
                };
                description.SetDidChangeNotification (d =>
                    expenseViewModel.SelectedExpense.Description = description.Text != description.Placeholder ? d.Text : string.Empty
                );

                photoCell = new UITableViewCell(UITableViewCellStyle.Default, null) {
                    SelectionStyle = UITableViewCellSelectionStyle.None
                };

                photoButton = UIButton.FromType (UIButtonType.Custom);
                photoButton.SetBackgroundImage (Theme.AddPhoto, UIControlState.Normal);
                photoButton.SetTitle ("Add Photo", UIControlState.Normal);
                photoButton.SetTitleColor (Theme.LabelColor, UIControlState.Normal);
                photoButton.ContentEdgeInsets = new UIEdgeInsets (0f, 0f, 2f, 0f);
                photoButton.Frame = new CGRect (210f, 130f, 115f, 40f);
                photoButton.TouchUpInside += (sender, e) => {
                    if (photoSheet == null) {
                        photoSheet = new PhotoAlertSheet();

                        //Set the desired size for the resulting image
                        var size = photo.Frame.Size;
                        var scale = UIScreen.MainScreen.Scale;
                        size.Width *= scale;
                        size.Height *= scale;
                        photoSheet.DesiredSize = size;

                        //Set the callback for when the image is selected
                        photoSheet.Callback = image => {
                            if (expenseViewModel.Photo == null)
                                expenseViewModel.Photo = new ExpensePhoto { ExpenseId = expenseViewModel.SelectedExpense.Id };

                            expenseViewModel.Photo.Image = image.ToByteArray ();
                            Load (enabled);
                        };
                    }
                    photoSheet.ShowFrom (photoButton.Frame, photoCell, true);
                };
                photoCell.AddSubview (photoButton);
                var frame = photoCell.Frame;
                frame.X = 18f;
                frame.Width -= 34f;

                photo = new UIImageView (frame) {
                    AutoresizingMask = UIViewAutoresizing.All,
                    ContentMode = UIViewContentMode.ScaleAspectFit
                };

                photo.Layer.BorderWidth = 1f;
                photo.Layer.BorderColor = new CGColor (0xcf, 0xcf, 0xcf, 0x7f);
                photo.Layer.CornerRadius = 10f;
                photo.Layer.MasksToBounds = true;
                photoCell.AddSubview (photo);
            }
예제 #4
0
            public TableSource()
            {
                expenseViewModel = ServiceContainer.Resolve <ExpenseViewModel>();

                categoryCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                categoryCell.TextLabel.Text = "Category";
                categoryCell.AccessoryView  = category = new UILabel(new RectangleF(0, 0, 200, 36))
                {
                    TextAlignment   = UITextAlignment.Right,
                    BackgroundColor = UIColor.Clear,
                };
                categoryCell.SelectionStyle = UITableViewCellSelectionStyle.None;

                costCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                costCell.TextLabel.Text = "Cost";
                costCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                costCell.AccessoryView  = cost = new UITextField(new RectangleF(0, 0, 200, 36))
                {
                    VerticalAlignment = UIControlContentVerticalAlignment.Center,
                    TextAlignment     = UITextAlignment.Right,
                };
                cost.SetDidChangeNotification(c =>
                {
                    string text = c.Text.Replace("$", string.Empty);
                    decimal value;
                    if (decimal.TryParse(text, out value))
                    {
                        expenseViewModel.SelectedExpense.Cost = Math.Abs(value);
                    }
                    else
                    {
                        expenseViewModel.SelectedExpense.Cost = 0;
                    }
                });

                descriptionCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                descriptionCell.AccessoryView = description = new PlaceholderTextView(new RectangleF(0, 0, 470, 90))
                {
                    BackgroundColor = UIColor.Clear,
                    Placeholder     = "Please enter notes here",
                };
                descriptionCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                description.SetDidChangeNotification(d => {
                    if (description.Text != description.Placeholder)
                    {
                        expenseViewModel.SelectedExpense.Description = d.Text;
                    }
                    else
                    {
                        expenseViewModel.SelectedExpense.Description = string.Empty;
                    }
                });

                photoCell = new UITableViewCell(UITableViewCellStyle.Default, null);
                photoCell.SelectionStyle = UITableViewCellSelectionStyle.None;
                photoButton = UIButton.FromType(UIButtonType.Custom);
                photoButton.SetBackgroundImage(Theme.AddPhoto, UIControlState.Normal);
                photoButton.SetTitle("Add Photo", UIControlState.Normal);
                photoButton.SetTitleColor(Theme.LabelColor, UIControlState.Normal);
                photoButton.ContentEdgeInsets = new UIEdgeInsets(0, 0, 2, 0);
                photoButton.Frame             = new RectangleF(210, 130, 115, 40);
                photoButton.TouchUpInside    += (sender, e) => {
                    if (photoSheet == null)
                    {
                        photoSheet = new PhotoAlertSheet();

                        //Set the desired size for the resulting image
                        var size  = photo.Frame.Size;
                        var scale = UIScreen.MainScreen.Scale;
                        size.Width            *= scale;
                        size.Height           *= scale;
                        photoSheet.DesiredSize = size;

                        //Set the callback for when the image is selected
                        photoSheet.Callback = image => {
                            if (expenseViewModel.Photo == null)
                            {
                                expenseViewModel.Photo = new ExpensePhoto {
                                    ExpenseId = expenseViewModel.SelectedExpense.Id
                                }
                            }
                            ;
                            expenseViewModel.Photo.Image = image.ToByteArray();
                            Load(enabled);
                        };
                    }
                    photoSheet.ShowFrom(photoButton.Frame, photoCell, true);
                };
                photoCell.AddSubview(photoButton);
                var frame = photoCell.Frame;

                frame.X                   = 18;
                frame.Width              -= 34;
                photo                     = new UIImageView(frame);
                photo.AutoresizingMask    = UIViewAutoresizing.All;
                photo.ContentMode         = UIViewContentMode.ScaleAspectFit;
                photo.Layer.BorderWidth   = 1;
                photo.Layer.BorderColor   = new CGColor(0xcf, 0xcf, 0xcf, 0x7f);
                photo.Layer.CornerRadius  = 10;
                photo.Layer.MasksToBounds = true;
                photoCell.AddSubview(photo);
            }