protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ActiveNotifications.DataSource = NotificationService.LoadActiveNotifications(SessionVariable.Current.Company.Id) .OrderByDescending(x => x.StartDate).ToList(); ActiveNotifications.DataBind(); var activeCourses = EnrolService.LoadActiveEnrollments(SessionVariable.Current.User.Id).OrderBy(x => x.Session.Course.Name); ActiveCourses.DataSource = activeCourses; ActiveCourses.DataBind(); if (activeCourses.Count() == 0) { Panel1.Visible = false; } Panel2.Visible = false; var newCourses = SessionService.LoadNewSessions(SessionVariable.Current.Company.Id, SessionVariable.Current.User.UserType).OrderBy(x => x.Course.Name); NewCourses.DataSource = newCourses; NewCourses.DataBind(); if (newCourses.Count() == 0) { Panel3.Visible = false; } } }
internal ActiveNotification(INotification handle, int duration) { // Initialize properties Handle = handle; Duration = duration; OffsetX = -200; ContentScale = 1; // Initialize rendering #region Text HeaderText = new Text(Handle.HeaderText, new FontDescription { FaceName = Handle.FontName, Height = TextHeight, Quality = FontQuality.Antialiased, Weight = FontWeight.Medium }) { Color = Handle.HeaderColor, DrawFlags = FontDrawFlags.WordBreak | FontDrawFlags.Right }; ContentText = new Text(Handle.ContentText, new FontDescription { FaceName = Handle.FontName, Height = TextHeight, Quality = FontQuality.Antialiased, Weight = FontWeight.Medium }) { Color = Handle.ContentColor, DrawFlags = FontDrawFlags.WordBreak | FontDrawFlags.Right }; #endregion #region Sprite if (Handle.Texture.Header != null) { Header = new Sprite(Handle.Texture.Header.Texture); } if (Handle.Texture.Content != null) { Content = new Sprite(Handle.Texture.Content.Texture); } if (Handle.Texture.Footer != null) { Footer = new Sprite(Handle.Texture.Footer.Texture); } #endregion Task.Run(() => { // Get max width var maxX = 0; var maxY = 0; foreach (var texture in new[] { Handle.Texture.Header, Handle.Texture.Content, Handle.Texture.Footer }.Where(texture => texture != null)) { int width; int height; if (texture.SourceRectangle.HasValue) { width = texture.SourceRectangle.Value.Width; height = texture.SourceRectangle.Value.Height; } else { var desc = texture.Texture().GetLevelDescription(0); width = desc.Width; height = desc.Height; } if (maxX < width) { maxX = width; } if (maxY < height) { maxY = height; } } // Set width and height Width = maxX; Height = maxY; // Calculate text height var boundingRect = HeaderText.MeasureBounding(Handle.HeaderText, new Rectangle(0, 0, Width - (int)TextOuterPadding.X * 2, MaxNotificationHeight - (int)TextOuterPadding.Y * 2), HeaderText.DrawFlags); HeaderText.Size = new Vector2(boundingRect.Width, boundingRect.Height); boundingRect = ContentText.MeasureBounding(Handle.ContentText, new Rectangle(0, 0, Width - (int)TextOuterPadding.X * 2, MaxNotificationHeight - (int)TextOuterPadding.Y * 2 - boundingRect.Height - HeaderToContentSpace), ContentText.DrawFlags); ContentText.Size = new Vector2(boundingRect.Width, boundingRect.Height); var notificationHeight = TextOuterPadding.Y * 2 + HeaderText.Size.Y + ContentText.Size.Y + HeaderToContentSpace; if (notificationHeight > maxY) { // Override height Height = (int)Math.Ceiling(notificationHeight); if (Handle.Texture.Content != null) { var relativeHeight = Height; if (Handle.Texture.Header != null) { if (Handle.Texture.Header.SourceRectangle.HasValue) { relativeHeight -= Handle.Texture.Header.SourceRectangle.Value.Height; } else { relativeHeight -= Handle.Texture.Header.Texture().GetLevelDescription(0).Height; } } if (Handle.Texture.Footer != null) { if (Handle.Texture.Footer.SourceRectangle.HasValue) { relativeHeight -= Handle.Texture.Footer.SourceRectangle.Value.Height; } else { relativeHeight -= Handle.Texture.Footer.Texture().GetLevelDescription(0).Height; } } var contentHeight = Handle.Texture.Content.SourceRectangle.HasValue ? Handle.Texture.Content.SourceRectangle.Value.Height : Handle.Texture.Content.Texture().GetLevelDescription(0).Height; // Set content scaling ContentScale = (float)relativeHeight / contentHeight; } } lock (ActiveNotifications) { // Set notification index Index = (ActiveNotifications.Where(o => !o.IsFadingOut).Max(o => (int?)o.Index) ?? 0) + 1; // Set notification position PositionY = GetIndexY(Index); } // Set the start tick StartTick = Core.GameTickCount; _initialized = true; }); }