public override void OnSelected() { if (SelectedTab == null && TabItems.Any()) { SelectedTab = TabItems.First(); } SelectedTab?.OnSelected(); }
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); }
public override void AddTabItem(IFile <LogFileItem> logFile) { if (!TabItems.Any(x => String.Compare((string)x.Tag, logFile.Tag, true) == 0)) { SetStatus("adding tab:" + logFile.Tag); LogTabViewModel tabItem = new LogTabViewModel() { Name = logFile.FileName, Tag = logFile.Tag, Header = logFile.FileName, IsNew = logFile.IsNew }; TabItems.Add(tabItem); SelectedIndex = TabItems.Count - 1; } }
public void Render() { Clear(); this.RaiseEvent(nameof(Rendering), EventArgs.Empty); DroidFactory.Tabs = this; AddAll(TabItems.Select(t => t.Title).ToList()); var actionBar = DroidFactory.MainActivity.ActionBar; if (!TabItems.Any()) { return; } HeaderColor = iApp.Instance.Style.HeaderColor; actionBar.Title = null; actionBar.Subtitle = null; actionBar.NavigationMode = ActionBarNavigationMode.List; actionBar.SetListNavigationCallbacks(this, this); actionBar.SetSelectedNavigationItem(PaneManager.Instance.CurrentTab > TabItems.Count() - 1 ? 0 : PaneManager.Instance.CurrentTab); }
public string GenerateTempTagName() { // generate -new ##- index number string tempTag = string.Empty; for (int i = 0; i < 100; i++) { tempTag = string.Format(_tempTabNameFormat, i); if (TabItems.Any(x => String.Compare((string)x.Header, tempTag, true) == 0)) { continue; } else { break; } } return(tempTag); }
public void Render() { this.RaiseEvent(nameof(Rendering), EventArgs.Empty); if (!TabItems.Any()) { return; } DroidFactory.Tabs = this; _inFlight = true; var actionBar = DroidFactory.MainActivity.ActionBar; actionBar.RemoveAllTabs(); var ig = new ImageGetter(); foreach (var tab in TabItems) { var abTab = actionBar.NewTab(); abTab.SetTabListener(this); abTab.SetText(tab.Title); abTab.SetIcon(ig.GetDrawable(tab.ImagePath)); actionBar.AddTab(abTab); } _inFlight = false; HeaderColor = iApp.Instance.Style.HeaderColor; actionBar.Title = null; actionBar.Subtitle = null; if (SelectedIndex > -1) { iApp.SetNavigationContext(new iLayer.NavigationContext { OutputOnPane = iApp.CurrentNavContext.ActivePane, NavigatedActiveTab = SelectedIndex, }); actionBar.SelectTab(actionBar.GetTabAt(SelectedIndex)); } actionBar.NavigationMode = ActionBarNavigationMode.Tabs; }
public override void AddTabItem(IFile <FilterFileItem> filterFile) { if (!TabItems.Any(x => String.Compare((string)x.Tag, filterFile.Tag, true) == 0)) { SetStatus("adding tab:" + filterFile.Tag); FilterTabViewModel tabItem = new FilterTabViewModel() { Name = filterFile.FileName, ContentList = ((FilterFile)filterFile).ContentItems, Tag = filterFile.Tag, Header = filterFile.FileName, Modified = false, IsNew = filterFile.IsNew }; // tabItem.ContentList.CollectionChanged += ContentList_CollectionChanged; tabItem.PropertyChanged += tabItem_PropertyChanged; TabItems.Add(tabItem); SelectedIndex = TabItems.Count - 1; } }
private void OnOpenWebLogs(object obj) { TabItem tab; if (!TabItems.Any(t => t.Header.Equals("Web Logs"))) { tab = new TabItem { Header = "Web Logs", Content = new WebLogView(), DataContext = new WebLogViewModel(this) }; TabItems.Add(tab); } else { tab = TabItems.FirstOrDefault(t => t.Header.Equals("Web Logs")); } SelectedTabIndex = TabItems.IndexOf(tab); }
private void OnAgentInteract(object obj) { TabItem tab; if (!TabItems.Any(t => t.Header.Equals(SelectedAgent.AgentId))) { tab = new TabItem { Header = SelectedAgent.AgentId, Content = new AgentInteractView(), DataContext = new AgentInteractViewModel(this, SelectedAgent.AgentId) }; TabItems.Add(tab); } else { tab = TabItems.FirstOrDefault(t => t.Header.Equals(SelectedAgent.AgentId)); } SelectedTabIndex = TabItems.IndexOf(tab); }
private void SetTabControlVisibility() { IsVisibleTabControl = TabItems.Any(); }
/// <summary> /// Method to handle fetching of User Interests from NewsAPI /// </summary> public async Task GetUserData() { if (TabItems.Any()) { TabItems.Clear(); } var userInterestsList = DatabaseHelper.GetSavedInterestsList(); if (userInterestsList != null && userInterestsList.Any()) { foreach (var interest in userInterestsList) { TabItems.Add(new Tab { Title = interest.Title, ArticlePage = 1 }); } CurrentTab = TabItems[0]; foreach (var tab in TabItems) { await LoadTabData(tab).ConfigureAwait(false); } } else { // Save locally and load user interests if null List <Interest> interests = new List <Interest> { new Interest { Title = "Headlines" }, new Interest { Title = "Business" }, new Interest { Title = "Technology" }, new Interest { Title = "Entertainment" }, new Interest { Title = "Sports" }, new Interest { Title = "Science" }, new Interest { Title = "Health" }, }; var interestsJson = JsonConvert.SerializeObject(interests); Settings.AddSetting(Settings.AppPrefrences.Interests, interestsJson); await GetUserData(); } }