Ejemplo n.º 1
0
        private void ProccessMilitaryMessages(TimeExtent timeExtent)
        {
            // get a list of military messages that intersect this time extent
            var militaryMessages = _mission.MilitaryMessages.Where(m => m.VisibleTimeExtent.Intersects(timeExtent)).ToList();
            var phaseID          = _mission.PhaseList[CurrentPhaseIndex].ID;

            foreach (var mm in militaryMessages)
            {
                if (mm.ContainsKey(MilitaryMessage.ControlPointsPropertyName))
                {
                    // load the correct control points for the current phase
                    if (mm.PhaseControlPointsDictionary.ContainsKey(phaseID))
                    {
                        mm[MilitaryMessage.ControlPointsPropertyName] = mm.PhaseControlPointsDictionary[phaseID];
                    }
                    else
                    {
                        Console.WriteLine(@"ERROR : Control points not found for phase id {0}", phaseID);
                    }
                }

                if (mm.ContainsKey(MilitaryMessage.ActionPropertyName))
                {
                    mm[MilitaryMessage.ActionPropertyName] = Constants.MSG_ACTION_UPDATE;
                }

                if (ProcessMessage(_militaryMessageLayer, mm))
                {
                    Mediator.NotifyColleagues(Constants.ACTION_ITEM_WITH_GUID_ADDED, mm.Id);
                }
            }

            DoCloneMission(null);
        }
Ejemplo n.º 2
0
        private TimeExtent Convert(string timeExtentString)
        {
            if (string.IsNullOrEmpty(timeExtentString))
            {
                return(null);
            }

            TimeExtent timeExtent      = null;
            var        timeExtentParts = timeExtentString.Split(new string[] { " - " }, StringSplitOptions.RemoveEmptyEntries);

            if (timeExtentParts.Length == 0 || timeExtentParts.Length > 2)
            {
                return(null);
            }

            DateTimeOffset startTime;

            if (!DateTimeOffset.TryParse(timeExtentParts[0], out startTime))
            {
                return(null);
            }

            DateTimeOffset endTime;

            if (timeExtentParts.Length == 2 && DateTimeOffset.TryParse(timeExtentParts[1], out endTime))
            {
                timeExtent = new TimeExtent(startTime, endTime);
            }
            else
            {
                timeExtent = new TimeExtent(startTime);
            }

            return(timeExtent);
        }
        private void ArcGISDynamicMapServiceLayer_Initialized(object sender, System.EventArgs e)
        {
            TimeExtent extent = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MaximumValue);
            MyTimeSlider.Intervals = TimeSlider.CreateTimeStopsByTimeInterval(extent, TimeSpan.FromDays(500));

            MyTimeSlider.Value = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MinimumValue.AddYears(10));
        }
Ejemplo n.º 4
0
        private async void OnLoadedPopulateData(object sender, LoadStatusEventArgs e)
        {
            // If layer isn't loaded, do nothing
            if (e.Status != LoadStatus.Loaded)
            {
                return;
            }

            // Create new query object that contains a basic 'include everything' clause
            QueryParameters queryParameters = new QueryParameters()
            {
                WhereClause = "1=1"
            };

            // Create a new time extent that covers the desired interval (beginning of time to September 16th, 2000)
            TimeExtent myExtent = new TimeExtent(new DateTime(1, 1, 1), new DateTime(2000, 9, 16));

            // Apply the time extent to the query parameters
            queryParameters.TimeExtent = myExtent;

            // Create list of the fields that are returned from the service
            string[] outputFields = { "*" };

            try
            {
                // Populate feature table with the data based on query
                await _myFeatureTable.PopulateFromServiceAsync(queryParameters, true, outputFields);
            }
            catch (Exception ex)
            {
                await((Page)Parent).DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
        private void ArcGISDynamicMapServiceLayer_Initialized(object sender, System.EventArgs e)
        {
            TimeExtent extent = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MaximumValue);

            MyTimeSlider.Intervals = TimeSlider.CreateTimeStopsByTimeInterval(extent, TimeSpan.FromDays(500));

            MyTimeSlider.Value = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MinimumValue.AddYears(10));
        }
        /// <summary>
        /// Merges two TimeExtents together to create one TimeExtent that will encompass both input extents
        /// </summary>
        /// <param name="timeExtent">The first extent to union</param>
        /// <param name="otherTimeExtent">The second extent to union</param>
        /// <returns>A TimeExtent instance with a start time that is the minimum of the that of the two input extents
        /// and an end time that is the maximum of that of the two input extents</returns>
        public static TimeExtent Union(this TimeExtent timeExtent, TimeExtent otherTimeExtent)
        {
            if (otherTimeExtent == null)
            {
                return(timeExtent);
            }

            var startTime = timeExtent.StartTime < otherTimeExtent.StartTime ? timeExtent.StartTime : otherTimeExtent.StartTime;
            var endTime   = timeExtent.EndTime > otherTimeExtent.EndTime ? timeExtent.EndTime : otherTimeExtent.EndTime;

            return(startTime == endTime ? new TimeExtent(startTime) : new TimeExtent(startTime, endTime));
        }
