protected virtual void OnBoundingBoxSelectCompletedClick(BoundingBoxSelectCompletedEventArgs e)
        {
            EventHandler <BoundingBoxSelectCompletedEventArgs> handler = BoundingBoxSelectCompletedClick;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            CurrentMap.Cursor = cursor;
            IsEnabled         = false;
            resultBoundingBox = null;

            CurrentMap.SizeChanged -= CurrentMap_SizeChanged;

            BoundingBoxSelectCompletedEventArgs args = new BoundingBoxSelectCompletedEventArgs(true);

            OnBoundingBoxSelectCompletedClick(args);
        }
        private void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            CurrentMap.Cursor = cursor;
            IsEnabled         = false;
            double     screenLeft      = Margin.Left;
            double     screenTop       = Margin.Top;
            PointShape upperLeftPoint  = CurrentMap.ToWorldCoordinate(screenLeft, screenTop);
            PointShape lowerRightPoint = CurrentMap.ToWorldCoordinate(screenLeft + Width, screenTop + Height);

            resultBoundingBox = new RectangleShape(upperLeftPoint, lowerRightPoint);

            BoundingBoxSelectCompletedEventArgs args = new BoundingBoxSelectCompletedEventArgs(resultBoundingBox);

            if (!preserveSizeRatio)
            {
                double scale = -1;
                if (!string.IsNullOrEmpty(scaleComboBox.Text) && scaleComboBox.SelectedValue != null)
                {
                    ScaleWrapper scaleWrapper = scaleComboBox.SelectedValue as ScaleWrapper;
                    if (scaleWrapper.DisplayScale.ToString() == scaleComboBox.Text)
                    {
                        scale = scaleWrapper.Scale;
                    }
                    else
                    {
                        double.TryParse(scaleComboBox.Text, out scale);
                    }
                }

                if (scale > 0)
                {
                    DistanceUnit unit = ((Tuple <DistanceUnit, string>)unitComboBox.SelectedItem).Item1;
                    scale = Conversion.ConvertMeasureUnits(scale, unit, DistanceUnit.Inch);
                    args  = new BoundingBoxSelectCompletedEventArgs(resultBoundingBox, scale);
                }
            }

            CurrentMap.SizeChanged -= CurrentMap_SizeChanged;

            args.ImageBytes = GetCroppedMapPreviewImage(CurrentMap, new Int32Rect((int)Margin.Left, (int)Margin.Top, (int)Width, (int)Height));
            OnBoundingBoxSelectCompletedClick(args);
        }