コード例 #1
0
        private XElement GetStateXElement()
        {
            XElement stateX = new XElement("state");

            stateX.SetAttributeValue("key", Proj4ProjectionParameters);
            if (viewModel.SelectedViewModel is CommonProjectionViewModel)
            {
                CommonProjectionViewModel commonProjectionViewModel = (CommonProjectionViewModel)viewModel.SelectedViewModel;
                DatumType      datumType      = commonProjectionViewModel.SelectedDatumType;
                string         selectedZone   = commonProjectionViewModel.SelectedZone;
                UnitType       unitType       = commonProjectionViewModel.SelectedUnitType;
                ProjectionType projectionType = commonProjectionViewModel.SelectedProjectionType;
                //int index1 = commonProjectionViewModel.SupportedDatumTypes.IndexOf(datumType);
                //int index2 = commonProjectionViewModel.SupportedUnits.IndexOf(commonProjectionViewModel.SelectedUnitType);
                //int index3 = (int)commonProjectionViewModel.SelectedProjectionType;
                commonProjectionViewModel.SelectedDatumType = datumType;
                int      index4 = commonProjectionViewModel.SupportedZones.IndexOf(selectedZone);
                string   value  = string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", projectionType, datumType, index4, unitType);
                XElement commonProjectionsStateX = new XElement("common", value);
                stateX.Add(commonProjectionsStateX);
            }
            else if (viewModel.SelectedViewModel is OtherProjectionViewModel)
            {
                OtherProjectionViewModel otherProjectionViewModel = (OtherProjectionViewModel)viewModel.SelectedViewModel;
                int      index1 = (int)otherProjectionViewModel.SelectedProjectionType;
                int      index2 = otherProjectionViewModel.SearchedResult.IndexOf(otherProjectionViewModel.SelectedProj4Model);
                string   value  = string.Format(CultureInfo.InvariantCulture, "{0},{1}", index1, index2);
                XElement customProjectionsStateX = new XElement("custom", value);
                stateX.Add(customProjectionsStateX);
            }

            return(stateX);
        }
コード例 #2
0
        public ProjectionWindow(string initializeProj4String, string descriptionText, string checkBoxContent)
        {
            proj4Parameters = initializeProj4String;

            InitializeComponent();
            commonProjectionViewModel = commonProjection.DataContext as CommonProjectionViewModel;
            otherProjectionViewModel  = otherProjection.DataContext as OtherProjectionViewModel;
            commonProjectionViewModel.SelectedProj4ProjectionParameters = initializeProj4String;

            viewModel   = new ProjectionSelectionViewModel(descriptionText, checkBoxContent);
            DataContext = viewModel;

            Messenger.Default.Register <bool>(this, viewModel, (result) =>
            {
                if (result)
                {
                    string proj4ProjectionParameter      = viewModel.SelectedProj4Parameter;
                    var selectedOtherProjectionViewModel = viewModel.SelectedViewModel as OtherProjectionViewModel;
                    if (selectedOtherProjectionViewModel != null && selectedOtherProjectionViewModel.SelectedProjectionType == SearchProjectionType.Custom)
                    {
                        proj4ProjectionParameter = viewModel.SelectedProj4Parameter;
                        string projectionWkt     = Proj4Projection.ConvertProj4ToPrj(proj4ProjectionParameter);
                        if (!string.IsNullOrEmpty(projectionWkt))
                        {
                            DialogResult = result;
                        }
                        else
                        {
                            System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("ProjectionSelectionWindowProj4InvalidText"), GisEditor.LanguageManager.GetStringResource("ProjectionSelectionWindowProj4InvalidCaption"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        DialogResult = result;
                    }

                    SaveProjectionWindowStateToXml();
                    if (!string.IsNullOrEmpty(proj4ProjectionParameter))
                    {
                        viewModel.SelectedProj4Parameter = proj4ProjectionParameter;
                    }
                }
                else
                {
                    DialogResult = result;
                }
            });
            Closing += (s, e) => Messenger.Default.Unregister(this);
            HelpContainer.Content = GetHelpButton();
        }
コード例 #3
0
 public OtherProjection()
 {
     InitializeComponent();
     viewModel   = new OtherProjectionViewModel();
     DataContext = viewModel;
 }