コード例 #1
0
 public PropertyAdapter(Context context, EntryDetailVM container)
     : base()
 {
     _context   = context;
     _container = container;
     _container.PropertyChanged += (sender, e) => { if (e.PropertyName == "Properties")
                                                    {
                                                        this.NotifyDataSetChanged();
                                                    }
     };
 }
コード例 #2
0
        public EntryDetail()
        {
            InitializeComponent();

            try
            {
                DataContext = new EntryDetailVM(Navigate.selectedEntry);

                if (Navigate.selectedItem.IsNewItem)
                {
                    ApplicationBar.Buttons.Add(
                        new MenuButton("/resources/icons/applicationbar.check.png", AppResources.AcceptNew,
                                       (DataContext as EntryDetailVM).CommitNewItem));
                }

                ApplicationBar.MenuItems.Add(new MenuLink(AppResources.TakeAPicture, (DataContext as EntryDetailVM).StartPicture));
                ApplicationBar.MenuItems.Add(new MenuLink(AppResources.AddServingSize, (DataContext as EntryDetailVM).AddServingSize));
                ApplicationBar.MenuItems.Add(new MenuLink(AppResources.SendFeedback, Navigate.ToFeedback));
            }
            catch (Exception ex) { LittleWatson.ReportException(ex); }
        }
コード例 #3
0
 public EntryDetailWindow(EntryDetailVM vm)
 {
     DataContext = vm;
     InitializeComponent();
     this.PreviewKeyDown += new KeyEventHandler(HandleEsc);
 }
コード例 #4
0
 public EntryInfoX(EntryDetailVM vm)
 {
     this.vm = vm;
 }
コード例 #5
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_entrydetail);
            OverridePendingTransition(Resource.Animation.zoom_enter, Resource.Animation.zoom_exit);
            var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar_addItem);

            SetSupportActionBar(toolbar);
            this.SupportActionBar.Title = AppResources.PageTitleItemDetail;
            this.SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            listEntryEdit = FindViewById <Android.Widget.LinearLayout>(Resource.Id.contentView);
            var e = Navigate.selectedEntry;

            vm = new EntryDetailVM(e);
            var view = listEntryEdit;

#if SCREENSHOT
            Navigate.screenshotScreen = this;
#endif

            var binding = DataContext <EntryDetailVM> .FromView(view);

            binding.VM = vm;
            listEntryEdit.AddView(View.Inflate(this, Resource.Layout.item_edit_entry_top, null));
            AmountCollectionVM avm = vm.AmountCollectionVM;
            ServingSizeAdapter a   = new ServingSizeAdapter(this, avm);

            // serving sizes
            listEntryEdit.AddView(View.Inflate(this, Resource.Layout.item_serving, null));
            var ServingExtraMenu = FindViewById(Resource.Id.addItemDialog);
            ServingExtraMenu.Click += (object sender, EventArgs e2) =>
            {
                ShowServingsExtraMenu();
            };

            var servingsizes = FindViewById <Android.Widget.LinearLayout>(Resource.Id.servingSizes);
            int cnt          = Math.Min(a.Count, MAXSERVINGSFIRST);
            for (int i = 0; i < cnt; i++)
            {
                servingsizes.AddView(a.GetView2(i, null, servingsizes));
            }

            View showmore = null;
            if (a.Count > MAXSERVINGSFIRST)
            {
                showmore = View.Inflate(this, Resource.Layout.item_servings_show_more, null);
                listEntryEdit.AddView(showmore);
                var button = FindViewById <TextView>(Resource.Id.button_showmoreoptions);
                button.Click += (sender, e2) =>
                {
                    servingsizes.RemoveAllViews();
                    for (int i = 0; i < a.Count; i++)
                    {
                        servingsizes.AddView(a.GetView2(i, null, servingsizes));
                    }
                    showmore.Visibility = ViewStates.Invisible;
                };
            }

            // add serving szie
            avm.Amounts.CollectionChanged += (sender, e3) =>
            {
                if (showmore != null)
                {
                    showmore.Visibility = ViewStates.Invisible;
                }
                servingsizes.RemoveAllViews();
                for (int i = 0; i < a.Count; i++)
                {
                    servingsizes.AddView(a.GetView2(i, null, servingsizes));
                }
            };

            PropertyAdapter p = new PropertyAdapter(this, vm);

            // properties
            listEntryEdit.AddView(View.Inflate(this, Resource.Layout.item_nutrition, null));
            var properties = FindViewById <Android.Widget.LinearLayout>(Resource.Id.properties);
            for (int i = 0; i < p.Count; i++)
            {
                properties.AddView(p.GetView2(i, null, properties));
            }

            Action action = () =>
            {
                servingsizes.RemoveAllViewsInLayout();
                for (int i = 0; i < a.Count; i++)
                {
                    servingsizes.AddView(a.GetView(i, null, servingsizes));
                }
            };

            a.RegisterDataSetObserver(new DSO(action));

            if (binding.Bindings.Count == 0)
            {
                binding.Add(Resource.Id.addInputDialog, x => x.Text);
                binding.Add(Resource.Id.opt_pergrams, x => x.Is100Gram);
                binding.Add(Resource.Id.opt_percup, x => x.IsNot100Gram);
                binding.Add(Resource.Id.opt_percup, x => x.SelectedServingText);
            }
            addInputDialog = listEntryEdit.FindViewById <EditText>(Resource.Id.addInputDialog);
            if (Navigate.selectedEntry.Item.IsNewItem)
            {
                addInputDialog.TextChanged += AddInputDialogTextChanged;
            }
            else
            {
                EditMode = true;
            }
            OriginalText = Navigate.selectedItem.Text;
#if DEBUG
            AndroidDebug.SetViewBorders(listEntryEdit);
#endif
        }