Ejemplo n.º 1
0
    /// <summary>
    /// 设置状态
    /// </summary>
    /// <param name="status"></param>
    public void SetStatus(DayEnum status)
    {
        if (tvStatus == null)
        {
            return;
        }
        string statusStr = "";

        switch (status)
        {
        case DayEnum.None:
            break;

        case DayEnum.Work:
            statusStr      = TextHandler.Instance.manager.GetTextById(72);
            tvStatus.color = Color.green;
            break;

        case DayEnum.Rest:
            statusStr      = TextHandler.Instance.manager.GetTextById(73);
            tvStatus.color = Color.red;
            break;
        }
        tvStatus.text = statusStr;
    }
Ejemplo n.º 2
0
        private static void OnDayChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            UTimeControl control = obj as UTimeControl;
            DayEnum      d       = (DayEnum)e.NewValue;

            control.cbxDay.Content = CUtil.DayEnumToString(d);
            control.grbBox.Header  = CUtil.DayEnumToString(d);
        }
Ejemplo n.º 3
0
 public void NextDay()
 {
     if (Day == DayEnum.Sunday)
     {
         Day = DayEnum.Monday;
         return;
     }
     Day++;
 }
Ejemplo n.º 4
0
    /// <summary>
    /// 设置按天状态
    /// </summary>
    /// <param name="dayStauts"></param>
    public void SetDayStatus(DayEnum dayStauts)
    {
        this.dayStauts = dayStauts;
        switch (dayStauts)
        {
        case DayEnum.Work:
            notifyForTime?.Invoke(NotifyTypeEnum.StartWork, -1);
            break;

        case DayEnum.Rest:
            notifyForTime?.Invoke(NotifyTypeEnum.StartRest, -1);
            break;
        }
    }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            // Monday is day #1.
            DayEnum someDay   = DayEnum.Wed;
            int     dayNumber = (int)someDay;

            Console.WriteLine("{0} is day # {1}.", someDay, dayNumber);

            // Mar is the 3rd month in the year!
            MonthEnum someMonth   = MonthEnum.Mar;
            int       monthNumber = (int)someMonth;

            Console.WriteLine("{0} is the {1}rd month in the year!", someMonth, monthNumber);

            // Monday: 1 Friday: 5
            int weekDayStart = (int)DayEnum.Mon;
            int weekDayEnd   = (int)DayEnum.Fri;

            Console.WriteLine("Monday: {0}", weekDayStart);
            Console.WriteLine("Friday: {0}", weekDayEnd);

            // getname
            string day = Enum.GetName(typeof(DayEnum), 3);

            Console.WriteLine(day);
            // string days = Enum.GetNames(typeof(DayEnum));
            // Console.WriteLine(string.Join(" ", days));

            // Switch

            switch (someDay)
            {
            case DayEnum.Sun:
                Console.WriteLine("Sunday!");
                break;

            case DayEnum.Mon:
                Console.WriteLine("Monday:(");
                break;

            case DayEnum.Tue:
                Console.WriteLine("Tuesday");
                break;

            default:
                Console.WriteLine("Unknown day");
                break;
            }
        }
Ejemplo n.º 6
0
        public void TestSinglePrimitives()
        {
            // protocol level 2
            Pickler p = new Pickler(false);

            byte[] o = p.dumps(null);   // none
            Assert.Equal(B("N"), o);
            o = p.dumps('@');           // char --> string
            Assert.Equal(B("X\u0001\u0000\u0000\u0000@"), o);
            o = p.dumps(true);          // bool
            Assert.Equal(B("\u0088"), o);
            o = p.dumps("hello");       // unicode string
            Assert.Equal(B("X\u0005\u0000\u0000\u0000hello"), o);
            o = p.dumps("hello\u20ac"); // unicode string with non ascii
            Assert.Equal(B("X\u0008\u0000\u0000\u0000hello\u00e2\u0082\u00ac"), o);
            o = p.dumps((byte)'@');
            Assert.Equal(B("K@"), o);
            o = p.dumps((sbyte)-40);
            Assert.Equal(B(new byte[] { (byte)'J', 0xd8, 0xff, 0xff, 0xff }), o);
            o = p.dumps((short)-0x1234);
            Assert.Equal(B("J\u00cc\u00ed\u00ff\u00ff"), o);
            o = p.dumps((ushort)0xf234);
            Assert.Equal(B("M\u0034\u00f2"), o);
            o = p.dumps(-0x12345678);
            Assert.Equal(B("J\u0088\u00a9\u00cb\u00ed"), o);
            o = p.dumps((uint)0x12345678);
            Assert.Equal(B(new byte[] { (byte)'J', 0x78, 0x56, 0x34, 0x12 }), o);
            o = p.dumps(0xf2345678);
            Assert.Equal(B("I4063516280\n"), o);
            o = p.dumps(0x12345678abcdefL);
            Assert.Equal(B("I5124095577148911\n"), o);
            o = p.dumps(1234.5678d);
            Assert.Equal(B(new byte[] { (byte)'G', 0x40, 0x93, 0x4a, 0x45, 0x6d, 0x5c, 0xfa, 0xad }), o);
            o = p.dumps(1234.5f);
            Assert.Equal(B(new byte[] { (byte)'G', 0x40, 0x93, 0x4a, 0, 0, 0, 0, 0 }), o);
            o = p.dumps(1234.9876543210987654321m);
            Assert.Equal(B("cdecimal\nDecimal\nX\u0018\u0000\u0000\u00001234.9876543210987654321\u0085R"), o);

            const DayEnum day = DayEnum.Wednesday;

            o = p.dumps(day);   // enum is returned as just a string representing the value
            Assert.Equal(B("X\u0009\u0000\u0000\u0000Wednesday"), o);


            o = p.dumps("tshirt👕");                  // t-shirt U+1f455
            Assert.Equal(B("X\n\u0000\u0000\u0000tshirt\u00f0\u009f\u0091\u0095"), o);
        }
