public void comboBoxEditPercentOfPage_EditValueChanged(object sender, EventArgs e) { var publicationControl = xtraTabControlPublications.SelectedTabPage as PrintProductControl; if (publicationControl != null && _allowToSave) { _allowToSave = false; Controller.Instance.PrintProductSharePageSquare.Items.Clear(); var shareUnits = new ShareUnit[] { }; if (Controller.Instance.PrintProductPercentOfPage.EditValue != null && Controller.Instance.PrintProductRateCard.EditValue != null) shareUnits = ListManager.Instance.ShareUnits.Where(x => x.RateCard.Equals(Controller.Instance.PrintProductRateCard.EditValue.ToString()) && x.PercentOfPage.Equals(Controller.Instance.PrintProductPercentOfPage.EditValue.ToString())).ToArray(); if (shareUnits.Length > 0) { ShareUnit storedShareUnit = publicationControl.PrintProduct.SizeOptions.RelatedShareUnit; foreach (ShareUnit shareUnit in shareUnits) Controller.Instance.PrintProductSharePageSquare.Items.Add(shareUnit, shareUnit.Dimensions, shareUnit.Dimensions.Equals(storedShareUnit.Dimensions) ? CheckState.Checked : CheckState.Unchecked, true); if (Controller.Instance.PrintProductSharePageSquare.CheckedIndices.Count == 0) Controller.Instance.PrintProductSharePageSquare.Items[0].CheckState = CheckState.Checked; } _allowToSave = true; SetSizeOptions(publicationControl); SettingsNotSaved = true; } }
private void LoadSizeOptions(PrintProductControl printProductControl) { _allowToSave = false; var sizeOptions = printProductControl.PrintProduct.SizeOptions; Controller.Instance.PrintProductPageSizeCheck.Checked = sizeOptions.EnablePageSize; Controller.Instance.PrintProductPageSizeGroup.Properties.Items.Clear(); Controller.Instance.PrintProductPageSizeGroup.Properties.Items.AddRange(ListManager.Instance.PageSizes.Select(ps => ps.Code).Distinct().ToArray()); Controller.Instance.PrintProductPageSizeGroupContainer.Visible = Controller.Instance.PrintProductPageSizeGroup.Properties.Items.Count > 1; if (!String.IsNullOrEmpty(sizeOptions.PageSizeGroup)) Controller.Instance.PrintProductPageSizeGroup.EditValue = sizeOptions.PageSizeGroup; else Controller.Instance.PrintProductPageSizeGroup.EditValue = ListManager.Instance.PageSizes.Select(ps => ps.Code).Distinct().FirstOrDefault(); Controller.Instance.PrintProductPageSizeName.Properties.Items.Clear(); Controller.Instance.PrintProductPageSizeName.Properties.Items.AddRange(ListManager.Instance.PageSizes.Where(ps => ps.Code.Equals(Controller.Instance.PrintProductPageSizeGroup.EditValue as String) || Controller.Instance.PrintProductPageSizeGroup.Properties.Items.Count <= 1).Select(ps => ps.Name).ToArray()); Controller.Instance.PrintProductPageSizeName.EditValue = sizeOptions.PageSize; Controller.Instance.PrintProductMechanicalsCheck.Checked = sizeOptions.EnableMechanicals; Controller.Instance.PrintProductMechanicalsName.EditValue = sizeOptions.Mechanicals; Controller.Instance.PrintProductRateCard.Properties.Items.Clear(); Controller.Instance.PrintProductRateCard.Properties.Items.AddRange(ListManager.Instance.ShareUnits.Select(x => x.RateCard).Distinct().ToArray()); switch (printProductControl.PrintProduct.AdPricingStrategy) { case AdPricingStrategies.StandartPCI: case AdPricingStrategies.FlatModular: Controller.Instance.PrintProductAdSizeStandartSquare.Checked = sizeOptions.EnableSquare; Controller.Instance.PrintProductStandartWidth.Value = (decimal)sizeOptions.Width; Controller.Instance.PrintProductStandartHeight.Value = (decimal)sizeOptions.Height; break; case AdPricingStrategies.SharePage: Controller.Instance.PrintProductRateCard.EditValue = sizeOptions.RateCard; Controller.Instance.PrintProductPercentOfPage.Properties.Items.Clear(); if (!string.IsNullOrEmpty(sizeOptions.RateCard)) Controller.Instance.PrintProductPercentOfPage.Properties.Items.AddRange(ListManager.Instance.ShareUnits.Where(x => x.RateCard.Equals(sizeOptions.RateCard)).Select(x => x.PercentOfPage).Distinct().ToArray()); Controller.Instance.PrintProductPercentOfPage.EditValue = sizeOptions.PercentOfPage; Controller.Instance.PrintProductSharePageSquare.Items.Clear(); var shareUnits = new ShareUnit[] { }; if (Controller.Instance.PrintProductPercentOfPage.EditValue != null && Controller.Instance.PrintProductRateCard.EditValue != null) shareUnits = ListManager.Instance.ShareUnits.Where(x => x.RateCard.Equals(Controller.Instance.PrintProductRateCard.EditValue.ToString()) && x.PercentOfPage.Equals(Controller.Instance.PrintProductPercentOfPage.EditValue.ToString())).ToArray(); if (shareUnits.Length > 0) { var storedShareUnit = printProductControl.PrintProduct.SizeOptions.RelatedShareUnit; foreach (var shareUnit in shareUnits) Controller.Instance.PrintProductSharePageSquare.Items.Add(shareUnit, shareUnit.Dimensions, shareUnit.Dimensions.Equals(storedShareUnit.Dimensions) ? CheckState.Checked : CheckState.Unchecked, true); if (Controller.Instance.PrintProductSharePageSquare.CheckedIndices.Count == 0) Controller.Instance.PrintProductSharePageSquare.Items[0].CheckState = CheckState.Checked; } break; } FormatAccordingSizeOptions(printProductControl); printProductControl.UpdateProductButtonsState(); _allowToSave = true; }