Esempio n. 1
0
        public void RemoveSelectedTabClick(object obj)
        {
            // Debugger.Launch();
            // WebBrowser.Navigate("about:blank");
            if (WebBrowser != null)
            {
                WebBrowser.Dispose();
            }

            GC.Collect();
            TabItemCollection.Remove(this);

            if (TabItemCollection.Where(x => x.CloseButtonVisibility == Visibility.Visible).Count() == 0)
            {
                AddNewTabClick(this);
                Model.SelectedIndex = 0;
                ShowAddNewTabIfNeeded();
            }
            else
            {
                Model.SelectedIndex = Model.TabItemCollection.Count - 2;
            }

            ShowAddNewTabIfNeeded();
        }
Esempio n. 2
0
        public void AddNewTabForUrl(string url, bool focusOnNewTab, Action <TabItem> callback = null)
        {
            if (!string.IsNullOrWhiteSpace(url))
            {
                int _tabElements = TabItemCollection.Count;

                TabItem newTab = new TabItem(Model, resolver);
                newTab.SearchBar.Address = url;

                newTab.CloseButtonVisibility = Visibility.Visible;

                int count = TabItemCollection.Where(x => x.CloseButtonVisibility == Visibility.Visible).Count();

                if (count > 0)
                {
                    if (count >= MAX_TAB_COUNT)
                    {
                        var tab = TabItemCollection.LastOrDefault(x => x.CloseButtonVisibility == Visibility.Visible);
                        tab.SearchBar.Address = url;
                        tab.SearchBar.Navigate();
                    }
                    else
                    {
                        TabItemCollection.Insert(count, newTab);
                    }
                }
                else
                {
                    TabItemCollection.Insert(0, newTab);
                }

                if (focusOnNewTab)
                {
                    if (TabItemCollection.Count > 1)
                    {
                        bool isNewButtonVisible = TabItemCollection.Any(x => x.NewTabButtonVisibility);
                        if (isNewButtonVisible)
                        {
                            Model.SelectedIndex = TabItemCollection.Count - 2;
                        }
                        else
                        {
                            Model.SelectedIndex = TabItemCollection.Count - 1;
                        }
                    }
                    else
                    {
                        Model.SelectedIndex = 0;
                    }
                }

                if (callback != null)
                {
                    callback(newTab);
                }
            }

            ShowAddNewTabIfNeeded();
        }
Esempio n. 3
0
 public void AddNewTabEmpty(object obj)
 {
     if (TabItemCollection.Where(x => x.NewTabButtonVisibility == true).Count() == 0)
     {
         TabItem newTab = new TabItem(Model, resolver);
         newTab.SearchBar.Title = (string)System.Windows.Application.Current.FindResource(NewTabMessage);
         HideAllHompageContainerItems();
         NewTabButtonVisibility = true;
         TabItemCollection.Add(newTab);
     }
     ShowAddNewTabIfNeeded();
 }
 public void RemoveFromFavoriteListClick(object obj)
 {
     if (obj != null)
     {
         var favorite = PBData.GetFavorites().Where(x => x.Url == obj.ToString()).FirstOrDefault();
         if (favorite != null)
         {
             this.PBData.RemoveFromFavorites(favorite);
             var tabItem = TabItemCollection.Where(x => x.SearchBar.Address == favorite.Url).FirstOrDefault();
             if (tabItem != null)
             {
                 tabItem.SearchBar.SetFavoriteIconVisibility(false);
             }
         }
         this.LoadSecureBrowserFavoriteList();
     }
 }
Esempio n. 5
0
        public void ShowAddNewTabIfNeeded()
        {
            int count = TabItemCollection.Where(x => x.NewTabButtonVisibility == true).Count();

            if (count == 0)
            {
                if (TabItemCollection.Count < MAX_TAB_COUNT)
                {
                    TabItem item = new TabItem(Model, resolver);
                    TabItemCollection.Add(item);
                }
            }

            if (TabItemCollection.Count > MAX_TAB_COUNT)
            {
                var tab = TabItemCollection.FirstOrDefault(x => x.NewTabButtonVisibility);
                TabItemCollection.Remove(tab);
            }
        }
Esempio n. 6
0
        public void AddNewTabClick(object obj)
        {
            TabItem newTab = new TabItem(Model, resolver);

            newTab.SearchBar.Title = (string)System.Windows.Application.Current.FindResource(NewTabMessage);
            var startPage = this.Model.PBData.GetPrivateSetting(DefaultProperties.Settings_StartPageUrl);

            if (!string.IsNullOrWhiteSpace(startPage))
            {
                newTab.SearchBar.Address = startPage;
            }
            newTab.CloseButtonVisibility = Visibility.Visible;

            int count = TabItemCollection.Where(x => x.CloseButtonVisibility == Visibility.Visible).Count();

            if (count > 0)
            {
                if (!(TabItemCollection.Count > MAX_TAB_COUNT))
                {
                    TabItemCollection.Insert(count, newTab);
                }
            }
            else
            {
                TabItemCollection.Insert(0, newTab);
            }

            if (!(obj is TabItem))
            {
                Model.SelectedIndex = Model.TabItemCollection.Count - 2;
            }
            if (TabItemCollection.Count == 2)
            {
                Model.SelectedIndex = 0;
            }

            ShowAddNewTabIfNeeded();
        }