Пример #1
0
 public MyTaskOrEventCircles(Context context) : base(context)
 {
     _itemsControlWrapper = new ItemsControlWrapper(this)
     {
         ItemTemplate = new CustomDataTemplate <BaseViewItemMegaItem>(CreateCircle)
     };
 }
Пример #2
0
 public ListItemClassGroupedTimesView(ViewGroup root) : base(Resource.Layout.ListItemClassGroupedTimes, root)
 {
     _itemsControlWrapper = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.GroupedTimesViewGroup))
     {
         ItemTemplate = new CustomDataTemplate <ViewItemSchedule>(CreateTimeView)
     };
 }
 public MyHomeworkCircles(Context context) : base(context)
 {
     _itemsControlWrapper = new ItemsControlWrapper(this)
     {
         ItemTemplate = new CustomDataTemplate <BaseViewItemHomeworkExamGrade>(CreateCircle)
     };
 }
Пример #4
0
        public override void OnViewModelLoadedOverride()
        {
            _itemsWrapperMenuItems = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.LinearLayoutMenuItems))
            {
                ItemsSource  = ViewModel.AvailableItems,
                ItemTemplate = new CustomDataTemplate <NavigationManager.MainMenuSelections>(CreateMenuItem)
            };

            // Place the content presenter
            _contentPresenter = new PagedViewModelPresenter(Context);
            _contentPresenter.ContentChanged += _contentPresenter_ContentChanged;
            FindViewById <FrameLayout>(Resource.Id.ContentFrame).AddView(_contentPresenter); // Add view before assigning ViewModel, so that parent can be found
            _contentPresenter.ViewModel = ViewModel;

            _popupsPresenter.ViewModel = ViewModel;

            _viewModelPropertyChangedEventHandler = new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged).Handler;
            ViewModel.PropertyChanged            += _viewModelPropertyChangedEventHandler;

            UpdateActionBarTitle();
            UpdateClassesVisibility();
            UpdateSyncBarStatus();
            UpdateIsOffline();
            UpdateSyncError();

            _buttonIsOffline.Click += delegate { ViewModel.SyncCurrentAccount(); };
            _buttonSyncError.Click += delegate { _drawerLayout.CloseDrawers(); ViewModel.ViewSyncErrors(); };
            FindViewById <View>(Resource.Id.ImageViewPowerPlannerMenuIcon).Click += delegate { ViewModel.SyncCurrentAccount(); };

            TryAskingForRatingIfNeeded();
        }
Пример #5
0
 public override void OnViewModelLoadedOverride()
 {
     _itemsWrapperErrors = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.ViewGroupSyncErrors))
     {
         ItemsSource  = ViewModel.SyncErrors,
         ItemTemplate = new CustomDataTemplate <LoggedError>(CreateLoggedErrorView)
     };
 }
Пример #6
0
 public override void OnViewModelLoadedOverride()
 {
     _itemsWrapper = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.ClassTimesViewGroup))
     {
         ItemsSource  = ViewModel.TimesGroupedByDay,
         ItemTemplate = new CustomDataTemplate <ClassTimesViewModel.GroupedDay>(CreateTimeGroup)
     };
 }
 private void Initialize()
 {
     _itemsControlWrapper = new ItemsControlWrapper(this)
     {
         ItemTemplate = new CustomDataTemplate <object>(CreateImageView)
     };
     ImageAttachmentsWrapGrid.SharedInitialize(this);
 }
        public override void OnViewModelLoadedOverride()
        {
            FindViewById <Button>(Resource.Id.ButtonAddGradeScale).Click += delegate { ViewModel.AddGradeScale(); };

            _itemsWrapperGradeScales = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.ViewGroupGradeScales))
            {
                ItemsSource  = ViewModel.GradeScales,
                ItemTemplate = new CustomDataTemplate <GradeScale>(CreateGradeScaleItemView)
            };
        }
Пример #9
0
        protected override void Init(string regionName, out IItemsControlWrapper <ItemsControl> target)
        {
            ItemsControl control = new ItemsControl();

            UIRegion.SetRegion(control, regionName);
            target = new ItemsControlWrapper()
            {
                Target = control
            };
        }
        public override void OnViewModelLoadedOverride()
        {
            base.OnViewModelLoadedOverride();

            _itemsWrapperRecoveredUsernames = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.ViewGroupRecoveredUsernames))
            {
                ItemsSource  = ViewModel.Usernames,
                ItemTemplate = new CustomDataTemplate <string>(CreateUsernameView)
            };
        }
