public void Remove(LcarsTabPage Tab) { //Removes the given tab from the collection. I know... duh. But comments are necessary evils. List.Remove(Tab); Tab = null; Parent.TabPagesChanged(); }
private void OnComponentRemoving(object sender, ComponentEventArgs e) { //This sub is fired when a control is removed from our LcarsTabControl. IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService)); LcarsTabPage mytabPage = null; IDesignerHost h = (IDesignerHost)GetService(typeof(IDesignerHost)); int i = 0; //If the user is removing a TabPage if (e.Component is LcarsTabPage) { mytabPage = (LcarsTabPage)e.Component; if (myControl.TabPages.Contains(mytabPage)) { c.OnComponentChanging(myControl, null); myControl.TabPages.Remove(mytabPage); c.OnComponentChanged(myControl, null, null, null); return; } } //If the user is removing the control itself, remove all of the TabPages first. if (object.ReferenceEquals(e.Component, myControl)) { for (i = myControl.TabPages.Count - 1; i >= 0; i += -1) { mytabPage = myControl.TabPages[i]; c.OnComponentChanging(myControl, null); myControl.TabPages.Remove(mytabPage); h.DestroyComponent(mytabPage); c.OnComponentChanged(myControl, null, null, null); } } }
private void AddTab(object sender, EventArgs e) { //I don't understand everthing that goes on here. I know that the end result is a new //tab being added to the LcarsTabPageControl. //Our new tab LcarsTabPage mytabpage = null; //An instance of the IDesignerHost interface which allows us to create transactions //in the designer. IDesignerHost myHost = (IDesignerHost)GetService(typeof(IDesignerHost)); //A transaction. From what I read, I believe that this just allows our "Add Tab" to //be undone using the "Undo" button. DesignerTransaction myTransaction = default(DesignerTransaction); //This is used to call events that are also used in the Undo and Redo functions. IComponentChangeService myChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); //Set the name of the transaction. I believe this also sets the starting point. myTransaction = myHost.CreateTransaction("Add Tab"); //Create a new LcarsTabPage using the DesignerHost. mytabpage = (LcarsTabPage)myHost.CreateComponent(typeof(LcarsTabPage)); //Let Visual Studio know we changed a component (our LcarsTabControl) myChangeService.OnComponentChanging(myControl, null); //Add the tabpage to the tabcontrol. myControl.TabPages.Add(mytabpage); //Visual Studio... we changed it again. myChangeService.OnComponentChanged(myControl, null, null, null); //Finish the transaction so it knows when the "undo" should stop. myTransaction.Commit(); }
private void ChangeTab(LcarsTabPage tab) { //Brings the provided tab to the front of all of the other tabs and sets it as //the selected tab. //NOTE: tab is used because if we used the property to set the selected tab, //we would get into an 'endless loop' because the 'SelectedTab' property calls //'ChangeTab' which in turn would call 'SelectedTab' again. Not good! if (tab != null) { tab.BringToFront(); selectedTab = tab; //Set the heading(the bar at the top)'s text to the tab's text horizantalBar.Text = tab.Text; //Set the selected tabs button's red alert to white and all others to normal foreach (FlatButton mybutton in tabButtonPanel.Controls) { if (ReferenceEquals(mybutton.Tag, tab)) { mybutton.AlertState = LcarsAlert.White; } else { mybutton.AlertState = LcarsAlert.Normal; } } } //Let the user of the control know that a tab has been selected. SelectedTabChanged?.Invoke(tab, TabPages.IndexOf(tab)); }
public int Add(LcarsTabPage tab) { //Adds the supplied tab to the tab collection and returns it's new index int i = 0; i = List.Add(tab); Parent.TabPagesChanged(); return(i); }
public void MoveUp(LcarsTabPage tab) { int index = List.IndexOf(tab); if (index > 0) { List[index] = List[index - 1]; List[index - 1] = tab; } Parent.TabPagesChanged(); }
public void MoveDown(LcarsTabPage tab) { int index = List.IndexOf(tab); if (index < Count - 1) { List[index] = List[index + 1]; List[index + 1] = tab; } Parent.TabPagesChanged(); }
public int IndexOf(LcarsTabPage tab) { //Returns the index of the given tab in the collection return(List.IndexOf(tab)); }
public bool Contains(LcarsTabPage tab) { //Returns 'true' if the tab is in the collection and 'false' if it is not. return(List.Contains(tab)); }
public override void Initialize(IComponent component) { base.Initialize(component); myControl = (LcarsTabPage)component; }