protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Forms.Init(this, bundle);

            UserName     = Intent.GetStringExtra("USERNAME");
            UserPassword = Intent.GetStringExtra("PASSWORD");
            // Deactivated local User Database
            // UserId = Intent.GetIntExtra("USERID", -1);

            #region Connect to OPC UA Server
            // when View is created: connect the client to the specified Endpoint
            Connect();
            #endregion

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Find views
            _pager     = FindViewById <ViewPager>(Resource.Id.pager);
            _tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs);
            var adapter = new MenuPagerAdapter(this, SupportFragmentManager);
            _toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            //Setup Toolbar
            SetSupportActionBar(_toolbar);
            SetupSupportActionBar();

            // Set adapter to view pager and add OnPageChangeListener
            _pager.Adapter = adapter;
            _pager.AddOnPageChangeListener(this);

            // Setup tablayout with view pager
            _tabLayout.SetupWithViewPager(_pager);

            // Iterate over all tabs and set the custom view
            for (int i = 0; i < _tabLayout.TabCount; i++)
            {
                TabLayout.Tab tab = _tabLayout.GetTabAt(i);
                tab.SetCustomView(adapter.GetTabView(i));
            }
        }
        private void SetSelectedTabIcon(TabLayout.Tab tab, string icon, bool selected)
        {
            if (string.IsNullOrEmpty(icon))
            {
                return;
            }

            if (selected)
            {
                var selectedResource = IdFromTitle(string.Format("{0}_selected", icon), ResourceManager.DrawableClass);
                if (selectedResource != 0)
                {
                    tab.SetIcon(selectedResource);
                    return;
                }
            }

            var resource = IdFromTitle(icon, ResourceManager.DrawableClass);

            tab.SetIcon(resource);
        }
Exemplo n.º 3
0
 void TabLayout.IOnTabSelectedListener.OnTabReselected(TabLayout.Tab tab)
 {
     // To have the logic only on he tab on position 1
     if (tab == null || tab.Position != 1)
     {
         return;
     }
     if (tab.Text == "Play")
     {
         tab.SetText("Pause");
         tab.SetIcon(Resource.Drawable.ionicons_2_0_1_pause_outline_25);
         App.pauseCard = false;
     }
     else
     {
         tab.SetText("Play");
         tab.SetIcon(Resource.Drawable.ionicons_2_0_1_play_outline_25);
         App.pauseCard = true;
     }
     SetTintColor(tab, GetTabColor());
 }
Exemplo n.º 4
0
        void UpdateTabIcons()
        {
            if (IsDisposed)
            {
                return;
            }

            TabLayout tabs = _tabLayout;

            if (tabs.TabCount != Element.Children.Count)
            {
                return;
            }

            for (var i = 0; i < Element.Children.Count; i++)
            {
                Page          child = Element.Children[i];
                TabLayout.Tab tab   = tabs.GetTabAt(i);
                SetTabIconImageSource(child, tab);
            }
        }
Exemplo n.º 5
0
        void UpdateItemIconColor()
        {
            if (IsDisposed)
            {
                return;
            }

            if (IsBottomTabPlacement)
            {
                _bottomNavigationView.ItemIconTintList = GetItemIconTintColorState() ?? _orignalTabIconColors;
            }
            else
            {
                var colors = GetItemIconTintColorState() ?? _orignalTabIconColors;
                for (int i = 0; i < _tabLayout.TabCount; i++)
                {
                    TabLayout.Tab tab = _tabLayout.GetTabAt(i);
                    this.SetIconColorFilter(tab);
                }
            }
        }