Пример #11
0
        public override void OnViewModelLoadedOverride()
        {
            FindViewById <Button>(Resource.Id.ButtonAddWeightCategory).Click += delegate { ViewModel.AddWeightCategory(); };

            _itemsWrapperWeights = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.ViewGroupWeightCategories))
            {
                ItemsSource  = ViewModel.WeightCategories,
                ItemTemplate = new CustomDataTemplate <EditingWeightCategoryViewModel>(CreateWeightCategoryItemView)
            };
        }
Пример #12
0
        protected override void Init(out IViewInjectionService service, out IItemsControlWrapper <ItemsControl> target)
        {
            ItemsControl control = new ItemsControl();
            var          s       = new ViewInjectionService();

            Interaction.GetBehaviors(control).Add(s);
            target = new ItemsControlWrapper()
            {
                Target = control
            };
            service = s;
        }
        public override void OnViewModelLoadedOverride()
        {
            // Must keep a strong reference so doesn't get disposed
            _itemsWrapperYears = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.YearsListView))
            {
                ItemsSource  = ViewModel.YearsViewItemsGroup.School.Years,
                ItemTemplate = new CustomDataTemplate <ViewItemYear>(CreateYearView)
            };

            FindViewById <Button>(Resource.Id.ButtonAddYear).Click += ButtonAddYear_Click;

            FindViewById(Resource.Id.YearsContent).Visibility = ViewStates.Visible;
        }
Пример #14
0
        public ListItemYearView(ViewGroup root, ViewItemYear year) : base(Resource.Layout.ListItemYear, root)
        {
            DataContext = year;
            Year        = year;

            FindViewById <Button>(Resource.Id.ButtonAddSemester).Click += delegate { OnAddSemesterRequested?.Invoke(this, new EventArgs()); };
            FindViewById <View>(Resource.Id.YearName).Click            += delegate { OnEditRequested?.Invoke(this, new EventArgs()); };

            _itemsWrapperSemester = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.ViewGroupSemesters))
            {
                ItemsSource  = year.Semesters,
                ItemTemplate = new CustomDataTemplate <ViewItemSemester>(CreateSemester)
            };
        }
        private void Initialize()
        {
            _spinnerRepeatOptions = FindViewById <Spinner>(Resource.Id.SpinnerRepeatOptions);
            _spinnerRepeatOptions.ItemSelected += _spinnerRepeatOptions_ItemSelected;

            _dayCheckBoxesLeftSideWrapper = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.LinearLayoutDayCheckBoxesLeftSide))
            {
                ItemTemplate = new CustomDataTemplate <RecurrenceControlViewModel.DayCheckBox>(CreateDayCheckBoxView)
            };
            _dayCheckBoxesRightSideWrapper = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.LinearLayoutDayCheckBoxesRightSide))
            {
                ItemTemplate = new CustomDataTemplate <RecurrenceControlViewModel.DayCheckBox>(CreateDayCheckBoxView)
            };
        }
        public ListItemSemesterView(ViewGroup root) : base(Resource.Layout.ListItemSemester, root)
        {
            FindViewById <Button>(Resource.Id.ButtonOpenSemester).Click += delegate { OpenSemesterRequested?.Invoke(this, (ViewItemSemester)DataContext); };
            FindViewById <View>(Resource.Id.SemesterName).Click         += delegate { EditSemesterRequested?.Invoke(this, (ViewItemSemester)DataContext); };
            FindViewById <View>(Resource.Id.SemesterView).Click         += delegate { OpenSemesterRequested?.Invoke(this, (ViewItemSemester)DataContext); };

            _viewNoClasses = FindViewById(Resource.Id.TextViewNoClasses);
            _classesHeader = FindViewById(Resource.Id.ClassesHeader);
            _classesFooter = FindViewById(Resource.Id.ClassesFooter);

            _classesItemsWrapper = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.ViewGroupClasses))
            {
                ItemTemplate = new CustomDataTemplate <ViewItemClass>(CreateClass)
            };
        }
        public ListItemEditingScheduleClassView(ViewGroup root, ViewItemClass c) : base(Resource.Layout.ListItemEditingScheduleClass, root)
        {
            DataContext = c;

            FindViewById <Button>(Resource.Id.ButtonAddTime).Click += delegate { OnAddClassTimeRequested?.Invoke(this, (ViewItemClass)DataContext); };
            FindViewById(Resource.Id.ListItemEditingScheduleClass_ClassName).Click += delegate { OnEditClassRequested?.Invoke(this, (ViewItemClass)DataContext); };

            _timesItemsControlWrapper = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.ViewGroupClassTimes))
            {
                ItemTemplate = new CustomDataTemplate <ViewItemSchedule[]>(CreateListViewTimeItem)
            };

            c.Schedules.CollectionChanged += new WeakEventHandler <NotifyCollectionChangedEventArgs>(Schedules_CollectionChanged).Handler;
            UpdateTimes();
        }
