public PLDateSelection()
 {
     this._Types = SelectionTypes.All;
     this._ReturnType = TimeType.Date;
     this.InitializeComponent();
     this.SetLookup();
 }
示例#2
0
 public ExchangeItem(string location, string quantity, Unit unit, TimeType timetype)
   {
     Location = location;
     Quantity = quantity;
     this.Unit = unit;
     this.timeType = timeType;
   }
示例#3
0
 public SearchDescription(RouteDescription routing, PreferKey preferKey, DateTime time, TimeType type)
 {
     this._route = routing;
     this.PreferKey = preferKey;
     this.Time = time;
     this.TimeType = type;
 }
示例#4
0
        public static string Get(this DateTime time, TimeType type, string splitter = "")
        {
            switch (type)
            {
            case TimeType.ByYear:
                return(string.Format("{0:yy}", time));

            case TimeType.ByMonth:
                return(time.ToString(string.Format("yy{0}MM", splitter)));

            case TimeType.ByDay:
                return(time.ToString(string.Format("yy{0}MM{1}dd", splitter, splitter)));

            case TimeType.ByHour:
                return(time.ToString(string.Format("yy{0}MM{1}dd{2}HH", splitter, splitter, splitter)));

            case TimeType.ByMinute:
                return(time.ToString(string.Format("yy{0}MM{1}dd{2}HH{3}mm", splitter, splitter, splitter, splitter)));

            case TimeType.BySecond:
                return(time.ToString(string.Format("yy{0}MM{1}dd{2}HH{3}mm{4}ss", splitter, splitter, splitter, splitter, splitter)));

            case TimeType.ByMillisecond:
                return(time.ToString(string.Format("yy{0}MM{1}dd{2}HH{3}mm{4}ss{5}fff", splitter, splitter, splitter, splitter, splitter, splitter)));

            default:
                return(string.Format("{0:yyMMddHHmmss}", time));
            }
        }
示例#5
0
        public static DataTable GetTimesOfDay(TimeType type)
        {
            DataTable timeTable = new DataTable("TimeOfDay");
            timeTable.Columns.Add(new DataColumn("TimeType"));
            timeTable.Columns.Add(new DataColumn("Time"));
            
            if (type == TimeType.Hour)
            {
                for (int i = 0; i < 24; i++)
                {
                    
                    DataRow row = timeTable.NewRow();
                    row["TimeType"] = type.ToString();
                    row["Time"] = i.ToString("d2");
                    timeTable.Rows.Add(row);
                }
            }

            if (type == TimeType.Minute)
            {
                for (int i = 0; i < 60; i += 15)
                {
                    DataRow row = timeTable.NewRow();
                    row["TimeType"] = type.ToString();
                    row["Time"] = i.ToString("d2");
                    timeTable.Rows.Add(row);
                }
            }

            if (type == TimeType.Second)
            {
                for (int i = 0; i < 60; i += 15)
                {
                    DataRow row = timeTable.NewRow();
                    row["TimeType"] = type.ToString();
                    row["Time"] = i.ToString("d2");
                    timeTable.Rows.Add(row);
                }
            }

            if (type == TimeType.All)
            {
                for (int i = 0; i < 24; i++)
                {
                    for (int j = 0; j < 60; j += 15)
                    {
                        DataRow row = timeTable.NewRow();
                        row["TimeType"] = type.ToString();
                        row["Time"] = i.ToString("d2") + ":" + j.ToString("d2") + ":00";
                        timeTable.Rows.Add(row);
                    }
                }
            }

            return timeTable;
        }
示例#6
0
 /// <summary>
 /// Takes a start and end points and query for possible transit routes.
 /// </summary>
 /// <param name="start">Start location.</param>
 /// <param name="end">End location.</param>
 /// <param name="time">A time or date that relates to the route query.</param>
 /// <param name="timeType">The TimeType of the dateTime parameter.</param>
 public static Task<BingMapsQueryResult> GetTransitRoute(GeoCoordinate start, GeoCoordinate end, DateTime time, TimeType timeType)
 {
     string rqp = new TransitQueryParameters(start.AsBingMapsPoint(), end.AsBingMapsPoint(), time, timeType)
                      {
                          MaxSolutions = 5,
                          RoutePathOutput = RoutePathOutput.Points
                      }.ToString();
     var queryUri = ConstructQueryUri("Routes/Transit", rqp);
     return ExecuteQuery(queryUri);
 }
