Exemple #1
0
        /// <summary>
        /// Called when the measurement unit of the measurements stored in this template
        /// have changed and all measurements must be converted to the new unit
        /// </summary>
        /// <remarks>
        /// Overriden to convert the X and Y radiuses
        /// </remarks>
        /// <param name="converter">measurement unit converter to use</param>
        /// <param name="from">from measurement unit</param>
        /// <param name="to">to measurement unit</param>
        public override void ConvertMeasurementUnit(NMeasurementUnitConverter converter, NMeasurementUnit from, NMeasurementUnit to)
        {
            base.ConvertMeasurementUnit(converter, from, to);

            m_fRadiusX = converter.ConvertX(from, to, m_fRadiusX);
            m_fRadiusY = converter.ConvertY(from, to, m_fRadiusY);
        }
Exemple #2
0
        private void UpdatePageSettingsFromControls()
        {
            if (m_Updating)
            {
                return;
            }

            if (PrinterSettings.InstalledPrinters.Count == 0)
            {
                return;
            }

            m_Updating = true;

            PageSettings pageSettings = m_PrintManager.PageSettings;

            // portrait / landscape
            pageSettings.Landscape = LandscapeRadioButton.Checked;

            // margins
            NMarginsL margins = this.PageMarginsEditorUC.Margins;

            NMeasurementUnitConverter converter = new NMeasurementUnitConverter(pageSettings.PrinterResolution.X, pageSettings.PrinterResolution.Y);

            float left   = converter.ConvertX(margins.Left.MeasurementUnit, NGraphicsUnit.Inch, margins.Left.Value) * 100;
            float top    = converter.ConvertY(margins.Top.MeasurementUnit, NGraphicsUnit.Inch, margins.Top.Value) * 100;
            float right  = converter.ConvertX(margins.Right.MeasurementUnit, NGraphicsUnit.Inch, margins.Right.Value) * 100;
            float bottom = converter.ConvertY(margins.Bottom.MeasurementUnit, NGraphicsUnit.Inch, margins.Bottom.Value) * 100;

            pageSettings.Margins = new Margins((int)left, (int)right, (int)top, (int)bottom);

            // paper sizes
            if (PagePaperSizeComboBox.SelectedIndex != -1)
            {
                string paperName = PagePaperSizeComboBox.SelectedItem.ToString();

                for (int i = 0; i < pageSettings.PrinterSettings.PaperSizes.Count; i++)
                {
                    if (pageSettings.PrinterSettings.PaperSizes[i].PaperName == paperName)
                    {
                        pageSettings.PaperSize = pageSettings.PrinterSettings.PaperSizes[i];
                        break;
                    }
                }
            }

            // paper source
            if (PagePaperSourceComboBox.SelectedIndex != -1)
            {
                string paperSourceName = PagePaperSourceComboBox.SelectedItem.ToString();

                for (int i = 0; i < pageSettings.PrinterSettings.PaperSources.Count; i++)
                {
                    if (paperSourceName == pageSettings.PrinterSettings.PaperSources[i].SourceName)
                    {
                        pageSettings.PaperSource = pageSettings.PrinterSettings.PaperSources[i];
                        break;
                    }
                }
            }

            nChartControl1.PrintManager.PageSettings = pageSettings;

            m_Updating = false;
        }