Пример #18
0
        public override void OnViewModelLoadedOverride()
        {
            //FindViewById<AdapterLinearLayout>(Resource.Id.YearsListView).Adapter = ObservableAdapter.Create(
            //    ViewModel.YearsViewItemsGroup.School.Years,
            //    CreateYearView);

            _itemsWrapperYears = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.YearsListView))
            {
                ItemsSource  = ViewModel.YearsViewItemsGroup.School.Years,
                ItemTemplate = new CustomDataTemplate <ViewItemYear>(CreateYearView)
            };

            FindViewById <Button>(Resource.Id.ButtonAddYear).Click += ButtonAddYear_Click;

            base.Visibility = ViewStates.Visible;
        }
Пример #19
0
        public override void OnViewModelLoadedOverride()
        {
            ViewModel.InitializeArrangers(HEIGHT_OF_HOUR, MyCollapsedEventItem.SPACING_WITH_NO_ADDITIONAL, MyCollapsedEventItem.SPACING_WITH_ADDITIONAL, MyCollapsedEventItem.WIDTH_OF_COLLAPSED_ITEM);

            FindViewById <Button>(Resource.Id.ButtonAddClass).Click        += delegate { ViewModel.AddClass(); };
            FindViewById <Button>(Resource.Id.ButtonWelcomeAddClass).Click += delegate { ViewModel.AddClass(); };

            ViewModel.OnFullReset           += new WeakEventHandler(ViewModel_OnFullReset).Handler;
            ViewModel.OnItemsForDateChanged += new WeakEventHandler <DateTime>(ViewModel_OnItemsForDateChanged).Handler;
            ViewModel.PropertyChanged       += new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged).Handler;

            _itemsWrapperEditingClasses = new ItemsControlWrapper(FindViewById <ViewGroup>(Resource.Id.EditingClassesViewGroup))
            {
                ItemsSource  = ViewModel.SemesterViewItemsGroup.Classes,
                ItemTemplate = new CustomDataTemplate <ViewItemClass>(CreateListItemEditingScheduleClass)
            };

            UpdateLayoutMode();

            // First prepare the schedule host
            _scheduleHost        = FindViewById <LinearLayout>(Resource.Id.ScheduleHost);
            _scheduleHost.Click += ScheduleHost_Click;
            _scheduleHost.AddView(CreateColumn(0));
            DayOfWeek dayOfWeek = ViewModel.FirstDayOfWeek;

            for (int i = 0; i < 7; i++, dayOfWeek++)
            {
                var column = CreateColumn(i + 1);

                TextView dayHeader = new TextView(Context)
                {
                    Text = DateTools.ToLocalizedString(dayOfWeek)
                };

                column.AddView(dayHeader);

                _scheduleHost.AddView(column);
            }

            RenderSchedule();
        }
        public ClassGradesTopHeaderView(ViewGroup root, bool hideWhatIfModeButton) : base(Resource.Layout.ClassGradesTopHeader, root)
        {
            var viewGroupWeightCategoriesSummary = FindViewById <ViewGroup>(Resource.Id.ViewGroupWeightCategoriesSummary);

            _itemsControlWeightCategoriesSummary = new ItemsControlWrapper(viewGroupWeightCategoriesSummary)
            {
                ItemTemplate = new CustomDataTemplate <ViewItemWeightCategory>(CreateWeightCategorySummary)
            };

            var buttonWhatIfMode = FindViewById <Button>(Resource.Id.ButtonWhatIfMode);

            if (hideWhatIfModeButton)
            {
                buttonWhatIfMode.Visibility = ViewStates.Gone;
            }
            else
            {
                buttonWhatIfMode.Click += ButtonWhatIfMode_Click;
            }

            FindViewById <Button>(Resource.Id.ButtonEditGradeOptions).Click += ClassGradesTopHeaderView_Click;
        }