Ejemplo n.º 7
0
        private async void Initialize()
        {
            // Create new Map
            Map myMap = new Map(Basemap.CreateOceans());

            // Create the hurricanes feature layer once
            FeatureLayer noOffsetLayer = new FeatureLayer(_featureLayerUri);

            // Apply a blue dot renderer to distinguish hurricanes without offsets
            SimpleMarkerSymbol blueDot = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Blue, 10);

            noOffsetLayer.Renderer = new SimpleRenderer(blueDot);

            // Add the non-offset layer to the map
            myMap.OperationalLayers.Add(noOffsetLayer);

            // Create the offset hurricanes feature layer
            FeatureLayer withOffsetLayer = new FeatureLayer(_featureLayerUri);

            // Apply a red dot renderer to distinguish these hurricanes from the non-offset hurricanes
            SimpleMarkerSymbol redDot = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 10);

            withOffsetLayer.Renderer = new SimpleRenderer(redDot);

            // Apply the time offset (red hurricane dots will be from 10 days before the current extent)
            withOffsetLayer.TimeOffset = new TimeValue(10, Esri.ArcGISRuntime.ArcGISServices.TimeUnit.Days);

            // Add the layer to the map
            myMap.OperationalLayers.Add(withOffsetLayer);

            // Apply the Map to the MapView
            MyMapView.Map = myMap;

            try
            {
                // Ensure the no offset layer is loaded
                await noOffsetLayer.LoadAsync();

                // Store a reference to the original time extent
                _originalExtent = noOffsetLayer.FullTimeExtent;

                // Update the time extent set on the map
                UpdateTimeExtent();

                // Enable the slider
                TimeSlider.IsEnabled = true;
            }
            catch (Exception e)
            {
                await new MessageDialog(e.ToString(), "Error").ShowAsync();
            }
        }
Ejemplo n.º 8
0
        private async void Initialize()
        {
            // Create new Map with oceans basemap.
            Map myMap = new Map(Basemap.CreateOceans());

            // Create the hurricanes feature layer once.
            FeatureLayer noOffsetLayer = new FeatureLayer(_featureLayerUri);

            // Apply a blue dot renderer to distinguish hurricanes without offsets.
            SimpleMarkerSymbol blueDot = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Blue, 10);

            noOffsetLayer.Renderer = new SimpleRenderer(blueDot);

            // Add the non-offset layer to the map.
            myMap.OperationalLayers.Add(noOffsetLayer);

            // Create the offset hurricanes feature layer.
            FeatureLayer withOffsetLayer = new FeatureLayer(_featureLayerUri);

            // Apply a red dot renderer to distinguish these hurricanes from the non-offset hurricanes.
            SimpleMarkerSymbol redDot = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 10);

            withOffsetLayer.Renderer = new SimpleRenderer(redDot);

            // Apply the time offset (red hurricane dots will be from 10 days before the current extent).
            withOffsetLayer.TimeOffset = new TimeValue(10, Esri.ArcGISRuntime.ArcGISServices.TimeUnit.Days);

            // Add the layer to the map.
            myMap.OperationalLayers.Add(withOffsetLayer);

            // Apply the Map to the MapView.
            _myMapView.Map = myMap;

            try
            {
                // Ensure the no offset layer is loaded.
                await noOffsetLayer.LoadAsync();

                // Store a reference to the original time extent.
                _originalExtent = noOffsetLayer.FullTimeExtent;

                // Update the time extent set on the map.
                UpdateTimeExtent();

                // Listen for slider changes.
                _timeSlider.ValueChanged += TimeSlider_ValueChanged;
            }
            catch (Exception e)
            {
                new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show();
            }
        }
Ejemplo n.º 9
0
        private async void Initialize()
        {
            // Create new Map
            Map myMap = new Map(BasemapStyle.ArcGISOceans);

            // Create the hurricanes feature layer once
            FeatureLayer noOffsetLayer = new FeatureLayer(_featureLayerUri);

            // Apply a blue dot renderer to distinguish hurricanes without offsets
            SimpleMarkerSymbol blueDot = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Blue, 10);

            noOffsetLayer.Renderer = new SimpleRenderer(blueDot);

            // Add the non-offset layer to the map
            myMap.OperationalLayers.Add(noOffsetLayer);

            // Create the offset hurricanes feature layer
            FeatureLayer withOffsetLayer = new FeatureLayer(_featureLayerUri);

            // Center the Viewpoint on the FeatureLayer once the feature layer has loaded.
            withOffsetLayer.Loaded += (s, e) => { _myMapView.SetViewpointGeometryAsync(withOffsetLayer.FullExtent, 50); };

            // Apply a red dot renderer to distinguish these hurricanes from the non-offset hurricanes
            SimpleMarkerSymbol redDot = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, System.Drawing.Color.Red, 10);

            withOffsetLayer.Renderer = new SimpleRenderer(redDot);

            // Apply the time offset (red hurricane dots will be from 10 days before the current extent)
            withOffsetLayer.TimeOffset = new TimeValue(10, Esri.ArcGISRuntime.ArcGISServices.TimeUnit.Days);

            // Add the layer to the map
            myMap.OperationalLayers.Add(withOffsetLayer);

            // Apply the Map to the MapView
            _myMapView.Map = myMap;

            try
            {
                // Ensure the no offset layer is loaded
                await noOffsetLayer.LoadAsync();

                // Store a reference to the original time extent
                _originalExtent = noOffsetLayer.FullTimeExtent;

                // Update the time extent set on the map
                UpdateTimeExtent();
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            double     listWidth         = (double)values[0];
            TimeExtent messageTimeExtent = (TimeExtent)values[1];
            TimeExtent missionTimeExtent = (TimeExtent)values[2];

            TimeSpan ts  = messageTimeExtent.End.Subtract(messageTimeExtent.Start);
            TimeSpan mts = missionTimeExtent.End.Subtract(missionTimeExtent.Start);

            var widthFactor = ts.TotalSeconds / mts.TotalSeconds;
            var width       = listWidth * widthFactor;

            return(Math.Max(0.0, width - 12));
        }
