コード例 #1
0
ファイル: MDILayoutControl.cs プロジェクト: esker/cardmaker
        private void btnConfigureSize_Click(object sender, EventArgs e)
        {
            const string CARD_WIDTH  = "cardWidth";
            const string CARD_HEIGHT = "cardHeight";
            var          zQuery      = new QueryPanelDialog("CardMaker Settings", 450, 250, false);

            zQuery.SetIcon(CardMakerInstance.ApplicationIcon);
            zQuery.SetMaxHeight(600);
            zQuery.AddPullDownBox("Unit of Measure", Enum.GetNames(typeof(MeasurementUnit)), (int)CardMakerSettings.PrintPageMeasurementUnit, IniSettings.PrintPageMeasurementUnit);
            zQuery.AddNumericBox("Width", 10, 0, int.MaxValue, 1, 2, CARD_WIDTH);
            zQuery.AddNumericBox("Height", 10, 0, int.MaxValue, 1, 2, CARD_HEIGHT);
            if (DialogResult.OK == zQuery.ShowDialog(this))
            {
                switch ((MeasurementUnit)zQuery.GetIndex(IniSettings.PrintPageMeasurementUnit))
                {
                case MeasurementUnit.Inch:
                    numericCardSetWidth.Value  = zQuery.GetDecimal(CARD_WIDTH) * numericCardSetDPI.Value;
                    numericCardSetHeight.Value = zQuery.GetDecimal(CARD_HEIGHT) * numericCardSetDPI.Value;
                    break;

                case MeasurementUnit.Millimeter:
                    numericCardSetWidth.Value  = (decimal)(MeasurementUtil.GetInchesFromMillimeter((double)zQuery.GetDecimal(CARD_WIDTH)) * (double)numericCardSetDPI.Value);
                    numericCardSetHeight.Value = (decimal)(MeasurementUtil.GetInchesFromMillimeter((double)zQuery.GetDecimal(CARD_HEIGHT)) * (double)numericCardSetDPI.Value);
                    break;

                case MeasurementUnit.Centimeter:
                    numericCardSetWidth.Value  = (decimal)(MeasurementUtil.GetInchesFromCentimeter((double)zQuery.GetDecimal(CARD_WIDTH)) * (double)numericCardSetDPI.Value);
                    numericCardSetHeight.Value = (decimal)(MeasurementUtil.GetInchesFromCentimeter((double)zQuery.GetDecimal(CARD_HEIGHT)) * (double)numericCardSetDPI.Value);
                    break;
                }
            }
        }