private void ScalePopupCancel_Click(object sender, EventArgs e) { ScalePopup.HidePopup(); }
/// <summary> /// Accept the values /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ScalePopupOk_Click(object sender, EventArgs e) { PrintingSystem ps = (PrintingSystem)Instance.PrintControl.PrintingSystem; PrintableComponentLink pcl = ps.Links[0] as PrintableComponentLink; Qm.DataTableManager.ResetFormattedBitmaps(); // reset so structures are drawn correct size if (Qm.MoleculeGrid.MainView is BandedGridView) { BandedGridView v = Qm.MoleculeGrid.MainView as BandedGridView; v.OptionsPrint.UsePrintStyles = false; if (ScaleAdjustToOption.CheckState == CheckState.Checked) { // Scale the view not the page ps.Document.ScaleFactor = 1.0f; // Keep page scale at 100% ps.Document.AutoFitToPagesWidth = 0; // no autofit Qm.Query.PrintScale = (int)ScaleAdjustToSpinner.Value; // store with query Qm.ResultsFormat.PageScale = Qm.Query.PrintScale; // for fieldFormatter use Qm.MoleculeGrid.ScaleBandedGridView(Qm.Query.PrintScale / 100.0); pcl.CreateDocument(); // recreate the doc } else { Qm.MoleculeGrid.ScaleBandedGridView(1.0); // scale grid to full size before setting doc scale pcl.CreateDocument(); // create the doc full size ps.Document.AutoFitToPagesWidth = (int)(ScaleFitToSpinner.Value); Qm.Query.PrintScale = (int)-ScaleFitToSpinner.Value; // store fit-to as negative value int pctScale = (int)(ps.Document.ScaleFactor * 100); Qm.ResultsFormat.PageScale = pctScale; Qm.MoleculeGrid.ScaleBandedGridView(pctScale / 100.0); // scale again to get structures correct size pcl.CreateDocument(); // recreate the doc (this takes the most time, could probably refactor to avoid this) } } else if (Qm.MoleculeGrid.MainView is CardView) { CardView v = Qm.MoleculeGrid.MainView as CardView; if (ScaleAdjustToOption.Checked) { // scale the card not the page ps.Document.ScaleFactor = 1.0f; // Keep page scale at 100% ps.Document.AutoFitToPagesWidth = 0; // no autofit Qm.Query.PrintScale = (int)ScaleAdjustToSpinner.Value; // store with query Qm.ResultsFormat.PageScale = Qm.Query.PrintScale; // for fieldFormatter use Qm.MoleculeGrid.ScaleCardView(Qm.Query.PrintScale / 100.0); // scale the cards pcl.CreateDocument(); // recreate the doc } else { ps.Document.AutoFitToPagesWidth = (int)(ScaleFitToSpinner.Value); Qm.Query.PrintScale = (int)-ScaleFitToSpinner.Value; // store fit-to as negative value Qm.ResultsFormat.PageScale = (int)(ps.Document.ScaleFactor * 100); Qm.MoleculeGrid.ScaleCardView(1.0); // make the cards normal size pcl.CreateDocument(); // recreate the doc } } else { throw new Exception("Expected BandedGridView or CardView"); } ScalePopup.HidePopup(); }