public void AddToTab(BaseForm mdiForm, string code, Image pageImage) { var tabItemNew = new SuperTabItem(); var tabControlPanelNew = new SuperTabControlPanel { AutoScroll = true, Dock = DockStyle.Fill, Name = code, TabItem = tabItemNew }; tabItemNew.AttachedControl = tabControlPanelNew; tabItemNew.Name = code; mdiForm.FormClosed += RemoveSelectedTab; mdiForm.FormBorderStyle = FormBorderStyle.None; mdiForm.TopLevel = false; mdiForm.Parent = tabControlPanelNew; mdiForm.Dock = DockStyle.Fill; tabControlPanelNew.Controls.Add(mdiForm); mdiForm.Show(); mdiForm.AutoSize = true; tabItemNew.Text = mdiForm.Text; //tabItemNew.Image = buttomItem.Image; if (pageImage != null) { tabItemNew.Image = ImageHelper.Scale(pageImage, new Size(24, 24)); //把图标缩放到24*24的尺寸 } tabControlMain.Controls.Add(tabControlPanelNew); tabControlMain.Tabs.Add(tabItemNew); tabControlMain.Refresh(); tabControlMain.SelectedTab = tabItemNew; }
public void AddControl(Control ctrl, string title, Image image = null) { // // superTabItem // SuperTabItem superTabItem = new SuperTabItem(); SuperTabControlPanel superTabControlPanel = new SuperTabControlPanel(); superTabItem.AttachedControl = superTabControlPanel; superTabItem.CloseButtonVisible = true; superTabItem.GlobalItem = false; if (image == null) { image = Properties.Resources.editor; } superTabItem.Image = image; superTabItem.Text = title; // // superTabControlPanel // ctrl.Dock = DockStyle.Fill; superTabControlPanel.Controls.Add(ctrl); superTabControlPanel.Dock = System.Windows.Forms.DockStyle.Fill; //superTabControlPanel.Location = new System.Drawing.Point(0, 28); //superTabControlPanel.Size = new System.Drawing.Size(764, 608); superTabControlPanel.TabItem = superTabItem; this.superTabControl.Controls.Add(superTabControlPanel); this.superTabControl.Tabs.Add(superTabItem); this.superTabControl.SelectedTab = superTabItem; }
/// <summary> /// 创建 <see cref="QueryPageContainer" /> 的新实例(QueryPageContainer) /// </summary> public QueryPageContainer(Session session, Entity.QueryParam queryParam, SuperTabControl control) { Session = session; QueryParam = queryParam; if (!Program.IsRunning) { return; } QueryPage = new QueryPage(Session, queryParam) { Dock = DockStyle.Fill, BackColor = SystemColors.Window }; _panel = new SuperTabControlPanel(); _panel.Controls.Add(QueryPage); AttachedControl = _panel; _panel.TabItem = this; _tabControl = control; var idx = control.Tabs.OfType <QueryPageContainer>().LastOrDefault(); _tabControl.CreateTab(this, _panel, idx == null ? 0 : control.Tabs.IndexOf(idx) + 1); Text = queryParam.Name; Image = Properties.Resources.calendar_16; DataBindings.Add("Text", queryParam, "Name", false, DataSourceUpdateMode.OnPropertyChanged); BindQueryState(); EnableImageAnimation = false; this.DoubleClick += QueryPageContainer_DoubleClick; }
/// <summary> /// 大小改变时,调整窗体位置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void superTabControlPanel_SizeChanged(object sender, EventArgs e) { SuperTabControlPanel superTabControlPanel = sender as SuperTabControlPanel; Form form = superTabControlPanel.Controls[0] as Form; if (form == null) { return; } int x = 0, y = 0; if (form.Size.Width < superTabControlPanel.Size.Width) { x = (superTabControlPanel.Size.Width - form.Size.Width) / 2; } if (form.Size.Height < superTabControlPanel.Size.Height) { y = (superTabControlPanel.Size.Height - form.Size.Height) / 2; } form.Location = new Point(x, y); superTabControlPanel.AutoScroll = (form.Size.Width > superTabControlPanel.Size.Width || form.Size.Height > superTabControlPanel.Size.Height); }
void CreateTab(SuperTabControl tabControlName, string strTextSuperTabItem, string strNameSuperTabItem, string strNameSuperTabControlPanel, Office2007RibbonForm Form) { int intCheck = CheckExist(tabControlName, strNameSuperTabItem); if (intCheck > -1) { tabControlName.SelectedTabIndex = intCheck; Variable.stiSelected = tabControlName.SelectedTab; } else { SuperTabItem sti = new SuperTabItem(); sti.Name = strNameSuperTabItem; sti.Text = strTextSuperTabItem; SuperTabControlPanel stcp = new SuperTabControlPanel(); stcp.Name = strNameSuperTabControlPanel; stcp.Dock = DockStyle.Fill; tabControlName.Controls.Add(stcp); sti.AttachedControl = stcp; tabControlName.SelectedPanel = stcp; tabControlName.Tabs.Add(sti); Form.TopLevel = false; Form.Parent = stcp; Form.Show(); Form.Dock = DockStyle.Fill; tabControlName.SelectedTab = sti; Variable.stiSelected = sti; } }
public SuperTabControlPanel AddTab(string tabName) { SuperTabControlPanel panel = new SuperTabControlPanel(); AddTab(tabName, panel); panel.Controls.Add(new Button()); return(panel); }
private void addTransactionTabPanel(SuperTabControlPanel tabPanel) { TransactionTabPanel transactionTab = new TransactionTabPanel(); transactionTab.Dock = DockStyle.Fill; transactionTab.ParentTransForm = this; tabPanel.Controls.Add(transactionTab); transactionTab.Name = "lendingTabPanel1"; transactionTab.Select(); }
/// <summary> /// 节点双击事件,点击查看日志消息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void advTreeLogList_NodeDoubleClick(object sender, TreeNodeMouseEventArgs e) { Node selectNode = advTreeLogList.SelectedNode; if (selectNode.Level == 2) { if (!superTabControlLogs.Tabs.Contains(selectNode.Text)) { SuperTabItem logItem = new SuperTabItem(); SuperTabControlPanel logPanel = new SuperTabControlPanel(); RichTextBoxEx logContet = new RichTextBoxEx(); logItem.Name = selectNode.Text; logItem.Text = selectNode.Text; logItem.GlobalItem = false; logItem.AttachedControl = logPanel; logPanel.Dock = DockStyle.Fill; logPanel.Location = new Point(0, 28); logPanel.Size = new Size(300, 300); logPanel.TabItem = logItem; logContet.Dock = DockStyle.Fill; logContet.Location = new Point(0, 0); logContet.Size = new Size(420, 340); logContet.Multiline = true; logContet.ScrollBars = RichTextBoxScrollBars.Vertical; logContet.Font = new Font("微软雅黑", 10); logContet.SelectedText = "2017"; if (selectNode.Text.Split('.')[0].Equals(DateTime.Now.ToString("yyyy-MM-dd"))) { string tempLogFile = Path.Combine(PathUtils.LOG_TEMP_DIRECTORY, selectNode.Text + ".temp"); File.Copy(selectNode.Tag.ToString(), tempLogFile, true); logContet.Text = FileUtils.ReadFileToString(tempLogFile); } else { logContet.Text = FileUtils.ReadFileToString(selectNode.Tag.ToString()); } logPanel.Controls.Add(logContet); superTabControlLogs.Controls.Add(logPanel); superTabControlLogs.Tabs.Add(logItem); superTabControlLogs.SelectedTab = logItem; } else { superTabControlLogs.SelectedTabIndex = superTabControlLogs.Tabs.IndexOf(selectNode.Text); } } }
public SuperTabControlPanel GetTabPanel() { this.TopLevel = false; this.Dock = DockStyle.Fill; this.FormBorderStyle = FormBorderStyle.None; this.DoubleBuffered = true; var pnl = new SuperTabControlPanel(); pnl.Controls.Add(this); pnl.Padding = new System.Windows.Forms.Padding(1); this.Visible = true; return(pnl); }
private void NewPage(string url) { WebPage webPage = new WebPage(); webPage.Dock = DockStyle.Fill; webPage.Name = "webPage"; webPage.NewWindow += WebPage_NewWindow; webPage.StatusTextChange += WebPage_StatusTextChange; webPage.DocumentTitleChange += WebPage_DocumentTitleChange; webPage.PageClose += WebPage_PageClose; //TabPage tabPage = new TabPage("新标签页"); //tabPage.Controls.Add(webPage); SuperTabControlPanel panel = new SuperTabControlPanel(); panel.Dock = DockStyle.Fill; panel.Controls.Add(webPage); superTabControl1.Controls.Add(panel); SuperTabItem tabItem = new SuperTabItem(); tabItem.AttachedControl = panel; tabItem.Text = "新标签页"; panel.TabItem = tabItem; //tabControl1.Tabs.Add(tabItem); if (superTabControl1.Tabs.Count > 0) { superTabControl1.Tabs.Insert(superTabControl1.SelectedTabIndex + 1, tabItem); } else { superTabControl1.Tabs.Add(tabItem); } if (superTabControl1.SelectedTab != tabItem) { superTabControl1.SelectedTab = tabItem; } webPage.Navigate(url); }
private void addTab(SuperTabControl tabControl) { SuperTabItem tabItem = new SuperTabItem(); SuperTabControlPanel tabPanel = new SuperTabControlPanel(); tabControl.Controls.Add(tabPanel); tabControl.Tabs.Insert(tabControl.Tabs.Count - 1, tabItem); //tabPanel tabPanel.Dock = DockStyle.Fill; tabPanel.TabItem = tabItem; //tabItem tabItem.AttachedControl = tabPanel; tabItem.GlobalItem = false; tabItem.Text = "New"; addTransactionTabPanel(tabPanel); }
public QueryNonLogin(SuperTabControl parent) { _session = new Session("temp", true); _control = parent; _contentPanel = new SuperTabControlPanel() { TabItem = this, }; AttachedControl = _contentPanel; _contentPanel.Controls.Add(new QueryPage(_session, ProgramConfiguration.Instance.DefaultQuery) { Dock = DockStyle.Fill }); parent.Controls.Add(_contentPanel); _control.Tabs.Add(this, 1); Text = "查票(未登录)"; Image = Properties.Resources.testtube_16; }
/// <summary> /// 添加一个选项卡 /// </summary> /// <param name="tabName">选项卡标题</param> /// <param name="uniqueKey">唯一标识符,用于区别于其他选项卡</param> /// <param name="form">要被添加到选项卡的窗体</param> /// <param name="isFill">是否填满</param> /// <param name="closeButtonVisible">显示关闭选项卡按钮</param> public void CreateTab(string tabName, string uniqueKey, Form form, bool isFill, bool closeButtonVisible) { SuperTabItem superTabItem = GetTab(uniqueKey); if (superTabItem == null) { superTabItem = this.superTabControl.CreateTab(tabName); superTabItem.GlobalItem = true; superTabItem.GlobalName = uniqueKey; superTabItem.CloseButtonVisible = closeButtonVisible; superTabItem.TextAlignment = eItemAlignment.Center; SuperTabControlPanel superTabControlPanel = superTabItem.AttachedControl as SuperTabControlPanel; // 当窗体尺寸超过本身时显示滚动条 superTabControlPanel.AutoScroll = true; //superTabControlPanel.PanelColor.Default = new SuperTabPanelItemColorTable() //{ // Background = new SuperTabLinearGradientColorTable() // { // Colors = new Color[] { Color.White } // } //}; form.FormBorderStyle = FormBorderStyle.None; form.TopLevel = false; form.Visible = true; if (isFill) { form.Dock = DockStyle.Fill; } else { form.Dock = DockStyle.None; superTabControlPanel.SizeChanged += new EventHandler(superTabControlPanel_SizeChanged); } superTabItem.AttachedControl.Controls.Add(form); } // 设为当前选中的选项 this.superTabControl.SelectedTab = superTabItem; }
public CefWebBrowserX NewBrowser(string url = null, bool selected = false, string injectScript = null) { try { var superItem = new SuperTabItem(); superItem.Text = "空白页"; superItem.TabFont = new Font("微软雅黑", 9f); SuperTabControlPanel superTabControlPanel = new SuperTabControlPanel(); superItem.AttachedControl = superTabControlPanel; superTabControlPanel.TabItem = superItem; CefWebBrowserX cefWebBrowerX = new CefWebBrowserX(); cefWebBrowerX.Dock = DockStyle.Fill; cefWebBrowerX.NewNavigateBrowser += cefWebBrowerX_NewTabEvent; cefWebBrowerX.LoadingStateChanged += cefWebBrowerX_LoadingStateChanged; cefWebBrowerX.FrameLoadStart += cefWebBrowerX_FrameLoadStart; cefWebBrowerX.CreateTab += cefWebBrowerX_CreateTab; cefWebBrowerX.TitleChanged += cefWebBrowerX_TitleChanged; superTabControlPanel.Controls.Add(cefWebBrowerX); this.superTabControlX.Tabs.Add(superItem); if (selected) { this.superTabControlX.SelectedTab = superItem; } this.superTabControlX.Controls.Add(superTabControlPanel); cefWebBrowerX.OpenUrl(url, injectScript); return(cefWebBrowerX); } catch (Exception ex) { MessageBox.Show("打开页面异常:" + ex.Message + "\r\n" + ex.StackTrace); return(null); } finally { } }
public UserTabDnb(Session session, SuperTabControl parent) { InitSession(session); _userPage = new UserMainPageContent(session) { Dock = DockStyle.Fill, BackColor = SystemColors.Window }; _panel = new SuperTabControlPanel(); _panel.Controls.Add(_userPage); _panel.TabItem = this; AttachedControl = _panel; parent.Controls.Add(_panel); //set property Text = session.DisplayText; session.UserKeyData.DisplayNameChanged += (s, e) => { var action = new Action(() => { Text = Session.DisplayText; }); AppContext.MainForm.UiInvoke(action); }; TaskManager.Instance.EnqueueTask("获得账号【" + session.UserName + "】的注册用户姓名", () => new GetDisplayNameWorker() { Session = Session }.Run()); Image = session.TemporaryMode ? Properties.Resources.cou_16_protection : session.ShadowMode ? Properties.Resources.cou_16_users : Properties.Resources.user_16; //find index _controlParent = parent; var last = parent.Tabs.OfType <UserTabDnb>().LastOrDefault(); var idx = last == null ? 1 : parent.Tabs.IndexOf(last) + 1; parent.Tabs.Add(this, idx); }
public void AddTab(string tabName, SuperTabControlPanel tabPanel) { SuperTabControl tabControl = this.SuperTabControl1; if (tabControl == null) { throw new Exception("无法找到SuperTabControl。"); } tabControl.SuspendLayout(); SuperTabItem tabItem = new SuperTabItem(); tabControl.Controls.Add(tabPanel); tabControl.Tabs.Add(tabItem); tabPanel.TabItem = tabItem; tabItem.Text = tabName; tabItem.AttachedControl = tabPanel; tabControl.ResumeLayout(false); }
/// <summary> /// 添加一个选项卡 /// </summary> /// <param name="tabName">选项卡标题</param> /// <param name="uniqueKey">唯一标识符,用于区别于其他选项卡</param> /// <param name="form">要被添加到选项卡的窗体</param> /// <param name="showCloseButton">是否允许关闭该选项卡</param> public void CreateTab(string tabName, string uniqueKey, Form form, bool showCloseButton) { SuperTabItem superTabItem = ErgodicModiForm(uniqueKey); if (superTabItem == null) { superTabItem = this.superTabControl.CreateTab(tabName); superTabItem.GlobalItem = true; superTabItem.GlobalName = uniqueKey; superTabItem.CloseButtonVisible = showCloseButton; superTabItem.TextAlignment = eItemAlignment.Center; SuperTabControlPanel superTabControlPanel = superTabItem.AttachedControl as SuperTabControlPanel; // 当窗体尺寸超过本身时显示滚动条 //superTabControlPanel.AutoScroll = true; superTabControlPanel.PanelColor.Default = new SuperTabPanelItemColorTable() { Background = new SuperTabLinearGradientColorTable() { Colors = new Color[] { Color.White } } }; //superTabControlPanel.SizeChanged += new EventHandler(superTabControlPanel_SizeChanged); form.FormBorderStyle = FormBorderStyle.None; form.TopLevel = false; form.Visible = true; superTabItem.AttachedControl.Controls.Add(form); // 设置当前选项卡为新增选项卡 this.superTabControl.SelectedTab = superTabItem; } else { // 设为当前选中的选项 this.superTabControl.SelectedTab = superTabItem; } }
/// <summary> /// 打开窗体 /// </summary> /// <param name="code">编辑(如:FrmModuleAdmin)</param> /// <param name="assembly">程序集名称(如:RDIFramework.WinModule.dll)</param> /// <param name="formName">窗体名称(如:RDIFramework.WinModule.FrmModuleAdmin)</param> /// <param name="imgIndex">图标索引</param> private void OpenForm(string code, string assembly, string formName, int imgIndex = 0) { if (string.IsNullOrEmpty(formName) || string.IsNullOrEmpty(assembly) || string.IsNullOrEmpty(formName)) { return; } if (assembly.ToLower().Contains(".dll")) { assembly = assembly.Substring(0, assembly.LastIndexOf('.')); } // 通过数据库的值获得要打开的模块对应的窗体类型。 var type = System.Type.GetType(formName.Trim() + "," + assembly); if (type == null) { MessageBoxHelper.ShowStopMsg(RDIFrameworkMessage.MSG1000); return; } var obj = (object)Activator.CreateInstance(type, null); var mdiForm = obj as BaseForm; mdiForm.Stringlist = base.Stringlist; mdiForm.DbLinks = base.DbLinks; if (mdiForm.ShowDialogOnly) { mdiForm.HelpButton = false; mdiForm.ShowInTaskbar = false; mdiForm.MinimizeBox = false; mdiForm.ShowDialog(this); return; } if (!AllowSamePage && TabIsExist(code)) { return; } var tabItemNew = new SuperTabItem(); var tabControlPanelNew = new SuperTabControlPanel { AutoScroll = true, Dock = DockStyle.Fill, Name = code, TabItem = tabItemNew }; tabItemNew.AttachedControl = tabControlPanelNew; tabItemNew.Name = code; mdiForm.FormClosed += RemoveSelectedTab; mdiForm.FormBorderStyle = FormBorderStyle.None; mdiForm.TopLevel = false; mdiForm.Parent = tabControlPanelNew; mdiForm.Dock = DockStyle.Fill; tabControlPanelNew.Controls.Add(mdiForm); mdiForm.Show(); mdiForm.AutoSize = true; tabItemNew.Text = mdiForm.Text; tabItemNew.Image = tmpImageList.Images.Count > imgIndex & imgIndex > 0 ? tmpImageList.Images[imgIndex] : imageListMain.Images[0]; tabControlMain.Controls.Add(tabControlPanelNew); tabControlMain.Tabs.Add(tabItemNew); tabControlMain.Refresh(); tabControlMain.SelectedTab = tabItemNew; }
/// <summary> /// 把窗体显示在主界面的Tab中 /// 实例如打开增加用户的窗体: /// var frmUserAdd = new FrmUserAdd(); /// this.ShowFormInMainTab(frmUserAdd, "FrmUserAdd", frmUserAdd.Icon.ToBitmap()); /// </summary> /// <param name="mdiForm">窗体</param> /// <param name="code">窗体编辑</param> /// <param name="pageImage">窗体图标</param> public void ShowFormInMainTab(BaseForm mdiForm, string code, Image pageImage) { var tabItemNew = new SuperTabItem(); var tabControlPanelNew = new SuperTabControlPanel { AutoScroll = true, Dock = DockStyle.Fill, Name = code, TabItem = tabItemNew }; tabItemNew.AttachedControl = tabControlPanelNew; tabItemNew.Name = code; mdiForm.FormClosed += RemoveSelectedTab; mdiForm.FormBorderStyle = FormBorderStyle.None; mdiForm.TopLevel = false; mdiForm.Parent = tabControlPanelNew; mdiForm.Dock = DockStyle.Fill; tabControlPanelNew.Controls.Add(mdiForm); mdiForm.Show(); mdiForm.AutoSize = true; tabItemNew.Text = mdiForm.Text; if (pageImage != null) { tabItemNew.Image = ImageHelper.Scale(pageImage, new Size(24, 24)); //把图标缩放到24*24的尺寸 } FormCollection formList = Application.OpenForms; BaseMainForm mdiMainForm = null; BaseRibbonForm mdiRibbonForm = null; foreach (Form frm in formList) { if (frm.Name == "FrmRDIFrameworkNav" || frm.Name == "FrmRDIFrameworkTree") { mdiMainForm = frm as BaseMainForm; break; } if (frm.Name == "FrmRDIFrameworkRibbon") { mdiRibbonForm = frm as BaseRibbonForm; break; } } if (mdiMainForm != null) { mdiMainForm.MainTableControl.Controls.Add(tabControlPanelNew); mdiMainForm.MainTableControl.Tabs.Add(tabItemNew); mdiMainForm.MainTableControl.Refresh(); mdiMainForm.MainTableControl.SelectedTab = tabItemNew; } if (mdiRibbonForm != null) { mdiRibbonForm.MainTableControl.Controls.Add(tabControlPanelNew); mdiRibbonForm.MainTableControl.Tabs.Add(tabItemNew); mdiRibbonForm.MainTableControl.Refresh(); mdiRibbonForm.MainTableControl.SelectedTab = tabItemNew; } }
private void WebPage_DocumentTitleChange(object sender, DocumentTitleEventArgs e) { SuperTabControlPanel panel = (sender as Control).Parent as SuperTabControlPanel; panel.TabItem.Text = e.Title; }