Exemplo n.º 1
0
        /// <summary>
        /// Opens an <see cref="OptionsWindow"/> instance when the user clicks on the "Options" menu item from a <see cref="ConnectionWindow"/>.
        /// </summary>
        public void OpenOptions()
        {
            TitleBarTab tab = Tabs.FirstOrDefault(t => t.Content is OptionsWindow);

            // Focus on the options tab if a window is already open
            if (tab != null)
            {
                SelectedTab = tab;
                return;
            }

            _previousEncryptionType = Options.EncryptionType ?? EncryptionType.Rijndael;

            // Create the options window and then add entries for each protocol type to the window
            OptionsWindow       optionsWindow       = new OptionsWindow(this);
            GlobalOptionsWindow globalOptionsWindow = new GlobalOptionsWindow();

            globalOptionsWindow.Closed += globalOptionsWindow_Closed;
            optionsWindow.OptionsForms.Add(globalOptionsWindow);

            foreach (IProtocol protocol in ConnectionFactory.GetProtocols())
            {
                Form optionsForm = protocol.GetOptionsFormInDefaultsMode();

                optionsForm.Closed += (sender, args) => ConnectionFactory.SetDefaults(((IOptionsForm)optionsForm).Connection);
                optionsWindow.OptionsForms.Add(optionsForm);
            }

            ShowInEmptyTab(optionsWindow);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens an <see cref="SettingsWindow"/> instance when the user clicks on the "Settings" menu item from a <see cref="ConnectionWindow"/>.
        /// </summary>
        public async Task OpenSettings()
        {
            TitleBarTab tab = Tabs.FirstOrDefault(t => t.Content is SettingsWindow);

            // Focus on the settings tab if a window is already open
            if (tab != null)
            {
                SelectedTab = tab;
                return;
            }

            _previousEncryptionType = GlobalSettings.Instance.EncryptionType ?? EncryptionType.Rijndael;

            // Create the settings window and then add entries for each protocol type to the window
            SettingsWindow       settingsWindow       = new SettingsWindow(this);
            GlobalSettingsWindow globalSettingsWindow = new GlobalSettingsWindow();

            globalSettingsWindow.Closed += globalSettingsWindow_Closed;
            settingsWindow.SettingsForms.Add(globalSettingsWindow);

            foreach (IProtocol protocol in ConnectionFactory.GetProtocols())
            {
                Form settingsForm = await protocol.GetSettingsFormInDefaultsMode();

                settingsForm.Closed += settingsForm_Closed;
                settingsWindow.SettingsForms.Add(settingsForm);
            }

            ShowInEmptyTab(settingsWindow);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new tab to hold <paramref name="form"/>.
        /// </summary>
        /// <param name="form">Form instance that we are to open in a new tab.</param>
        protected void ShowInEmptyTab(Form form)
        {
            // If we're opening the form from an unconnected ConnectionWindow, just replace its content with the new form
            if (SelectedTab != null && SelectedTab.Content is ConnectionWindow && !(SelectedTab.Content as ConnectionWindow).IsConnected)
            {
                Form oldWindow = SelectedTab.Content;

                SelectedTab.Content = form;
                ResizeTabContents();

                oldWindow.Close();
            }

            // Otherwise, create a new tab associated with the form
            else
            {
                TitleBarTab newTab = new TitleBarTab(this)
                {
                    Content = form
                };

                Tabs.Add(newTab);
                ResizeTabContents(newTab);
                SelectedTabIndex = _tabs.Count - 1;
            }

            form.Show();

            if (_overlay != null)
            {
                _overlay.Render(true);
            }
        }
Exemplo n.º 4
0
        public void CreateNewTab(string url)
        {
            var newtab = new TitleBarTab(ParentTabs)
            {
                Content = new BrowserMain(url, true)
                {
                    Text = "New Tab"
                }
            };

            if (ParentTabs.InvokeRequired)
            {
                ParentTabs.Invoke(new Action(() => {
                    ParentTabs.Tabs.Insert(ParentTabs.SelectedTabIndex + 1, newtab);
                    ParentTabs.SelectedTabIndex++;
                    ParentTabs.RedrawTabs();
                    ParentTabs.Refresh();
                }));
            }
            else
            {
                ParentTabs.Tabs.Insert(ParentTabs.SelectedTabIndex + 1, newtab);
                ParentTabs.SelectedTabIndex++;
                ParentTabs.RedrawTabs();
                ParentTabs.Refresh();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method to create a new tab when the add button in the title bar is clicked; creates a new <see cref="ConnectionWindow"/>.
        /// </summary>
        /// <returns>Tab for a new <see cref="ConnectionWindow"/> instance.</returns>
        public override TitleBarTab CreateTab()
        {
            _previouslyClickedTab = new TitleBarTab(this)
            {
                Content = new ConnectionWindow()
            };

            return(_previouslyClickedTab);
        }
Exemplo n.º 6
0
        public override TitleBarTab CreateTab()
        {
            TitleBarTab tb = new TitleBarTab(this);

            //tb.ShowCloseButton = false;
            tb.Content      = new FrmBrowser(tb, string.Empty);
            tb.Content.Text = "新标签";
            return(tb);
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override TitleBarTab CreateTab()
        {
            TitleBarTab tab = new TitleBarTab(this);

            tab.Content = new frmMain()
            {
                Text = "New Tab"
            };
            return(tab);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Handler method that's called when a tab is clicked on.  This is different from the <see cref="TitleBarTabs.TabSelected"/> event handler in that
        /// this is called even if the tab is currently active.  This is used to show the toolbar for <see cref="ConnectionWindow"/> instances that
        /// automatically hide their toolbars when the connection's UI is focused on.
        /// </summary>
        /// <param name="sender">Object from which this event originated.</param>
        /// <param name="e">Arguments associated with this event.</param>
        private void MainForm_TabClicked(object sender, TitleBarTabEventArgs e)
        {
            // Only show the toolbar if the user clicked on an already-selected tab
            if (e.Tab.Content is ConnectionWindow && e.Tab == _previouslyClickedTab && !e.WasDragging)
            {
                (e.Tab.Content as ConnectionWindow).ShowToolbar();
            }

            _previouslyClickedTab = e.Tab;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the image to use for the right side of the tab.  For Chrome, we pick a specific image for inactive tabs that aren't at the end of the list to allow for the separation between inactive tabs to be more clearly defined
        /// </summary>
        /// <param name="tab">Tab that we are retrieving the image for</param>
        /// <returns>Right-side image for <paramref name="tab"/></returns>
        protected override Image GetTabRightImage(TitleBarTab tab)
        {
            ListWithEvents <TitleBarTab> allTabs = tab.Parent.Tabs;

            if (tab.Active || allTabs.IndexOf(tab) == allTabs.Count - 1)
            {
                return(base.GetTabRightImage(tab));
            }
            return(InactiveRightSideShadowImage);
        }
Exemplo n.º 10
0
        public FrmBrowser(TitleBarTab tabObj)
        {
            InitializeComponent();
            CefSettings settings = new CefSettings();

            settings.Locale = "zh-CN";
            if (!Cef.IsInitialized)
            {
                Cef.Initialize(settings);
            }
            thisTab = tabObj;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Handler method that's called when the user clicks on the "Properties..." menu item in the context menu that appears when the user right-clicks on
        /// a history entry; opens up the options for the connection in a new tab.
        /// </summary>
        /// <param name="sender">Object from which this event originated.</param>
        /// <param name="e">Argument associated with this event.</param>
        private void propertiesMenuItem_Click(object sender, EventArgs e)
        {
            // Get the options form for the connection type and open it in a new tab
            Form        optionsWindow = ConnectionFactory.CreateOptionsForm(_connections[_historyListView.SelectedItems[0]].Connection);
            TitleBarTab optionsTab    = new TitleBarTab(_applicationForm)
            {
                Content = optionsWindow
            };

            _applicationForm.Tabs.Add(optionsTab);
            _applicationForm.SelectedTab = optionsTab;
        }
Exemplo n.º 12
0
        public override TitleBarTab CreateTab()
        {
            var TBTab = new TitleBarTab(this)
            {
                Content = new MainWindow
                {
                    Text        = "New Tab",
                    WindowState = FormWindowState.Normal
                }
            };

            return(TBTab);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Opens a <see cref="BookmarksWindow"/> instance when the user clicks on the "Bookmarks" menu item in the tools menu from a
        /// <see cref="ConnectionWindow"/> instance.
        /// </summary>
        public void OpenBookmarkManager()
        {
            TitleBarTab tab = Tabs.FirstOrDefault(t => t.Content is BookmarksWindow);

            // Focus on the existing bookmarks manager tab if it exists
            if (tab != null)
            {
                SelectedTab = tab;
                return;
            }

            Bookmarks.FormClosed += Bookmarks_FormClosed;
            ShowInEmptyTab(Bookmarks);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Opens a <see cref="HistoryWindow"/> instance when the user clicks on the "History" menu item in the tools menu from a
        /// <see cref="ConnectionWindow"/> instance.
        /// </summary>
        public void OpenHistory()
        {
            TitleBarTab tab = Tabs.FirstOrDefault(t => t.Content is HistoryWindow);

            // Focus on the existing history window tab if it exists
            if (tab != null)
            {
                SelectedTab = tab;
                return;
            }

            History.FormClosed += History_FormClosed;
            ShowInEmptyTab(History);
        }
Exemplo n.º 15
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            frmTab      frmTab = new frmTab();
            TitleBarTab tab    = new TitleBarTab(frmTab);

            frmTab.Tabs.Add(frmTab.CreateTab());
            frmTab.SelectedTabIndex = 0;

            TitleBarTabsAppContext appContext = new TitleBarTabsAppContext();

            appContext.Start(frmTab);

            Application.Run(appContext);
        }
Exemplo n.º 16
0
        public FrmBrowser(TitleBarTab tabObj, string urlp)
        {
            InitializeComponent();
            this.Icon = Properties.Resources.vei;
            CefSettings settings = new CefSettings();

            settings.Locale = "zh-CN";
            if (!Cef.IsInitialized)
            {
                Cef.Initialize(settings);
            }
            thisTab = tabObj;
            if (!string.IsNullOrEmpty(urlp))
            {
                urlparam = urlp;
            }
        }
Exemplo n.º 17
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Frm_Main());
            Config.container = new AppContainer();
            AppContainer container = Config.container;
            TitleBarTab  tb        = new TitleBarTab(container);

            tb.Content         = new FrmBrowser(tb, string.Empty);
            tb.Content.Text    = "首页";
            tb.ShowCloseButton = false;//禁止关闭首页
            container.Tabs.Add(tb);
            container.SelectedTabIndex = 0;
            TitleBarTabsApplicationContext applicationContext = new TitleBarTabsApplicationContext();

            applicationContext.Start(container);
            Application.Run(applicationContext);
        }
Exemplo n.º 18
0
 public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
 {
     newBrowser = null;
     //在原窗口加载跳转的页面
     //var br = (ChromiumWebBrowser)chromiumWebBrowser;
     //br.Load(targetUrl);
     if (Config.container.InvokeRequired)
     {
         Config.container.Invoke(new Action(() =>
         {
             TitleBarTab tb  = new TitleBarTab(Config.container);
             tb.Content      = new FrmBrowser(tb, targetUrl);
             tb.Content.Text = "跳转中";
             Config.container.Tabs.Add(tb);
             Config.container.SelectedTabIndex = Config.container.Tabs.Count - 1;
         }));
     }
     return(true); //Return true to cancel the popup creation copyright by codebye.com.
 }
Exemplo n.º 19
0
        /// <summary>
        /// Opens a new tab for <paramref name="connection"/>.
        /// </summary>
        /// <param name="connection">Connection that we are to open a new tab for.</param>
        /// <param name="focusNewTab">Flag indicating whether we should focus on the new tab.</param>
        /// <returns>Tab that was created for <paramref name="connection"/>.</returns>
        public TitleBarTab Connect(IConnection connection, bool focusNewTab)
        {
            ConnectionWindow connectionWindow = new ConnectionWindow(connection);

            TitleBarTab newTab = new TitleBarTab(this)
            {
                Content = connectionWindow
            };

            Tabs.Insert(SelectedTabIndex + 1, newTab);
            ResizeTabContents(newTab);

            if (focusNewTab)
            {
                SelectedTab           = newTab;
                _previouslyClickedTab = newTab;
            }

            connectionWindow.Connect();

            return(newTab);
        }