|
@@ -43,7 +43,7 @@ namespace Compdfkit_Tools.Measure
|
|
|
|
|
|
public void ShowAreaAndLength(Visibility visibility)
|
|
|
{
|
|
|
- if (visibility==Visibility.Visible)
|
|
|
+ if (visibility == Visibility.Visible)
|
|
|
{
|
|
|
SettingPanel.Height = 350;
|
|
|
}
|
|
@@ -79,7 +79,11 @@ namespace Compdfkit_Tools.Measure
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- SaveMeasureSetting();
|
|
|
+ if (UpdateArgsList != null && UpdateArgsList.Count == 0)
|
|
|
+ {
|
|
|
+ SaveMeasureSetting();
|
|
|
+ }
|
|
|
+
|
|
|
if (UpdateArgsList != null && UpdateArgsList.Count > 0)
|
|
|
{
|
|
|
List<AnnotArgsType> allowTypeList = new List<AnnotArgsType>()
|
|
@@ -103,11 +107,32 @@ namespace Compdfkit_Tools.Measure
|
|
|
{
|
|
|
CPDFDistanceMeasure lineMeasure = lineAnnot.GetDistanceMeasure();
|
|
|
CPDFMeasureInfo measureInfo = lineMeasure.MeasureInfo;
|
|
|
- measureInfo.Precision = MeasureSetting.GetMeasureSavePrecision();
|
|
|
- measureInfo.RulerBase = (float)MeasureSetting.RulerBase;
|
|
|
- measureInfo.RulerBaseUnit = MeasureSetting.RulerBaseUnit;
|
|
|
- measureInfo.RulerTranslate = (float)MeasureSetting.RulerTranslate;
|
|
|
- measureInfo.RulerTranslateUnit = MeasureSetting.RulerTranslateUnit;
|
|
|
+ if (PrecisionBox.SelectedValue != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem checkItem = PrecisionBox.SelectedValue as ComboBoxItem;
|
|
|
+ if (double.TryParse(checkItem.Content.ToString(), out double precision))
|
|
|
+ {
|
|
|
+ measureInfo.Precision = GetMeasureSavePrecision(precision);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (double.TryParse(RulerBaseText.Text, out double ruleBasedata))
|
|
|
+ {
|
|
|
+ measureInfo.RulerBase = (float)ruleBasedata;
|
|
|
+ }
|
|
|
+ if (RulerBaseUnitCombo.SelectedItem != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem RulerBaseUnitcheckItem = RulerBaseUnitCombo.SelectedItem as ComboBoxItem;
|
|
|
+ measureInfo.RulerBaseUnit = RulerBaseUnitcheckItem.Content.ToString();
|
|
|
+ }
|
|
|
+ if (double.TryParse(RulerTranslateText.Text, out double ruletranBasedata))
|
|
|
+ {
|
|
|
+ measureInfo.RulerTranslate = (float)ruletranBasedata;
|
|
|
+ }
|
|
|
+ if (RulerTranslateCombo.SelectedItem != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem RulerTranslatecheckItem = RulerTranslateCombo.SelectedItem as ComboBoxItem;
|
|
|
+ measureInfo.RulerTranslateUnit = RulerTranslatecheckItem.Content.ToString();
|
|
|
+ }
|
|
|
lineMeasure.SetMeasureInfo(measureInfo);
|
|
|
lineMeasure.SetMeasureScale(
|
|
|
measureInfo.RulerBase,
|
|
@@ -135,11 +160,32 @@ namespace Compdfkit_Tools.Measure
|
|
|
{
|
|
|
CPDFPerimeterMeasure polylineMeasure = polylineAnnot.GetPerimeterMeasure();
|
|
|
CPDFMeasureInfo measureInfo = polylineMeasure.MeasureInfo;
|
|
|
- measureInfo.Precision = MeasureSetting.GetMeasureSavePrecision();
|
|
|
- measureInfo.RulerBase = (float)MeasureSetting.RulerBase;
|
|
|
- measureInfo.RulerBaseUnit = MeasureSetting.RulerBaseUnit;
|
|
|
- measureInfo.RulerTranslate = (float)MeasureSetting.RulerTranslate;
|
|
|
- measureInfo.RulerTranslateUnit = MeasureSetting.RulerTranslateUnit;
|
|
|
+ if (PrecisionBox.SelectedValue != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem checkItem = PrecisionBox.SelectedValue as ComboBoxItem;
|
|
|
+ if (double.TryParse(checkItem.Content.ToString(), out double precision))
|
|
|
+ {
|
|
|
+ measureInfo.Precision = GetMeasureSavePrecision(precision);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (double.TryParse(RulerBaseText.Text, out double ruleBasedata))
|
|
|
+ {
|
|
|
+ measureInfo.RulerBase = (float)ruleBasedata;
|
|
|
+ }
|
|
|
+ if (RulerBaseUnitCombo.SelectedItem != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem RulerBaseUnitcheckItem = RulerBaseUnitCombo.SelectedItem as ComboBoxItem;
|
|
|
+ measureInfo.RulerBaseUnit = RulerBaseUnitcheckItem.Content.ToString();
|
|
|
+ }
|
|
|
+ if (double.TryParse(RulerTranslateText.Text, out double ruletranBasedata))
|
|
|
+ {
|
|
|
+ measureInfo.RulerTranslate = (float)ruletranBasedata;
|
|
|
+ }
|
|
|
+ if (RulerTranslateCombo.SelectedItem != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem RulerTranslatecheckItem = RulerTranslateCombo.SelectedItem as ComboBoxItem;
|
|
|
+ measureInfo.RulerTranslateUnit = RulerTranslatecheckItem.Content.ToString();
|
|
|
+ }
|
|
|
polylineMeasure.SetMeasureInfo(measureInfo);
|
|
|
polylineMeasure.SetMeasureScale(
|
|
|
measureInfo.RulerBase,
|
|
@@ -167,18 +213,39 @@ namespace Compdfkit_Tools.Measure
|
|
|
{
|
|
|
CPDFAreaMeasure areaMeasure = areaAnnot.GetAreaMeasure();
|
|
|
CPDFMeasureInfo measureInfo = areaMeasure.MeasureInfo;
|
|
|
- measureInfo.Precision = MeasureSetting.GetMeasureSavePrecision();
|
|
|
- measureInfo.RulerBase = (float)MeasureSetting.RulerBase;
|
|
|
- measureInfo.RulerBaseUnit = MeasureSetting.RulerBaseUnit;
|
|
|
- measureInfo.RulerTranslate = (float)MeasureSetting.RulerTranslate;
|
|
|
- measureInfo.RulerTranslateUnit = MeasureSetting.RulerTranslateUnit;
|
|
|
+ if (PrecisionBox.SelectedValue != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem checkItem = PrecisionBox.SelectedValue as ComboBoxItem;
|
|
|
+ if (double.TryParse(checkItem.Content.ToString(), out double precision))
|
|
|
+ {
|
|
|
+ measureInfo.Precision = GetMeasureSavePrecision(precision);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (double.TryParse(RulerBaseText.Text, out double ruleBasedata))
|
|
|
+ {
|
|
|
+ measureInfo.RulerBase = (float)ruleBasedata;
|
|
|
+ }
|
|
|
+ if (RulerBaseUnitCombo.SelectedItem != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem RulerBaseUnitcheckItem = RulerBaseUnitCombo.SelectedItem as ComboBoxItem;
|
|
|
+ measureInfo.RulerBaseUnit = RulerBaseUnitcheckItem.Content.ToString();
|
|
|
+ }
|
|
|
+ if (double.TryParse(RulerTranslateText.Text, out double ruletranBasedata))
|
|
|
+ {
|
|
|
+ measureInfo.RulerTranslate = (float)ruletranBasedata;
|
|
|
+ }
|
|
|
+ if (RulerTranslateCombo.SelectedItem != null)
|
|
|
+ {
|
|
|
+ ComboBoxItem RulerTranslatecheckItem = RulerTranslateCombo.SelectedItem as ComboBoxItem;
|
|
|
+ measureInfo.RulerTranslateUnit = RulerTranslatecheckItem.Content.ToString();
|
|
|
+ }
|
|
|
|
|
|
measureInfo.CaptionType = CPDFCaptionType.CPDF_CAPTION_NONE;
|
|
|
- if (MeasureSetting.IsShowArea)
|
|
|
+ if ((bool)AreaCheckBox.IsChecked)
|
|
|
{
|
|
|
measureInfo.CaptionType |= CPDFCaptionType.CPDF_CAPTION_AREA;
|
|
|
}
|
|
|
- if (MeasureSetting.IsShowLength)
|
|
|
+ if ((bool)LengthCheckBox.IsChecked)
|
|
|
{
|
|
|
measureInfo.CaptionType |= CPDFCaptionType.CPDF_CAPTION_LENGTH;
|
|
|
}
|
|
@@ -214,6 +281,31 @@ namespace Compdfkit_Tools.Measure
|
|
|
ReturnToInfoPanel = false;
|
|
|
}
|
|
|
|
|
|
+ private int GetMeasureSavePrecision(double Precision)
|
|
|
+ {
|
|
|
+ if (Precision == 1)
|
|
|
+ {
|
|
|
+ return CPDFMeasure.PRECISION_VALUE_ZERO;
|
|
|
+ }
|
|
|
+ if (Precision == 0.1)
|
|
|
+ {
|
|
|
+ return CPDFMeasure.PRECISION_VALUE_ONE;
|
|
|
+ }
|
|
|
+ if (Precision == 0.01)
|
|
|
+ {
|
|
|
+ return CPDFMeasure.PRECISION_VALUE_TWO;
|
|
|
+ }
|
|
|
+ if (Precision == 0.001)
|
|
|
+ {
|
|
|
+ return CPDFMeasure.PRECISION_VALUE_THREE;
|
|
|
+ }
|
|
|
+ if (Precision == 0.0001)
|
|
|
+ {
|
|
|
+ return CPDFMeasure.PRECISION_VALUE_FOUR;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
|
|
|
{
|
|
|
List<Key> allowKeys = new List<Key>()
|
|
@@ -252,6 +344,10 @@ namespace Compdfkit_Tools.Measure
|
|
|
|
|
|
public void BindMeasureSetting()
|
|
|
{
|
|
|
+ if (UpdateArgsList != null && UpdateArgsList.Count>0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
RulerBaseText.Text = MeasureSetting.RulerBase.ToString();
|
|
|
RulerTranslateText.Text = MeasureSetting.RulerTranslate.ToString();
|
|
|
RulerTranslateCombo.SelectedIndex = -1;
|
|
@@ -288,6 +384,48 @@ namespace Compdfkit_Tools.Measure
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ public void BindMeasureSetting(MeasureEventArgs measureEventArgs)
|
|
|
+ {
|
|
|
+ if (measureEventArgs != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ RulerBaseText.Text = measureEventArgs.RulerBase.ToString();
|
|
|
+ RulerTranslateText.Text = measureEventArgs.RulerTranslate.ToString();
|
|
|
+ RulerTranslateCombo.SelectedIndex = -1;
|
|
|
+ RulerBaseUnitCombo.SelectedIndex = -1;
|
|
|
+ PrecisionBox.SelectedIndex = -1;
|
|
|
+ if (measureEventArgs.RulerBaseUnit == "in")
|
|
|
+ {
|
|
|
+ RulerBaseUnitCombo.SelectedIndex = 0;
|
|
|
+ }
|
|
|
+ if (measureEventArgs.RulerBaseUnit == "cm")
|
|
|
+ {
|
|
|
+ RulerBaseUnitCombo.SelectedIndex = 1;
|
|
|
+ }
|
|
|
+ if (measureEventArgs.RulerBaseUnit == "mm")
|
|
|
+ {
|
|
|
+ RulerBaseUnitCombo.SelectedIndex = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < RulerTranslateCombo.Items.Count; i++)
|
|
|
+ {
|
|
|
+ ComboBoxItem checkItem = RulerTranslateCombo.Items[i] as ComboBoxItem;
|
|
|
+ if (checkItem != null && checkItem.Content.ToString() == measureEventArgs.RulerTranslateUnit.ToString())
|
|
|
+ {
|
|
|
+ RulerTranslateCombo.SelectedIndex = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < PrecisionBox.Items.Count; i++)
|
|
|
+ {
|
|
|
+ ComboBoxItem checkItem = PrecisionBox.Items[i] as ComboBoxItem;
|
|
|
+ if (checkItem != null && checkItem.Content.ToString() == ((decimal)measureEventArgs.Precision).ToString())
|
|
|
+ {
|
|
|
+ PrecisionBox.SelectedIndex = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
private void SaveMeasureSetting()
|
|
|
{
|