コード例 #1
0
            protected override void OnPaint(PaintEventArgs e)
            {
                base.OnPaint(e);
                bool prev       = (index == 0);
                Size parentDims = parent.calendarDims;

                bool     next = (index == parentDims.Width - 1);
                DateTime d    = parent.selectionStart;

                // Note: this is to prevent 31 Dec + 2 being 31 Feb :)
                d = new DateTime(d.Year, d.Month, 1);
                d = d.AddMonths(index - parent.selectedIndex);
                CalendarFlags flags = CalendarFlags.None;

                flags |= (index == 0) ?
                         (CalendarFlags.PrevButton | CalendarFlags.ShowLastMonth)
                                                : CalendarFlags.None;

                flags |= (index == parentDims.Width - 1) ?
                         CalendarFlags.NextButton : CalendarFlags.None;


                flags |= (index == parentDims.Width * parentDims.Height - 1) ?  CalendarFlags.ShowNextMonth : CalendarFlags.None;

                DrawMonth(e.Graphics, d, flags);
            }
コード例 #2
0
 public CalendarEvent(ulong eventId, ObjectGuid ownerGuid, ulong guildId, CalendarEventType type, int textureId, long date, CalendarFlags flags, string title, string description, long lockDate)
 {
     EventId     = eventId;
     OwnerGuid   = ownerGuid;
     GuildId     = guildId;
     EventType   = type;
     TextureId   = textureId;
     Date        = date;
     Flags       = flags;
     LockDate    = lockDate;
     Title       = title;
     Description = description;
 }
コード例 #3
0
        public void LoadFromDB()
        {
            uint count = 0;

            _maxEventId  = 0;
            _maxInviteId = 0;

            //                                              0        1      2      3            4          5          6     7      8
            SQLResult result = DB.Characters.Query("SELECT EventID, Owner, Title, Description, EventType, TextureID, Date, Flags, LockDate FROM calendar_events");

            if (!result.IsEmpty())
            {
                do
                {
                    ulong             eventID     = result.Read <ulong>(0);
                    ObjectGuid        ownerGUID   = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(1));
                    string            title       = result.Read <string>(2);
                    string            description = result.Read <string>(3);
                    CalendarEventType type        = (CalendarEventType)result.Read <byte>(4);
                    int           textureID       = result.Read <int>(5);
                    uint          date            = result.Read <uint>(6);
                    CalendarFlags flags           = (CalendarFlags)result.Read <uint>(7);
                    uint          lockDate        = result.Read <uint>(8);
                    ulong         guildID         = 0;

                    if (flags.HasAnyFlag(CalendarFlags.GuildEvent) || flags.HasAnyFlag(CalendarFlags.WithoutInvites))
                    {
                        guildID = Global.CharacterCacheStorage.GetCharacterGuildIdByGuid(ownerGUID);
                    }

                    CalendarEvent calendarEvent = new CalendarEvent(eventID, ownerGUID, guildID, type, textureID, date, flags, title, description, lockDate);
                    _events.Add(calendarEvent);

                    _maxEventId = Math.Max(_maxEventId, eventID);

                    ++count;
                }while (result.NextRow());
            }

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} calendar events", count);
            count = 0;

            //                                    0         1        2        3       4       5             6               7
            result = DB.Characters.Query("SELECT InviteID, EventID, Invitee, Sender, Status, ResponseTime, ModerationRank, Note FROM calendar_invites");
            if (!result.IsEmpty())
            {
                do
                {
                    ulong                inviteId   = result.Read <ulong>(0);
                    ulong                eventId    = result.Read <ulong>(1);
                    ObjectGuid           invitee    = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(2));
                    ObjectGuid           senderGUID = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(3));
                    CalendarInviteStatus status     = (CalendarInviteStatus)result.Read <byte>(4);
                    uint responseTime           = result.Read <uint>(5);
                    CalendarModerationRank rank = (CalendarModerationRank)result.Read <byte>(6);
                    string note = result.Read <string>(7);

                    CalendarInvite invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, responseTime, status, rank, note);
                    _invites.Add(eventId, invite);

                    _maxInviteId = Math.Max(_maxInviteId, inviteId);

                    ++count;
                }while (result.NextRow());
            }

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} calendar invites", count);

            for (ulong i = 1; i < _maxEventId; ++i)
            {
                if (GetEvent(i) == null)
                {
                    _freeEventIds.Add(i);
                }
            }

            for (ulong i = 1; i < _maxInviteId; ++i)
            {
                if (GetInvite(i) == null)
                {
                    _freeInviteIds.Add(i);
                }
            }
        }