Exemplo n.º 6
0
        void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == Page.TitleProperty.PropertyName)
            {
                var page  = (Page)sender;
                var index = Element.Children.IndexOf(page);

                if (IsBottomTabPlacement)
                {
                    IMenuItem tab = _bottomNavigationView.Menu.GetItem(index);
                    tab.SetTitle(page.Title);
                }
                else
                {
                    TabLayout.Tab tab = _tabLayout.GetTabAt(index);
                    tab.SetText(page.Title);
                }
            }
            else if (e.PropertyName == Page.IconImageSourceProperty.PropertyName)
            {
                var page  = (Page)sender;
                var index = Element.Children.IndexOf(page);
                if (IsBottomTabPlacement)
                {
                    var menuItem = _bottomNavigationView.Menu.GetItem(index);
                    _ = this.ApplyDrawableAsync(page, Page.IconImageSourceProperty, Context, icon =>
                    {
                        menuItem.SetIcon(icon);
                    });
                }
                else
                {
                    TabLayout.Tab tab = _tabLayout.GetTabAt(index);
                    _ = this.ApplyDrawableAsync(page, Page.IconImageSourceProperty, Context, icon =>
                    {
                        SetTabIcon(tab, icon);
                    });
                }
            }
        }
Exemplo n.º 7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            CurrentPlatform.Init();

            byDateFilter   = false;
            byAuthorFilter = false;

            // Set our view from the "main" layout resource
            base.SetContentView(PlanYourJourney.Resource.Layout.Main);
            List = new List <Arrangement>();
            UpdateData();

            ISharedPreferences settings = GetSharedPreferences("MyPrefsFile", 0);

            MyUsername = settings.GetString("author", "");

            // Find views
            _pager     = FindViewById <ViewPager>(PlanYourJourney.Resource.Id.pager);
            _tabLayout = FindViewById <TabLayout>(PlanYourJourney.Resource.Id.sliding_tabs);
            _adapter   = new CustomPagerAdapter(this, SupportFragmentManager);
            _toolbar   = FindViewById <Toolbar>(PlanYourJourney.Resource.Id.my_toolbar);

            // Setup Toolbar
            SetSupportActionBar(_toolbar);
            base.SupportActionBar.Title = GetString(PlanYourJourney.Resource.String.app_name);

            // Set adapter to view pager
            _pager.Adapter = _adapter;

            // Setup tablayout with view pager
            _tabLayout.SetupWithViewPager(_pager);

            // Iterate over all tabs and set the custom view
            for (int i = 0; i < 3; i++)
            {
                TabLayout.Tab tab = _tabLayout.GetTabAt(i);
                tab.SetCustomView(_adapter.GetTabView(i));
            }
        }
Exemplo n.º 8
0
        void Handle_UpdateIcons(object sender, EventArgs e)
        {
            TabLayout tabs = layout;

            if (tabs == null)
            {
                return;
            }

            for (var i = 0; i < Element.Children.Count; i++)
            {
                var child = Element.Children[i].BindingContext as IIconChange;
                var icon  = child.CurrentIcon;
                if (string.IsNullOrEmpty(icon))
                {
                    continue;
                }

                TabLayout.Tab tab = tabs.GetTabAt(i);
                SetCurrentTabIcon(tab, icon);
            }
        }
Exemplo n.º 9
0
        void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == Page.TitleProperty.PropertyName)
            {
                var page  = (Page)sender;
                var index = Element.Children.IndexOf(page);

                if (IsBottomTabPlacement)
                {
                    IMenuItem tab = _bottomNavigationView.Menu.GetItem(index);
                    tab.SetTitle(page.Title);
                }
                else
                {
                    TabLayout.Tab tab = _tabLayout.GetTabAt(index);
                    tab.SetText(page.Title);
                }
            }
            else if (e.PropertyName == Page.IconImageSourceProperty.PropertyName)
            {
                var page  = (Page)sender;
                var index = Element.Children.IndexOf(page);
                if (IsBottomTabPlacement)
                {
                    var menuItem = _bottomNavigationView.Menu.GetItem(index);
                    page.IconImageSource.LoadImage(
                        _context,
                        result =>
                    {
                        menuItem.SetIcon(result.Value);
                    });
                }
                else
                {
                    TabLayout.Tab tab = _tabLayout.GetTabAt(index);
                    SetTabIconImageSource(page, tab);
                }
            }
        }
Exemplo n.º 10
0
        void UpdateTabIcons()
        {
            TabLayout tabs = _tabLayout;

            if (tabs.TabCount != Element.Children.Count)
            {
                return;
            }

            for (var i = 0; i < Element.Children.Count; i++)
            {
                Page            child = Element.Children[i];
                FileImageSource icon  = child.Icon;
                if (string.IsNullOrEmpty(icon))
                {
                    continue;
                }

                TabLayout.Tab tab = tabs.GetTabAt(i);
                tab.SetIcon(ResourceManager.IdFromTitle(icon, ResourceManager.DrawableClass));
            }
        }