示例#7
0
 public ExchangeItem()
 {
     Location = null;
     Quantity = null;
     Description = null;
     Unit = null;
     timeType = TimeType.TimeStamp;
     IsInput = true;
     IsOutput = true;
 }
 public PLDateSelection(SelectionTypes SelectionTypes, SelectionTypes Default, TimeType ReturnType)
 {
     this._Types = SelectionTypes.All;
     this._ReturnType = TimeType.Date;
     this.InitializeComponent();
     this._Types = SelectionTypes;
     this._Default = Default;
     this._ReturnType = ReturnType;
     this.SetLookup();
 }
 public static void addTime(int add, TimeType TimeType, TextBox TimeFormat)
 {
     if (TimeType == TimeType.Countdown)
         TimeFormat.Text = (int.Parse(TimeFormat.Text) + add).ToString();
     else
     {
         double NewTime = ((InterpretTime(TimeFormat.Text) / 60000) + add);
         TimeSpan timeTo = new TimeSpan((int)(NewTime / 60), (int)(NewTime % 60) + 1, 0); // This +1 is a confusing. When removed, the time seems to sometimes add 8 or 9 instead of 10. This might not be a fix!
         DateTime NewDateTime = DateTime.Now + timeTo;
         TimeFormat.Text = (NewDateTime).ToShortTimeString();
     }
 }
示例#10
0
        public void AddTime(TimeType tipo, bool isAdding)
        {
            switch (tipo)
            {
                case TimeType.Hours:
                    MaxHours = GetNextValue(MaxHours, isAdding);
                    break;
                case TimeType.Minutes:
                    MaxMinutes = GetNextValue(MaxMinutes, isAdding);
                    break;
                case TimeType.Seconds:
                    MaxSeconds = GetNextValue(MaxSeconds, isAdding);
                    break;
            }

            SetCronoText();
        }
        /// <summary>
        /// Initializes the time struct to a given time.
        /// </summary>
        /// <param name="hour">The hour in the day.</param>
        /// <param name="minute">The minute in the hour.</param>
        /// <param name="second">The second in the minute.</param>
        /// <param name="isAm">True if time is AM and false if time is PM, if TimeType is digit, then isAm will be calculated.</param>
        /// <param name="timeType">Enum describing if AM/PM should be used instead of 24 hours in a day.</param>
        private Time(byte hour, byte minute, byte second, bool isAm, TimeType timeType)
            : this()
        {
            // validation...
            if (hour < 0 || hour > 23) throw new Exception("When using 24 hours a day, legal hour values range from 0 to 23. Given hour value is: " + hour);
            if (minute < 0 || minute > 59) throw new Exception("Legal minute values range from 0 to 59. Given hour value is: " + minute);
            if (second < 0 || second > 59) throw new Exception("Legal minute values range from 0 to 59. Given hour value is: " + minute);
            if (timeType == TimeType.UseAmPm && hour > 12) hour = (byte)(hour - 12);
            else
            {	// Applies only if TimeType is digit.
                if (hour >= 12) isAm = false;
                else isAm = true;
            }

            this.hour = hour;
            this.minute = minute;
            this.second = second;
            IsAm = isAm;
            TimeType = timeType;
        }
