public OutputCoordinateViewModel()
        {
            ConfigCommand = new RelayCommand(OnConfigCommand);
            ExpandCommand = new RelayCommand(OnExpandCommand);
            DeleteCommand = new RelayCommand(OnDeleteCommand);
            CopyCommand   = new RelayCommand(OnCopyCommand);

            // set default CoordinateGetter
            coordinateGetter = new CoordinateGetBase();

            Mediator.Register(CoordinateConversionLibrary.Constants.AddNewOutputCoordinate, OnAddNewOutputCoordinate);
            Mediator.Register(CoordinateConversionLibrary.Constants.CopyAllCoordinateOutputs, OnCopyAllCoordinateOutputs);
            Mediator.Register(CoordinateConversionLibrary.Constants.SetCoordinateGetter, OnSetCoordinateGetter);
            Mediator.Register(CoordinateConversionLibrary.Constants.RequestOutputUpdate, OnOutputUpdate);
            Mediator.Register(CoordinateConversionLibrary.Constants.ClearOutputCoordinates, OnClearOutputs);

            //for testing without a config file, init a few sample items
            //OutputCoordinateList = new ObservableCollection<OutputCoordinateModel>();
            ////var tempProps = new Dictionary<string, string>() { { "Lat", "70.49N" }, { "Lon", "40.32W" } };
            ////var mgrsProps = new Dictionary<string, string>() { { "GZone", "17T" }, { "GSquare", "NE" }, { "Northing", "86309" }, { "Easting", "77770" } };
            //OutputCoordinateList.Add(new OutputCoordinateModel { Name = "DD", CType = CoordinateType.DD, OutputCoordinate = "70.49N 40.32W" });
            //OutputCoordinateList.Add(new OutputCoordinateModel { Name = "DMS", CType = CoordinateType.DMS, OutputCoordinate = "40°26'46\"N,79°58'56\"W", Format = "A0°B0'C0\"N X0°Y0'Z0\"E" });
            //OutputCoordinateList.Add(new OutputCoordinateModel { Name = "MGRS", CType = CoordinateType.MGRS, OutputCoordinate = @"", Format = "Z S X00000 Y00000" });
            //OutputCoordinateList.Add(new OutputCoordinateModel { Name = "UTM", CType = CoordinateType.UTM, OutputCoordinate = @"", Format = "Z#B X0 Y0" });
            //OutputCoordinateList.Add(new OutputCoordinateModel { Name = "GARS", CType = CoordinateType.GARS, OutputCoordinate = @"", Format = "X#YQK" });
            //OutputCoordinateList.Add(new OutputCoordinateModel { Name = "USNG", CType = CoordinateType.USNG, OutputCoordinate = @"", Format = "Z S X0 Y0" });
            //OutputCoordinateList.Add(new OutputCoordinateModel { Name = "DDM", CType = CoordinateType.DDM, OutputCoordinate = @"", Format = "A0 B0.0### N X0 Y0.0### E" });

            //DefaultFormatList = new ObservableCollection<DefaultFormatModel>();

            //DefaultFormatList.Add(new DefaultFormatModel { CType = CoordinateType.DD, DefaultNameFormatDictionary = new SerializableDictionary<string, string> { { "70.49N 40.32W", "Y0.0#N X0.0#E" }, { "70.49N,40.32W", "Y0.0#N,X0.0#E" } } });

            configObserver = new PropertyObserver <CoordinateConversionLibraryConfig>(CoordinateConversionLibraryConfig.AddInConfig)
                             .RegisterHandler(n => n.OutputCoordinateList, n => RaisePropertyChanged(() => OutputCoordinateList));
        }
コード例 #2
0
        public CoordinateToolViewModel()
        {
            OCView = new OutputCoordinateView();

            // set default CoordinateGetter
            coordinateGetter = new CoordinateGetBase();

            Mediator.Register(CoordinateToolLibrary.Constants.RequestOutputUpdate, OnUpdateOutputs);
            Mediator.Register(CoordinateToolLibrary.Constants.SelectSpatialReference, OnSelectSpatialReference);
        }
 private void OnSetCoordinateGetter(object obj)
 {
     coordinateGetter = obj as CoordinateGetBase;
 }
