Esempio n. 1
0
        private void OnAreaChanged(object sender, EventArgs e)
        {
            var ext = MapExtents;

            var units = _context.Map.MapUnits;

            lblArea.Text = string.Format("{0} × {1}", UnitsHelper.FormatDistance(units, ext.MaxX - ext.MinX),
                                         UnitsHelper.FormatDistance(units, ext.MaxY - ext.MinY));
        }
Esempio n. 2
0
        public float ToPoint(float unit)
        {
            switch (ResultType)
            {
            case UnitType.Centimeter: return(UnitsHelper.CentimeterToPoint(unit));

            case UnitType.Millimeter: return(UnitsHelper.MmToPt(unit));

            case UnitType.Point: return(unit);

            default: throw new Exception("Unit not reconized " + ResultType.ToString());
            }
        }
Esempio n. 3
0
        public float FromPoint(float pt)
        {
            switch (ResultType)
            {
            case UnitType.Centimeter: return(UnitsHelper.PointToCentimeter(pt));

            case UnitType.Millimeter: return(UnitsHelper.PointToMillimeter(pt));

            case UnitType.Point: return(pt);

            default: throw new Exception("Unit not reconized " + ResultType.ToString());
            }
        }
Esempio n. 4
0
        private void GeometryService_ProjectCompleted(object sender, GraphicsEventArgs e)
        {
            ScaleLine.ScaleLineUnit units = UnitsHelper.GetUnitsByWKID(widgetConfig.ProjectToWKID);

            switch (this.measurementMode)
            {
            case MODE_LENGTH:
                geometryService.LengthsAsync(e.Results, units);
                break;

            case MODE_AREA:
                geometryService.AreasAndLengthsAsync(e.Results, units);
                break;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Runs the tool.
        /// </summary>
        public override bool Run(ITaskHandle task)
        {
            var  fs      = Input.Datasource;
            bool editing = fs.EditingTable;

            if (!editing)
            {
                fs.StartEditingTable();
            }

            bool result = false;

            try
            {
                if (!fs.Fields.Exists(FieldName))
                {
                    fs.Fields.Add(new AttributeField()
                    {
                        Name  = FieldName,
                        Type  = AttributeType.Double,
                        Alias = FieldName + ", " + UnitsHelper.GetAbbreviatedName(Units)
                    });
                }

                result = Calcualte(task);
            }
            catch (Exception ex)
            {
                if (!editing)
                {
                    fs.StopEditingTable(false);
                }

                throw;
            }

            if (!editing)
            {
                fs.StopEditingTable();
            }

            return(result);
        }
Esempio n. 6
0
        public MapData(JSONConfiguration config)
        {
            this.ShowConvoyLink = (config.Convoy != null);
            this.ShowShopLink   = (config.Shop != null);

            //Process data, order is important on these
            this.System = new SystemInfo(config.System);
            this.Map    = new MapObj(config.Map, this.System.TerrainTypes, this.System.TerrainEffects);

            this.Units = UnitsHelper.Process(config.Units, this.System, this.Map);

            //Calculate unit ranges
            RangeHelper rangeHelper = new RangeHelper(this.Units, this.Map);

            rangeHelper.CalculateUnitRanges();

            //Clean up
            this.System.RemoveUnusedObjects();
        }
Esempio n. 7
0
        private void ShowMeasurementResult(bool showLabel, ScaleLine.ScaleLineUnit outUnits)
        {
            showLabel = showLabel && CheckResultOnMap.IsChecked.Value;
            if (outUnits != ScaleLine.ScaleLineUnit.Undefined)
            {
                resultUnits = outUnits;
            }

            if (measurementMode == MODE_LENGTH && geometryService.LengthsLastResult != null)
            {
                // Length in meters
                double length = geometryService.LengthsLastResult[0] * UnitsHelper.GetConversionToMeter(resultUnits);

                // Length in selected units
                MeasurementUnits lenUnits = (ListLengthUnits.SelectedItem as ComboBoxItem).Tag as MeasurementUnits;
                TextLengthResult.Text = string.Format("{0}", Math.Round(length * lenUnits.Conversion, 3));

                if (showLabel && this.GraphicsLayer.Graphics.Count > 0)
                {
                    int k = this.GraphicsLayer.Graphics.Count - 1;
                    ESRI.ArcGIS.Client.Geometry.Geometry geometry = this.GraphicsLayer.Graphics[k].Geometry;
                    string  label      = string.Format("Length: {0} {1}", TextLengthResult.Text, lenUnits.Abbreviation);
                    Graphic lblGraphic = new Graphic()
                    {
                        Geometry = geometry.Extent.GetCenter(), Symbol = new TextSymbol()
                        {
                            Text = label, OffsetX = 30, OffsetY = 15, FontSize = 12.0, FontFamily = new FontFamily("Arial Black"), Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0xFF))
                        }
                    };
                    AddGraphic(lblGraphic);
                }
            }
            else if (measurementMode == MODE_AREA && geometryService.AreasAndLengthsLastResult != null)
            {
                // Length in meters
                double length = geometryService.AreasAndLengthsLastResult.Lengths[0] * UnitsHelper.GetConversionToMeter(resultUnits);
                // Area in square meters
                double area = Math.Abs(geometryService.AreasAndLengthsLastResult.Areas[0]) * Math.Pow(UnitsHelper.GetConversionToMeter(resultUnits), 2);

                // Length in selected units
                MeasurementUnits lenUnits = (ListLengthUnits.SelectedItem as ComboBoxItem).Tag as MeasurementUnits;
                TextLengthResult.Text = string.Format("{0}", Math.Round(length * lenUnits.Conversion, 3));

                // Area in selected units
                MeasurementUnits areaUnits = (ListAreaUnits.SelectedItem as ComboBoxItem).Tag as MeasurementUnits;
                TextAreaResult.Text = string.Format("{0}", Math.Round(area * areaUnits.Conversion, 3));

                if (showLabel && this.GraphicsLayer.Graphics.Count > 0)
                {
                    int k = this.GraphicsLayer.Graphics.Count - 1;
                    ESRI.ArcGIS.Client.Geometry.Geometry geometry = this.GraphicsLayer.Graphics[k].Geometry;
                    string  label      = string.Format("Parimeter: {0} {1}\nArea: {2} {3}", TextLengthResult.Text, lenUnits.Abbreviation, TextAreaResult.Text, areaUnits.Abbreviation);
                    Graphic lblGraphic = new Graphic()
                    {
                        Geometry = geometry.Extent.GetCenter(), Symbol = new TextSymbol()
                        {
                            Text = label, OffsetX = 50, OffsetY = 15, FontSize = 12.0, FontFamily = new FontFamily("Arial Black"), Foreground = new SolidColorBrush(Color.FromArgb(0xFF, 0x00, 0x00, 0x99))
                        }
                    };
                    AddGraphic(lblGraphic);
                }
            }

            this.IsBusy = false;
        }