public void Indexer() { TabControl tab = new TabControl(); TabControl.TabPageCollection tabPages = new TabControl.TabPageCollection(tab); TabPage tabPageA = new TabPage(); TabPage tabPageB = new TabPage(); TabPage tabPageC = new TabPage(); TabPage tabPageD = new TabPage(); tabPages.Add(tabPageA); Assert.AreSame(tabPageA, tabPages [0], "#1"); tabPages [0] = tabPageB; Assert.AreSame(tabPageB, tabPages [0], "#2"); tabPages.Add(tabPageC); Assert.AreSame(tabPageB, tabPages [0], "#3"); Assert.AreSame(tabPageC, tabPages [1], "#4"); tabPages.Remove(tabPageB); Assert.AreSame(tabPageC, tabPages [0], "#5"); tabPages [0] = tabPageD; Assert.AreSame(tabPageD, tabPages [0], "#6"); Form form = new Form(); form.ShowInTaskbar = false; form.Controls.Add(tab); form.Show(); form.Dispose(); }
/// <summary> /// add elements on the tab /// </summary> /// <param name="i">an index of the current tab</param> void AddTab(int i) { headerLab.Add(new Label()); headerLab[i].TextAlign = ContentAlignment.MiddleCenter; headerLab[i].Font = new Font("Microsoft Sans Serif", 12, FontStyle.Bold); headerLab[i].AutoSize = true; replayButton.Add(new Button()); replayButton[i].Text = "Replay"; replayButton[i].Location = new Point(104, 315); gameTabs.Add("Game " + (i + 1)); winLab.Add(new Label()); winLab[i].TextAlign = ContentAlignment.MiddleCenter; winLab[i].Font = headerLab[i].Font; winLab[i].AutoSize = true; winLab[i].Location = new Point(341, 275); statLab.Add(new Label()); statLab[i].Font = new Font("Microsoft Sans Serif", 12); nowTurn.Add(new Label()); nowTurn[i].Font = statLab[i].Font; statLab[i].Location = new Point(341, 60); nowTurn[i].Location = new Point(341, 170); nowTurn[i].AutoSize = true; fieldBox.Add(new PictureBox()); fieldBox[i].Size = new Size(221, 221); fieldBox[i].Location = new Point(29, 44); fieldBox[i].BackColor = Color.White; fieldBox[i].Image = new Bitmap(fieldBox[i].Width, fieldBox[i].Height); graphic.Add(Graphics.FromImage(fieldBox[i].Image)); paintNewField(fieldBox[i], graphic[i]); headerLab[i].Location = new Point(29, 13); headerLab[i].Show(); historyBar.Add(new TrackBar()); historyBar[i].Size = new Size(220, 45); historyBar[i].Location = new Point(29, 267); historyBar[i].Minimum = 1; gameTabs[i].Controls.Add(headerLab[i]); gameTabs[i].Controls.Add(winLab[i]); gameTabs[i].Controls.Add(statLab[i]); gameTabs[i].Controls.Add(nowTurn[i]); gameTabs[i].Controls.Add(fieldBox[i]); gameTabs[i].Controls.Add(historyBar[i]); gameTabs[i].Controls.Add(replayButton[i]); gameTabs[i].Show(); //add events historyBar[i].Scroll += new EventHandler(historyBar_Scroll); replayButton[i].Click += new EventHandler(replayButton_Click); previousField.Add(new GraphicField()); }
/// <summary> /// Updates a TabControl to reflect all loaded items. /// </summary> /// <typeparam name="T">The type of element that is loaded.</typeparam> /// <param name="loaded">A list of all loaded elements.</param> /// <param name="tabControl">The TabControl to be updated.</param> /// <param name="onChange">Callback function when the Tabs where updates.</param> private void UpdateTabs <T>(List <T> loaded, TabControl tabControl, Action <object, EventArgs> onChange) { // save the current selected index int prevIndex = tabControl.SelectedIndex; TabControl.TabPageCollection pageCollection = tabControl.TabPages; // remove all pages while (pageCollection.Count != 0) { pageCollection.RemoveAt(0); } // readd all pages for (int i = 0; i < loaded.Count; i++) { pageCollection.Add(loaded[i].ToString()); } // is the index still valid? if (prevIndex >= pageCollection.Count) { prevIndex = pageCollection.Count - 1; } if (prevIndex < 0) { prevIndex = 0; } // restore the index tabControl.SelectedIndex = prevIndex; onChange.Invoke(null, null); }
public void Create(Style style) { string key = string.Format("{0}_{1}", pages.Count, (int)style); string text = string.Empty; TabPage tab = new TabPage() { Name = key }; switch (style) { case Style.RDB: tab.Controls.Add(new Styles.rdbTab(key) { Dock = DockStyle.Fill }); text = "RDB Utility"; break; case Style.DATA: tab.Controls.Add(new Styles.Data(key) { Dock = DockStyle.Fill }); text = "Data Utility"; break; case Style.HASHER: tab.Controls.Add(new Styles.Hasher() { Dock = DockStyle.Fill }); text = "Hash Utility"; break; case Style.USEFLAG: tab.Controls.Add(new Styles.UseFlag() { Dock = DockStyle.Fill }); text = "Use Flag Utility"; break; //case Style.DROPS: // tab.Controls.Add(new Styles.DropEditor() { Dock = DockStyle.Fill }); // text = "Drop Utility"; // break; //case Style.LOG: // tab.Controls.Add(new Styles.Log() { Dock = DockStyle.Fill }); // text = "Log Utility"; // break; } pages.Add(tab); tabs.SelectedTab = pages[key]; tabs.SelectedTab.Text = text; lManager.Enter(Logs.Sender.MANAGER, Logs.Level.NOTICE, "Tab created with name: {0} and style: {1}", text, ((Style)style).ToString()); }
protected void OnMusicListSelectedIndexChanged(object sender, EventArgs e) { if (MusicList.SelectedIndex == -1) { return; } Music music = SearchMusicByName(MusicList.SelectedItem); if (ScriptTabs.Count < music.Scripts.Count) { while (ScriptTabs.Count < music.Scripts.Count) { ScriptTabs.Add($"Part {ScriptTabs.Count + 1}"); } } else if (ScriptTabs.Count > music.Scripts.Count) { while (ScriptTabs.Count > music.Scripts.Count) { ScriptTabs.RemoveAt(ScriptTabs.Count - 1); } } for (int i = 0, l = music.Scripts.Count; i < l; i++) { ScriptTabs[i].ToolTipText = music.Scripts[i]; ScriptTabs[i].ImageKey = music.Volumes[i]; } NameText.Text = music.Name; KeyText.Text = music.Key; BpmText.Text = music.Bpm; if (ScriptTabList.SelectedIndex == 0) { OnScriptTabControlSelectedIndexChanged(null, null); } else { ScriptTabList.SelectedIndex = 0; } }
/// <summary> /// Verify that the tab pages are in the correct order /// </summary> public void VerifyDiagramOrder(IList <Diagram> diagrams) { TabControl.TabPageCollection pages = TabPages; int pageCount = pages.Count; int diagramCount = diagrams.Count; for (int i = 0; i < pageCount; ++i) { DiagramTabPage tabPage = (DiagramTabPage)pages[i]; if (i < diagramCount && tabPage.Diagram == diagrams[i]) { continue; } SuspendLayout(); // We're out of sync, pull remaining tabs and readd in diagram order DiagramTabPage reselectPage = SelectedDiagramTab; Dictionary <Diagram, DiagramTabPage> keyedPages = new Dictionary <Diagram, DiagramTabPage>(pageCount - i + 1); for (int j = pageCount - 1; j >= i; --j) { tabPage = (DiagramTabPage)pages[j]; keyedPages.Add(tabPage.Diagram, tabPage); tabPage.Parent = null; } // Add the diagram pages back in order for (int j = i; j < diagramCount; ++j) { Diagram diagram = diagrams[j]; if (keyedPages.TryGetValue(diagram, out tabPage)) { pages.Add(tabPage); keyedPages.Remove(diagram); } } // Dispose any remaining pages foreach (DiagramTabPage unboundPage in keyedPages.Values) { unboundPage.Dispose(); } SelectedTab = reselectPage; ResumeLayout(false); break; } }
public void Create(Style style) { string key = string.Format("{0}_{1}", pages.Count, (int)style); string text = string.Empty; TabPage tab = new TabPage() { Name = key }; switch (style) { case Style.RDB: tab.Controls.Add(new Styles.rdbTab(key) { Dock = DockStyle.Fill }); text = "RDB Utility"; break; case Style.DATA: tab.Controls.Add(new Styles.Data(key) { Dock = DockStyle.Fill }); text = "Data Utility"; break; case Style.HASHER: tab.Controls.Add(new Styles.Hasher() { Dock = DockStyle.Fill }); text = "Hash Utility"; break; case Style.ITEM: tab.Controls.Add(new Styles.Item() { Dock = DockStyle.Fill }); text = "Item Utility"; break; case Style.MARKET: tab.Controls.Add(new Styles.MarketEditor() { Dock = DockStyle.Fill }); text = "Market Utility"; break; //case Style.DROPS: // tab.Controls.Add(new Styles.DropEditor() { Dock = DockStyle.Fill }); // text = "Drop Utility"; // break; } pages.Add(tab); SetText(key, text); tabs.SelectedTab = pages[key]; lManager.Enter(Sender.MANAGER, Level.NOTICE, "Tab created with name: {0} and style: {1}", text, ((Style)style).ToString()); }
public DiagramTabPage(MultiDiagramDocViewControl docViewControl, DiagramView designer) { myDocViewControl = docViewControl; Designer = designer; base.SuspendLayout(); base.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true); base.UseVisualStyleBackColor = false; Diagram diagram = designer.Diagram; base.Text = base.Name = diagram.Name; base.Controls.Add(designer); // Find the correct tab location for this diagram, depending on the diagram order and the // pages that have already been added TabControl.TabPageCollection pages = docViewControl.TabPages; bool inserted = false; Store store = diagram.Store; bool useDiagramDisplay = store.FindDomainModel(DiagramDisplayDomainModel.DomainModelId) != null; if (useDiagramDisplay) { DiagramDisplay display = DiagramDisplayHasDiagramOrder.GetDiagramDisplay(diagram); if (display != null) { // Walk the existing pages and match up the expected display order. Note that // there is no guarantee that all of the preceding diagrams have tab pages already. // If the previous pages are out of order, then we will get a reorder event later on // that puts them in the correct order. This will add them in an unpredictable order // if the sequences are different. IList <Diagram> orderedDiagrams = display.OrderedDiagramCollection; int diagramCount = orderedDiagrams.Count; int nextDiagramIndex = 0; Diagram nextDiagram = orderedDiagrams[nextDiagramIndex]; int pageCount = pages.Count; if (nextDiagram == diagram) { if (pageCount != 0) { // The new diagram is first, insert at the beginning pages.Insert(0, this); inserted = true; } } else { for (int pageIndex = 0; pageIndex < pageCount && !inserted; ++pageIndex) { DiagramTabPage page = (DiagramTabPage)pages[pageIndex]; Diagram pageDiagram = page.Diagram; bool getNextDiagram = false; if (pageDiagram == nextDiagram) { getNextDiagram = true; } else { // Keep walking diagrams until we get a match while (nextDiagramIndex < diagramCount) { nextDiagram = orderedDiagrams[++nextDiagramIndex]; if (pageDiagram == nextDiagram) { getNextDiagram = true; } else if (nextDiagram == diagram) { if ((pageIndex + 1) < pageCount) { pages.Insert(pageIndex + 1, this); inserted = true; break; } } } } if (getNextDiagram) { if (nextDiagramIndex < diagramCount) { nextDiagram = orderedDiagrams[++nextDiagramIndex]; if (nextDiagram == diagram) { // Insert immediately after the current page if ((pageIndex + 1) < pageCount) { pages.Insert(pageIndex + 1, this); inserted = true; } break; } } else { break; } } } } } } if (!inserted) { pages.Add(this); } // If the image key is set before the page is inserted then the tab size is incorrect // and nothing draws property. I have no idea why. base.ImageKey = diagram.GetType().GUID.ToString("N", null); base.ResumeLayout(false); store.EventManagerDirectory.ElementPropertyChanged.Add(diagram.GetDomainClass().NameDomainProperty, diagram.Id, (EventHandler <ElementPropertyChangedEventArgs>)DiagramNameChanged); if (useDiagramDisplay) { designer.DiagramClientView.GotFocus += new EventHandler(ViewGotFocus); designer.DiagramClientView.Resize += new EventHandler(InitialViewResize); myTurnOffResizeEventInFocusEvent = true; } designer.DiagramClientView.DiagramDisassociating += DiagramDisassociating; }
public void Init() { HashSet <String> listedModules = new HashSet <string>(); List <ProjectSetting> sortedSettings = Settings.List().ToList <ProjectSetting>(); sortedSettings.Sort(); // get all modules that have displayed options foreach (ProjectSetting setting in sortedSettings) { if (!(String.IsNullOrWhiteSpace(setting.Display_Type) || String.IsNullOrWhiteSpace(setting.Module) ) ) { listedModules.Add(setting.Module); // returns false if already there. Don't care. } } foreach (String module in listedModules) { //TabPage page = new TabPage(module); String tabText = new CultureInfo("en-US").TextInfo.ToTitleCase(module); TabControl.TabPageCollection pages = tabControlSettings.TabPages; if (!pages.ContainsKey(module)) // should only happen for general tab { pages.Add(module, tabText); //pages[module].BackColor = Color.Transparent; // for some reason, the general page is a different background color?! // TODO: Fix } // general tab doesn't currently have these things. FlowLayoutPanel flowpanel = new FlowLayoutPanel(); flowpanel.Name = "flowpanel_" + module; flowpanel.FlowDirection = FlowDirection.LeftToRight; flowpanel.WrapContents = true; flowpanel.Dock = DockStyle.Fill; //flowpanel.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right); flowpanel.AutoScroll = true; pages[module].Controls.Add(flowpanel); } foreach (ProjectSetting setting in sortedSettings) { CtlSetting control; switch (setting.Display_Type) { case "": continue; case "info": control = new CtlSettingInfo(setting.Name); break; case "select": case "field": control = new CtlSettingSelect(setting.Name); if (setting.Display_Type == "field") { // if it's not required, add in a blank if (!setting.Required) { if (!setting.options.Contains("")) { setting.options.Insert(0, ""); } } control.setOptions(setting.options); } break; case "bool": control = new CtlSettingBool(setting.Name); break; default: control = new CtlSettingText(setting.Name); break; } // ??? FromSetting would remove the options we addded above? control.FromSetting(setting); control.Display_Text = setting.Display_Name == "" ? new CultureInfo("en-US").TextInfo.ToTitleCase(setting.Name) : setting.Display_Name; control.Visible = true; control.resetStatus(); control.Anchor = AnchorStyles.Left | AnchorStyles.Right; TabPage page = tabControlSettings.TabPages[setting.Module]; Control.ControlCollection controls = page.Controls; FlowLayoutPanel panel = (FlowLayoutPanel)controls["flowpanel_" + setting.Module]; panel.SuspendLayout(); panel.Controls.Add(control); panel.ResumeLayout(true); settingControls.Add(control); //tabControlSettings.TabPages[setting.Module].Controls.Add(control); control.OnFocus += Set_Description; //control.LostFocus += new EventHandler(Clear_Description); } // remove any pages, add any, etc foreach (TabPage page in tabControlSettings.TabPages) { if (page.Controls.Count <= 0) { tabControlSettings.TabPages.Remove(page); } } }
/// <summary> /// Adds a tab page to the collection /// </summary> public void Add(ITabPage page) { _tabPages.Add((TabPage)page); }
/** * PLink 초기화 * * */ public virtual void OnLoad() { // 실행위치 설정 PLink.host.AppName = getAppName(); // 트레이 메뉴에 PLink Remote 추가 ContextMenuStrip menu = getMenuStrip(); if (menu != null) { menu.Items.Insert(0, new ToolStripSeparator()); WebBrowser browser = new WebBrowser(); browser.Navigate("about:blank"); browser.Size = new System.Drawing.Size(400, 250); browser.ScrollBarsEnabled = false; ToolStripControlHost host = new ToolStripControlHost(browser); host.Margin = Padding.Empty; host.Padding = Padding.Empty; host.AutoSize = false; host.DoubleClickEnabled = false; menu.Items.Insert(0, host); menu.VisibleChanged += delegate { if (menu.Visible) { browser.Navigate("http://api.plink/view"); } }; } // PLink HostTab 설정 TabControl.TabPageCollection tabPage = getTabPages(); if (tabPage != null) { TabPage tab = new TabPage(Util.NAME); OnTabStateChange(tab); hostTab.Dock = DockStyle.Fill; tab.Controls.Add(hostTab); tabPage.Add(tab); } // UI 초기화 및 프로그램 초기화 initializeUI(); // URL 설정 PLink.host.VersionUrl = Util.getDefaultPref("URL", "version", Util.VERSION_URL); PLink.host.NoticeUrl = Util.getDefaultPref("URL", "notice", Util.NOTICE_URL); // UI 설정 로드 hostTab.OnLoad(); // 업데이트 체크 System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; string version_text = version.ToString(); PLink.host.Version = version_text; PLink.host.UpdateVersion = Util.checkVersion(PLink.host.Version); }
public void OpenMap() { try { map = World.GetFacetByIndex(0).GetLandByIndex(this.landIndex).GetMapByIndex(this.mapIndex); this.Text = "Dragon's Spine Map Editor [" + World.GetFacetByIndex(0).GetLandByIndex(this.landIndex).Name + " - " + map.Name + "]"; this.mapTabControl.Controls.Clear(); TabControl.TabPageCollection collection = new TabControl.TabPageCollection(this.mapTabControl); int[] zPlanesCopy = new int[map.ZPlanes.Count]; map.ZPlanes.Keys.CopyTo(zPlanesCopy, 0); Array.Sort(zPlanesCopy); for (int z = 0; z < zPlanesCopy.Length; z++) { TabPage tabPage = new TabPage(zPlanesCopy[z].ToString()); DataGridView dataGridView = new DataGridView(); DataGridViewCellStyle style = new DataGridViewCellStyle(); style.Alignment = DataGridViewContentAlignment.MiddleCenter; style.Font = new Font("Courier New", 12); style.WrapMode = DataGridViewTriState.False; style.ForeColor = Color.Black; style.BackColor = Color.White; dataGridView.DefaultCellStyle = style; dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.ColumnHeader; dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders; dataGridView.MultiSelect = false; dataGridView.Dock = System.Windows.Forms.DockStyle.Fill; dataGridView.Name = map.Name + " [" + zPlanesCopy[z].ToString() + "]"; dataGridView.ColumnCount = map.ZPlanes[zPlanesCopy[z]].xcordMax - map.ZPlanes[zPlanesCopy[z]].xcordMin; dataGridView.RowCount = map.ZPlanes[zPlanesCopy[z]].ycordMax - map.ZPlanes[zPlanesCopy[z]].ycordMin; for (int y = map.ZPlanes[zPlanesCopy[z]].ycordMin, b = 0; y <= map.ZPlanes[zPlanesCopy[z]].ycordMax; y++, b++) { for (int x = map.ZPlanes[zPlanesCopy[z]].xcordMin, a = 0; x <= map.ZPlanes[zPlanesCopy[z]].xcordMax; x++, a++) { Cell cell = Cell.GetCell(map.FacetID, map.LandID, map.MapID, x, y, zPlanesCopy[z]); if (cell != null) { if (dataGridView.Columns.Count > a && dataGridView.Rows.Count > b) { //if (this.rbtnColorSpawnZones.Checked && cell.SpawnZoneList.Count > 0) //{ // dataGridView[a, b].Style.BackColor = Color.Green; //} if (this.rbtnColorItemLocations.Checked && cell.Items.Count > 0) { dataGridView[a, b].Style.BackColor = Color.Green; } else if (this.rbtnColorCreatureLocations.Checked && cell.Characters.Count > 0) { foreach (Character ch in cell.Characters.Values) { if (!ch.IsPC) { dataGridView[a, b].Style.BackColor = Color.Green; break; } } } else if (this.rbtnColorPlayerLocations.Checked && cell.Characters.Count > 0) { foreach (Character ch in cell.Characters.Values) { if (ch.IsPC) { dataGridView[a, b].Style.BackColor = Color.Green; break; } } } dataGridView[a, b].Value = cell.CellGraphic; if (dataGridView[a, b].OwningColumn.Width != dataGridView[a, b].OwningRow.Height) { dataGridView[a, b].OwningColumn.Width = dataGridView[a, b].OwningRow.Height; } if ((string)dataGridView[a, b].OwningRow.HeaderCell.Value != cell.Y.ToString()) { dataGridView[a, b].OwningRow.HeaderCell.Value = cell.Y.ToString(); } if (dataGridView[a, b].OwningColumn.HeaderText != cell.X.ToString()) { dataGridView[a, b].OwningColumn.HeaderText = cell.X.ToString(); } } } } } tabPage.Controls.Add(dataGridView); collection.Add(tabPage); } } catch (Exception e) { Utils.LogException(e); } populateLandTab(); populateMapTab(map); }