private void AddZoomLevelClick(object sender, RoutedEventArgs e)
        {
            AddZoomLevelWindow addZoomLevelWindow = new AddZoomLevelWindow();
            ScaleSettingsRibbonGroupViewModel addZoomLevelViewModel = new ScaleSettingsRibbonGroupViewModel();

            addZoomLevelViewModel.UpdateValues();
            double currentScale = GisEditor.ActiveMap.CurrentScale * Conversion.ConvertMeasureUnits(1, DistanceUnit.Inch, addZoomLevelViewModel.SelectedDistanceUnit);

            addZoomLevelViewModel.SelectedScale = addZoomLevelViewModel.Scales.FirstOrDefault(s => Math.Abs(s.Scale - currentScale) < 1);
            addZoomLevelViewModel.Value         = addZoomLevelViewModel.SelectedScale.DisplayScale;
            addZoomLevelWindow.DataContext      = addZoomLevelViewModel;
            if (addZoomLevelWindow.ShowDialog().GetValueOrDefault())
            {
                var existedScales = viewModel.ZoomLevelSetViewModel.Select(z => z.Scale).ToList();
                if (existedScales.Any(s => Math.Round(s, 0) == Math.Round(addZoomLevelWindow.Scale, 0)))
                {
                    System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("ZoomLevelSetWindowNumberDuplicateText"), GisEditor.LanguageManager.GetStringResource("MessageBoxWarningTitle"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                }
                else
                {
                    viewModel.ZoomLevelSetViewModel.Add(new ZoomLevelViewModel(viewModel.ZoomLevelSetViewModel.Count, addZoomLevelWindow.Scale));
                    var sortedArray = viewModel.ZoomLevelSetViewModel.OrderByDescending(z => z.Scale).ToArray();
                    viewModel.ZoomLevelSetViewModel.Clear();
                    for (int i = 0; i < sortedArray.Length; i++)
                    {
                        var zoomLevelModel = sortedArray[i];
                        zoomLevelModel.ZoomLevelIndex = i;
                        viewModel.ZoomLevelSetViewModel.Add(zoomLevelModel);
                    }
                }
            }
        }
        private static void SetScale()
        {
            ScaleSettingsRibbonGroupViewModel viewModel = new ScaleSettingsRibbonGroupViewModel();
            double currentScale = GisEditor.ActiveMap.CurrentScale * Conversion.ConvertMeasureUnits(1, DistanceUnit.Inch, viewModel.SelectedDistanceUnit);

            viewModel.UpdateValues();
            viewModel.SelectedScale = viewModel.Scales.FirstOrDefault(s => Math.Abs(s.Scale - currentScale) < 1);
            viewModel.Value         = viewModel.SelectedScale.DisplayScale;

            AddZoomLevelWindow window = new AddZoomLevelWindow();

            window.Title                 = GisEditor.LanguageManager.GetStringResource("NavigateViewModelSetScaleContent");
            window.DataContext           = viewModel;
            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            window.Owner                 = System.Windows.Application.Current.MainWindow;
            if (window.ShowDialog().GetValueOrDefault())
            {
                ScaleSettingsRibbonGroupViewModel.SetNewScale(window.Scale);
            }
        }
Ejemplo n.º 3
0
        private void ZoomToPreciseScaleItem_Click(object sender, RoutedEventArgs e)
        {
            AddZoomLevelWindow window = new AddZoomLevelWindow();

            window.Title                 = GisEditor.LanguageManager.GetStringResource("ScalePluginZoomToScaleText");
            window.DataContext           = viewModel;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.Owner                 = Application.Current.MainWindow;
            if (window.ShowDialog().GetValueOrDefault())
            {
                var menuItem = sender as MenuItem;
                if (menuItem != null)
                {
                    var centerPoint = menuItem.Tag as PointShape;
                    ScaleSettingsRibbonGroupViewModel.SetNewScale(window.Scale, centerPoint);
                }
                else
                {
                    ScaleSettingsRibbonGroupViewModel.SetNewScale(window.Scale);
                }
            }
        }