protected override void OnDragDrop(DragEventArgs drgevent) { if (AllowDrop) { try { if (mblnDragging) { TabPages.Clear(); TabPages.AddRange((TabPage[])mPages.ToArray(typeof(TabPage))); SelectedTab = mDragTab; mblnDragging = false; mDragTab = null; if (AfterDragDrop != null) { AfterDragDrop(this, EventArgs.Empty); } } } catch { } } }
private void BeforeLoad() { ModelViewModel._skeletons.Clear(); ResourceCache.Cleanup(); MessengerInstance.Send <object>(null, CleanupEvent); foreach (var tabItem in TabPages) { var page = tabItem.Content as AssetTreePage; if (page != null) { var vm = page.DataContext as AssetTreeViewModel; if (vm != null) { vm.Cleanup(); } } } TabPages.Clear(); DefaultDependenceResolver.Clear(); AssetPanelUri = null; AssetPreviewUri = null; RaisePropertyChanged("AssetPanelUri"); RaisePropertyChanged("AssetPreviewUri"); GC.Collect(); }
protected override void Render(HtmlTextWriter writer) { bool noTabs = false; string selected = null; // If no tabs have been defined in design mode write a canned HTML display if (DesignMode && TabPages.Count == 0) { noTabs = true; AddTab("No Tabs", "default", "Tab1"); AddTab("No Tabs 2", "default", "Tab2"); selected = SelectedTab; SelectedTab = "Tab2"; } // Render the actual control RenderControl(); // Dump the output into the ASP out stream writer.Write(Output); // Call the base to let it output the writer's output base.Render(writer); if (noTabs) { TabPages.Clear(); SelectedTab = selected; } }
/// ------------------------------------------------------------------------------------ public void MakeAppropriateEditorsVisible() { try { var visibleEditors = EditorProviders.Where(ep => ep.IsOKToShow).ToList(); if (visibleEditors.Count == TabPages.Count && GetAreAppropriateEditorsAlreadyVisible(visibleEditors.Select(e => e.GetType()).ToList())) { return; } this.SetWindowRedraw(false); TabPages.Clear(); foreach (var editor in EditorProviders.Where(ep => ep.IsOKToShow)) { TabPages.Add(new ComponentEditorTabPage(editor, _componentEditorBorderColor)); editor.Control.BackColor = _componentEditorBackColor; editor.Control.UseWaitCursor = false; } this.SetWindowRedraw(true); } catch (ObjectDisposedException) { // This can happen when shutting down. } }
private bool CloseAllRaw(TabPage exceptTab) { var pagesBuffer = new List <TabPage>(); foreach (TabPage tab in TabPages) { if (tab != exceptTab) { pagesBuffer.Add(tab); } } foreach (var tab in pagesBuffer) { if (!ConfirmCloseTab(tab)) { return(false); } } TabPages.Clear(); if (exceptTab != null) { TabPages.Add(exceptTab); } foreach (var tab in pagesBuffer) { tab.Dispose(); } return(true); }
/// <summary> /// Raises the Resize event. /// </summary> /// <param name="e"></param> protected override void OnResize(EventArgs e) { base.OnResize(e); CheckIfResizeIsNeeded(); if (Extensions.IsDesignMode(this)) { if (!stupidDesigner) { //We need to rebind tabpages. If not, TabControl will look weird. //This happens even with an empty class that inherit from TabControl. this.SelectedIndex = this.SelectedIndex; List <TabPage> pages = new List <TabPage>(); foreach (Control c in Controls) { pages.Add((TabPage)c); } Controls.Clear(); TabPages.Clear(); foreach (TabPage p in pages) { TabPages.Add(p); } stupidDesigner = true; } } }
void OnDocumentChanged(Document old) { TabPages.Clear(); if (old != null) { old.Charts.ItemAdded -= new XListEventHandler <ChartPage>(Charts_ItemAdded); old.Charts.ItemRemoved -= new XListEventHandler <ChartPage>(Charts_ItemRemoved); } if (Document != null) { var activeIndex = Document.ActiveChartIndex; foreach (var chart in Document.Charts) { var page = CreateNewPage(chart); page.IconChanged += Page_IconChanged; TabPages.Add(page); } if (activeIndex > -1 && activeIndex < TabPages.Count) { ActivePage(activeIndex); } Document.Charts.ItemAdded += new XListEventHandler <ChartPage>(Charts_ItemAdded); Document.Charts.ItemRemoved += new XListEventHandler <ChartPage>(Charts_ItemRemoved); Document.ModifiedChanged += Document_ModifiedChanged; } }
//--------------------------------------------------------------------- public void TabPagesClear() { SuspendLayout(); UpdateDrawTabPages(false); _clearAllCache(); TabPages.Clear(); ResumeLayout(); }
protected override void CleanupManagedResources() { TabPages.DisposeListObjects(); TabPages.Clear(); TabBar = null; base.CleanupManagedResources(); }
protected override void OnDragOver(System.Windows.Forms.DragEventArgs e)//拖過 { base.OnDragOver(e); Point pt = new Point(e.X, e.Y);//抓出目前座標 //We need client coordinates. pt = PointToClient(pt);//將指定的螢幕點的位置計算為工作區座標 (Client Coordinate)。-public class Control內的成員函數 //Get the tab we are hovering over. TabPage hover_tab = GetTabPageByTab(pt);//從工作區座標計算出被重疊的目的TabPage //Make sure we are on a tab. if (hover_tab != null) { //Make sure there is a TabPage being dragged. if (e.Data.GetDataPresent(typeof(TabPage))) { e.Effect = DragDropEffects.Move; TabPage drag_tab = (TabPage)e.Data.GetData(typeof(TabPage)); int item_drag_index = FindIndex(drag_tab); //找出目前TabPage所在位置 int drop_location_index = FindIndex(hover_tab); //找出目前被重疊TabPage所在位置 //Don't do anything if we are hovering over ourself. if (item_drag_index != drop_location_index)//確定有移動 { ArrayList pages = new ArrayList(); //Put all tab pages into an array. for (int i = 0; i < TabPages.Count; i++)//把所有不是被拖拉的物件記錄下來 { //Except the one we are dragging. if (i != item_drag_index) { pages.Add(TabPages[i]); } } //Now put the one we are dragging it at the proper location. pages.Insert(drop_location_index, drag_tab);//把是被拖拉的物件指定到目的之位置 //Make them all go away for a nanosec. TabPages.Clear();//清空所有內容 //Add them all back in. TabPages.AddRange((TabPage[])pages.ToArray(typeof(TabPage)));//重新填入所有頁面 //Make sure the drag tab is selected. SelectedTab = drag_tab;//指定目前顯示頁面 } } } else { e.Effect = DragDropEffects.None; } }
protected override void OnDragOver(System.Windows.Forms.DragEventArgs e) { base.OnDragOver(e); Point pt = new Point(e.X, e.Y); //We need client coordinates. pt = PointToClient(pt); //Get the tab we are hovering over. TabPage hover_tab = GetTabPageByTab(pt); //Make sure we are on a tab. if (hover_tab != null) { //Make sure there is a TabPage being dragged. if (e.Data.GetDataPresent(typeof(TabPage))) { e.Effect = DragDropEffects.Move; TabPage drag_tab = (TabPage)e.Data.GetData(typeof(TabPage)); int item_drag_index = FindIndex(drag_tab); int drop_location_index = FindIndex(hover_tab); //Don't do anything if we are hovering over ourself. if (item_drag_index != drop_location_index) { ArrayList pages = new ArrayList(); //Put all tab pages into an array. for (int i = 0; i < TabPages.Count; i++) { //Except the one we are dragging. if (i != item_drag_index) { pages.Add(TabPages[i]); } } //Now put the one we are dragging it at the proper location. pages.Insert(drop_location_index, drag_tab); //Make them all go away for a nanosec. TabPages.Clear(); //Add them all back in. TabPages.AddRange((TabPage[])pages.ToArray(typeof(TabPage))); //Make sure the drag tab is selected. SelectedTab = drag_tab; } } } else { e.Effect = DragDropEffects.None; } }
/// <summary> /// Check to see when the tab page changes, in order to refresh the data /// </summary> /// <param name="e"></param> protected override void OnSelectedIndexChanged(EventArgs e) { if (this.SelectedTab != null && this.SelectedTab.Text == "(back) ") { TabPages.Clear(); this.SendToBack(); this.Hide(); } base.OnSelectedIndexChanged(e); }
private void _showTabPagesByCacheOriginalTabPages(IEnumerable <int> tabPageIndexCollection, bool updateCache) { _updateCacheOriginalTabPages(updateCache); var selectedOriginalIndex = _selectedOriginalIndex; var isTabPageSelectedIndexContainsInShowTabPages = false; _isSelectedIndexFreeze = true; SuspendLayout(); SelectedIndex = -1; _cacheDrawOriginalTabPages.Clear(); if (!IsDisposed) { TabPages.Clear(); } foreach (var tabPageIndex in tabPageIndexCollection) { if (_cacheOriginalTabPages.ContainsKey(tabPageIndex)) { var tabPage = _cacheOriginalTabPages[tabPageIndex]; if (tabPage != null) { tabPage.Index = TabCount; TabPages.Add(tabPage); _cacheDrawOriginalTabPages.Add(tabPage.OriginalIndex, tabPage); if (tabPage.OriginalIndex == selectedOriginalIndex) { isTabPageSelectedIndexContainsInShowTabPages = true; selectedOriginalIndex = tabPage.Index; } } } } _isSelectedIndexFreeze = false; _isShowOriginalTabPage = _cacheOriginalTabPages.Count == _cacheDrawOriginalTabPages.Count; selectedOriginalIndex = isTabPageSelectedIndexContainsInShowTabPages ? selectedOriginalIndex : (TabCount == 0 ? -1 : 0); if (SelectedIndex == selectedOriginalIndex) { OnSelectedIndexChanged(EventArgs.Empty); } else { SelectedIndex = isTabPageSelectedIndexContainsInShowTabPages ? selectedOriginalIndex : (TabCount == 0 ? -1 : 0); } ResumeLayout(); }
public void Reset() { foreach (TabPage page in TabPages) { foreach (Control control in page.Controls) { control.Dispose(); } } TabPages.Clear(); Grade.Clear(); FullGrade = 0; }
private void SetTabProperties(XtraTabPage page, XtraTabSmartPartInfo smartPartInfo) { page.Text = String.IsNullOrEmpty(smartPartInfo.Title) ? page.Text : smartPartInfo.Title; try { XtraTabPage currentSelection = SelectedTabPage; callComposerActivateOnIndexChange = false; if (smartPartInfo.Position == TabPosition.Beginning) { XtraTabPage[] tabPages = GetTabPages(); TabPages.Clear(); TabPages.Add(page); TabPages.AddRange(tabPages); } else if (TabPages.Contains(page) == false) { TabPages.Add(page); } page.BackColor = smartPartInfo.BackColor; page.ForeColor = smartPartInfo.ForeColor; page.Image = smartPartInfo.Image; page.ImageIndex = smartPartInfo.ImageIndex; page.PageEnabled = smartPartInfo.PageEnabled; page.PageVisible = smartPartInfo.PageVisible; page.ShowCloseButton = smartPartInfo.ShowCloseButton; if (smartPartInfo.Text != null || smartPartInfo.Text != null) // don't apply if not set { page.Text = smartPartInfo.Text ?? smartPartInfo.Title; } page.Tooltip = smartPartInfo.Tooltip; if (smartPartInfo.PageHeaderFont != null) { page.Appearance.Header.Font = smartPartInfo.PageHeaderFont; page.Appearance.Header.Options.UseFont = true; } SelectedTabPage = currentSelection; // preserve selection through the operation } finally { callComposerActivateOnIndexChange = true; } }
/// <summary> /// Muestra / oculta una ficha /// </summary> public void ShowHideTab(int intTab, bool blnVisible) { // Inicializa el control InitControl(); // Oculta la página arrBoolPagesVisible[intTab] = blnVisible; // Elimina todas las fichas TabPages.Clear(); // Añade únicamente las fichas visibles for (int intIndex = 0; intIndex < objColPages.Count; intIndex++) { if (arrBoolPagesVisible[intIndex]) { TabPages.Add(objColPages[intIndex]); } } }
public void CloseDocument() { TabPages.Clear(); }
//EDDiscovery Init calls this public void CreateTabs(EDDiscoveryForm edf) { eddiscovery = edf; string majortabs = SQLiteConnectionUser.GetSettingString("MajorTabControlList", ""); string[] majortabnames = null; int[] tabctrl; if (!majortabs.RestoreArrayFromString(out tabctrl) || tabctrl.Length == 0 || (tabctrl.Length % 2) != 1) // need it odd as we have an index tab as first { tabctrl = new int[] { 0, -1, 0, // reset.. (int)PanelInformation.PanelIDs.Route, 0, (int)PanelInformation.PanelIDs.Expedition, 0, (int)PanelInformation.PanelIDs.Settings, 0, (int)PanelInformation.PanelIDs.PanelSelector, 0 }; } else { majortabnames = SQLiteConnectionUser.GetSettingString("MajorTabControlName", "").Replace("!error!", "+").Split(';'); // if its okay, load the name list } TabPage history = TabPages[0]; // remember history page, remove TabPages.Clear(); UserControls.UserControlHistory uch = history.Controls[0] as UserControls.UserControlHistory; travelgrid = uch.GetTravelGrid; // remember travel grid globally for later bool donehistory = false; for (int i = 1; i < tabctrl.Length; i += 2) { int nameindex = (i - 1) / 2; string name = majortabnames != null && nameindex < majortabnames.Length && majortabnames[nameindex].Length > 0 ? majortabnames[nameindex] : null; if (tabctrl[i] != -1) // this means UserControlHistory, which is a special one { try { PanelInformation.PanelIDs p = (PanelInformation.PanelIDs)tabctrl[i]; CreateTab(p, name, tabctrl[i + 1], TabPages.Count, false); // no need the theme, will be themed as part of overall load // may fail if p is crap, then just ignore } catch { } // paranoia in case tabctrl number is crappy. } else if (!donehistory) // just double check for repeats { if (name != null) // set name. if set. { history.Text = name; } TabPages.Add(history); // add back in right place donehistory = true; } } if (!donehistory) // just in case its missing.. be something up if it is. { TabPages.Add(history); // add back in right place } uch.Dock = System.Windows.Forms.DockStyle.Fill; // Crucial ! uccb has to be fill, even though the VS designer does not indicate you need to set it.. copied from designer code uch.Location = new System.Drawing.Point(3, 3); uch.Init(eddiscovery, null, UserControls.UserControlCommonBase.DisplayNumberHistoryGrid); // and init at this point with 0 as dn EnsureMajorTabIsPresent(PanelInformation.PanelIDs.PanelSelector, true); // just in case it disappears due to weirdness or debugging if (tabctrl.Length > 0 && tabctrl[0] >= 0 && tabctrl[0] < TabPages.Count) // make sure external data does not crash us { SelectedIndex = tabctrl[0]; } }
public void ClearTabs() { TabPages.Clear(); controlToTab.Clear(); GC.Collect(); }
// ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- /// <summary> /// Removes all open editors. /// </summary> internal void ClearEditors() { TabPages.Clear(); _openEditors.Clear(); Visible = false; }