Ejemplo n.º 11
0
        private string Convert(TimeExtent timeExtent)
        {
            if (timeExtent == null)
            {
                return(null);
            }

            if (timeExtent.StartTime == timeExtent.EndTime)
            {
                return(timeExtent.StartTime.ToString());
            }
            else
            {
                return($"{timeExtent.StartTime.ToString()} - {timeExtent.EndTime.ToString()}");
            }
        }
        /// <summary>
        /// Initialize the TimeExtent Filter Slider
        /// </summary>
        /// <param name="lyrTimeExtent">Feature Layer Time Extent</param>
        private void InitializeTimeSlider(TimeExtent lyrTimeExtent)
        {
            if (widgetConfig.UseTimeInfo)
            {
                timeExtentSlider.MinimumValue = lyrTimeExtent.Start;
                timeExtentSlider.MaximumValue = lyrTimeExtent.End;

                List <DateTime> intervals = new List <DateTime>();
                DateTime        delta     = lyrTimeExtent.Start;

                while (delta < lyrTimeExtent.End)
                {
                    intervals.Add(delta);
                    delta = delta.AddMonths(widgetConfig.TimeInterval);
                }

                intervals.Add(lyrTimeExtent.End);
                timeExtentSlider.Intervals = intervals;

                if (!string.IsNullOrEmpty(widgetConfig.InitInterval))
                {
                    if (widgetConfig.InitInterval.Equals("Last", StringComparison.CurrentCultureIgnoreCase))
                    {
                        timeExtentSlider.Value = new TimeExtent(intervals[intervals.Count - 2], intervals.Last());
                    }
                    else if (widgetConfig.InitInterval.Equals("First", StringComparison.CurrentCultureIgnoreCase))
                    {
                        timeExtentSlider.Value = new TimeExtent(intervals[0], intervals[1]);
                    }
                }
            }
            else
            {
                borderTimeSlider.Visibility = Visibility.Collapsed;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TimeExtentChangedEventArgs"/> class.
 /// </summary>
 /// <param name="newExtent">The new <see cref="TimeExtent"/> value.</param>
 /// <param name="oldExtent">The old <see cref="TimeExtent"/> value.</param>
 internal TimeExtentChangedEventArgs(TimeExtent newExtent, TimeExtent oldExtent)
 {
     NewExtent = newExtent;
     OldExtent = oldExtent;
 }
 public TimeAwareMilitaryMessage(TimeExtent timeExtent)
 {
     VisibleTimeExtent = new TimeExtent(timeExtent.Start, timeExtent.End);
 }
Ejemplo n.º 15
0
		private TimeExtent Snap(TimeExtent extent, bool preserveSpan)
		{
			if (extent == null) return null;
			if (Intervals != null && Intervals.GetEnumerator().MoveNext())
			{				
				DateTime start = (extent.Start < MinimumValue ? MinimumValue : extent.Start);
				DateTime end = (extent.End > MaximumValue ? MaximumValue : extent.End);
				start = (start > end ? end : start);
				end = (end < start ? start : end);
				TimeExtent result = new TimeExtent(start, end);
				
				//snap min thumb.								
				long d0 = long.MaxValue;
				foreach (DateTime d in Intervals)
				{
					long delta = Math.Abs((d - start).Ticks);
					if (delta < d0)
					{
						if (TimeMode == TimeMode.CumulativeFromStart || TimeMode == TimeMode.TimeInstant || (TimeMode == TimeMode.TimeExtent && d < end))
						{
							d0 = delta;
							result.Start = d;
						}
					}
				}				

				if (preserveSpan)
				{
					//check interval difference between min and max.
					int intervalDifference = 0;
					bool count = false;
					if (TimeMode == TimeMode.TimeExtent)
					{
						foreach (DateTime d in Intervals)
						{
							count = (d >= ValidValue.Start && d < ValidValue.End) ? true : false;
							if (count) intervalDifference++;
						}
					}

					//snap max thumb.
					long d1 = long.MaxValue;
					count = false;
					int diff = 0;
					foreach (DateTime d in Intervals)
					{
						long delta = Math.Abs((d - end).Ticks);
						if (delta < d1)
						{
							if (TimeMode == TimeMode.CumulativeFromStart || TimeMode == TimeMode.TimeInstant || (TimeMode == TimeMode.TimeExtent && d > result.Start))
							{
								if (intervalDifference != 0)
								{
									count = (d >= result.Start) ? true : false;
									if (count) diff++;
									if (diff == intervalDifference)
									{
										result.End = d;
										return result;
									}
								}
								else
								{
									d1 = delta;
									result.End = d;
								}
							}
						}
					}
				}
				else
				{
					long d1 = long.MaxValue;
					foreach (DateTime d in Intervals)
					{
						long delta = Math.Abs((d - end).Ticks);
						if (delta < d1)
						{
							if (TimeMode == TimeMode.CumulativeFromStart || TimeMode == TimeMode.TimeInstant || (TimeMode == TimeMode.TimeExtent && d > result.Start))
							{																
								d1 = delta;
								result.End = d;								
							}
						}
					}
				}
				//return snaped extent
				return result;
			}
			else return extent;
			
		}
        public void ReadXml(XmlReader reader)
        {
            reader.Read(); // move to inner element, PersistenMessage

            XmlSerializer serializer = new XmlSerializer(typeof(PersistentMessage));

            var temp = serializer.Deserialize(reader) as PersistentMessage;

            if (temp != null)
            {
                VisibleTimeExtent = temp.VisibleTimeExtent;

                foreach (var pi in temp.PropertyItems)
                {
                    if (ContainsKey(pi.Key))
                    {
                        this[pi.Key] = pi.Value;
                    }
                    else
                    {
                        Add(pi.Key, pi.Value);
                    }
                }

                foreach (var pc in temp.PhaseControlPoints)
                {
                    PhaseControlPointsDictionary.Add(pc.Key, pc.Value);
                }
            }

            reader.Read();
        }
 /// <summary>
 /// Determines whether the input extent represents instantaneous time
 /// </summary>
 /// <param name="timeExtent">The time extent to interrogate</param>
 /// <returns>A boolean indicating whether the extent represents an instant in time</returns>
 public static bool IsTimeInstant(this TimeExtent timeExtent)
 {
     return(timeExtent.StartTime == timeExtent.EndTime);
 }
        /// <summary>
        /// Divides the specified TimeExtent by the specified number
        /// </summary>
        /// <param name="timeExtent">The extent to divide</param>
        /// <param name="count">The amount to divide the extent by</param>
        /// <returns>A TimeValue instance which, will fit evenly into the input TimeExtent the specified number of times</returns>
        public static TimeValue Divide(this TimeExtent timeExtent, int count)
        {
            if (timeExtent == null)
            {
                return(null);
            }

            if (timeExtent.StartTime.TimeOfDay == timeExtent.EndTime.TimeOfDay &&
                timeExtent.StartTime.Day == timeExtent.EndTime.Day &&
                (timeExtent.StartTime.Month != timeExtent.EndTime.Month ||
                 timeExtent.StartTime.Year != timeExtent.EndTime.Year))
            {
                // There is a whole number of months between the start and end dates.  Check whether those can be divided evenly
                // by the specified number of time steps.
                var fullExtentSpanInMonths = ((timeExtent.EndTime.Year - timeExtent.StartTime.Year) * 12)
                                             + timeExtent.EndTime.Month - timeExtent.StartTime.Month;
                if (fullExtentSpanInMonths % count == 0)
                {
                    // Time steps can be represented as whole months.  Check whether they could also be represented as whole
                    // centuries, decades, or years.

                    var monthsPerTimeStep = fullExtentSpanInMonths / count;
                    if (monthsPerTimeStep % 1200 == 0) // 1200 months in a century
                    {
                        return(new TimeValue(monthsPerTimeStep / 1200, TimeUnit.Centuries));
                    }
                    else if (monthsPerTimeStep % 120 == 0) // 120 months in a decade
                    {
                        return(new TimeValue(monthsPerTimeStep / 120, TimeUnit.Decades));
                    }
                    else if (monthsPerTimeStep % 12 == 0) // 12 months in a year
                    {
                        return(new TimeValue(monthsPerTimeStep / 12, TimeUnit.Years));
                    }
                    else // largest whole unit the time step interval can be represented in is months
                    {
                        return(new TimeValue(monthsPerTimeStep, TimeUnit.Months));
                    }
                }
            }

            // The time step interval couldn't be represented as a whole number of months, decades, or centuries.  Check for smaller units.

            const int millisecondsPerSecond = 1000;
            const int millisecondsPerMinute = millisecondsPerSecond * 60;
            const int millisecondsPerHour   = millisecondsPerMinute * 60;
            const int millisecondsPerDay    = millisecondsPerHour * 24;
            const int millisecondsPerWeek   = millisecondsPerDay * 7;

            // Get how many milliseconds would be in each of the specified number of time steps
            var fullExtentTimeSpan      = timeExtent.EndTime - timeExtent.StartTime;
            var millisecondsPerTimeStep = fullExtentTimeSpan.TotalMilliseconds / count;

            if (millisecondsPerTimeStep - Math.Truncate(millisecondsPerTimeStep) == 0) // Check whether milliseconds per time step is a whole number
            {
                // Time steps can be represented as whole milliseconds.  Check whether they could also be represented as
                // whole weeks, days, hours, minutes or seconds.

                if (millisecondsPerTimeStep % millisecondsPerWeek == 0)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerWeek, TimeUnit.Weeks));
                }
                else if (millisecondsPerTimeStep % millisecondsPerDay == 0)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerDay, TimeUnit.Days));
                }
                else if (millisecondsPerTimeStep % millisecondsPerHour == 0)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerHour, TimeUnit.Hours));
                }
                else if (millisecondsPerTimeStep % millisecondsPerMinute == 0)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerMinute, TimeUnit.Minutes));
                }
                else if (millisecondsPerTimeStep % millisecondsPerSecond == 0)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerSecond, TimeUnit.Seconds));
                }
                else
                {
                    return(new TimeValue(millisecondsPerTimeStep, TimeUnit.Milliseconds));
                }
            }
            else
            {
                // The full time extent cannot be divided into a non-fractional time step interval.  Fall back to the smallest fractional
                // time step interval with a unit of days or less that is greater than one.  Avoid units of months or greater since the
                // temporal value of a fractional month is dependent on when in the calendar year the value is applied.

                if (millisecondsPerTimeStep / millisecondsPerDay > 1)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerDay, TimeUnit.Days));
                }
                else if (millisecondsPerTimeStep / millisecondsPerHour > 1)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerHour, TimeUnit.Hours));
                }
                else if (millisecondsPerTimeStep / millisecondsPerMinute > 1)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerMinute, TimeUnit.Minutes));
                }
                else if (millisecondsPerTimeStep / millisecondsPerSecond > 1)
                {
                    return(new TimeValue(millisecondsPerTimeStep / millisecondsPerSecond, TimeUnit.Seconds));
                }
                else
                {
                    return(new TimeValue(millisecondsPerTimeStep, TimeUnit.Milliseconds));
                }
            }
        }