Ejemplo n.º 7
0
        public EventOption(string paper, string paperName, string input)
        {
            string[] splitInput = input.Split(',');
            this.paper     = paper;
            this.paperName = paperName;

            day = ToDay(splitInput[0]);

            if (splitInput[1].Contains('-'))
            {
                startTime = Convert.ToInt32(splitInput[1].Split('-')[0].Split(':')[0]);
                endTime   = Convert.ToInt32(splitInput[1].Split('-')[1].Split(':')[0]);
                duration  = endTime - startTime;
            }

            fullLocation = splitInput[2];
            if (fullLocation[0] == ' ')
            {
                fullLocation = fullLocation.Replace(" ", "");
            }
            block = fullLocation.Split('.')[0];
            string tempFloor = fullLocation.Split('.')[1].Replace(" ", "");

            if (tempFloor == "G")
            {
                floor = 0;
            }
            else if (tempFloor == "B")
            {
                floor = -1;
            }
            else
            {
                floor = Convert.ToInt32(tempFloor);
            }
            room = Convert.ToInt32(fullLocation.Split('.')[2]);

            name = splitInput[3];
            if (name[0] == ' ')
            {
                name = name.Substring(1, name.Length - 1);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Converts a DayEnum value to a corresponding string value
        /// </summary>
        /// <param name="enumValue">The DayEnum value to convert</param>
        /// <returns>The representative string value</returns>
        public static string ToValue(DayEnum enumValue)
        {
            switch (enumValue)
            {
            //only valid enum elements can be used
            //this is necessary to avoid errors
            case DayEnum.MONDAY:
            case DayEnum.TUESDAY:
            case DayEnum.WEDNESDAY:
            case DayEnum.THURSDAY:
            case DayEnum.FRIDAY:
            case DayEnum.SATURDAY:
            case DayEnum.SUNDAY:
                return(StringValues[(int)enumValue]);

            //an invalid enum value was requested
            default:
                return(null);
            }
        }
Ejemplo n.º 9
0
        public void testSinglePrimitives()
        {
            // protocol level 2
            Pickler p = new Pickler(false);

            byte[] o = p.dumps(null);   // none
            Assert.AreEqual(B("N"), o);
            o = p.dumps('@');           // char --> string
            Assert.AreEqual(B("X\u0001\u0000\u0000\u0000@"), o);
            o = p.dumps(true);          // bool
            Assert.AreEqual(B("\u0088"), o);
            o = p.dumps("hello");       // unicode string
            Assert.AreEqual(B("X\u0005\u0000\u0000\u0000hello"), o);
            o = p.dumps("hello\u20ac"); // unicode string with non ascii
            Assert.AreEqual(B("X\u0008\u0000\u0000\u0000hello\u00e2\u0082\u00ac"), o);
            o = p.dumps((byte)'@');
            Assert.AreEqual(B("K@"), o);
            o = p.dumps((sbyte)-40);
            Assert.AreEqual(B(new byte[] { (byte)'J', 0xd8, 0xff, 0xff, 0xff }), o);
            o = p.dumps((short)-0x1234);
            Assert.AreEqual(B("J\u00cc\u00ed\u00ff\u00ff"), o);
            o = p.dumps((ushort)0xf234);
            Assert.AreEqual(B("M\u0034\u00f2"), o);
            o = p.dumps((int)-0x12345678);
            Assert.AreEqual(B("J\u0088\u00a9\u00cb\u00ed"), o);
            o = p.dumps((uint)0x12345678);
            Assert.AreEqual(B(new byte[] { (byte)'J', 0x78, 0x56, 0x34, 0x12 }), o);
            o = p.dumps((uint)0xf2345678);
            Assert.AreEqual(B("I4063516280\n"), o);
            o = p.dumps((long)0x12345678abcdefL);
            Assert.AreEqual(B("I5124095577148911\n"), o);
            o = p.dumps(1234.5678d);
            Assert.AreEqual(B(new byte[] { (byte)'G', 0x40, 0x93, 0x4a, 0x45, 0x6d, 0x5c, 0xfa, 0xad }), o);
            o = p.dumps(1234.5f);
            Assert.AreEqual(B(new byte[] { (byte)'G', 0x40, 0x93, 0x4a, 0, 0, 0, 0, 0 }), o);

            DayEnum day = DayEnum.WEDNESDAY;

            o = p.dumps(day);   // enum is returned as just a string representing the value
            Assert.AreEqual(B("X\u0009\u0000\u0000\u0000WEDNESDAY"), o);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Body10" /> class.
 /// </summary>
 /// <param name="day">day (required).</param>
 /// <param name="email">email (required).</param>
 /// <param name="month">month (required).</param>
 /// <param name="year">year (required).</param>
 public Body10(DayEnum day = default(DayEnum), string email = default(string), MonthEnum month = default(MonthEnum), YearEnum year = default(YearEnum))
 {
     // to ensure "day" is required (not null)
     if (day == null)
     {
         throw new InvalidDataException("day is a required property for Body10 and cannot be null");
     }
     else
     {
         this.Day = day;
     }
     // to ensure "email" is required (not null)
     if (email == null)
     {
         throw new InvalidDataException("email is a required property for Body10 and cannot be null");
     }
     else
     {
         this.Email = email;
     }
     // to ensure "month" is required (not null)
     if (month == null)
     {
         throw new InvalidDataException("month is a required property for Body10 and cannot be null");
     }
     else
     {
         this.Month = month;
     }
     // to ensure "year" is required (not null)
     if (year == null)
     {
         throw new InvalidDataException("year is a required property for Body10 and cannot be null");
     }
     else
     {
         this.Year = year;
     }
 }
Ejemplo n.º 11
0
 public static IEnumerable<DateTime> DayInYear(MonthEnum month, DayEnum day)
 {
     foreach (var year in EveryYear())
     {
         if (HaveDay(year, month, day))
             yield return GetDayInYear(year, month, day);
     }
 }
Ejemplo n.º 12
0
 public static bool HaveMoreDaysThan(DateTime month, DayEnum day)
 {
     return DateTime.DaysInMonth(month.Year, month.Month) >= (int)day;
 }
Ejemplo n.º 13
0
 public Weekday(DayEnum day)
 {
     Day = day;
 }
Ejemplo n.º 14
0
 public static DateTime GetDayInMonth(DateTime month, DayEnum day)
 {
     return new DateTime(month.Year, month.Month, (int)day);
 }
Ejemplo n.º 15
0
 private static bool HaveDay(DateTime year, MonthEnum month, DayEnum day)
 {
     return DateTime.DaysInMonth(year.Year, (int)month) >= (int)day;
 }
Ejemplo n.º 16
0
 private static DateTime GetDayInYear(DateTime year, MonthEnum month, DayEnum day)
 {
     return new DateTime(year.Year, (int)month, (int)day);
 }
Ejemplo n.º 17
0
 private static DateTime GetDayInChineseYear(int year, int monthIndex, DayEnum day)
 {
     return chineseCalendar.ToDateTime(year, monthIndex, (int)day, 0, 0, 0, 0);
 }
Ejemplo n.º 18
0
        public static IEnumerable<DateTime> DayInChineseYear(MonthEnum month, DayEnum day)
        {
            foreach (var dt in EveryYear())
            {
                var year = dt.Year -1;
                var monthIndex = (int)month;

                //如果有闰月,则只返回第一个
                var leapMonth = chineseCalendar.GetLeapMonth(year);//返回的是闰月加1
                if (leapMonth != 0 && leapMonth <= monthIndex)
                    monthIndex++;

                if (Chinese_HaveMoreDaysThan(year, monthIndex, day))
                    yield return GetDayInChineseYear(year, monthIndex, day);
            }
        }
Ejemplo n.º 19
0
 private static bool Chinese_HaveMoreDaysThan(int year, int month, DayEnum day)
 {
     return chineseCalendar.GetDaysInMonth(year, month) >= (int)day;
 }
Ejemplo n.º 20
0
 public DayModel(DayEnum Day1) : this()
 {
     this.Day1 = Day1;
 }