diff --git a/Source/Menu/MainForm.Designer.cs b/Source/Menu/MainForm.Designer.cs index 76663bd221..8d13f1bae1 100644 --- a/Source/Menu/MainForm.Designer.cs +++ b/Source/Menu/MainForm.Designer.cs @@ -100,16 +100,19 @@ private void InitializeComponent() this.contextMenuStripTools = new System.Windows.Forms.ContextMenuStrip(this.components); this.linkLabelChangeLog = new System.Windows.Forms.LinkLabel(); this.contextMenuStripDocuments = new System.Windows.Forms.ContextMenuStrip(this.components); - this.pbNotifications = new System.Windows.Forms.PictureBox(); + this.pbNotificationsNone = new System.Windows.Forms.PictureBox(); this.pictureBoxLogo = new System.Windows.Forms.PictureBox(); + this.pbNotificationsSome = new System.Windows.Forms.PictureBox(); + this.lblNotificationCount = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox3.SuspendLayout(); this.panel1.SuspendLayout(); this.panelModeActivity.SuspendLayout(); this.panelModeTimetable.SuspendLayout(); this.contextMenuStripTools.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pbNotifications)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pbNotificationsNone)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLogo)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pbNotificationsSome)).BeginInit(); this.SuspendLayout(); // // buttonStart @@ -887,16 +890,16 @@ private void InitializeComponent() this.contextMenuStripDocuments.Name = "contextMenuStripDocuments"; this.contextMenuStripDocuments.Size = new System.Drawing.Size(61, 4); // - // pbNotifications + // pbNotificationsNone // - this.pbNotifications.Image = global::ORTS.Properties.Resources.chat_icon_no_message_transparent; - this.pbNotifications.InitialImage = ((System.Drawing.Image)(resources.GetObject("pbNotifications.InitialImage"))); - this.pbNotifications.Location = new System.Drawing.Point(805, 0); - this.pbNotifications.Name = "pbNotifications"; - this.pbNotifications.Size = new System.Drawing.Size(37, 31); - this.pbNotifications.TabIndex = 40; - this.pbNotifications.TabStop = false; - this.pbNotifications.Click += new System.EventHandler(this.pbNotifications_Click); + this.pbNotificationsNone.Image = global::ORTS.Properties.Resources.chat_icon_no_message_transparent; + this.pbNotificationsNone.InitialImage = ((System.Drawing.Image)(resources.GetObject("pbNotificationsNone.InitialImage"))); + this.pbNotificationsNone.Location = new System.Drawing.Point(805, 0); + this.pbNotificationsNone.Name = "pbNotificationsNone"; + this.pbNotificationsNone.Size = new System.Drawing.Size(37, 31); + this.pbNotificationsNone.TabIndex = 40; + this.pbNotificationsNone.TabStop = false; + this.pbNotificationsNone.Click += new System.EventHandler(this.pbNotificationsNone_Click); // // pictureBoxLogo // @@ -909,12 +912,38 @@ private void InitializeComponent() this.pictureBoxLogo.TabIndex = 5; this.pictureBoxLogo.TabStop = false; // + // pbNotificationsSome + // + this.pbNotificationsSome.BackColor = System.Drawing.Color.Transparent; + this.pbNotificationsSome.Image = global::ORTS.Properties.Resources.chat_icon_new_message_transparent; + this.pbNotificationsSome.Location = new System.Drawing.Point(805, 0); + this.pbNotificationsSome.Name = "pbNotificationsSome"; + this.pbNotificationsSome.Size = new System.Drawing.Size(37, 31); + this.pbNotificationsSome.TabIndex = 41; + this.pbNotificationsSome.TabStop = false; + this.pbNotificationsSome.Click += new System.EventHandler(this.pbNotificationsSome_Click); + // + // lblNotificationCount + // + this.lblNotificationCount.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(234)))), ((int)(((byte)(0)))), ((int)(((byte)(6))))); + this.lblNotificationCount.Font = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblNotificationCount.ForeColor = System.Drawing.Color.White; + this.lblNotificationCount.Location = new System.Drawing.Point(827, 3); + this.lblNotificationCount.Name = "lblNotificationCount"; + this.lblNotificationCount.Size = new System.Drawing.Size(8, 8); + this.lblNotificationCount.TabIndex = 42; + this.lblNotificationCount.Text = "1"; + this.lblNotificationCount.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.lblNotificationCount.Click += new System.EventHandler(this.lblNotificationCount_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(854, 548); - this.Controls.Add(this.pbNotifications); + this.Controls.Add(this.lblNotificationCount); + this.Controls.Add(this.pbNotificationsSome); + this.Controls.Add(this.pbNotificationsNone); this.Controls.Add(this.linkLabelChangeLog); this.Controls.Add(this.panelModeTimetable); this.Controls.Add(this.panelModeActivity); @@ -950,8 +979,9 @@ private void InitializeComponent() this.panelModeTimetable.ResumeLayout(false); this.panelModeTimetable.PerformLayout(); this.contextMenuStripTools.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pbNotifications)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pbNotificationsNone)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxLogo)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pbNotificationsSome)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -1027,6 +1057,8 @@ private void InitializeComponent() private System.Windows.Forms.Button buttonStartMP; private System.Windows.Forms.Label labelTimetableWeatherFile; private System.Windows.Forms.ComboBox comboBoxTimetableWeatherFile; - private System.Windows.Forms.PictureBox pbNotifications; + private System.Windows.Forms.PictureBox pbNotificationsNone; + private System.Windows.Forms.PictureBox pbNotificationsSome; + private System.Windows.Forms.Label lblNotificationCount; } } diff --git a/Source/Menu/MainForm.cs b/Source/Menu/MainForm.cs index d1aa04aab4..3881c6e9e4 100644 --- a/Source/Menu/MainForm.cs +++ b/Source/Menu/MainForm.cs @@ -1107,24 +1107,31 @@ void ShowTimetableEnvironment() void ShowDetails() { Win32.LockWindowUpdate(Handle); - ClearDetails(); + ClearPanel(); + AddDetails(); + FlowDetails(); + Win32.LockWindowUpdate(IntPtr.Zero); + } + + private void AddDetails() + { if (SelectedRoute != null && SelectedRoute.Description != null) - ShowDetail(catalog.GetStringFmt("Route: {0}", SelectedRoute.Name), SelectedRoute.Description.Split('\n')); + AddDetail(catalog.GetStringFmt("Route: {0}", SelectedRoute.Name), SelectedRoute.Description.Split('\n')); if (radioButtonModeActivity.Checked) { if (SelectedConsist != null && SelectedConsist.Locomotive != null && SelectedConsist.Locomotive.Description != null) { - ShowDetail(catalog.GetStringFmt("Locomotive: {0}", SelectedConsist.Locomotive.Name), SelectedConsist.Locomotive.Description.Split('\n')); + AddDetail(catalog.GetStringFmt("Locomotive: {0}", SelectedConsist.Locomotive.Name), SelectedConsist.Locomotive.Description.Split('\n')); } if (SelectedActivity != null && SelectedActivity.Description != null) { - ShowDetail(catalog.GetStringFmt("Activity: {0}", SelectedActivity.Name), SelectedActivity.Description.Split('\n')); - ShowDetail(catalog.GetString("Activity Briefing"), SelectedActivity.Briefing.Split('\n')); + AddDetail(catalog.GetStringFmt("Activity: {0}", SelectedActivity.Name), SelectedActivity.Description.Split('\n')); + AddDetail(catalog.GetString("Activity Briefing"), SelectedActivity.Briefing.Split('\n')); } else if (SelectedPath != null) { - ShowDetail(catalog.GetStringFmt("Path: {0}", SelectedPath.Name), new[] { + AddDetail(catalog.GetStringFmt("Path: {0}", SelectedPath.Name), new[] { catalog.GetStringFmt("Starting at: {0}", SelectedPath.Start), catalog.GetStringFmt("Heading to: {0}", SelectedPath.End) }); @@ -1133,29 +1140,26 @@ void ShowDetails() if (radioButtonModeTimetable.Checked) { if (SelectedTimetableSet != null) - ShowDetail(catalog.GetStringFmt("Timetable set: {0}", SelectedTimetableSet), new string[0]); - // Description not shown as no description is available for a timetable set. + AddDetail(catalog.GetStringFmt("Timetable set: {0}", SelectedTimetableSet), new string[0]); + // Description not shown as no description is available for a timetable set. if (SelectedTimetable != null) - ShowDetail(catalog.GetStringFmt("Timetable: {0}", SelectedTimetable), SelectedTimetable.Briefing.Split('\n')); + AddDetail(catalog.GetStringFmt("Timetable: {0}", SelectedTimetable), SelectedTimetable.Briefing.Split('\n')); if (SelectedTimetableTrain != null) { - ShowDetail(catalog.GetStringFmt("Train: {0}", SelectedTimetableTrain), HideStartParameters(SelectedTimetableTrain.ToInfo())); + AddDetail(catalog.GetStringFmt("Train: {0}", SelectedTimetableTrain), HideStartParameters(SelectedTimetableTrain.ToInfo())); if (SelectedTimetableConsist != null) { - ShowDetail(catalog.GetStringFmt("Consist: {0}", SelectedTimetableConsist.Name), new string[0]); + AddDetail(catalog.GetStringFmt("Consist: {0}", SelectedTimetableConsist.Name), new string[0]); if (SelectedTimetableConsist.Locomotive != null && SelectedTimetableConsist.Locomotive.Description != null) - ShowDetail(catalog.GetStringFmt("Locomotive: {0}", SelectedTimetableConsist.Locomotive.Name), SelectedTimetableConsist.Locomotive.Description.Split('\n')); + AddDetail(catalog.GetStringFmt("Locomotive: {0}", SelectedTimetableConsist.Locomotive.Name), SelectedTimetableConsist.Locomotive.Description.Split('\n')); } if (SelectedTimetablePath != null) - ShowDetail(catalog.GetStringFmt("Path: {0}", SelectedTimetablePath.Name), SelectedTimetablePath.ToInfo()); + AddDetail(catalog.GetStringFmt("Path: {0}", SelectedTimetablePath.Name), SelectedTimetablePath.ToInfo()); } } - - FlowDetails(); - Win32.LockWindowUpdate(IntPtr.Zero); } /// @@ -1194,14 +1198,14 @@ public Detail(Control title, Control expander, Control summary, Control lines) } } - void ClearDetails() + void ClearPanel() { Details.Clear(); while (panelDetails.Controls.Count > 0) panelDetails.Controls.RemoveAt(0); } - void ShowDetail(string title, string[] lines) + void AddDetail(string title, string[] lines) { var titleControl = new Label { Margin = new Padding(2), Text = title, UseMnemonic = false, Font = new Font(panelDetails.Font, FontStyle.Bold), TextAlign = ContentAlignment.BottomLeft }; panelDetails.Controls.Add(titleControl); @@ -1225,7 +1229,7 @@ void ShowDetail(string title, string[] lines) summaryControl.Width = panelDetails.ClientSize.Width - summaryControl.Margin.Horizontal; summaryControl.Height = TextRenderer.MeasureText("1\n2\n3\n4\n5", summaryControl.Font).Height; - // Find out where we need to cut the text to make the summary 5 lines long. Uses a binaty search to find the cut point. + // Find out where we need to cut the text to make the summary 5 lines long. Uses a binary search to find the cut point. var size = MeasureText(summaryControl.Text, summaryControl); if (size > summaryControl.Height) { @@ -1463,68 +1467,77 @@ void comboBoxTimetable_EnabledChanged(object sender, EventArgs e) } #region Notifications + // Will probably move this region and the Details region into separate files. - bool IsNotificationsVisible = false; + bool AreNotificationsVisible = false; + int NewNotificationCount = 1; + int LastNotificationViewed = 0; List NotificationList = new List(); class Notification { - //readonly Control Title; - //readonly Control Expander; - //readonly Control Summary; - //readonly Control Description; - //bool Expanded; - //Notification(Control title, Control expander, Control summary, Control lines) - //{ - // Title = title; - // Expander = expander; - // Summary = summary; - // Description = lines; - // Expanded = false; - //} } - void ClearNotifications() + private void pbNotificationsNone_Click(object sender, EventArgs e) { - NotificationList.Clear(); - while (panelDetails.Controls.Count > 0) - panelDetails.Controls.RemoveAt(0); + ToggleNotifications(); + } + private void pbNotificationsSome_Click(object sender, EventArgs e) + { + ToggleNotifications(); + } + private void lblNotificationCount_Click(object sender, EventArgs e) + { + ToggleNotifications(); } - private void pbNotifications_Click(object sender, EventArgs e) + private void ToggleNotifications() { - // Show/hide notifications - IsNotificationsVisible = !IsNotificationsVisible; - if (IsNotificationsVisible) + if (AreNotificationsVisible == false) { - ClearDetails(); ShowNotifications(); + FiddleNewNotificationCount(); } else { - ClearNotifications(); ShowDetails(); } + AreNotificationsVisible = !AreNotificationsVisible; + } + + private void FiddleNewNotificationCount() + { + LastNotificationViewed = 1; + if (LastNotificationViewed >= NewNotificationCount) + { + pbNotificationsSome.Visible = false; + lblNotificationCount.Visible = false; + } } void ShowNotifications() { - if (NotificationList.Count == 0) + Win32.LockWindowUpdate(Handle); + ClearPanel(); + AddNotifications(); + FlowDetails(); + Win32.LockWindowUpdate(IntPtr.Zero); + } + + private void AddNotifications() + { + //if (NotificationList.Count == 0) + if (NotificationList.Count != 0) { - var titleControl = new Label - { Margin = new Padding(2) - , Text = "No notifications are available" - , UseMnemonic = false - , Font = new Font(panelDetails.Font, FontStyle.Bold) - , TextAlign = ContentAlignment.BottomLeft - }; - panelDetails.Controls.Add(titleControl); - titleControl.Left = titleControl.Margin.Left; - titleControl.Width = panelDetails.ClientSize.Width - titleControl.Margin.Horizontal - titleControl.PreferredHeight; - titleControl.Height = titleControl.PreferredHeight; - titleControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; + AddDetail("Notifications", new string[] { "No notifications are available." }); } + else + { + AddDetail("Notification 1", new string[] { "This is a dummy notification." }); + } + AddDetail("", new string[] { "Toggle icon to hide notifications." }); } + #endregion Notifications } } diff --git a/Source/Menu/MainForm.resx b/Source/Menu/MainForm.resx index 5bd9d9a72b..6e5742bbab 100644 --- a/Source/Menu/MainForm.resx +++ b/Source/Menu/MainForm.resx @@ -127,10 +127,10 @@ 358, 17 - + iVBORw0KGgoAAAANSUhEUgAAACUAAAAfCAYAAABgfwTIAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO - vgAADr4B6kKxwAAABk5JREFUWEfNmHlMVFcUxkdttdVWW621VYtaWtQqxlptG+JaG1Nj05j+0dQ0jYnV + vQAADr0BR/uQrQAABk5JREFUWEfNmHlMVFcUxkdttdVWW621VYtaWtQqxlptG+JaG1Nj05j+0dQ0jYnV NjGBGJeCOgouDSCDsrYqVFka6xJEkGU0ERgXGiCoKApI1SCKCMMMw5KBWd7p903mmbFOiLZCvMkv793l 3fvdc5c5ZzQi8hJ4B8wD34LvwFLwBZgPPnIzFfgBXzAe+IBxYBR4DQwG00EA+AAMB0P5dDY1Te6Mjl7c qdOJefFiMfr5iXHSJDEvWiQoa7EVF4cqZvPnaPsuGERR7JDCXgWjwRjwpgccmEIoaArgwMxTFL8hats3