Ejemplo n.º 19
0
		private void Rewind()
		{
			if (ValidValue == null) return;
			if (TimeMode == TimeMode.CumulativeFromStart)
				Value = new TimeExtent(ValidValue.Start);
			else
			{
				IEnumerator<DateTime> enumerator = Intervals.GetEnumerator();
				while (enumerator.MoveNext())
				{
					if (ValidValue.Start == ValidValue.End)
						break;
					if (enumerator.Current == ValidValue.Start)
						break;
				}
				if (ValidValue.Start == ValidValue.End)				
					Value = new TimeExtent(enumerator.Current, enumerator.Current);				
				else
				{
					int i = 0;
					while (enumerator.MoveNext())
					{
						if (enumerator.Current == ValidValue.End)
							break;
						i++;
					}
					enumerator = Intervals.GetEnumerator();
					enumerator.MoveNext();
					DateTime start = enumerator.Current;
					for (int j = 0; j <= i; j++) enumerator.MoveNext();
					DateTime end = enumerator.Current;
					Value = new TimeExtent(start, end);
				}
			}
		}
 public TimeAwareMilitaryMessage(TimeExtent timeExtent)
 {
     VisibleTimeExtent = new TimeExtent(timeExtent.Start,timeExtent.End);
 }
Ejemplo n.º 21
0
		/// <summary>
		/// Jumps to the next position in the intervals.
		/// </summary>
		/// <returns><c>true</c> if succeeded, <c>false</c> if there are no <see cref="Intervals"/> 
		/// or the <see cref="MaximumValue"/> was reached.</returns>
		/// <see cref="Intervals"/>
		public bool Next()
		{
			if (Intervals == null || ValidValue == null) return false;
			DateTime nextA = ValidValue.Start;
			DateTime nextB = ValidValue.End;
			IEnumerator<DateTime> enumerator = Intervals.GetEnumerator();
			bool next = false;
			bool hasMore = enumerator.MoveNext();
			while (hasMore)
			{
				if (next)
				{					
					nextB = enumerator.Current;
					break;
				}
				if (enumerator.Current == ValidValue.End)
					next = true;
				hasMore = enumerator.MoveNext();
			}
			if (!hasMore) return false; //reached the end
			next = false; 
			if (TimeMode == TimeMode.TimeExtent || TimeMode == TimeMode.TimeInstant)
			{
				enumerator = Intervals.GetEnumerator();
				hasMore = enumerator.MoveNext();
				while (hasMore)
				{
					if (next)
					{
						nextA = enumerator.Current;
						break;
					}
					if (enumerator.Current == ValidValue.Start)
						next = true;
					hasMore = enumerator.MoveNext();
				}
			}
			
			Value = new TimeExtent(nextA, nextB);
			return true;
		}