示例#12
0
        /// <summary>
        /// Refresh the text displayed in the text box.
        /// </summary>
        /// <returns>
        /// Status of update.
        /// </returns>
        private bool ValidateAndUpdateValue()
        {
            NhsTime result;
            bool status = true;
            bool containedPM = this.ISPMContained();
            this.SetValid();
            this.recentSelectionStart = this.txtInput.SelectionStart;
            this.recentSelectionLength = this.txtInput.SelectionLength;

            // for null index nothing to be done as index is updated while setting.
            if (this.EditingTimeType != TimeType.NullIndex)
            {
                if (NhsTime.IsAddValid(this.txtInput.Text))
                {
                    this.Value.Add(this.txtInput.Text);
                    this.RefreshDisplayText();
                    this.ResetFields();
                    return status;
                }
                else if (NhsTime.TryParseExact(this.txtInput.Text, out result, CultureInfo.CurrentCulture))
                {
                    // Handles an exception case, TryParse always returns the text in am no matter
                    // input contains am or pm.
                    if (containedPM && result.TimeValue.Hour < 12)
                    {
                        result.TimeValue = result.TimeValue.AddHours(12);
                    }

                    this.Value = result;
                    this.invalidFormat = false;
                }
                else
                {
                    this.SetInvalid(ref status);
                } 
            }

            this.allowTimeTypeChange = true;
            this.currentValue = this.Value;
            this.EditingTimeType = this.TimeType;
            this.currentMode = InputMode.Simple;
            this.txtInput.SelectionStart = this.txtInput.TextLength;
            this.txtInput.SelectionLength = 0;
            return status;
        }
示例#13
0
        /// <summary>
        /// Displays the appropriate null string in the control
        /// </summary>
        private void DisplayNullString()
        {
            if (this.IsNullEnabled())
            {
                if (this.NullIndex < 0 || this.NullIndex >= this.NullStrings.Length)
                {
                    this.NullIndex = 0;
                }

                if (this.TimeType == TimeType.NullIndex)
                {
                    this.NullIndex = (this.NullIndex + 1) % this.NullStrings.Length;
                }
                else
                {
                    this.TimeType = TimeType.NullIndex;
                }

                this.EditingTimeType = TimeType.NullIndex;
            
                // this is to ensure that once user is in NullIndex mode then he can only switch to other
                // mode when the control gets focus next time. This is to match the functionality in web
                // counterpart.
                this.allowTimeTypeChange = false;
            }
        }
示例#14
0
        /// <summary>
        /// Validates the format of string in txtInput.
        /// </summary>
        /// <remarks>
        /// Cut/Paste can change the pattern of input string, however, TimeType remains same. This
        /// function is called to validate the string format in txtInput for specified TimeType. 
        /// </remarks>
        /// <returns>True if pattern is correct, else false.</returns>
        private bool IsCorrectFormat()
        {            
            this.txtInput.Text = this.txtInput.Text.Trim();

            // Simple functionality
            if (this.Functionality == TimeFunctionality.Simple)
            {
                return this.IsCorrectFormatForExactTime();
            }

            // Complex functionality 
            else
            {
                int index;               

                index = this.GetNullIndexExact(this.txtInput.Text);
                if (index >= 0)
                {
                    this.NullIndex = index;
                    this.EditingTimeType = TimeType.NullIndex;
                    this.allowTimeTypeChange = false;
                    this.TimeType = TimeType.NullIndex;
                    this.currentMode = InputMode.Simple;
                    return true;
                }

                if (this.IsArithmeticModeFormat())
                {
                    this.currentMode = InputMode.Arithmetic;
                    return true;
                }

                if (this.IsCorrectFormatForExactTime())
                {
                    this.EditingTimeType = this.chkApprox.Checked ? TimeType.Approximate : TimeType.Exact;
                    return true;
                }

                return false;
            }          
        }