Exemplo n.º 11
0
 protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
 {
     base.SetTabIcon(tab, icon);
     if (tab.Text == "菜单" || tab.Text == "搜索")
     {
         tab.SetCustomView(Resource.Layout.CustomTablayout);
         var customView = Element as CustomTabbedPage;
         var imagebtn   = tab.CustomView.FindViewById <Android.Widget.ImageButton>(Resource.Id.tabpage_btn);
         imagebtn.Background = tab.Icon;
         imagebtn.Click     += (sender, e) =>
         {
             if (tab.Text == "菜单")
             {
                 CustomTabbedPage.OnMenuClicked(customView, EventArgs.Empty);
             }
             else if (tab.Text == "搜索")
             {
                 CustomTabbedPage.OnSearchClick(customView, EventArgs.Empty);
             }
         };
     }
 }
Exemplo n.º 12
0
        private void SetTab(TabLayout.Tab tab, string name)
        {
            try
            {
                int id = Resources.GetIdentifier(name, "drawable", Context.PackageName);
                tab.SetIcon(null);

                LinearLayout.LayoutParams linearLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                linearLayoutParams.SetMargins(0, -48, 0, 0);

                ImageView img = new ImageView(Context);
                img.LayoutParameters = linearLayoutParams;
                img.SetPadding(0, 0, 0, 48);
                img.SetImageResource(id);

                tab.SetCustomView(img);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.StackTrace);
            }
        }
Exemplo n.º 13
0
        void UpdateTabIcons()
        {
            TabLayout tabs = _tabLayout;

            if (tabs.TabCount != Element.Children.Count)
            {
                return;
            }

            for (var i = 0; i < Element.Children.Count; i++)
            {
                Page            child = Element.Children[i];
                FileImageSource icon  = child.Icon;
                if (string.IsNullOrEmpty(icon))
                {
                    continue;
                }

                TabLayout.Tab tab = tabs.GetTabAt(i);
                SetTabIcon(tab, icon);
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = base.OnCreateView(inflater, container, savedInstanceState);

            viewPager = view.FindViewById <UnscrollingViewPager>(Resource.Id.points_view_pager);
            viewPager.SetPagingEnabled(true);
            PointsSmoothViewPagerHelper.Customize(viewPager);
            if (viewPager != null)
            {
                fragments = new List <MvxViewPagerFragmentInfo>
                {
                    new MvxViewPagerFragmentInfo(tabTitles[0], typeof(PointsFragment), (Activity as MainActivity).vmHelper.PointsVM),
                    new MvxViewPagerFragmentInfo(tabTitles[1], typeof(LeaderboardFragment), (Activity as MainActivity).vmHelper.LeaderboardVM),
                    new MvxViewPagerFragmentInfo(tabTitles[2], typeof(TransactionsFragment), (Activity as MainActivity).vmHelper.TransactionsVM),
                };
                pagerAdapter = new MvxCachingFragmentStatePagerAdapter(Activity, this.ChildFragmentManager, fragments);

                viewPager.Adapter = pagerAdapter;
                tabLayout         = view.FindViewById <TabLayout>(Resource.Id.points_tabs);
                tabLayout.SetupWithViewPager(viewPager);
                viewPager.AddOnPageChangeListener(this);

                tabLayout.SetupWithViewPager(viewPager);
                for (int i = 0; i < tabLayout.TabCount; i++)
                {
                    TabLayout.Tab tab = tabLayout.GetTabAt(i);
                    tab.SetCustomView(GetTabView(i));
                }
                tabLayout.AddOnTabSelectedListener(this);
                TabHighlited(tabLayout.GetTabAt(0));
            }
            ViewModel.AddCurrentVM += ViewModel_AddCurrentVM;

            (Activity as MainActivity).vmHelper.PointsVM.DetailsViewOpened += (s, e) => {
                viewPager.SetPagingEnabled(!e);
            };
            return(view);
        }
Exemplo n.º 15
0
        void UpdateTabIcons()
        {
            if (IsDisposed)
            {
                return;
            }

            TabLayout tabs = _tabLayout;

            if (tabs.TabCount != Element.Children.Count)
            {
                return;
            }

            for (var i = 0; i < Element.Children.Count; i++)
            {
                Page          child = Element.Children[i];
                TabLayout.Tab tab   = tabs.GetTabAt(i);
                _ = this.ApplyDrawableAsync(child, Page.IconImageSourceProperty, Context, icon =>
                {
                    SetTabIcon(tab, icon);
                });
            }
        }
Exemplo n.º 16
0
        void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == Page.TitleProperty.PropertyName)
            {
                var page  = (Page)sender;
                var index = Element.Children.IndexOf(page);

                if (IsBottomTabPlacement)
                {
                    IMenuItem tab = _bottomNavigationView.Menu.GetItem(index);
                    tab.SetTitle(page.Title);
                }
                else
                {
                    TabLayout.Tab tab = _tabLayout.GetTabAt(index);
                    tab.SetText(page.Title);
                }
            }
            else if (e.PropertyName == Page.IconProperty.PropertyName)
            {
                var             page  = (Page)sender;
                var             index = Element.Children.IndexOf(page);
                FileImageSource icon  = page.Icon;

                if (IsBottomTabPlacement)
                {
                    var menuItem = _bottomNavigationView.Menu.GetItem(index);
                    menuItem.SetIcon(GetIconDrawable(icon));
                }
                else
                {
                    TabLayout.Tab tab = _tabLayout.GetTabAt(index);
                    SetTabIcon(tab, icon);
                }
            }
        }