Пример #21
0
        private void render()
        {
            if (_holidaysLayout == null)
            {
                _holidaysLayout = new LinearLayout(Context)
                {
                    Orientation = Orientation.Vertical
                };

                _holidaysItemsWrapper = new ItemsControlWrapper(_holidaysLayout)
                {
                    ItemTemplate = new CustomDataTemplate <ViewItemHoliday>(CreateHolidayView)
                };

                base.AddView(_holidaysLayout);
            }

            if (_schedulesContent == null)
            {
                _schedulesContent = new RelativeLayout(Context);
                base.AddView(_schedulesContent);
            }
            else
            {
                _schedulesContent.RemoveAllViews();
            }

            if (Classes == null || Date == DateTime.MinValue || !ViewModel.Semester.IsDateDuringThisSemester(Date))
            {
                base.Visibility = ViewStates.Gone;
                return;
            }

            if (!_arrangedItems.IsValid())
            {
                base.Visibility = ViewStates.Gone;
                return;
            }

            base.Visibility = ViewStates.Visible;

            //put in the vertical gap divider
            View verticalGap = new View(Context)
            {
                LayoutParameters = new RelativeLayout.LayoutParams(
                    GapSize,
                    RelativeLayout.LayoutParams.MatchParent)
                {
                    LeftMargin = TimeIndicatorSize + GapSize
                }
            };

            verticalGap.SetBackgroundResource(Resource.Color.scheduleSnapshotDividers);
            _schedulesContent.AddView(verticalGap);

            int row = 0;

            for (TimeSpan time = _arrangedItems.StartTime; time <= _arrangedItems.EndTime; time = time.Add(TimeSpan.FromHours(1)), row++)
            {
                int startHeight = row * HeightOfHour;

                _schedulesContent.AddView(new TextView(Context)
                {
                    Text             = Android.Text.Format.DateFormat.Is24HourFormat(Context) ? time.Hours.ToString() : new DateTime().Add(time).ToString("h ").TrimEnd(),
                    TextSize         = 26,
                    LayoutParameters = new RelativeLayout.LayoutParams(
                        TimeIndicatorSize,
                        TimeIndicatorSize)
                    {
                        TopMargin = startHeight
                    },
                    Gravity = GravityFlags.Center
                });

                //if not last row, add the divider
                if (time + TimeSpan.FromHours(1) <= _arrangedItems.EndTime)
                {
                    var v = new View(Context)
                    {
                        Background       = new ColorDrawable(Color.White),
                        LayoutParameters = new RelativeLayout.LayoutParams(
                            RelativeLayout.LayoutParams.MatchParent,
                            GapSize)
                        {
                            TopMargin = startHeight + TimeIndicatorSize
                        }
                    };
                    v.SetBackgroundResource(Resource.Color.scheduleSnapshotDividers);
                    _schedulesContent.AddView(v);
                }
            }

            // Render the schedules
            foreach (var s in _arrangedItems.ScheduleItems)
            {
                MyScheduleItem visual = new MyScheduleItem(Context, s.Item);
                visual.Click += TimeItem_Click;

                AddVisualItem(visual, s);
            }

            // Reverse the order so that when items expand, they appear on top of the items beneath them.
            // Otherwise I would have to do some crazy Z-order logic.
            foreach (var e in _arrangedItems.EventItems.Reverse())
            {
                View visual;
                if (e.IsCollapsedMode)
                {
                    visual = new MyCollapsedEventItem(Context)
                    {
                        Item = e
                    };
                }
                else
                {
                    visual = new MyFullEventItem(Context)
                    {
                        Item = e
                    };
                }

                AddVisualItem(visual, e);
            }
        }