示例#15
0
        private static TimeZoneInfo ParseTZBuffer(string id, byte [] buffer, int length)
        {
            //Reading the header. 4 bytes for magic, 16 are reserved
            int ttisgmtcnt = ReadBigEndianInt32(buffer, 20);
            int ttisstdcnt = ReadBigEndianInt32(buffer, 24);
            int leapcnt    = ReadBigEndianInt32(buffer, 28);
            int timecnt    = ReadBigEndianInt32(buffer, 32);
            int typecnt    = ReadBigEndianInt32(buffer, 36);
            int charcnt    = ReadBigEndianInt32(buffer, 40);

            if (length < 44 + timecnt * 5 + typecnt * 6 + charcnt + leapcnt * 8 + ttisstdcnt + ttisgmtcnt)
            {
                throw new InvalidTimeZoneException();
            }

            Dictionary <int, string>   abbreviations = ParseAbbreviations(buffer, 44 + 4 * timecnt + timecnt + 6 * typecnt, charcnt);
            Dictionary <int, TimeType> time_types    = ParseTimesTypes(buffer, 44 + 4 * timecnt + timecnt, typecnt, abbreviations);
            List <KeyValuePair <DateTime, TimeType> > transitions = ParseTransitions(buffer, 44, timecnt, time_types);

            if (time_types.Count == 0)
            {
                throw new InvalidTimeZoneException();
            }

            if (time_types.Count == 1 && ((TimeType)time_types[0]).IsDst)
            {
                throw new InvalidTimeZoneException();
            }

            TimeSpan baseUtcOffset                = new TimeSpan(0);
            TimeSpan dstDelta                     = new TimeSpan(0);
            string   standardDisplayName          = null;
            string   daylightDisplayName          = null;
            bool     dst_observed                 = false;
            DateTime dst_start                    = DateTime.MinValue;
            List <AdjustmentRule> adjustmentRules = new List <AdjustmentRule> ();

            for (int i = 0; i < transitions.Count; i++)
            {
                var      pair  = transitions [i];
                DateTime ttime = pair.Key;
                TimeType ttype = pair.Value;
                if (!ttype.IsDst)
                {
                    if (standardDisplayName != ttype.Name || baseUtcOffset.TotalSeconds != ttype.Offset)
                    {
                        standardDisplayName = ttype.Name;
                        daylightDisplayName = null;
                        baseUtcOffset       = new TimeSpan(0, 0, ttype.Offset);
                        adjustmentRules     = new List <AdjustmentRule> ();
                        dst_observed        = false;
                    }
                    if (dst_observed)
                    {
                        //FIXME: check additional fields for this:
                        //most of the transitions are expressed in GMT
                        dst_start += baseUtcOffset;
                        DateTime dst_end = ttime + baseUtcOffset + dstDelta;

                        //some weird timezone (America/Phoenix) have end dates on Jan 1st
                        if (dst_end.Date == new DateTime(dst_end.Year, 1, 1) && dst_end.Year > dst_start.Year)
                        {
                            dst_end -= new TimeSpan(24, 0, 0);
                        }

                        DateTime dateStart, dateEnd;
                        if (dst_start.Month < 7)
                        {
                            dateStart = new DateTime(dst_start.Year, 1, 1);
                        }
                        else
                        {
                            dateStart = new DateTime(dst_start.Year, 7, 1);
                        }

                        if (dst_end.Month >= 7)
                        {
                            dateEnd = new DateTime(dst_end.Year, 12, 31);
                        }
                        else
                        {
                            dateEnd = new DateTime(dst_end.Year, 6, 30);
                        }


                        TransitionTime transition_start = TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1) + dst_start.TimeOfDay, dst_start.Month, dst_start.Day);
                        TransitionTime transition_end   = TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1) + dst_end.TimeOfDay, dst_end.Month, dst_end.Day);
                        if (transition_start != transition_end)                          //y, that happened in Argentina in 1943-1946
                        {
                            adjustmentRules.Add(AdjustmentRule.CreateAdjustmentRule(dateStart, dateEnd, dstDelta, transition_start, transition_end));
                        }
                    }
                    dst_observed = false;
                }
                else
                {
                    if (daylightDisplayName != ttype.Name || dstDelta.TotalSeconds != ttype.Offset - baseUtcOffset.TotalSeconds)
                    {
                        daylightDisplayName = ttype.Name;
                        dstDelta            = new TimeSpan(0, 0, ttype.Offset) - baseUtcOffset;
                    }
                    dst_start    = ttime;
                    dst_observed = true;
                }
            }

            if (adjustmentRules.Count == 0)
            {
                TimeType t = (TimeType)time_types [0];
                if (standardDisplayName == null)
                {
                    standardDisplayName = t.Name;
                    baseUtcOffset       = new TimeSpan(0, 0, t.Offset);
                }
                return(CreateCustomTimeZone(id, baseUtcOffset, id, standardDisplayName));
            }
            else
            {
                return(CreateCustomTimeZone(id, baseUtcOffset, id, standardDisplayName, daylightDisplayName, ValidateRules(adjustmentRules).ToArray()));
            }
        }
示例#16
0
 static SideStep(DimensionType dim, JointType jnt, StatType stat, TimeType tm, FeatureType ftr)
 {
 }
