public void LoadData() { if (!_needToReload) return; _allowApplyValues = false; checkEditShowFlightDates.Text = String.Format("{0}", _container.EditedContent.ScheduleSettings.FlightDates); xtraTabControlProducts.SuspendLayout(); Application.DoEvents(); xtraTabControlProducts.SelectedPageChanged -= OnProductsTabControlSelectedPageChanged; xtraTabControlProducts.TabPages.OfType<IDigitalProductControl>().ToList().ForEach(c => c.Release()); xtraTabControlProducts.TabPages.Clear(); _tabPages.Clear(); foreach (var product in _container.EditedContent.DigitalProducts.Where(p => !String.IsNullOrEmpty(p.Name))) { var productTab = new DigitalProductControl(this); AssignCloseActiveEditorsOnOutsideClick(productTab); _tabPages.Add(productTab); Application.DoEvents(); productTab.Product = product; productTab.LoadValues(); Application.DoEvents(); } _tabPages.Sort((x, y) => x.Product.Index.CompareTo(y.Product.Index)); xtraTabControlProducts.TabPages.AddRange(_tabPages.ToArray()); Application.DoEvents(); xtraTabControlProducts.ResumeLayout(); xtraTabControlProducts.SelectedPageChanged += OnProductsTabControlSelectedPageChanged; _allowApplyValues = true; LoadProduct(_tabPages.FirstOrDefault()); Application.DoEvents(); _needToReload = false; }
private void OnProductsTabControlMouseDown(object sender, MouseEventArgs e) { var tabControl = (XtraTabControl)sender; var hitInfo = tabControl.CalcHitInfo(new Point(e.X, e.Y)); if (hitInfo.HitTest != XtraTabHitTest.PageHeader || e.Button != MouseButtons.Right) return; var productControl = (DigitalProductControl)hitInfo.Page; using (var form = new FormCloneProduct()) { if (form.ShowDialog() != DialogResult.Yes) return; var selectedPage = (DigitalProductControl)xtraTabControlProducts.SelectedTabPage; var newPrintProduct = productControl.Product.Clone<DigitalProduct, DigitalProduct>(); xtraTabControlProducts.SelectedPageChanged -= OnProductsTabControlSelectedPageChanged; xtraTabControlProducts.TabPages.Clear(); var newPublicationTab = new DigitalProductControl(this); newPublicationTab.Product = newPrintProduct; newPublicationTab.Text = newPrintProduct.Name; newPublicationTab.LoadValues(); _tabPages.Add(newPublicationTab); _tabPages.Sort((x, y) => x.Product.Index.CompareTo(y.Product.Index)); xtraTabControlProducts.TabPages.AddRange(_tabPages.ToArray()); xtraTabControlProducts.SelectedPageChanged += OnProductsTabControlSelectedPageChanged; xtraTabControlProducts.SelectedTabPage = selectedPage; RaiseDataChanged(); } }