Ejemplo n.º 22
0
		/// <summary>
		/// Creates time stops within an interval dispersed with by specified <see cref="TimeSpan"/>.
		/// </summary>
		/// <param name="extent">The time extent.</param>
		/// <param name="interval">Interval between each time stop.</param>
		/// <returns>IEnumerable of time stops.</returns>
		public static IEnumerable<DateTime> CreateTimeStopsByTimeInterval(TimeExtent extent, TimeSpan interval)
		{
			DateTime d = extent.Start;
			while (d <= extent.End)
			{
				yield return d;
				try { d = d.Add(interval); }
				catch (ArgumentOutOfRangeException) { }
			}			
		}
Ejemplo n.º 23
0
		/// <summary>
		/// Creates the specified number of time stops evenly distributed in the time extent.
		/// </summary>
		/// <param name="extent">The time extent.</param>
		/// <param name="count">Number of stops.</param>
		/// <returns>IEnumerable of time stops.</returns>
		public static IEnumerable<DateTime> CreateTimeStopsByCount(TimeExtent extent, int count)
		{			
			long span = (extent.End - extent.Start).Ticks / (count - 1);
			DateTime d = extent.Start;
			for (int i = 0; i < count-1; i++)
			{
				yield return d;				
				try { d = d.AddTicks(span); }
				catch (ArgumentOutOfRangeException) { }				
			}
			yield return extent.End;
		}
Ejemplo n.º 24
0
			/// <summary>
			/// Initializes a new instance of the <see cref="ValueChangedEventArgs"/> class.
			/// </summary>
			/// <param name="newValue">The new <see cref="TimeExtent"/> value.</param>
			/// <param name="oldValue">The old <see cref="TimeExtent"/> value.</param>
			internal ValueChangedEventArgs(TimeExtent newValue, TimeExtent oldValue)
			{
				NewValue = newValue;
				OldValue = oldValue;
			}