示例#17
0
 static Kick(DimensionType dim, JointType jnt, StatType stat, TimeType tm, FeatureType ftr)
 {
 }
示例#18
0
文件: CuiTime.cs 项目: rbirkby/mscui
 /// <summary>
 /// Constructs a CuiTime object, initializes the <see cref="P:Microsoft.Cui.Controls.Common.DateAndTime.CuiTime.TimeValue">TimeValue</see> to the 
 /// given value and sets <see cref="P:Microsoft.Cui.Controls.Common.DateAndTime.CuiTime.TimeType">TimeType</see> to Exact. 
 /// </summary>
 /// <param name="time">The given time value. </param>
 public CuiTime(DateTime time)
 {
     this.timeValue = time;
     this.timeType = TimeType.Exact;
 }
示例#19
0
        private static TimeZoneInfo ParseTZBuffer(string id, byte[] buffer, int length)
        {
            int num  = ReadBigEndianInt32(buffer, 20);
            int num2 = ReadBigEndianInt32(buffer, 24);
            int num3 = ReadBigEndianInt32(buffer, 28);
            int num4 = ReadBigEndianInt32(buffer, 32);
            int num5 = ReadBigEndianInt32(buffer, 36);
            int num6 = ReadBigEndianInt32(buffer, 40);

            if (length < 44 + num4 * 5 + num5 * 6 + num6 + num3 * 8 + num2 + num)
            {
                throw new InvalidTimeZoneException();
            }
            Dictionary <int, string>   abbreviations       = ParseAbbreviations(buffer, 44 + 4 * num4 + num4 + 6 * num5, num6);
            Dictionary <int, TimeType> dictionary          = ParseTimesTypes(buffer, 44 + 4 * num4 + num4, num5, abbreviations);
            List <KeyValuePair <DateTime, TimeType> > list = ParseTransitions(buffer, 44, num4, dictionary);

            if (dictionary.Count == 0)
            {
                throw new InvalidTimeZoneException();
            }
            if (dictionary.Count == 1)
            {
                TimeType timeType = dictionary[0];
                if (timeType.IsDst)
                {
                    throw new InvalidTimeZoneException();
                }
            }
            TimeSpan timeSpan           = new TimeSpan(0L);
            TimeSpan timeSpan2          = new TimeSpan(0L);
            string   text               = null;
            string   a                  = null;
            bool     flag               = false;
            DateTime d                  = DateTime.MinValue;
            List <AdjustmentRule> list2 = new List <AdjustmentRule>();

            for (int i = 0; i < list.Count; i++)
            {
                KeyValuePair <DateTime, TimeType> keyValuePair = list[i];
                DateTime key   = keyValuePair.Key;
                TimeType value = keyValuePair.Value;
                if (!value.IsDst)
                {
                    if (text != value.Name || timeSpan.TotalSeconds != (double)value.Offset)
                    {
                        text     = value.Name;
                        a        = null;
                        timeSpan = new TimeSpan(0, 0, value.Offset);
                        list2    = new List <AdjustmentRule>();
                        flag     = false;
                    }
                    if (flag)
                    {
                        d += timeSpan;
                        DateTime d2 = key + timeSpan + timeSpan2;
                        if (d2.Date == new DateTime(d2.Year, 1, 1) && d2.Year > d.Year)
                        {
                            d2 -= new TimeSpan(24, 0, 0);
                        }
                        DateTime       dateStart       = (d.Month < 7) ? new DateTime(d.Year, 1, 1) : new DateTime(d.Year, 7, 1);
                        DateTime       dateEnd         = (d2.Month >= 7) ? new DateTime(d2.Year, 12, 31) : new DateTime(d2.Year, 6, 30);
                        TransitionTime transitionTime  = TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1) + d.TimeOfDay, d.Month, d.Day);
                        TransitionTime transitionTime2 = TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1) + d2.TimeOfDay, d2.Month, d2.Day);
                        if (transitionTime != transitionTime2)
                        {
                            list2.Add(AdjustmentRule.CreateAdjustmentRule(dateStart, dateEnd, timeSpan2, transitionTime, transitionTime2));
                        }
                    }
                    flag = false;
                }
                else
                {
                    if (a != value.Name || timeSpan2.TotalSeconds != (double)value.Offset - timeSpan.TotalSeconds)
                    {
                        a         = value.Name;
                        timeSpan2 = new TimeSpan(0, 0, value.Offset) - timeSpan;
                    }
                    d    = key;
                    flag = true;
                }
            }
            if (list2.Count == 0)
            {
                TimeType timeType2 = dictionary[0];
                if (text == null)
                {
                    text     = timeType2.Name;
                    timeSpan = new TimeSpan(0, 0, timeType2.Offset);
                }
                return(CreateCustomTimeZone(id, timeSpan, id, text));
            }
            return(CreateCustomTimeZone(id, timeSpan, id, text, a, ValidateRules(list2).ToArray()));
        }