コード例 #4
0
		// Fix: move this into theming API
		private void DrawMonth(Graphics g, DateTime monthDate, CalendarFlags flags)
		{
			UpdateRects(new Point(0,0), monthDate);
			DateTime today=DateTime.Today;
			Size cellSize=parent.cellSize;
			Size numSize=parent.numSize;
			Size textSize=parent.textSize;
			
			Brush enabledBrush, disabledBrush, lightBrush;
	
			enabledBrush = new SolidBrush(SystemColors.ControlText);
			disabledBrush = new SolidBrush(SystemColors.GrayText);
			lightBrush = new SolidBrush(SystemColors.ControlLight);
			
			DateTime startDate = new DateTime(monthDate.Year, monthDate.Month, 1);
			hasSelectedItem = false;
			monthStartPos = -1;
			monthEndPos = -1;
	
			// NOTE: why would someone have two different ways of DayOfWeek
			// and Day enums. So for today the weeks starts with sunday
	
			while(startDate.DayOfWeek != DayOfWeek.Sunday)
			{
				startDate = startDate.AddDays(-1);
			}
	
			firstDateCell = startDate;
							
			g.FillRectangle(lightBrush,titleRect);
	
			String monthString = monthDate.ToString("MMMM");
			String yearString = monthDate.ToString("yyyy");
				
			Font boldFont = new Font(Font, FontStyle.Bold);
				
			g.DrawString(monthString,
				boldFont,
				enabledBrush,
				monthRect.Left,
				monthRect.Top,	
				null);
					
			g.DrawString(yearString,
				boldFont,
				enabledBrush,
				yearRect.Left,
				yearRect.Top,	
				null);

			DateTime weekStart=firstDateCell;
			for(int i=0;i<7;i++)
			{
				int offset=(cellSize.Width-textSize.Width*3)/2;
				g.DrawString(weekStart.ToString("ddd"),
					Font,
					disabledBrush,
					titleRect.Left + cellSize.Width * i + offset,
					titleRect.Bottom,
					null);

				weekStart = weekStart.AddDays(1);
			}
			for(int i=0;i<6*7;i++)
			{
				int day=startDate.Day;
				/* Note: the difference between years cannot be more
					 * than 1 as a MAXIMUM of 7 days will be the difference
					 * between startDate and endDate */
				int monthRelation = (startDate.Year != monthDate.Year) ?
					startDate.Year - monthDate.Year :
					startDate.Month - monthDate.Month;
					
				Brush b = enabledBrush;
					
				if(monthRelation!=0) b = disabledBrush;

				if(monthRelation==0 && monthStartPos==-1) 
				{
					monthStartPos = i;
				}

				if(monthRelation==1 && monthEndPos==-1)
				{
					monthEndPos = i;
				}
	
				int offset= (cellSize.Width - (day > 9 ? 2 : 1) * numSize.Width)/ 2;
	
				Rectangle rect=new Rectangle(dayRect.Left+cellSize.Width * (i%7),
					dayRect.Top+ (i/7) * cellSize.Height,
					cellSize.Width,
					cellSize.Height);
	
				if(monthRelation==0 && startDate >= parent.selectionStart 
					&& startDate <= parent.selectionEnd)
				{
					hasSelectedItem = true;
					g.FillRectangle(lightBrush, rect);
				}
				if(monthRelation==0 && startDate == today)
				{
					using(Pen redPen = new Pen(Color.Red, 1.0f))
					{
						rect.Size+=new Size(-1,0);
						g.DrawRectangle(redPen, rect);
					}
				}
				if(monthRelation==0 
					||	((monthRelation < 0) && ((flags & CalendarFlags.ShowLastMonth) != 0)) 
					||  ((monthRelation > 0) &&	((flags & CalendarFlags.ShowNextMonth) != 0)))
				{
					Font font = IsBolded(startDate) ? boldFont : Font ;

					g.DrawString(day.ToString(),
						font,
						b,
						rect.Left + offset,
						rect.Top,	
						null);
					posHasDate[i]=true;
				}
				else
				{
					posHasDate[i]=false;
				}
				startDate=startDate.AddDays(1);
				
				boldFont.Dispose();

				if((flags & CalendarFlags.PrevButton) != 0)
				{
					ControlPaint.DrawScrollButton(g, 
						prevBtnRect, ScrollButton.Left, 
						ButtonState.Flat);
				}
	
				if((flags & CalendarFlags.NextButton) != 0)
				{
					ControlPaint.DrawScrollButton(g, 
						nextBtnRect, ScrollButton.Right, 
						ButtonState.Flat);
				}
			}
	
			lightBrush.Dispose();
			enabledBrush.Dispose();
			disabledBrush.Dispose();
		}
コード例 #5
0
 public CalendarSettings(CalendarFlags flags, int reminderTime)
 {
     this.settingsFlags       = flags;
     this.defaultReminderTime = reminderTime;
 }