コード例 #4
0
        public Dictionary <string, string> GetOutputFormats(AddInPoint input)
        {
            var    results = new Dictionary <string, string>();
            IPoint point;
            var    inputText = input.Point.Y + " " + input.Point.X;
            var    ctype     = GetCoordinateType(inputText, out point);

            if (point != null)
            {
                ArcMapCoordinateGet arcMapCoordinateGetter = new ArcMapCoordinateGet();
                arcMapCoordinateGetter.Point = point;
                CoordinateGetBase coordinateGetter = arcMapCoordinateGetter as CoordinateGetBase;
                results.Add(CoordinateFieldName, input.Text);
                CoordinateBase.IsOutputInProcess = true;
                foreach (var output in CoordinateConversionLibraryConfig.AddInConfig.OutputCoordinateList)
                {
                    var    props = new Dictionary <string, string>();
                    string coord = string.Empty;

                    switch (output.CType)
                    {
                    case CoordinateType.DD:
                        CoordinateDD cdd;
                        if (coordinateGetter.CanGetDD(output.SRFactoryCode, out coord) &&
                            CoordinateDD.TryParse(coord, out cdd, true))
                        {
                            results.Add(output.Name, cdd.ToString(output.Format, new CoordinateDDFormatter()));
                        }
                        break;

                    case CoordinateType.DMS:
                        CoordinateDMS cdms;
                        if (coordinateGetter.CanGetDMS(output.SRFactoryCode, out coord) &&
                            CoordinateDMS.TryParse(coord, out cdms, true))
                        {
                            results.Add(output.Name, cdms.ToString(output.Format, new CoordinateDMSFormatter()));
                        }
                        break;

                    case CoordinateType.DDM:
                        CoordinateDDM ddm;
                        if (coordinateGetter.CanGetDDM(output.SRFactoryCode, out coord) &&
                            CoordinateDDM.TryParse(coord, out ddm, true))
                        {
                            results.Add(output.Name, ddm.ToString(output.Format, new CoordinateDDMFormatter()));
                        }
                        break;

                    case CoordinateType.GARS:
                        CoordinateGARS gars;
                        if (coordinateGetter.CanGetGARS(output.SRFactoryCode, out coord) &&
                            CoordinateGARS.TryParse(coord, out gars))
                        {
                            results.Add(output.Name, gars.ToString(output.Format, new CoordinateGARSFormatter()));
                        }
                        break;

                    case CoordinateType.MGRS:
                        CoordinateMGRS mgrs;
                        if (coordinateGetter.CanGetMGRS(output.SRFactoryCode, out coord) &&
                            CoordinateMGRS.TryParse(coord, out mgrs))
                        {
                            results.Add(output.Name, mgrs.ToString(output.Format, new CoordinateMGRSFormatter()));
                        }
                        break;

                    case CoordinateType.USNG:
                        CoordinateUSNG usng;
                        if (coordinateGetter.CanGetUSNG(output.SRFactoryCode, out coord) &&
                            CoordinateUSNG.TryParse(coord, out usng))
                        {
                            results.Add(output.Name, usng.ToString(output.Format, new CoordinateMGRSFormatter()));
                        }
                        break;

                    case CoordinateType.UTM:
                        CoordinateUTM utm;
                        if (coordinateGetter.CanGetUTM(output.SRFactoryCode, out coord) &&
                            CoordinateUTM.TryParse(coord, out utm))
                        {
                            results.Add(output.Name, utm.ToString(output.Format, new CoordinateUTMFormatter()));
                        }
                        break;

                    default:
                        break;
                    }
                }
                CoordinateBase.IsOutputInProcess = false;
            }
            return(results);
        }
コード例 #5
0
 public void SetCoordinateGetter(CoordinateGetBase coordGetter)
 {
     coordinateGetter = coordGetter;
 }