示例#20
0
文件: CuiTime.cs 项目: rbirkby/mscui
 public CuiTime(string time, bool parseAll)
 {
     CuiTime newTime = CuiTime.ParseExact(time, CultureInfo.CurrentCulture);
     this.timeValue = newTime.timeValue;
     this.timeType = newTime.timeType;
     this.nullIndex = newTime.nullIndex;
 }
示例#21
0
 public Hltb_Rule( Hltb_Rule other ) {
     Name = other.Name;
     MinHours = other.MinHours;
     MaxHours = other.MaxHours;
     TimeType = other.TimeType;
 }
示例#22
0
        /// <summary>
        /// Handles the text changed event of the child textbox
        /// </summary>
        /// <param name="sender">Object calling the event</param>
        /// <param name="e">Event arguments</param>
        private void TextBox1_TextChanged(object sender, EventArgs e)
        {
            if (this.selectedPaste)
            {
                this.selectedPaste = false;
                return;
            }

            if (this.inlineEditing)
            {
                return;
            }

            if (this.txtInput.TextLength == 0)
            {
                this.currentMode = InputMode.Simple;
                this.invalidFormat = false;
                this.editingTimeType = TimeType.Null;
            }

            if (this.acceptedKey)
            {
                this.acceptedKey = false;
                return;
            }            

            if (!this.IsCorrectFormat())
            {
                this.invalidFormat = true;              
            }
            else
            {
                this.invalidFormat = false;
                if (this.editingTimeType == TimeType.Exact || this.editingTimeType == TimeType.Approximate)
                {
                    this.HandleAmPmDisplay();                    
                }                
            }
        }
示例#23
0
 /// <summary>
 /// Resets the control's state fields to their default value.
 /// </summary>
 private void ResetFields()
 {
     this.currentField = Field.Hours;
     this.currentMode = InputMode.Simple;
     this.allowTimeTypeChange = true;
     this.currentValue = this.Value;
     this.EditingTimeType = this.TimeType;
     this.invalidFormat = false;
     this.LoadResources();
     this.SelectCurrentField();
 }
示例#24
0
文件: CuiTime.cs 项目: rbirkby/mscui
 /// <summary>
 /// Constructs a CuiTime object. 
 /// </summary>
 public CuiTime()
 {
     this.timeValue = DateTime.Now;
     this.timeType = TimeType.Exact;
 }
示例#25
0
 public TransitQueryParameters(Point start, Point end, DateTime dateTime, TimeType timeType)
     : base(start, end)
 {
     this.DateTime = dateTime;
     this.TimeType = timeType;
 }
示例#26
0
        /// <summary>
        /// Handles the key press in txt input when allow time change is true.
        /// </summary>
        /// <param name="e">Key Press Event Argument</param>
        /// <returns>True if the event is handled, else false.</returns>
        private bool HandleAllowTimeChange(KeyPressEventArgs e)
        {
            int temp;
            int selectionStart = this.txtInput.SelectionStart;           
            temp = this.GetNullIndex(this.txtInput.Text.Substring(0, this.txtInput.SelectionStart) + e.KeyChar.ToString());
            if (temp >= 0 && this.IsNullEnabled())
            {
                this.TimeType = TimeType.NullIndex;
                this.NullIndex = temp;
                this.EditingTimeType = TimeType.NullIndex;
                this.allowTimeTypeChange = false;
                if (this.GetNullIndex(this.txtInput.Text.Substring(0, this.txtInput.SelectionStart) + e.KeyChar.ToString(), temp + 1) >= 0)
                {
                    this.SelectToEnd(selectionStart + 1);
                }
                else
                {
                    this.txtInput.SelectionStart = this.txtInput.TextLength;
                }
                                
                e.Handled = true;
                return true;
            }

            return false;            
        }               