Exemplo n.º 17
0
        private void InitTabs()
        {
            for (var i = 0; i < _adapter.TabIconsInactive.Length; i++)
            {
                var tab     = _tabLayout.NewTab();
                var tabView = new ImageView(this)
                {
                    Id = Android.Resource.Id.Icon
                };
                tabView.SetScaleType(ImageView.ScaleType.CenterInside);
                tabView.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, _tabHeight);
                tab.SetCustomView(tabView);

                _tabLayout.AddTab(tab);
                if (i == _adapter.TabIconsInactive.Length - 1)
                {
                    SetProfileChart(_tabLayout.LayoutParameters.Height);
                }
                tab.SetIcon(ContextCompat.GetDrawable(this, _adapter.TabIconsInactive[i]));
            }
            SelectTab(BasePresenter.User.SelectedTab);
            _prevTab = _tabLayout.GetTabAt(BasePresenter.User.SelectedTab);
            _viewPager.OffscreenPageLimit = _adapter.Count - 1;
        }
Exemplo n.º 18
0
 private void OnTabLayoutOnTabSelected(object sender, TabLayout.TabSelectedEventArgs e)
 {
     if (e.Tab.Position == 2)
     {
         if (PermissionChecker.CheckSelfPermission(this, Android.Manifest.Permission.Camera) == (int)Permission.Granted &&
             PermissionChecker.CheckSelfPermission(this, Android.Manifest.Permission.WriteExternalStorage) == (int)Permission.Granted)
         {
             _prevTab.Select();
             var intent = new Intent(this, typeof(CameraActivity));
             StartActivity(intent);
         }
         else
         {
             //Replace for Permission request
             this.ShowAlert(LocalizationKeys.CheckPermission);
         }
     }
     else
     {
         SelectTab(e.Tab.Position);
         _prevTab = e.Tab;
         BasePresenter.User.SelectedTab = e.Tab.Position;
     }
 }
Exemplo n.º 19
0
 void TabLayout.IOnTabSelectedListener.OnTabUnselected(TabLayout.Tab tab)
 {
 }
Exemplo n.º 20
0
 protected virtual void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
 {
     tab.SetIcon(ResourceManager.IdFromTitle(icon, ResourceManager.DrawableClass));
 }
Exemplo n.º 21
0
 public void OnTabSelected(TabLayout.Tab tab)
 {
     viewPager.CurrentItem = tab.Position;
     adapter.OnRefresh(tab.Position);
 }
