public void SetUp ()
        {
            ServiceContainer.Register<ISynchronizeInvoke> (() => new Mocks.MockSynchronizeInvoke ());
            ServiceContainer.Register<IAssignmentService> (() => new Mocks.MockAssignmentService ());

            viewModel = new ExpenseViewModel ();
        }
		public SummaryHistoryActivity ()
		{
			historyViewModel = ServiceContainer.Resolve<HistoryViewModel> ();
			itemViewModel = ServiceContainer.Resolve<ItemViewModel> ();
			laborViewModel = ServiceContainer.Resolve<LaborViewModel> ();
			photoViewModel = ServiceContainer.Resolve<PhotoViewModel> ();
			expenseViewModel = ServiceContainer.Resolve<ExpenseViewModel> ();
			documentViewModel = ServiceContainer.Resolve<DocumentViewModel> ();
			menuViewModel = ServiceContainer.Resolve<MenuViewModel> ();

			assignmentHistory = historyViewModel.SelectedAssignmentHistory;
		}
Example #3
0
        public ExpenseDialog(Activity activity)
            : base(activity)
        {
            this.activity = activity;
            expenseViewModel = ServiceContainer.Resolve<ExpenseViewModel> ();
            expenseTypes = new ExpenseCategory [] {
                ExpenseCategory.Gas,
                ExpenseCategory.Food,
                ExpenseCategory.Supplies,
                ExpenseCategory.Other,
            };

            mediaPicker = new MediaPicker (activity);
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView (inflater, container, savedInstanceState);

            expenseViewModel = ServiceContainer.Resolve<ExpenseViewModel> ();

            var view = inflater.Inflate (Resource.Layout.ExpensesFragmentLayout, null, true);

            expensesListView = view.FindViewById<ListView> (Resource.Id.expenseListView);

            ReloadExpenses ();
            expensesListView.ItemClick += (sender, e) => {
                var textView = e.View.FindViewById<TextView> (Resource.Id.expenseText);

                var expense = Expenses.ElementAtOrDefault ((int)textView.Tag);

                expenseDialog = new ExpenseDialog (Activity);
                expenseDialog.Assignment = Assignment;
                expenseDialog.CurrentExpense = expense;
                expenseDialog.Show ();
            };

            return view;
        }
 public AddExpenseController(IntPtr handle)
     : base(handle)
 {
     assignmentViewModel = ServiceContainer.Resolve<AssignmentViewModel>();
     expenseViewModel = ServiceContainer.Resolve<ExpenseViewModel>();
 }
            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);
            }
			public TableSource (ExpenseController controller)
			{
				this.controller = controller;
				expenseViewModel = ServiceContainer.Resolve<ExpenseViewModel>();
				assignmentViewModel = ServiceContainer.Resolve<AssignmentViewModel>();
			}