示例#27
0
        /// <summary>
        /// Handles the enter event of the child textbox
        /// </summary>
        /// <param name="sender">Object calling the event</param>
        /// <param name="e">Event arguments</param>
        private void TextBox1_Enter(object sender, EventArgs e)
        {
            this.validated = false;
            this.hasFocus = true;
            if (this.focusAfterSpin)
            {
                this.focusAfterSpin = false;
                return;
            }

            this.ResetFields();

            if (this.EditingTimeType == TimeType.Null && this.IsCorrectFormatForExactTime())
            {
                this.EditingTimeType = TimeType.Exact;
            }

            if (this.editingTimeType == TimeType.Exact || this.editingTimeType == TimeType.Approximate)
            {
                this.SetCurrentField();                
            }
            
            this.txtInput.SelectionStart = 0;
            this.txtInput.SelectionLength = this.txtInput.TextLength;            
        }
示例#28
0
 public static string Get(TimeType type, string splitter = "")
 {
     return(DateTime.Now.Get(type, splitter));
 }
示例#29
0
        private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
       {           
           this.inlineEditing = true;
           if (Array.IndexOf(this.allowedSpecialKeys, (int)e.KeyChar) >= 0)
           {
               if ((int)e.KeyChar == 22 && this.txtInput.SelectedText.Length > 0)
               {
                   this.selectedPaste = true;
               }

               this.ExitKeyPressEvent(e, false);
               return;
           }

           if (e.KeyChar == '\r' || e.KeyChar == '\n')
           {
               // Implement lost focus on enter key
               this.TopLevelControl.SelectNextControl(this, true, true, true, true);
               
               // this.ValidateAndUpdateValue();

               this.ExitKeyPressEvent(e, true);
               return;
           }
            
           // If editing time type is null let the user enter values.
           if ((!this.Enabled || this.invalidFormat) && this.editingTimeType != TimeType.Null)
           {
               this.ExitKeyPressEvent(e, true);
               return;
           }

            // Backspace key
           if ((int)e.KeyChar == (int)Keys.Back)
           {
               if (this.currentMode == InputMode.Simple)
               {
                   this.ExitKeyPressEvent(e, true);                              
               }

               // Arithmetic mode
               else
               {
                   this.ExitKeyPressEvent(e, false);
                   this.acceptedKey = true;
               }

               return;
           }

            // Case to handle Null Index Values
            if (e.KeyChar == ' ')
            {
                this.DisplayNullString();
                this.ExitKeyPressEvent(e, true);
                return;
            }

            // case to check whether current input belongs to arithmetic mode
            if (this.IsArithmeticMode(e))
            {
                this.ExitKeyPressEvent(e, false);
                return;
            }

            // case to check whether the entered key leds to some special type.
            // applies to all time type provided time type change is allowed.
            if (this.Functionality == TimeFunctionality.Complex)
            {
                if (this.HandleAllowTimeChange(e))
                {
                    this.ExitKeyPressEvent(e, false);
                }
            }

            // Current editing format is number.            
            if (this.editingTimeType == TimeType.Exact ||
                this.editingTimeType == TimeType.Approximate)
            {
                this.HandleExactTimeInput(e);
                this.ExitKeyPressEvent(e, true);
                return;
            }

            // editing time type is null or null index.
            else 
            {                              
                // we can change the time type. If a digit is pressed accept it and change editingTimeType
                if (this.allowTimeTypeChange)
                {                  
                    // Case for normal digit.
                   if (char.IsDigit(e.KeyChar))
                        {
                            this.SetDisplayText(e.KeyChar.ToString() + "0", "00", "00");
                            this.EditingTimeType = this.chkApprox.Checked ? TimeType.Approximate : TimeType.Exact;
                            this.invalidFormat = false;
                            this.ExitKeyPressEvent(e, true);
                            return;
                        }                    
                }

                // editing time type is null index. we can't change it just check if entered character 
                // matches some null string.                
                else 
                {
                    int tmp = this.GetNullIndex(this.txtInput.Text.Substring(0, this.txtInput.SelectionStart) + e.KeyChar.ToString());                    
                    if (tmp >= 0)
                    {
                        this.NullIndex = tmp;
                    }
                }

                this.ExitKeyPressEvent(e, true);           
            }
        }             
        private void primary_timing(TsipPacket tp)
        {
            Debug.Print(":0x8F.AB (Primary Timing)");

            UInt32 pri_tow = tp.GetNextDWord();
            UInt16 pri_gps_week = tp.GetNextWord();
            Int16 pri_utc_offset = (short)tp.GetNextWord();
            byte time_flags = tp.GetNextByte();
            byte pri_seconds = tp.GetNextByte();
            byte pri_minutes = tp.GetNextByte();
            byte pri_hours = tp.GetNextByte();
            byte pri_day = tp.GetNextByte();
            byte pri_month = tp.GetNextByte();
            UInt16 pri_year = tp.GetNextWord();
            try
            {
                // if this fires an execption, just skip the bad packet
                current_time = new DateTime(pri_year, pri_month, pri_day, pri_hours, pri_minutes, pri_seconds);

                tow = pri_tow;
                utc_offset = pri_utc_offset;
                gps_week = pri_gps_week;

                if ((time_flags & 0x04) == 0x04)
                    time_value = TimeType.NoTimeAvailable;
                else if ((time_flags & 0x08) == 0x08)
                    time_value = TimeType.NoUTCOffset;
                else if ((time_flags & 0x10) == 0x10)
                    time_value = TimeType.UserSetTime;
                else if ((time_flags & 0x01) == 0x01)
                    time_value = TimeType.UTCTimeOk;
                else
                    time_value = TimeType.GPSTimeOk;

                // Set the time on the netduino to the current time on the Thunderbolt.
                Microsoft.SPOT.Hardware.Utility.SetLocalTime(current_time);

                if ((last_current_time != current_time) && (TimeChanged != null))
                    TimeChanged(this, new EventArgs());

                last_current_time = current_time;
            }
            catch (Exception e)
            {
                current_time = last_current_time;
                Debug.Print("Exception:" + e.Message);
            }
        }
