public static DateTime GetCurrentIntervalTime(DateTime lastTime, DateTime newTime, Interval interval)
 {
     if (newTime.Subtract(lastTime) < AppConst.AppTimeSpans[interval])
     {
         return lastTime;
     }
     else
     {
         while (newTime.Subtract(lastTime) >= AppConst.AppTimeSpans[interval])
         {
             lastTime = lastTime.Add(AppConst.AppTimeSpans[interval]);
         }
         return lastTime;
     }
 }
 public static DateTime GetLatestIntervalTime(DateTime lastTime, DateTime newTime, Interval interval)
 {
     if (newTime.Subtract(lastTime) < AppConst.AppTimeSpans[interval].Add(AppConst.AppTimeSpans[interval])
         && newTime.Subtract(lastTime) >= AppConst.AppTimeSpans[interval])
     {
         return lastTime;
     }
     else
     {
         while (newTime.Subtract(lastTime) < AppConst.AppTimeSpans[interval].Add(AppConst.AppTimeSpans[interval]))
         {
             if (lastTime.CompareTo(newTime) >= 0)
             {
                 lastTime = newTime;
                 break;
             }
             lastTime = lastTime.Add(AppConst.AppTimeSpans[interval]);
         }
         return lastTime;
     }
 }
Esempio n. 3
0
		public bool IsAdjacent (Interval i) {
			if (IsEmpty || i.IsEmpty)
				return false;
		
			return low == i.high + 1 || high == i.low - 1;
		}
Esempio n. 4
0
		public bool IsDisjoint (Interval i) {
			if (IsEmpty || i.IsEmpty)
				return true;
			
			return !(low <= i.high && i.low <= high);
		}
Esempio n. 5
0
		public void Add (Interval i) {
			intervals.Add (i);
		}
Esempio n. 6
0
		public void Intersect (Interval i) {
			if (IsDisjoint (i)) {
				low = 0;
				high = low - 1;
				return;
			}
		
			if (i.low > low)
				low = i.low;
			if (i.high > high)
				high = i.high;
		}
Esempio n. 7
0
		public void Merge (Interval i) {
			if (i.IsEmpty)
				return;
			if (IsEmpty) {
				this.low = i.low;
				this.high = i.high;
			}
		
			if (i.low < low)
				low = i.low;
			if (i.high > high)
				high = i.high;
		}
Esempio n. 8
0
		public bool Intersects (Interval i) {
 			if (IsEmpty || i.IsEmpty)
 				return false;
 			
 			return ((Contains (i.low) && !Contains (i.high)) ||
				(Contains (i.high) && !Contains (i.low)));
 		}	
Esempio n. 9
0
		public bool Contains (Interval i) {
			if (!IsEmpty && i.IsEmpty)
				return true;
			if (IsEmpty)
				return false;
		
			return low <= i.low && i.high <= high;
		}
Esempio n. 10
0
 public void Process(
     Interval<int> interval,
     ITextString match
     )
 {
     // Defining the highlight box of the text pattern match...
     IList<Quad> highlightQuads = new List<Quad>();
     {
       /*
     NOTE: A text pattern match may be split across multiple contiguous lines,
     so we have to define a distinct highlight box for each text chunk.
       */
       RectangleF? textBox = null;
       foreach(TextChar textChar in match.TextChars)
       {
     RectangleF textCharBox = textChar.Box;
     if(!textBox.HasValue)
     {textBox = textCharBox;}
     else
     {
       if(textCharBox.Y > textBox.Value.Bottom)
       {
     highlightQuads.Add(Quad.Get(textBox.Value));
     textBox = textCharBox;
       }
       else
       {textBox = RectangleF.Union(textBox.Value, textCharBox);}
     }
       }
       highlightQuads.Add(Quad.Get(textBox.Value));
     }
     // Highlight the text pattern match!
     new TextMarkup(page, null, TextMarkup.MarkupTypeEnum.Highlight, highlightQuads);
 }
        public static string IntervalToString(Interval intv)
        {
            switch (intv)
            {
                case Interval.MIN5:
                    return "5";

                case Interval.MIN15:
                    return "15";

                case Interval.MIN30:
                    return "30";

                case Interval.MIN60:
                    return "60";

                case Interval.MIN120:
                    return "120";

                case Interval.DAY1:
                    return "1440";
                default:
                    return "5";
            }
        }