Ejemplo n.º 25
0
		private void UpdateTrackLayout(TimeExtent extent)
		{						
			if (extent == null || extent.Start < MinimumValue || extent.End > MaximumValue ||
				MinimumThumb == null || MaximumThumb == null || MaximumValue <=
				MinimumValue || SliderTrack == null) 
				return;

			TimeMode timeMode = this.TimeMode;			
			double sliderWidth = SliderTrack.ActualWidth;
			double minimum = MinimumValue.Ticks;
			double maximum = MaximumValue.Ticks;

			// time			
			TimeExtent snapped = Snap(extent,false);
			double start = snapped.Start.Ticks;
			double end = snapped.End.Ticks;
				
			//margins 
			double left = 0;
			double right = 0;
			bool hasIntervals = (Intervals == null) ? false : Intervals.GetEnumerator().MoveNext();
			
			// rate = (distance) / (time)				
			double rate =  GetTrackWidth() / (maximum - minimum);

			if (timeMode == TimeMode.TimeExtent && !hasIntervals)
			{												
				//left repeater	
				right = Math.Min(sliderWidth,((maximum - start) * rate) + MinimumThumb.ActualWidth + MaximumThumb.ActualWidth);
				ElementHorizontalLargeDecrease.Margin = new Thickness(0, 0, right, 0);												

				//minimum thumb
				left = Math.Min(sliderWidth, (start - minimum) * rate);
				right = Math.Min(sliderWidth, ((maximum - start) * rate) + MaximumThumb.ActualWidth);
				MinimumThumb.Margin = new Thickness(left, 0, right, 0);

				//middle thumb
				left = Math.Min(sliderWidth, ((start - minimum) * rate) + MinimumThumb.ActualWidth);
				right = Math.Min(sliderWidth, (maximum - end) * rate + MaximumThumb.ActualWidth);
				HorizontalTrackThumb.Margin = new Thickness(left, 0, right, 0);
				HorizontalTrackThumb.Width = Math.Max(0, (sliderWidth - right - left));

				//maximum thumb
				left = Math.Min(sliderWidth, (end - minimum) * rate + MinimumThumb.ActualWidth);
				right = Math.Min(sliderWidth, ((maximum - end) * rate));
				MaximumThumb.Margin = new Thickness(left, 0, right, 0);

				//right repeater
				left = Math.Min(sliderWidth, ((end - minimum) * rate) + MinimumThumb.ActualWidth + MaximumThumb.ActualWidth);
				ElementHorizontalLargeIncrease.Margin = new Thickness(left, 0, 0, 0);
			}
			else if (hasIntervals) //one or two thumbs
			{				
				//left repeater								
				right = Math.Min(sliderWidth, ((maximum - start) * rate) + MaximumThumb.ActualWidth);
				ElementHorizontalLargeDecrease.Margin = new Thickness(0, 0, right, 0);

				//minimum thumb
				if (timeMode == TimeMode.TimeExtent)
				{
					left = Math.Min(sliderWidth, (start - minimum) * rate);
					right = Math.Min(sliderWidth, ((maximum - start) * rate));
					MinimumThumb.Margin = new Thickness(left, 0, right, 0);
				}
				else
				{
					MinimumThumb.Margin = new Thickness(0, 0, sliderWidth, 0);
				}

				//middle thumb
				if (timeMode == TimeMode.TimeInstant)
				{
					HorizontalTrackThumb.Margin = new Thickness(0, 0, sliderWidth, 0);
					HorizontalTrackThumb.Width = 0;
				}
				else if(timeMode == TimeMode.TimeExtent)
				{
					left = Math.Min(sliderWidth, ((start - minimum) * rate) + MinimumThumb.ActualWidth);
					right = Math.Min(sliderWidth, (maximum - end) * rate + MaximumThumb.ActualWidth);
					HorizontalTrackThumb.Margin = new Thickness(left, 0, right, 0);
					HorizontalTrackThumb.Width = Math.Max(0, (sliderWidth - right - left));
					HorizontalTrackThumb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
				}
				else
				{
					right = Math.Min(sliderWidth, ((maximum - end) * rate) + MaximumThumb.ActualWidth);
					HorizontalTrackThumb.Margin = new Thickness(0, 0, right, 0);
					HorizontalTrackThumb.Width = (sliderWidth - right);
					HorizontalTrackThumb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
				}

				//maximum thumb
				left = Math.Min(sliderWidth,(end - minimum) * rate);
				right = Math.Min(sliderWidth,((maximum - end) * rate));
				MaximumThumb.Margin = new Thickness(left, 0, right, 0);

				//right repeater
				left = Math.Min(sliderWidth,((end - minimum) * rate) + MaximumThumb.ActualWidth);
				ElementHorizontalLargeIncrease.Margin = new Thickness(left, 0, 0, 0);				
			}
			else //no intervals, one thumb or two thumbs where start==end
			{				
				//left repeater				
				right = Math.Min(sliderWidth,((maximum - end) * rate) + MaximumThumb.ActualWidth);
				ElementHorizontalLargeDecrease.Margin = new Thickness(0, 0, right, 0);

				//minimum thumb
				MinimumThumb.Margin = new Thickness(0, 0, sliderWidth, 0);

				//middle thumb
				if (timeMode == TimeMode.TimeInstant)
				{
					HorizontalTrackThumb.Margin = new Thickness(0, 0, sliderWidth, 0);
					HorizontalTrackThumb.Width = 0;
				}
				else
				{
					HorizontalTrackThumb.Margin = new Thickness(0, 0, right, 0);
					HorizontalTrackThumb.Width = (sliderWidth - right);
					HorizontalTrackThumb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
				}

				//maximum thumb
				left = Math.Min(sliderWidth,(end - minimum) * rate);
				right = Math.Min(sliderWidth,((maximum - end) * rate));
				MaximumThumb.Margin = new Thickness(left, 0, right, 0);

				//right repeater
				left = Math.Min(sliderWidth,((end - minimum) * rate) + MaximumThumb.ActualWidth);
				ElementHorizontalLargeIncrease.Margin = new Thickness(left, 0, 0, 0);
			}
		}
        private void ProccessMilitaryMessages(TimeExtent timeExtent)
        {
            // get a list of military messages that intersect this time extent
            var militaryMessages = _mission.MilitaryMessages.Where(m => m.VisibleTimeExtent.Intersects(timeExtent)).ToList();
            var phaseID = _mission.PhaseList[CurrentPhaseIndex].ID;

            foreach (var mm in militaryMessages)
            {
                if (mm.ContainsKey(MilitaryMessage.ControlPointsPropertyName))
                {
                    // load the correct control points for the current phase
                    if (mm.PhaseControlPointsDictionary.ContainsKey(phaseID))
                    {
                        mm[MilitaryMessage.ControlPointsPropertyName] = mm.PhaseControlPointsDictionary[phaseID];
                    }
                    else
                    {
                        Console.WriteLine(@"ERROR : Control points not found for phase id {0}", phaseID);
                    }
                }

                if (mm.ContainsKey(MilitaryMessage.ActionPropertyName))
                {
                    mm[MilitaryMessage.ActionPropertyName] = Constants.MSG_ACTION_UPDATE;
                }

                if (ProcessMessage(_militaryMessageLayer, mm))
                {
                    Mediator.NotifyColleagues(Constants.ACTION_ITEM_WITH_GUID_ADDED, mm.Id);
                }
            }

            DoCloneMission(null);
        }
Ejemplo n.º 27
0
		private void MinimumThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
		{
			if (IsPlaying) IsPlaying = false;
			if (e.HorizontalChange == 0) return;
			if (currentValue == null) currentValue = ValidValue;
#if SILVERLIGHT
			totalHorizontalChange += e.HorizontalChange;
			if (HorizontalChangeExtent == null)
				HorizontalChangeExtent = new TimeExtent(currentValue.Start, currentValue.End);
#else
			totalHorizontalChange = e.HorizontalChange;
			HorizontalChangeExtent = new TimeExtent(currentValue.Start, currentValue.End);
#endif
			// time ratio 
			long TimeRate = (MaximumValue.Ticks - MinimumValue.Ticks) / (long)GetTrackWidth();

			// time change
			long TimeChange = (long)(TimeRate * totalHorizontalChange);
			
			TimeExtent tempChange = null;
			try
			{
				tempChange = new TimeExtent(HorizontalChangeExtent.Start.AddTicks(TimeChange), HorizontalChangeExtent.End);
			}
			catch (ArgumentOutOfRangeException)
			{
				if(totalHorizontalChange < 0) 
					tempChange = new TimeExtent(MinimumValue,currentValue.End); 
				else if(totalHorizontalChange > 0) 
					tempChange = new TimeExtent(currentValue.End);
			}

			if (tempChange.Start.Ticks < MinimumValue.Ticks)
				currentValue = Snap(new TimeExtent(MinimumValue, currentValue.End), false);
			else if (tempChange.Start >= currentValue.End)
				currentValue = Snap(new TimeExtent(currentValue.End), false);
			else
				currentValue = Snap(new TimeExtent(tempChange.Start, tempChange.End), false);	

			UpdateTrackLayout(currentValue);
		}
