예제 #1
0
        public void Render()
        {
            lock (SyncRoot) if (_instance == null)
                {
                    _instance = this;
                }

            Rendering.Raise(this, EventArgs.Empty);
            if (!TabItems.Any())
            {
                return;
            }
            if (string.IsNullOrEmpty(Text))
            {
                Text = "Go to...";
            }

            PaneManager.Instance.Clear();
            var tabs = TabItems.Select(item => CompactFactory.GetNativeObject <TabItem>(item, item.Title)).ToList();

            for (int i = 0; i < tabs.Count; i++)
            {
                var tab = tabs[i];
                if (tab == null)
                {
                    continue;
                }
                tab.View  = this;
                tab.Index = i;
                MenuItems.Add(tab);
                var context = new iApp.AppNavigationContext {
                    ActivePane = Pane.Master, ActiveTab = i
                };
                PaneManager.Instance.AddStack(new HistoryStack {
                    Context = context
                }, context);
            }

            var cxt = new iApp.AppNavigationContext {
                ActivePane = Pane.Popover,
            };

            PaneManager.Instance.AddStack(new HistoryStack {
                Context = cxt
            }, cxt);
            if (PaneManager.Instance.CurrentTab > TabItems.Count() || PaneManager.Instance.CurrentTab < 0)
            {
                PaneManager.Instance.CurrentTab = 0;
            }
            CompactFactory.Navigate(TabItems.ElementAt(PaneManager.Instance.CurrentTab).NavigationLink, this);
        }
 private void DeleteTabItem()
 {
     for (int i = 0; i < TabItems.Count; i++)
     {
         if (SelectedItem == null)
         {
             break;
         }
         if (TabItems.ElementAt(i).Title == SelectedItem.Title)
         {
             if (!IsSessionLoaded) //for database
             {
                 db.tabItems.Remove(TabItems.ElementAt(i));
                 db.SaveChanges();
                 LoadDbModels();
             }
             else   //for xml file
             {
                 TabItems.Remove(TabItems.ElementAt(i));
             }
         }
     }
 }
예제 #3
0
        public bool OnNavigationItemSelected(int itemPosition, long itemId)
        {
            if (DroidFactory.Tabs != this)
            {
                return(false);
            }

            var masterStack = (FragmentHistoryStack)PaneManager.Instance.FromNavContext(Pane.Master, itemPosition);
            var tab         = TabItems.ElementAt(itemPosition);
            var nativeTab   = DroidFactory.GetNativeObject <TabItem>(TabItems.ElementAt(itemPosition), "tab");

            if (itemPosition != SelectedIndex && !PaneManager.Instance.ShouldNavigate(tab.NavigationLink, Pane.Tabs, NavigationType.Tab))
            {
                return(false);
            }

            if (masterStack.CurrentView == null)
            {
                SelectedIndex = itemPosition;
                this.OnPropertyChanged("SelectedIndex");
                nativeTab.Activate(this);
            }
            else
            {
                if (itemPosition == SelectedIndex)
                {
                    masterStack.Align(NavigationType.Tab);
                    return(true);
                }

                SelectedIndex = itemPosition;
                var navTabs = _model as NavigationTabs;
                if (navTabs != null && navTabs.TabItems[itemPosition].RefreshOnFocus)
                {
                    this.OnPropertyChanged("SelectedIndex");
                    nativeTab.Activate(this);
                    return(true);
                }

                iLayer.NavigationContext context;
                if (masterStack.CurrentLayer != null && (context = masterStack.CurrentLayer.NavContext) != null)
                {
                    //Fix layer context if it was modified in a different tab
                    context.ClearPaneHistoryOnOutput = false;
                    context.NavigatedActivePane      = Pane.Tabs;
                    context.NavigatedActiveTab       = itemPosition;
                    context.OutputOnPane             = Pane.Master;
                }

                if (itemPosition != iApp.CurrentNavContext.ActiveTab)
                {
                    var masterView = (PaneManager.Instance.FromNavContext(Pane.Master, iApp.CurrentNavContext.ActiveTab) as FragmentHistoryStack)?.CurrentView as IView;
                    iApp.SetNavigationContext(new iLayer.NavigationContext {
                        OutputOnPane = Pane.Tabs, NavigatedActiveTab = itemPosition,
                    });
                    masterView?.RaiseEvent("Deactivated", EventArgs.Empty);
                }

                nativeTab.OnSelected();
                this.OnPropertyChanged("SelectedIndex");
                masterStack.Align(NavigationType.Tab);
                (PaneManager.Instance.FromNavContext(Pane.Detail, 0) as FragmentHistoryStack)?.PopToRoot();
            }
            return(true);
        }