예제 #1
0
        //----------------------------------------------------------------------
        public void SetActiveTab(NotebookTab _tab)
        {
            Debug.Assert(Tabs.Contains(_tab));

            ActiveTabIndex = Tabs.IndexOf(_tab);
            _tab.IsUnread  = false;
        }
예제 #2
0
        protected override void OnDragEnter(DragEventArgs e)
        {
            ExitRenameMode();

            base.OnDragEnter(e);

            Point p = PointToClient(new Point(e.X, e.Y));

            if (e.Data.GetDataPresent(typeof(SideTabItem)))
            {
                e.Effect = (e.KeyState & 8) > 0 ? DragDropEffects.Copy : DragDropEffects.Move;
            }
            else if (e.Data.GetDataPresent(typeof(SideTab)))
            {
                SideTab tab = (SideTab)e.Data.GetData(typeof(SideTab));
                if (Tabs.Contains(tab))
                {
                    Tabs.DragOverTab = tab;
                    e.Effect         = GetDragDropEffect(e);
                }
                else
                {
                    e.Effect = DragDropEffects.None;
                }
            }
            else if (e.Data.GetDataPresent(typeof(string)))
            {
                e.Effect = GetDragDropEffect(e);
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
예제 #3
0
 public void AddTag(string tag)
 {
     if (Tabs.Contains(tag) == false)
     {
         Tabs.Add(tag);
     }
 }
예제 #4
0
 internal void TabsPanel_PreviewMouseMove(object sender, MouseEventArgs e)
 {
     if (dragStart != null && DragDistance(dragStart.Value, e.GetPosition(null)) > SystemParameters.MinimumHorizontalDragDistance && draggedTab != null && !doingDragDrop)
     {
         doingDragDrop = true;
         draggedTab.SetDragging(true);
         Tabs.Remove(draggedTab);
         DragDropEffects dragResult = DragDrop.DoDragDrop(this, draggedTab, DragDropEffects.Move);
         doingDragDrop = false;
         if (dragResult == DragDropEffects.None)
         {
             if (!Tabs.Contains(draggedTab))
             {
                 Tabs.Add(draggedTab);
             }
         }
         else
         {
             for (int x = 0; x < Tabs.Count; x++)
             {
                 Tabs[x].DisplayIndex = x;
             }
         }
         SelectedTab = draggedTab;
         draggedTab.SetDragging(false);
         draggedTab = null;
     }
 }
예제 #5
0
 public void ShowTab(UserControl tab)
 {
     if (Tabs.Contains(tab))
     {
         (tab as Tab_WOC)?.OnShowTab();
         tab.BringToFront();
     }
 }
예제 #6
0
 public virtual void SetCurrentTab(Tab tab)
 {
     if (!Tabs.Contains(tab))
     {
         throw new Exception($"Passed tab is not contained in the collection of tabs.");
     }
     CurrentTabIndex = Tabs.IndexOf(tab);
 }
예제 #7
0
 /// <summary>
 /// Activates a given tab
 /// </summary>
 /// <param name="tab">Tab to activate</param>
 /// <returns>Was activation successful?</returns>
 public bool SwitchToTab(ITabInfo tab)
 {
     if (Tabs.Contains(tab))
     {
         ActiveTab = (Tab)tab;
         return(true);
     }
     return(false);
 }
        protected internal override void EnsureTabVisible(IDockContent content)
        {
            if (Appearance != DockPane.AppearanceStyle.Document || !Tabs.Contains(content))
            {
                return;
            }

            CalculateTabs();
            EnsureDocumentTabVisible(content, true);
        }
예제 #9
0
        public void CloseTab(string tab)
        {
            if (!Tabs.Contains(tab))
            {
                throw new ArgumentOutOfRangeException("The specified tab does not belong to this processor");
            }

            driver.SwitchTo().Window(tab).Close();
            Tabs.Remove(tab);
        }
예제 #10
0
        public void SwitchToTab(string tab)
        {
            if (tab == driver.CurrentWindowHandle)
            {
                return;
            }

            if (!Tabs.Contains(tab))
            {
                throw new ArgumentOutOfRangeException("The specified tab does not belong to this processor");
            }

            CurrentTab = tab;
            driver.SwitchTo().Window(tab);
        }
예제 #11
0
        protected override void OnPreviewDragLeave(DragEventArgs e)
        {
            if (e is null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            base.OnPreviewDragLeave(e);
            if (e.Data.GetDataPresent(typeof(Tab)))
            {
                hitResults = new List <DependencyObject>();
                VisualTreeHelper.HitTest(this, null, HitTestResultCallback, new PointHitTestParameters(e.GetPosition(this)));
                bool validLeave = true;
                if (hitResults.Count == 0 && e.OriginalSource is DependencyObject)
                {
                    hitResults.Add(e.OriginalSource as DependencyObject);
                }
                foreach (DependencyObject thisHit in hitResults)
                {
                    DependencyObject testHit = VisualTreeHelper.GetParent(thisHit);
                    while (testHit != null)
                    {
                        if (testHit is BetterTabControl && (testHit as BetterTabControl).id == id && (testHit as BetterTabControl).id == id)
                        {
                            validLeave = false;
                            break;
                        }
                        testHit = VisualTreeHelper.GetParent(testHit);
                    }
                    if (!validLeave)
                    {
                        break;
                    }
                }
                if (validLeave)
                {
                    Tab localDraggedTab = (Tab)e.Data.GetData(typeof(Tab));
                    if (Tabs.Contains(localDraggedTab))
                    {
                        Tabs.Remove(localDraggedTab);
                    }

                    e.Handled = true;
                }
            }
        }
 private void OpenItem(TabItem toOpen)
 {
     if (!Tabs.Contains(toOpen))
     {
         Tabs.Add(toOpen);
         toOpen.CloseIt = MainWindowViewModel_CloseIt;
         if (toOpen.Content is DominoProviderTabItem ti && ti.CurrentProject != null)
         {
             ti.GetNewViewModel      = GetNewViewModel;
             ti.RegisterNewViewModel = RegisterNewViewModel;
         }
         if (toOpen.Content is EditProjectVM v)
         {
             v.DisplaySettingsTool.ResetCanvas();
         }
     }
     SelectedTab = toOpen;
 }
예제 #13
0
 private void OpenItem(UserControls.ViewModel.TabItem toOpen)
 {
     if (!Tabs.Contains(toOpen))
     {
         Tabs.Add(toOpen);
         toOpen.CloseIt = MainWindowViewModel_CloseIt;
         if (toOpen.Content is DominoProviderTabItem ti && ti.CurrentProject != null)
         {
             ti.GetNewViewModel      = GetNewViewModel;
             ti.RegisterNewViewModel = RegisterNewViewModel;
         }
         if (toOpen.Content is EditProjectVM v)
         {
             v.RecreateCanvasViewModel();
         }
     }
     SelectedTab = toOpen;
 }
예제 #14
0
 protected override void OnPreviewDragEnter(DragEventArgs e)
 {
     if (e is null)
     {
         throw new ArgumentNullException(nameof(e));
     }
     base.OnPreviewDragEnter(e);
     if (e.Data.GetDataPresent(typeof(Tab)))
     {
         Tab localDraggedTab = (Tab)e.Data.GetData(typeof(Tab));
         ClearSelected();
         localDraggedTab.SetSelected(true);
         if (!Tabs.Contains(localDraggedTab))
         {
             Tabs.Add(localDraggedTab);
         }
         e.Handled = true;
     }
 }
예제 #15
0
        private void absorbTabPermissionsFrom(KeyChain chain)
        {
            if (chain.CanAccessAllTabs)
            {
                CanAccessAllTabs = true;
            }

            if (chain.Tabs == null)
            {
                return;
            }

            foreach (var cmd in chain.Tabs)
            {
                if (!Tabs.Contains(cmd))
                {
                    Tabs.Add(cmd);
                }
            }
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Don't allow this menu item to be chosen when there's only one tab.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        protected bool OnUpdateMoveToNewStackedTabGroup(object args)
        {
            // If we're not the tab group that owns the tab that was
            // clicked on, then we don't want to handle the message.
            if (!Tabs.Contains(ContextMenuTab))
            {
                return(false);
            }

            TMItemProperties itemProps = args as TMItemProperties;

            if (itemProps == null)
            {
                return(false);
            }

            itemProps.Visible = true;
            itemProps.Enabled = (Tabs.Count > 1);
            itemProps.Update  = true;
            return(true);
        }
        protected internal override void EnsureTabVisible(IDockContent content)
        {
            if (Appearance != DockPane.AppearanceStyle.Document || !Tabs.Contains(content))
            {
                return;
            }

            Rectangle rectTabStrip = TabsRectangle;
            Rectangle rectTab      = GetTabRectangle(Tabs.IndexOf(content));

            if (rectTab.Right > rectTabStrip.Right)
            {
                OffsetX   -= rectTab.Right - rectTabStrip.Right;
                rectTab.X -= rectTab.Right - rectTabStrip.Right;
            }

            if (rectTab.Left < rectTabStrip.Left)
            {
                OffsetX += rectTabStrip.Left - rectTab.Left;
            }

            OnRefreshChanges();
        }
예제 #18
0
 protected internal void ChangeSelectedTab(Tab tab)
 {
     if (tab is null)
     {
         throw new ArgumentNullException(nameof(tab));
     }
     if (Tabs.Contains(tab))
     {
         Tab oldSelection = SelectedTab;
         if (!OnSelectedTabChanging(oldSelection, tab))
         {
             ClearSelected();
             tab.SetSelected(true);
             SetValue(SelectedTabProperty, tab);
             OnSelectedTabChanged(oldSelection, tab);
             NotifySelectedChanged();
             tab.BringIntoView();
         }
     }
     else
     {
         throw new ArgumentException(Properties.Resources.ResourceManager.GetString("TabNotInControlException", CultureInfo.CurrentUICulture), nameof(tab));
     }
 }
예제 #19
0
        /// <summary>
        /// Closes a given tab
        /// </summary>
        /// <param name="tab">Tab to be closed</param>
        /// <returns>Was closing successful?</returns>
        public async void CloseTab(ITabInfo tab)
        {
            if (tab == null)
            {
                throw new ArgumentNullException(nameof(tab));
            }

            if (!Tabs.Contains(tab))
            {
                return;
            }

            var closedTab = (Tab)tab;

            if (closedTab == null)
            {
                throw new ArgumentException(nameof(tab));
            }

            //if the tab prevents closing, do not do anything
            if (!await tab.CurrentViewModel.CanCloseViewModelAsync())
            {
                return;
            }

            //the closed tab is the only tab opened
            if (Tabs.Count == 1)
            {
                if (closedTab.CurrentViewModel.GetType() == typeof(MainMenuViewModel))
                {
                    //shut down the app
                    if (!await RequestAppCloseAsync())
                    {
                        return;
                    }
                }
                else
                {
                    //create new main menu tab
                    ProcessViewModelRequest(
                        new MvxViewModelRequest(typeof(MainMenuViewModel), new MvxBundle(), new MvxBundle(),
                                                MvxRequestedBy.Unknown),
                        TabNavigationType.NewForegroundTab
                        );
                }
            }
            else
            {
                //is the closed tab active?
                if (closedTab == ActiveTab)
                {
                    //activate a different tab
                    var closedTabIndex = Tabs.IndexOf(closedTab);
                    if ((Tabs.Count - 1) > closedTabIndex)
                    {
                        //activate next tab
                        ActiveTab = Tabs[closedTabIndex + 1];
                    }
                    else
                    {
                        ActiveTab = Tabs[closedTabIndex - 1];
                    }
                }
            }
            Tabs.Remove(closedTab);
            //inform the view that its tab has been closed
            (closedTab.Frame.Content as ViewBase)?.TabClosed();
        }
        public WebBrowserPageViewModel(IWebViewManager webViewManager, LinkItemProvider provider, WebBrowserPlugin plugin, PanaceaServices core)
        {
            _webViewManager = webViewManager;
            ItemProvider    = provider;
            _core           = core;
            CloseTabCommand = new RelayCommand(args =>
            {
                var view = args as IWebView;
                if (Tabs.Contains(view))
                {
                    Tabs.Remove(view);
                    if (Tabs.Count == 0)
                    {
                        CreateTab();
                    }
                    else if (CurrentWebView == view)
                    {
                        CurrentWebView = Tabs.First();
                    }
                    //SwitchToTab(CurrentWebView);
                }
            });
            ItemClickCommand = new RelayCommand(args =>
            {
                var link = args as Link;
                NavigateCommand?.Execute(link.DataUrl);
            });
            IsFavoriteCommand = new RelayCommand((arg) =>
            {
            },
                                                 (arg) =>
            {
                var link = arg as Link;
                if (plugin.Favorites == null)
                {
                    return(false);
                }
                return(plugin.Favorites.Any(l => l.Id == link.Id));
            });
            FavoriteCommand = new AsyncCommand(async(args) =>
            {
                var game = args as Link;
                if (game == null)
                {
                    return;
                }
                if (core.TryGetFavoritesPlugin(out IFavoritesManager _favoritesManager))
                {
                    try
                    {
                        if (await _favoritesManager.AddOrRemoveFavoriteAsync("WebBrowser", game))
                        {
                            OnPropertyChanged(nameof(IsFavoriteCommand));
                        }
                    }
                    catch (Exception e)
                    {
                        core.Logger.Error(this, e.Message);
                    }
                }
            });
            NavigateCommand = new RelayCommand(async(args) =>
            {
                if (_core.TryGetKeyboard(out IKeyboardPlugin keyboard))
                {
                    keyboard.HideKeyboard();
                }
                var url = args.ToString();
                if (CurrentWebView == null)
                {
                    CreateTab(url);
                }

                if (url.ToLower() == "about:blank")
                {
                    CurrentWebView?.Navigate(url);
                    return;
                }
                if (core.TryGetBilling(out IBillingManager bill))
                {
                    if (!bill.IsPluginFree("WebBrowser"))
                    {
                        var service = await bill.GetOrRequestServiceAsync(new Translator("WebBrowser").Translate("Web browser requires service."), "WebBrowser");
                        if (service == null)
                        {
                            return;
                        }
                        if (_core.TryGetUiManager(out IUiManager ui))
                        {
                            if (ui.CurrentPage != this)
                            {
                                ui.Navigate(this);
                            }
                        }
                    }
                }
                if (CurrentWebView == null)
                {
                    CreateTab();
                }
                if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
                {
                    var uri = new Uri(url);

                    if (uri.Scheme != "https" && uri.Scheme != "http" && uri.Scheme != "javascript" && !uri.ToString().StartsWith("about:blank"))
                    {
                        //_window.ThemeManager.Toast(new Translator("WebBrowser").Translate("Access denied"));
                        return;
                    }
                    WebViewContainerVisibility = Visibility.Visible;
                    CurrentWebView?.Navigate(url);
                }
                else if (url.Contains(".") &&
                         Uri.IsWellFormedUriString("http://" + url, UriKind.Absolute))
                {
                    WebViewContainerVisibility = Visibility.Visible;
                    CurrentWebView?.Navigate(url);
                }
                else
                {
                    WebViewContainerVisibility = Visibility.Visible;
                    CurrentWebView?.Navigate("https://www.google.com/search?q=" + url);
                }

                Keyboard.ClearFocus();
            });

            BackCommand = new RelayCommand(args =>
            {
                CurrentWebView?.GoBack();
            },
                                           args =>
            {
                return(CurrentWebView?.CanGoBack == true);
            });
            ForwardCommand = new RelayCommand(args =>
            {
                CurrentWebView?.GoForward();
            },
                                              args =>
            {
                return(CurrentWebView?.CanGoForward == true);
            });
            SwitchTabSelectorCommand = new RelayCommand((args) =>
            {
                ShowTabSelector();
            });
            SelectTabCommand = new RelayCommand((args) =>
            {
                SwitchToTab(args as IWebView);
            });
            AddTabCommand = new RelayCommand((args) =>
            {
                CreateTab();
            });
        }