Ejemplo n.º 28
0
        /// <summary>
        /// Set the time intervals
        /// </summary>
        internal void SetTimer()
        {
            TimeExtent timeExtent = null;

            if (Layer is FeatureLayer)
            {
                timeExtent = ((FeatureLayer)Layer).TimeExtent;
            }
            else if (Layer is ArcGISDynamicMapServiceLayer)
            {
                timeExtent = ((ArcGISDynamicMapServiceLayer)Layer).TimeExtent;
            }
            else
            {
                return;
            }

            List <DateTime> intervals = new List <DateTime>();

            intervals.Add(timeExtent.Start);

            // irregular
            string[] dates =
            {
                "01/09/2008", "01/16/2008", "01/23/2008", "01/30/2008", "02/06/2008", "02/13/2008", "02/20/2008", "03/19/2008", "03/26/2008", "04/02/2008", "04/09/2008", "04/16/2008", "04/24/2008", "04/29/2008", "05/07/2008", "05/14/2008", "05/21/2008", "05/28/2008", "06/04/2008", "06/10/2008", "06/18/2008", "06/25/2008", "07/02/2008", "07/10/2008", "07/16/2008", "07/23/2008", "07/30/2008", "08/07/2008", "08/14/2008", "08/21/2008", "08/27/2008", "09/04/2008", "09/10/2008", "09/17/2008", "09/24/2008", "10/01/2008", "10/08/2008", "10/15/2008", "10/22/2008", "10/29/2008", "11/05/2008", "11/12/2008", "11/19/2008", "11/26/2008", "12/03/2008", "12/10/2008", "12/17/2008", "12/24/2008",
                "12/31/2008", "01/07/2009", "01/14/2009", "01/21/2009", "01/28/2009", "02/04/2009", "02/11/2009", "02/19/2009", "02/25/2009", "03/04/2009", "03/11/2009", "03/18/2009", "03/25/2009", "04/02/2009", "04/08/2009", "04/15/2009", "04/22/2009", "04/29/2009", "05/06/2009", "05/13/2009", "05/20/2009", "05/27/2009", "06/03/2009", "06/10/2009", "06/17/2009", "06/24/2009", "07/01/2009", "07/08/2009", "07/15/2009", "07/21/2009", "07/28/2009", "08/05/2009", "08/11/2009", "08/25/2009", "09/01/2009", "09/08/2009", "09/15/2009", "09/22/2009", "09/29/2009", "10/06/2009", "10/13/2009", "10/20/2009", "10/27/2009", "11/03/2009", "11/11/2009", "11/17/2009", "12/01/2009", "12/08/2009","12/15/2009",  "12/22/2009", "12/29/2009",
                "01/05/2010", "01/12/2010", "01/19/2010", "01/26/2010", "02/02/2010", "02/09/2010", "02/16/2010", "03/02/2010", "03/09/2010", "03/16/2010", "03/23/2010", "03/30/2010", "04/06/2010", "04/13/2010", "04/20/2010", "04/27/2010", "05/04/2010", "05/11/2010", "05/18/2010", "05/25/2010", "06/01/2010", "06/08/2010", "06/15/2010", "06/22/2010", "06/29/2010", "07/06/2010", "07/13/2010", "07/20/2010", "07/27/2010", "08/03/2010", "08/10/2010", "08/17/2010", "08/24/2010", "08/31/2010", "09/07/2010", "09/14/2010", "09/21/2010", "09/28/2010", "10/05/2010", "10/12/2010", "10/19/2010", "10/26/2010", "11/02/2010", "11/09/2010", "11/16/2010", "11/23/2010", "11/30/2010", "12/07/2010","12/14/2010",  "12/21/2010", "12/28/2010"
            };
            foreach (string date in dates)
            {
                DateTime irr_interval = DateTime.Parse(date + " 00:00:00 GMT", CultureInfo.InvariantCulture);
                if (irr_interval > timeExtent.Start)
                {
                    intervals.Add(irr_interval);
                }
            }

            // regular
            DateTime reg_interval = DateTime.Parse("01/04/2011 00:00:00 GMT", CultureInfo.InvariantCulture);

            while (reg_interval < timeExtent.End)
            {
                if (reg_interval > timeExtent.Start)
                {
                    intervals.Add(reg_interval);
                }
                reg_interval = reg_interval.AddDays(7);
            }

            intervals.Add(timeExtent.End);

            /*
             * // without irregular
             * TimeSpan timeSpan = timeExtent.End.Subtract(timeExtent.Start);
             * double timeInterval = Math.Floor(timeSpan.TotalDays/7);
             * DateTime dt = timeExtent.Start;
             * for (int i = 0; i < timeInterval ; i++)
             * {
             *  intervals.Add(dt);
             *  dt = dt.AddDays(7);
             * }
             */

            IceTimeSlider.MinimumValue = timeExtent.Start;
            IceTimeSlider.MaximumValue = timeExtent.End;
            IceTimeSlider.Intervals    = intervals;

            Map.TimeExtent = new TimeExtent(timeExtent.Start, timeExtent.Start.AddDays(7));
        }
        private void FeatureLayer_Initialized(object sender, EventArgs e)
        {
            TimeExtent extent = new TimeExtent(timeSlider.MinimumValue, timeSlider.MaximumValue);

            timeSlider.Intervals = TimeSlider.CreateTimeStopsByTimeInterval(extent, new TimeSpan(0, 6, 0, 0, 0));
        }
 private void FeatureLayer_Initialized(object sender, EventArgs e)
 {
     TimeExtent extent = new TimeExtent(MyTimeSlider.MinimumValue, MyTimeSlider.MaximumValue);
     MyTimeSlider.Intervals = TimeSlider.CreateTimeStopsByTimeInterval(extent, new TimeSpan(0, 6, 0, 0, 0));
 }
