public SelectTab ( TabPage tabPage ) : void | ||
tabPage | TabPage | |
Résultat | void |
public void ISelectionProviderEventTest () { TabControl tc = new TabControl (); TabPage tp1 = new TabPage (); TabPage tp2 = new TabPage (); tc.Controls.Add (tp1); tc.Controls.Add (tp2); Form.Controls.Add (tc); IRawElementProviderSimple provider = ProviderFactory.GetProvider (tc); ISelectionProvider selectionProvider = provider.GetPatternProvider ( SelectionPatternIdentifiers.Pattern.Id) as ISelectionProvider; Assert.IsNotNull (selectionProvider, "Not returning SelectionPatternIdentifiers."); tc.SelectTab (0); // Case 1: Select currently selected tab bridge.ResetEventLists (); tc.SelectTab (0); Assert.AreEqual (0, bridge.AutomationEvents.Count, "EventCount after selecting selected tab"); // Case 2: Select different tab bridge.ResetEventLists (); tc.SelectTab (1); Assert.AreEqual (1, bridge.GetAutomationPropertyEventCount (SelectionPatternIdentifiers.SelectionProperty), "EventCount after selecting new tab"); IRawElementProviderSimple[] pageProviders = selectionProvider.GetSelection (); Assert.IsNotNull (pageProviders, "Null selection returned"); Assert.AreEqual (1, pageProviders.Length, "Less/More than one selected page returned"); IRawElementProviderSimple child = ((IRawElementProviderFragmentRoot) provider) .Navigate (NavigateDirection.FirstChild); Assert.IsNotNull (child, "First child is null"); child = ((IRawElementProviderFragment) child) .Navigate (NavigateDirection.NextSibling); Assert.IsNotNull (child, "Second child is null"); Assert.AreEqual (child, pageProviders[0], "Selected child and second child aren't equal"); IRawElementProviderSimple pageProvider = pageProviders[0]; // TODO: flesh this out when we implement TabPageProvider Assert.IsNotNull (pageProvider); }
/// <summary> /// 显示指定的page,并使之成为当前page /// </summary> /// <param name="container"></param> /// <param name="page"></param> public static void ShowPage(TabControl container,TabPage page) { if (!container.Contains(page)) { container.TabPages.Add(page); } page.Show(); container.SelectTab(page); }
public EntryTemplateManager(IPluginHost host, PwEntryForm form) { m_host = host; this.form = form; our_page = new TabPage("Template"); our_page.AutoScroll = true; form_tab_control = get_control_from_form(form, "m_tabMain") as TabControl; Debug.Assert(form_tab_control != null); form_tab_control.Selecting += main_tabs_control_Selecting; _entry_is_template = form.EntryStrings.Get("_etm_template") != null; ProtectedString str = form.EntryStrings.Get("_etm_template_uuid"); entry_is_child = str != null; if (entry_is_child) child_template_uuid = str.ReadString(); form.EntrySaving += form_EntrySaving; our_page.UseVisualStyleBackColor = true; form_tab_control.TabPages.Insert(0, our_page); if (entry_is_child || entry_is_template) form_tab_control.SelectTab(0); }
/// <summary> /// ��tabcontrol���翨Ƭ�� /// </summary> /// <param name="tc">ָ����tabcontrol</param> public static void AddTabControl(TabControl tc, string title, Control c) { if (dicpage.ContainsKey(title)) { tc.SelectTab(title); return; } TabPage tp = new TabPage(title); tp.Name = title; dicpage.Add(title, tp); tp.Controls.Add(c); c.Dock = DockStyle.Fill; tc.TabPages.Add(dicpage[title]); tc.SelectTab(title); }
public void ux_tabcontrolMouseDownEvent(TabControl ux_tabcontrolDataview, MouseEventArgs e) { int clickedTabPage = ux_tabcontrolDataview.SelectedIndex; // Attempt to find the tabpage that was clicked... for (int i = 0; i < ux_tabcontrolDataview.TabPages.Count; i++) { if (ux_tabcontrolDataview.GetTabRect(i).Contains(e.Location)) clickedTabPage = i; //MessageBox.Show(ux_tabcontrolDataview.TabPages[i].Text + " : " + e.Location.ToString()); } if (e.Button == MouseButtons.Left) { // Begin tabpage drag and drop move (if the clicked tab is not // the "ux_tabpageDataviewNewTab" tabpage - which is use to add new dataviews)... if (ux_tabcontrolDataview.TabPages[clickedTabPage] != ux_tabcontrolDataview.TabPages["ux_tabpageDataviewNewTab"]) { ux_tabcontrolDataview.DoDragDrop(ux_tabcontrolDataview.TabPages[clickedTabPage], DragDropEffects.Move); } } else if (e.Button == MouseButtons.Right) { // Make the right clicked tabpage the selected tabpage for the control... ux_tabcontrolDataview.SelectTab(clickedTabPage); } }
public void ux_tabcontrolDragDropEvent(TabControl ux_tabcontrolDataview, DragEventArgs e) { if (e.AllowedEffect == e.Effect) { // Convert the mouse coordinates from screen to client... System.Drawing.Point ptClientCoord = ux_tabcontrolDataview.PointToClient(new System.Drawing.Point(e.X, e.Y)); int destinationTabPageIndex = -1; int originalTabPageIndex = -1; // Attempt to find where the tabpage should be dropped... for (int i = 0; i < ux_tabcontrolDataview.TabPages.Count; i++) { //if (ux_tabcontrolDataview.TabPages[i] == e.Data.GetData(typeof(TabPage))) originalTabPageIndex = i; if (ux_tabcontrolDataview.TabPages[i] == e.Data.GetData("System.Windows.Forms.TabPage")) originalTabPageIndex = i; if (ux_tabcontrolDataview.GetTabRect(i).Contains(ptClientCoord)) destinationTabPageIndex = i; } // Now create a copy of the tabpage that is being moved so that // you can remove the orginal and insert the copy at the right spot... TabPage newTabPage = new TabPage(); //newTabPage.Text = ((TabPage)e.Data.GetData(typeof(TabPage))).Text; newTabPage.Text = ((TabPage)e.Data.GetData("System.Windows.Forms.TabPage")).Text; //newTabPage.Tag = ((TabPage)e.Data.GetData(typeof(TabPage))).Tag; newTabPage.Tag = ((TabPage)e.Data.GetData("System.Windows.Forms.TabPage")).Tag; ux_tabcontrolDataview.TabPages.Insert(destinationTabPageIndex, newTabPage); ux_tabcontrolDataview.SelectTab(destinationTabPageIndex); if (originalTabPageIndex < destinationTabPageIndex) { ux_tabcontrolDataview.TabPages.RemoveAt(originalTabPageIndex); } else { ux_tabcontrolDataview.TabPages.RemoveAt(originalTabPageIndex + 1); } } }
protected bool showTabPage(TabPage tab, int index, TabControl control) { if(control.TabPages.Contains(tab)) { return false; } control.TabPages.Insert(index, tab); control.SelectTab(index); return true; }
/// <summary> /// List available resources of a given type, allowing the user to select one. /// </summary> /// <param name="resourceType">Type of resource to list</param> /// <param name="group">Group number of "this" group</param> /// <param name="form">Parent form</param> /// <param name="skip_pages">A flag per page (this package, private, semi, global, prim) to suppress pages</param> /// <param name="canDoEA">Whether to differentiate overriding resources</param> /// <returns>The chosen resource entry</returns> public pjse.FileTable.Entry Execute(uint resourceType, uint group, Control form, bool canDoEA, Boolset skip_pages) { CanDoEA = canDoEA; form.Cursor = Cursors.WaitCursor; this.Cursor = Cursors.WaitCursor; List <TabPage> ltp = new List <TabPage>(new TabPage[] { tpPackage, tpGroup, tpSemiGroup, tpGlobalGroup, tpBuiltIn }); btnViewBHAV.Visible = resourceType == SimPe.Data.MetaData.BHAV_FILE; this.tcResources.TabPages.Clear(); // There doesn't appear to be a way to compare two paths and have the OS decide if they refer to the same object if (!skip_pages[0] && pjse.FileTable.GFT.CurrentPackage != null && pjse.FileTable.GFT.CurrentPackage.FileName != null && !pjse.FileTable.GFT.CurrentPackage.FileName.ToLower().EndsWith("objects.package")) { FillPackage(resourceType, this.lvPackage, this.tpPackage); } if (!skip_pages[1]) { FillGroup(resourceType, group, this.lvGroup, this.tpGroup); } if (!skip_pages[2]) { Glob g = pjse.BhavWiz.GlobByGroup(group); if (g != null) { FillGroup(resourceType, g.SemiGlobalGroup, this.lvSemi, this.tpSemiGroup); this.tpSemiGroup.Text = g.SemiGlobalName; } } if (!skip_pages[3] && group != (uint)Group.Global) { FillGroup(resourceType, (uint)Group.Global, this.lvGlobal, this.tpGlobalGroup); } if (!skip_pages[4] && resourceType == SimPe.Data.MetaData.BHAV_FILE) { FillBuiltIn(resourceType, this.lvPrim, this.tpBuiltIn); } if (this.tcResources.TabCount > 0) { if (tcResources.Contains(ltp[PersistentTab])) { tcResources.SelectTab(ltp[PersistentTab]); } else { this.tcResources.SelectedIndex = 0; } } form.Cursor = Cursors.Default; this.Cursor = Cursors.Default; this.Size = ChooserSize; DialogResult dr = ShowDialog(); while (dr == DialogResult.Retry) { dr = ShowDialog(); } ChooserSize = this.Size; PersistentTab = ltp.IndexOf(this.tcResources.SelectedTab); Close(); if (dr == System.Windows.Forms.DialogResult.OK) { ListView lv = getListView(); if (lv != null) { if (lv != lvPrim) { return((pjse.FileTable.Entry)lv.SelectedItems[0].Tag); } else { IPackedFileDescriptor pfd = new SimPe.Packages.PackedFileDescriptor(); pfd.Instance = (uint)lvPrim.SelectedItems[0].Tag; return(new pjse.FileTable.Entry(null, pfd, true, true)); } } } return(null); }
private void getXML(TabControl t) { if (File.Exists(Application.StartupPath + "\\TabPage.xml")) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Application.StartupPath + "\\TabPage.xml"); XmlNode node = xmlDoc.SelectSingleNode("TabPage"); XmlNode node1 = node.SelectSingleNode(treeName); XmlNode node2 = node1.ChildNodes[0]; if (node2 != null) { if (node2.Name == "分站状态") { t.SelectTab(0); } else if (node2.Name == "实时下井人员") { t.SelectTab(1); } else if (node2.Name == "实时区域") { t.SelectTab(2); } else if (node2.Name == "检卡信息表") { t.SelectTab(0); } else { t.SelectTab(1); } #region[读字体] XmlDocument xmlDoc2 = new XmlDocument(); xmlDoc2.Load(Application.StartupPath + "\\tree.xml"); XmlNode nodeTree = xmlDoc2.SelectSingleNode("tree"); XmlNode nodePage = nodeTree.SelectSingleNode(treeName); foreach (XmlNode cruNode in nodePage) { if (cruNode.HasChildNodes && cruNode.ChildNodes[0].Name.Contains("表")) { string sql = cruNode.ChildNodes[0].SelectSingleNode("sql").InnerText; string ziti = cruNode.ChildNodes[0].SelectSingleNode("字体").InnerText; ziti = ziti.Replace("[FontFamily: Name=", "").Replace("]", ""); float zihao = (float)(Convert.ToDouble(cruNode.ChildNodes[0].SelectSingleNode("字号").InnerText)); string yangshi = cruNode.ChildNodes[0].SelectSingleNode("样式").InnerText; string yanse = cruNode.ChildNodes[0].SelectSingleNode("颜色").InnerText; yanse = yanse.Substring(yanse.IndexOf("[") + 1, yanse.IndexOf("]") - yanse.IndexOf("[") - 1); dataGridView1.RowsDefaultCellStyle.ForeColor = Color.FromName(yanse); dataGridView1.RowsDefaultCellStyle.Font = new Font(ziti, zihao, (System.Drawing.FontStyle)Enum.Parse(typeof(System.Drawing.FontStyle), yangshi, false)); dataGridView1.RowsDefaultCellStyle.SelectionForeColor = dataGridView1.RowsDefaultCellStyle.ForeColor; dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.FromName(yanse); dataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font(ziti, zihao, (System.Drawing.FontStyle)Enum.Parse(typeof(System.Drawing.FontStyle), yangshi, false)); } } #endregion NodeSelect = node2.Name; checkBox = node2.InnerText.Substring(0, node2.InnerText.Length - 1).Split(','); } } else { XmlDocument xmlDoc = new XmlDocument(); XmlElement ele1 = xmlDoc.CreateElement("TabPage"); xmlDoc.AppendChild(ele1); XmlElement ele2 = xmlDoc.CreateElement("文本信息"); XmlElement ele3 = xmlDoc.CreateElement("监控信息"); XmlElement ele4 = xmlDoc.CreateElement("常规信息"); ele1.AppendChild(ele2); ele1.AppendChild(ele3); ele1.AppendChild(ele4); xmlDoc.Save(Application.StartupPath + "\\TabPage.xml"); } XmlDocument xmlDoc1 = new XmlDocument(); xmlDoc1.Load(Application.StartupPath + "\\LedConfig.xml"); tableTime = Convert.ToInt32(xmlDoc1.SelectSingleNode("Config/TableFlesh").InnerText); #region【Led大屏显示特定分站信息-2013-12-05】 XmlDocument xmlCzlt = new XmlDocument(); xmlCzlt.Load(Application.StartupPath + "\\ShowConfig.xml"); LedStaID = xmlCzlt.SelectSingleNode("Config/LedStaID").InnerText.Trim(); if (LedStaID.Trim().Equals("")) { LedStaID = " and 1=1 "; } else { LedStaID = " and stationAddress in ("+LedStaID+") "; } MineStaID = xmlCzlt.SelectSingleNode("Config/MineStaID").InnerText.Trim(); if (MineStaID.Trim().Equals("")) { MineStaID = " and 1=1 "; } else { MineStaID = " and S.StationHeadID in (" + MineStaID + ")"; } #endregion }
private void ux_comboboxCNO_SelectedIndexChanged(object sender, EventArgs e) { // Change cursor to the wait cursor... Cursor origCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; if (ux_comboboxCNO.SelectedIndex != -1) { string tabOrder = ""; DataTable userListItems; if (_currentCooperatorID.Trim() == _usernameCooperatorID.Trim()) { // Save user settings... SetAllUserSettings(); _sharedUtils.SaveAllUserSettings(); // Save the user's list (if the user owns that list)... SaveNavigatorTabControlData(_ux_NavigatorTabControl, int.Parse(_usernameCooperatorID)); } // Get the treeview lists for the currently selected cooperator... userListItems = GetUserItemList((int)ux_comboboxCNO.SelectedValue); //// If the user is switching back to their own list - go get the tabOrder property... //if (cno.ToLower().Trim() == ux_comboboxCNO.SelectedValue.ToString().ToLower().Trim()) //{ // //tabOrder = userSettings[ux_tabcontrolGroupListNavigator.Name, "TabPages.Order"]; // tabOrder = _sharedUtils.GetUserSetting(ux_tabcontrolGroupListNavigator.Name, "TabPages.Order", ""); // // This is code to handle legacy user settings - pull this out after RC2... // if (!tabOrder.Contains(_pathSeparator)) // { // tabOrder = ""; // } //} //else //{ // tabOrder = ""; //} // Rebuild the Navigator Tab Control with the new user item list... _ux_NavigatorTabControl = BuildTabControl(userListItems); //_ux_NavigatorTabControl.Select(); //_ux_NavigatorTabControl.Focus(); //_ux_NavigatorTabControl.SelectTab(""); _ux_NavigatorTabControl.SelectTab(0); TreeView tv = (TreeView)_ux_NavigatorTabControl.SelectedTab.Controls[_ux_NavigatorTabControl.SelectedTab.Name + "TreeView"]; if (tv.SelectedNode == null) { RestoreActiveNode(tv); } //if (tv.SelectedNode == null) //{ // tv.SelectedNode = tv.Nodes[0]; //} //else //{ // TreeNode currentSelectedNode = tv.SelectedNode; // tv.SelectedNode = null; // tv.SelectedNode = currentSelectedNode; //} // Save the value of the new currentCooperatorID _currentCooperatorID = ux_comboboxCNO.SelectedValue.ToString().Trim(); } else { _ux_NavigatorTabControl.TabPages.Clear(); } // Now that selecting the CNO above has triggered the creation of the Navigator TabControl, place it in the left pane... ux_panelNavigator.Controls.Clear(); ux_panelNavigator.Controls.Add(_ux_NavigatorTabControl); _ux_NavigatorTabControl.Size = ux_panelNavigator.Size; _ux_NavigatorTabControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; // Restore cursor to default cursor... Cursor.Current = origCursor; }
/// <summary> /// Allows to add new task control /// </summary> /// <param name="id">task ID</param> /// <param name="tabControl">TabControl to add to</param> private void AddUserControl(TabControl tabControl, long id = -1) { try { tabControl.SelectTab( tabControl.TabPages .Cast<TabPage>() .First(x => x.Tag != null && x.Tag.ToString() == id.ToString(CultureInfo.InvariantCulture))); } catch (Exception) { var tp = new TabPage {Tag = id}; var tuc = new TaskUserControl(this, id) {Dock = DockStyle.Fill}; tuc.TaskOpened += AddUserControl; tuc.TaskClosed += TucTaskClosed; tp.Controls.Add(tuc); tabControl.TabPages.Add(tp); tabControl.SelectTab(tp); } }
protected override void OnClick(EventArgs e) { base.OnClick(e); owner.SelectTab(index); }
public void EventSelected () { Form f = new Form (); TabControl tc = new TabControl (); TabControlEventArgs tcea1 = new TabControlEventArgs (null, 0, TabControlAction.Deselected); TabControlEventArgs tcea2 = new TabControlEventArgs (null, 0, TabControlAction.Selected); TabControlCancelEventArgs tccea1 = new TabControlCancelEventArgs (null, 0, false, TabControlAction.Deselecting); TabControlCancelEventArgs tccea2 = new TabControlCancelEventArgs (null, 0, false, TabControlAction.Selecting); f.Controls.Add (tc); string events = string.Empty; tc.SelectedIndexChanged += new EventHandler (delegate (Object obj, EventArgs e) { events += ("SelectedIndexChanged;"); }); tc.Deselecting += new TabControlCancelEventHandler (delegate (Object obj, TabControlCancelEventArgs e) { events += ("Deselecting;"); tccea1 = e; }); tc.Deselected += new TabControlEventHandler (delegate (Object obj, TabControlEventArgs e) { events += ("Deselected;"); tcea1 = e; }); tc.Selecting += new TabControlCancelEventHandler (delegate (Object obj, TabControlCancelEventArgs e) { events += ("Selecting;"); tccea2 = e; }); tc.Selected += new TabControlEventHandler (delegate (Object obj, TabControlEventArgs e) { events += ("Selected;"); tcea2 = e; }); TabPage tp1 = new TabPage ("One"); TabPage tp2 = new TabPage ("Two"); tc.TabPages.Add (tp1); tc.TabPages.Add (tp2); f.Show (); tc.SelectTab (1); Assert.AreEqual ("Deselecting;Deselected;Selecting;Selected;SelectedIndexChanged;", events, "A1"); Assert.AreEqual (TabControlAction.Deselecting, tccea1.Action, "A2"); Assert.AreEqual (TabControlAction.Deselected, tcea1.Action, "A2"); Assert.AreEqual (TabControlAction.Selecting, tccea2.Action, "A2"); Assert.AreEqual (TabControlAction.Selected, tcea2.Action, "A2"); Assert.AreSame (tp2, tcea2.TabPage, "A3"); Assert.AreEqual (1, tcea2.TabPageIndex, "A4"); f.Close (); }
public void MethodSelectTabAOORE2 () { TabControl tc = new TabControl (); tc.TabPages.Add (new TabPage ("One")); tc.TabPages.Add (new TabPage ("Two")); tc.SelectTab (2); }
public void MethodSelectTab () { TabControl tc = new TabControl (); tc.TabPages.Add ("One", "One"); tc.TabPages.Add ("Two", "Two"); tc.TabPages.Add ("Three", "Three"); tc.SelectTab (1); Assert.AreEqual (1, tc.SelectedIndex, "A1"); tc.SelectTab (tc.TabPages[2]); Assert.AreEqual (2, tc.SelectedIndex, "A2"); tc.SelectTab ("One"); Assert.AreEqual (0, tc.SelectedIndex, "A3"); tc.SelectTab (1); tc.DeselectTab (1); Assert.AreEqual (2, tc.SelectedIndex, "A4"); tc.DeselectTab (2); Assert.AreEqual (0, tc.SelectedIndex, "A5"); tc.DeselectTab (tc.TabPages[0]); Assert.AreEqual (1, tc.SelectedIndex, "A6"); tc.DeselectTab (tc.TabPages[0]); Assert.AreEqual (1, tc.SelectedIndex, "A7"); tc.DeselectTab (tc.TabPages[1]); Assert.AreEqual (2, tc.SelectedIndex, "A7"); tc.DeselectTab ("Two"); Assert.AreEqual (2, tc.SelectedIndex, "A8"); tc.DeselectTab ("Three"); Assert.AreEqual (0, tc.SelectedIndex, "A8"); }