Exemplo n.º 22
0
 void SetIconColorFilter(TabLayout.Tab tab)
 {
     SetIconColorFilter(tab, _tabLayout.GetTabAt(_tabLayout.SelectedTabPosition) == tab);
 }
Exemplo n.º 23
0
 void TabLayout.IOnTabSelectedListener.OnTabUnselected(TabLayout.Tab tab)
 {
     SetIconColorFilter(tab, false);
 }
Exemplo n.º 24
0
 void TabLayout.IOnTabSelectedListener.OnTabReselected(TabLayout.Tab tab)
 {
     System.Diagnostics.Debug.WriteLine("Tab Reselected");
     //Handle Tab Reselected
 }
Exemplo n.º 25
0
 public void OnTabSelected(TabLayout.Tab tab)
 {
     _viewPagerHome.CurrentItem = tab.Position;
     currentPosition            = tab.Position;
 }
Exemplo n.º 26
0
 private ITabItem GetTabItem(TabLayout.Tab item, IList <ITabItem> tabItems)
 {
     return(tabItems.FirstOrDefault(m => m.Title.Equals(item.Text)));
 }
Exemplo n.º 27
0
        void TabLayout.IOnTabSelectedListener.OnTabUnselected(TabLayout.Tab tab)
        {
            var child = Element.Children[tab.Position];

            SetSelectedTabIcon(tab, child.Icon, false);
        }
Exemplo n.º 28
0
 protected virtual void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
 {
     tab.SetIcon(GetIconDrawable(icon));
     this.SetIconColorFilter(tab);
 }
Exemplo n.º 29
0
 public void OnTabUnselected(TabLayout.Tab tab)
 {
 }
Exemplo n.º 30
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ActivityTest);

            //Работа с контекстом приложения
            AppApplication myApp = (AppApplication)ApplicationContext;

            // Find views
            viewPager = FindViewById <ViewPager>(Resource.Id.pager);
            tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs);
            AdapterCustomPager adapter = new AdapterCustomPager(this, SupportFragmentManager);

            toolbar = FindViewById <SupportToolbar>(Resource.Id.my_toolbar);

            mButtonSettingsApp        = FindViewById <Button>(Resource.Id.settingsApp);
            mButtonSettingsApp.Click += (sender, args) => {
                Intent IntentSettings = new Intent(this, typeof(ActivitySettings));
                IntentSettings.PutExtra("settings", "app");
                StartActivity(IntentSettings);
            };
            mButtonSettingsAdmin        = FindViewById <Button>(Resource.Id.settingsAdmin);
            mButtonSettingsAdmin.Click += (sender, args) =>
            {
                Intent IntentSettings = new Intent(this, typeof(ActivitySettings));
                IntentSettings.PutExtra("settings", "admin");
                StartActivity(IntentSettings);
            };

            mButtonSettingsUser        = FindViewById <Button>(Resource.Id.settingsUser);
            mButtonSettingsUser.Click += (sender, args) =>
            {
                Intent IntentSettings = new Intent(this, typeof(ActivitySettings));
                IntentSettings.PutExtra("settings", "user");
                StartActivity(IntentSettings);
            };

            mButtonActivityMessage        = FindViewById <Button>(Resource.Id.activityMessage);
            mButtonActivityMessage.Click += (sender, args) =>
            {
                Intent IntentMessage = new Intent(this, typeof(ActivityMessage));
                StartActivity(IntentMessage);
            };

            Button mButtonActivityMap = FindViewById <Button>(Resource.Id.activityMap);

            mButtonActivityMap.Click += (sender, args) =>
            {
                Intent IntentMessage = new Intent(this, typeof(ActivityMaps));
                StartActivity(IntentMessage);
            };


            // Setup Toolbar
            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "View для тестирования";
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);

            setupViewPager(viewPager, adapter);

            tabLayout.SetupWithViewPager(viewPager);
            setupTabIcons();

            for (int i = 0; i < tabLayout.TabCount; i++)
            {
                TabLayout.Tab tab = tabLayout.GetTabAt(i);
                tab.SetCustomView(adapter.GetTabView(i));
            }
        }