Ejemplo n.º 31
0
		private void MaximumThumb_DragDelta(object sender, System.Windows.Controls.Primitives.DragDeltaEventArgs e)
		{
			if (IsPlaying) IsPlaying = false;
			if (e.HorizontalChange == 0) return;
			if (currentValue == null) currentValue = ValidValue;
#if SILVERLIGHT
			totalHorizontalChange += e.HorizontalChange;
			if (HorizontalChangeExtent == null)
				HorizontalChangeExtent = new TimeExtent(currentValue.Start, currentValue.End);
#else
			totalHorizontalChange = e.HorizontalChange;			
			HorizontalChangeExtent = new TimeExtent(currentValue.Start, currentValue.End);
#endif
			// time ratio 
			long TimeRate = (MaximumValue.Ticks - MinimumValue.Ticks) / (long)GetTrackWidth();
			
			// time change
			long TimeChange = (long)(TimeRate * totalHorizontalChange);

			TimeExtent tempChange = null;
			if (TimeMode == TimeMode.TimeInstant)
			{
				try
				{
					// If the mouse drag creates a date thats year is before 
					// 1/1/0001 or after 12/31/9999 then an out of renge 
					// exception will be trown.
					tempChange = new TimeExtent(HorizontalChangeExtent.End.AddTicks(TimeChange));
				}
				catch (ArgumentOutOfRangeException)
				{
					if (totalHorizontalChange > 0) // date is after 12/31/9999
						tempChange = new TimeExtent(MaximumValue);
					else if (totalHorizontalChange < 0) // date is before 1/1/0001
						tempChange = new TimeExtent(MinimumValue);					
				}
			}
			else
			{
				try
				{
					// If the mouse drag creates a date thats year is before 
					// 1/1/0001 or after 12/31/9999 then an out of renge 
					// exception will be trown.
					tempChange = new TimeExtent(HorizontalChangeExtent.Start, HorizontalChangeExtent.End.AddTicks(TimeChange));
				}
				catch (ArgumentOutOfRangeException)
				{
					if (totalHorizontalChange > 0) // date is after 12/31/9999
						tempChange = new TimeExtent(currentValue.Start, MaximumValue);
					else if (totalHorizontalChange < 0) // date is before 1/1/0001
 						tempChange = new TimeExtent(currentValue.Start);					
				}
			}

			// validate change
			if (TimeMode == TimeMode.TimeInstant)
			{
				if (tempChange.End.Ticks > MaximumValue.Ticks)
					currentValue = Snap(new TimeExtent(MaximumValue), false);
				else if (tempChange.End.Ticks < MinimumValue.Ticks)
					currentValue = Snap(new TimeExtent(MinimumValue), false);
				else
					currentValue = Snap(new TimeExtent(tempChange.End), false);
			}
			else
			{
				if (tempChange.End.Ticks > MaximumValue.Ticks)
					currentValue = Snap(new TimeExtent(currentValue.Start, MaximumValue), false);
				else if (tempChange.End <= currentValue.Start && TimeMode == TimeMode.TimeExtent )
					currentValue = Snap(new TimeExtent(currentValue.Start, currentValue.Start.AddMilliseconds(1)), false);
				else if (tempChange.End.Ticks < MinimumValue.Ticks)
					currentValue = Snap(new TimeExtent(MinimumValue), false);
				else
					currentValue = Snap(new TimeExtent(currentValue.Start, tempChange.End), false);
			}

			UpdateTrackLayout(currentValue);
		}
Ejemplo n.º 32
0
		/// <summary>
		/// Jumps to the previous position in the intervals.
		/// </summary>
		/// <returns><c>true</c> if succeeded, <c>false</c> if there are no <see cref="Intervals"/> 
		/// or the <see cref="MinimumValue"/> was reached.</returns>
		/// <see cref="Intervals"/>
		public bool Previous()
		{
			if (Intervals == null || ValidValue == null) return false;
			DateTime nextA = ValidValue.Start;
			DateTime nextB = ValidValue.End;
			IEnumerator<DateTime> enumerator = Intervals.GetEnumerator();
			bool hasMore = enumerator.MoveNext();
			if (!hasMore) return false;
			DateTime temp;
			if (TimeMode == TimeMode.TimeExtent || TimeMode == TimeMode.TimeInstant)
			{
				temp = enumerator.Current;
				if (temp == ValidValue.Start)
					return false;
				while (enumerator.MoveNext())
				{
					if (enumerator.Current == ValidValue.Start)
					{
						nextA = temp;
						break;
					}
					temp = enumerator.Current;
				}
			}
			if (ValidValue.Start == ValidValue.End)
			{
				Value = new TimeExtent(nextA);
			}
			else
			{
				temp = nextB;
				while (hasMore)
				{
					if (enumerator.Current == ValidValue.End)
					{
						nextB = temp;
						break;
					}
					temp = enumerator.Current;
					hasMore = enumerator.MoveNext();
				}
				if (!hasMore) return false; //reached the end
				Value = new TimeExtent(nextA, nextB);
			}
			return true;
		}
Ejemplo n.º 33
0
		private void DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
		{
#if SILVERLIGHT
			totalHorizontalChange = 0;
			HorizontalChangeExtent = null;
#endif		
			if (currentValue == null) return;
			if ((sender as Thumb).Name == "HorizontalTrackThumb")
				Value = Snap(new TimeExtent(currentValue.Start, currentValue.End), true);
			else if (TimeMode == TimeMode.CumulativeFromStart)
				Value = Snap(new TimeExtent(MinimumValue, currentValue.End), false);
			else
				Value = Snap(new TimeExtent(currentValue.Start, currentValue.End), false);			
		}