Пример #22
0
            public MenuItemCreator(ViewGroup root, NavigationManager.MainMenuSelections mainMenuSelection, MainScreenView mainScreenView)
            {
                _mainScreenView    = mainScreenView;
                _mainMenuSelection = mainMenuSelection;
                _mainScreenView.ViewModel.PropertyChanged += new WeakEventHandler <PropertyChangedEventArgs>(ViewModel_PropertyChanged1).Handler;

                TextView textView = new TextView(root.Context)
                {
                    Text             = PowerPlannerResources.GetStringMenuItem(mainMenuSelection),
                    TextSize         = 20,
                    Clickable        = true,
                    LayoutParameters = new LinearLayout.LayoutParams(
                        LinearLayout.LayoutParams.MatchParent,
                        LinearLayout.LayoutParams.WrapContent)
                };

                textView.SetTextColor(new Color(255, 255, 255));

                int paddingTopBottom = ThemeHelper.AsPx(root.Context, 11);
                int paddingLeft      = ThemeHelper.AsPx(root.Context, MENU_ITEM_PADDING_LEFT_PX);

                textView.SetPaddingRelative(paddingLeft, paddingTopBottom, 0, paddingTopBottom);

                textView.Click += delegate
                {
                    _mainScreenView.ViewModel.SelectedItem = mainMenuSelection;

                    if (mainMenuSelection != NavigationManager.MainMenuSelections.Classes)
                    {
                        _mainScreenView._drawerLayout.CloseDrawers();
                    }
                };

                if (mainMenuSelection == NavigationManager.MainMenuSelections.Classes)
                {
                    LinearLayout linearLayout = new LinearLayout(root.Context)
                    {
                        Orientation      = Orientation.Vertical,
                        LayoutParameters = new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.MatchParent,
                            LinearLayout.LayoutParams.WrapContent)
                    };

                    LinearLayout layoutClassesHeaderAndAddButton = new LinearLayout(root.Context)
                    {
                        Orientation      = Orientation.Horizontal,
                        LayoutParameters = new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.MatchParent,
                            LinearLayout.LayoutParams.WrapContent)
                    };

                    // This width will stretch
                    textView.LayoutParameters.Width = 0;
                    (textView.LayoutParameters as LinearLayout.LayoutParams).Weight = 1;

                    layoutClassesHeaderAndAddButton.AddView(textView);

                    // And then the add class button
                    ImageButton addClassButton = new ImageButton(root.Context)
                    {
                        LayoutParameters = new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.WrapContent,
                            LinearLayout.LayoutParams.MatchParent),
                        Visibility = ViewStates.Invisible
                    };
                    addClassButton.Background = ThemeHelper.GetAttributeDrawable(root.Context, Resource.Attribute.selectableItemBackground);
                    addClassButton.SetImageDrawable(ContextCompat.GetDrawable(root.Context, Android.Resource.Drawable.IcInputAdd));
                    if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                    {
                        addClassButton.ImageTintList = new Android.Content.Res.ColorStateList(new int[][] { new int[0] }, new int[] { new Color(255, 255, 255) });
                    }
                    addClassButton.Click += AddClassButton_Click;

                    _mainScreenView._classAddButtonReference = new WeakReference <View>(addClassButton);
                    layoutClassesHeaderAndAddButton.AddView(addClassButton);



                    linearLayout.AddView(layoutClassesHeaderAndAddButton);


                    LinearLayout classesViewGroup = new LinearLayout(root.Context)
                    {
                        Orientation      = Orientation.Vertical,
                        LayoutParameters = new LinearLayout.LayoutParams(
                            LinearLayout.LayoutParams.MatchParent,
                            LinearLayout.LayoutParams.WrapContent),
                        Visibility = ViewStates.Gone
                    };

                    _itemsWrapperClasses = new ItemsControlWrapper(classesViewGroup)
                    {
                        ItemsSource  = _mainScreenView.ViewModel.Classes,
                        ItemTemplate = new CustomDataTemplate <ViewItemClass>(_mainScreenView.CreateClassMenuItem)
                    };

                    _mainScreenView._classesViewGroupReference = new WeakReference <View>(classesViewGroup);

                    linearLayout.AddView(classesViewGroup);

                    View = linearLayout;
                }

                else
                {
                    View = textView;
                }

                UpdateIsSelected();
            }