コード例 #6
0
            // Fix: move this into theming API
            private void DrawMonth(Graphics g, DateTime monthDate, CalendarFlags flags)
            {
                UpdateRects(new Point(0, 0), monthDate);
                DateTime today    = DateTime.Today;
                Size     cellSize = parent.cellSize;
                Size     numSize  = parent.numSize;
                Size     textSize = parent.textSize;

                Brush enabledBrush, disabledBrush, lightBrush;

                enabledBrush  = new SolidBrush(SystemColors.ControlText);
                disabledBrush = new SolidBrush(SystemColors.GrayText);
                lightBrush    = new SolidBrush(SystemColors.ControlLight);

                DateTime startDate = new DateTime(monthDate.Year, monthDate.Month, 1);

                hasSelectedItem = false;
                monthStartPos   = -1;
                monthEndPos     = -1;

                // NOTE: why would someone have two different ways of DayOfWeek
                // and Day enums. So for today the weeks starts with sunday

                while (startDate.DayOfWeek != DayOfWeek.Sunday)
                {
                    startDate = startDate.AddDays(-1);
                }

                firstDateCell = startDate;

                g.FillRectangle(lightBrush, titleRect);

                String monthString = monthDate.ToString("MMMM");
                String yearString  = monthDate.ToString("yyyy");

                Font boldFont = new Font(Font, FontStyle.Bold);

                g.DrawString(monthString,
                             boldFont,
                             enabledBrush,
                             monthRect.Left,
                             monthRect.Top,
                             null);

                g.DrawString(yearString,
                             boldFont,
                             enabledBrush,
                             yearRect.Left,
                             yearRect.Top,
                             null);

                DateTime weekStart = firstDateCell;

                for (int i = 0; i < 7; i++)
                {
                    int offset = (cellSize.Width - textSize.Width * 3) / 2;
                    g.DrawString(weekStart.ToString("ddd"),
                                 Font,
                                 disabledBrush,
                                 titleRect.Left + cellSize.Width * i + offset,
                                 titleRect.Bottom,
                                 null);

                    weekStart = weekStart.AddDays(1);
                }
                for (int i = 0; i < 6 * 7; i++)
                {
                    int day = startDate.Day;

                    /* Note: the difference between years cannot be more
                     * than 1 as a MAXIMUM of 7 days will be the difference
                     * between startDate and endDate */
                    int monthRelation = (startDate.Year != monthDate.Year) ?
                                        startDate.Year - monthDate.Year :
                                        startDate.Month - monthDate.Month;

                    Brush b = enabledBrush;

                    if (monthRelation != 0)
                    {
                        b = disabledBrush;
                    }

                    if (monthRelation == 0 && monthStartPos == -1)
                    {
                        monthStartPos = i;
                    }

                    if (monthRelation == 1 && monthEndPos == -1)
                    {
                        monthEndPos = i;
                    }

                    int offset = (cellSize.Width - (day > 9 ? 2 : 1) * numSize.Width) / 2;

                    Rectangle rect = new Rectangle(dayRect.Left + cellSize.Width * (i % 7),
                                                   dayRect.Top + (i / 7) * cellSize.Height,
                                                   cellSize.Width,
                                                   cellSize.Height);

                    if (monthRelation == 0 && startDate >= parent.selectionStart &&
                        startDate <= parent.selectionEnd)
                    {
                        hasSelectedItem = true;
                        g.FillRectangle(lightBrush, rect);
                    }
                    if (monthRelation == 0 && startDate == today)
                    {
                        using (Pen redPen = new Pen(Color.Red, 1.0f))
                        {
                            rect.Size += new Size(-1, 0);
                            g.DrawRectangle(redPen, rect);
                        }
                    }
                    if (monthRelation == 0 ||
                        ((monthRelation < 0) && ((flags & CalendarFlags.ShowLastMonth) != 0)) ||
                        ((monthRelation > 0) && ((flags & CalendarFlags.ShowNextMonth) != 0)))
                    {
                        Font font = IsBolded(startDate) ? boldFont : Font;

                        g.DrawString(day.ToString(),
                                     font,
                                     b,
                                     rect.Left + offset,
                                     rect.Top,
                                     null);
                        posHasDate[i] = true;
                    }
                    else
                    {
                        posHasDate[i] = false;
                    }
                    startDate = startDate.AddDays(1);

                    boldFont.Dispose();

                    if ((flags & CalendarFlags.PrevButton) != 0)
                    {
                        ControlPaint.DrawScrollButton(g,
                                                      prevBtnRect, ScrollButton.Left,
                                                      ButtonState.Flat);
                    }

                    if ((flags & CalendarFlags.NextButton) != 0)
                    {
                        ControlPaint.DrawScrollButton(g,
                                                      nextBtnRect, ScrollButton.Right,
                                                      ButtonState.Flat);
                    }
                }

                lightBrush.Dispose();
                enabledBrush.Dispose();
                disabledBrush.Dispose();
            }