示例#31
0
 public Hltb_Rule( string name, float minHours, float maxHours, TimeType timeType ) {
     Name = name;
     MinHours = minHours;
     MaxHours = maxHours;
     TimeType = timeType;
 }
示例#32
0
 public static TIME AsTIME(this TimeSpan span, TZID tzid, TimeType format = TimeType.NONE)
 {
     if (tzid != null)
     {
         if (format == TimeType.Utc) throw new ArgumentException();
         return format == TimeType.LocalAndTimeZone 
             ? new TIME((uint)span.Hours, (uint)span.Minutes, (uint)span.Seconds, format, tzid) 
             : new TIME((uint)span.Hours, (uint)span.Minutes, (uint)span.Seconds);
     }
     return format == TimeType.Utc 
         ? new TIME((uint)span.Hours, (uint)span.Minutes, (uint)span.Seconds, format) 
         : new TIME((uint)span.Hours, (uint)span.Minutes, (uint)span.Seconds);
 }
示例#33
0
        public static IGraph SetTimeType(this IGraph myIGraph, TimeType myTimeType)
        {
            if (myIGraph == null)
                throw new ArgumentNullException("myIGraph must not be null!");

            myIGraph.TimeType = myTimeType;

            return myIGraph;
        }
示例#34
0
        public Time GetTime(TimeType type)
        {
            #region Require

            if(IsDisposed)
            {
                throw new ObjectDisposedException("OutputStream");
            }

            #endregion

            Time t = new Time();

            t.type = (int)type;

            lock(lockObject)
            {
                int result = midiStreamPosition(Handle, ref t, Marshal.SizeOf(typeof(Time)));

                if(result != MidiDeviceException.MMSYSERR_NOERROR)
                {
                    throw new OutputDeviceException(result);
                }
            }

            return t;
        }