Ejemplo n.º 1
0
 public string GetEnumDescription(CoordinateType coordinateType)
 {
     return(coordinateType
            .GetType()
            .GetMember(coordinateType.ToString())
            .FirstOrDefault()
            ?.GetCustomAttribute <DescriptionAttribute>()
            ?.Description
            ?? coordinateType.ToString());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new Coordinate object
        /// </summary>
        /// <param name="degrees">The degrees in the coordinate</param>
        /// <param name="minutes">The minutes in the coordinate</param>
        /// <param name="seconds">The seconds in the coordinate</param>
        /// <param name="type">The coordinate type</param>
        protected Coordinate(int degrees, int minutes, int seconds, CoordinateType type)
        {
            if (minutes >= 60 || minutes < 0)
            {
                throw new ArgumentOutOfRangeException("minutes", "Minutes must be less than 60 and cannot be negative.");
            }

            if (seconds >= 60 || seconds < 0)
            {
                throw new ArgumentOutOfRangeException("seconds", "Seconds must be less than 60 and cannot be negative.");
            }

            switch (type)
            {
            case CoordinateType.LATITUDE:
            {
                if ((degrees > 90 || degrees < -90) ||
                    ((degrees == 90 || degrees == -90) && minutes != 0 && seconds != 0))
                {
                    throw new ArgumentOutOfRangeException("A latitude must be between -90 and 90 degrees");
                }

                this.MaxDegrees = 90;
                this.MinDegrees = -90;

                break;
            }

            case CoordinateType.LONGITUDE:
            {
                if ((degrees > 180 || degrees < -180) ||
                    ((degrees == 180 || degrees == -180) && minutes != 0 && seconds != 0))
                {
                    throw new ArgumentOutOfRangeException("A longitude must be between -180 and 180 degrees");
                }

                this.MaxDegrees = 180;
                this.MinDegrees = -180;

                break;
            }

            default:
            {
                throw new ArgumentException($"The type {type.ToString()} is unknown.");
            }
            }

            this.Degrees        = degrees;
            this.Minutes        = minutes;
            this.Seconds        = seconds;
            this.Type           = type;
            this.DecimalDegrees = this.Degrees + (this.Minutes / 60) + (this.Seconds / 3600);
        }
Ejemplo n.º 3
0
 private void SelectCategory(CoordinateType coordinateType)
 {
     foreach (var item in CategoryList)
     {
         if (item == coordinateType.ToString())
         {
             CategorySelection = item;
             RaisePropertyChanged(() => CategorySelection);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 开始从局部坐标到全局坐标的转换
        /// </summary>
        /// <param name="ct">参考坐标系</param>
        public void Generate(CoordinateType ct)
        {
            CoordPara = ct.ToString().ToLower();

            if (null == Skeleton || null == Motion)
            {
                return;
            }

            for (int indpos = 0; indpos < Motion.Postures.Count; ++indpos)
            {
                Motion.Posture motpos = Motion.Postures[indpos];
                Posture        anipos = new Posture();
                anipos.Index = motpos.Index;
                TransformBone("root", motpos, anipos);
                Postures.Add(anipos);
            }
        }
        public CoordinateFormattingOptions(CoordinateType coordType, string formatOption)
        {
            InitializeComponent();
            FormatSpecifier = formatOption;
            this.CoordinateType = coordType;

            if (formatOption.Equals(SupportService.COORD_FORMAT_DECIMAL_DEGREES)) {
                optDecDeg.IsChecked = true;
            } else if (formatOption.Equals(SupportService.COORD_FORMAT_DEGREES_DECIMAL_MINUTES)) {
                optDegDecM.IsChecked = true;
            } else {
                optDMS.IsChecked = true;
            }

            this.Title = string.Format("Format {0} options", coordType.ToString());

            UpdatePreview();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new Coordinate object
        /// </summary>
        /// <param name="decimalDegrees">The decimal degrees representation of the coordinate</param>
        /// <param name="type">The coordinate type</param>
        protected Coordinate(double decimalDegrees, CoordinateType type)
        {
            this.DecimalDegrees = decimalDegrees;
            this.Type           = type;

            switch (this.Type)
            {
            case CoordinateType.LATITUDE:
            {
                if (this.DecimalDegrees > 90 || this.DecimalDegrees < -90)
                {
                    throw new ArgumentOutOfRangeException("decimalDegrees", "The decimal degrees cannot be greather than 90 or less than -90.");
                }

                this.MaxDegrees = 90;
                this.MinDegrees = -90;

                break;
            }

            case CoordinateType.LONGITUDE:
            {
                if (this.DecimalDegrees > 180 || this.DecimalDegrees < -180)
                {
                    throw new ArgumentOutOfRangeException("decimalDegrees", "The decimal degrees cannot be greather than 180 or less than -180.");
                }

                this.MaxDegrees = 180;
                this.MinDegrees = -180;

                break;
            }

            default:
            {
                throw new ArgumentException($"The type {type.ToString()} is unknown.");
            }
            }

            this.Degrees = (int)Math.Floor(this.DecimalDegrees);
            this.Minutes = (int)Math.Floor(60 * (this.DecimalDegrees - this.Degrees));
            this.Seconds = (int)((3600 * (this.DecimalDegrees - this.Degrees)) - (60 * this.Minutes));
        }
        public CoordinateFormattingOptions(CoordinateType coordType, string formatOption)
        {
            InitializeComponent();
            FormatSpecifier     = formatOption;
            this.CoordinateType = coordType;

            if (formatOption.Equals(SupportService.COORD_FORMAT_DECIMAL_DEGREES))
            {
                optDecDeg.IsChecked = true;
            }
            else if (formatOption.Equals(SupportService.COORD_FORMAT_DEGREES_DECIMAL_MINUTES))
            {
                optDegDecM.IsChecked = true;
            }
            else
            {
                optDMS.IsChecked = true;
            }

            this.Title = string.Format("Format {0} options", coordType.ToString());

            UpdatePreview();
        }
 private void SelectCategory(CoordinateType coordinateType)
 {
     foreach(var item in CategoryList)
     {
         if(item == coordinateType.ToString())
         {
             CategorySelection = item;
             RaisePropertyChanged(() => CategorySelection);
         }
     }
 }