using System.Windows.Forms; namespace $safeprojectname$ { /// /// Host form responsible for navigating between view and search online modes of the application. /// /// /// View MainForm.vb file in designer to modify additional properties. /// public partial class MainForm : Form { //User control objects responsible for viewing the collection and searching online ListDetails listDetailsPart; SearchOnline searchOnlinePart; public MainForm() { InitializeComponent(); } /// /// Gets user control instance responsible for viewing the collection of movies. /// /// Live instance of the ListDetails user control. /// Singleton instance pattern; the object is created upon first access, and the reused for all future accesses. internal ListDetails ListDetailsPart { get { //Initialize the variable with a new object instance if nothing exists if (this.listDetailsPart == null) //creating object { this.listDetailsPart = new ListDetails(); //site the control on the host user control and dock fill it this.targetPanel.Controls.Add(this.listDetailsPart); this.listDetailsPart.Dock = DockStyle.Fill; } return this.listDetailsPart; } } /// /// Gets user control property responsible for viewing the collection of movies. /// /// Live instance of the ListDetails user control. /// Singleton instance pattern; the object is created upon first access, and the reused for all future accesses. internal SearchOnline SearchOnlinePart { get { //Initialize the variable with a new object instance if nothing exists if (this.searchOnlinePart == null) //creating object { this.searchOnlinePart = new SearchOnline(); this.searchOnlinePart.MainForm = this; //site the control on the host user control and dock fill it this.targetPanel.Controls.Add(this.searchOnlinePart); this.searchOnlinePart.Dock = DockStyle.Fill; } return this.searchOnlinePart; } } /// /// Shows the ListDetails user control on first load of the application. /// private void MainForm_Load(System.Object sender, System.EventArgs e) { this.ShowListDetailsPart(); } /// /// Restores window when the tray icon is clicked. /// private void NotifyIcon1_Click(object sender, System.EventArgs e) { this.RestoreWindow(); } /// /// Restores window when the try icon is double clicked. /// private void NotifyIcon1_DoubleClick(object sender, System.EventArgs e) { this.RestoreWindow(); } /// /// Makes the ListDetails user control visible and hides the SearchOnline user control. /// private void ViewDetailsButton_Click(object sender, System.EventArgs e) { this.ShowListDetailsPart(); } /// /// Makes the SearchOnline user control visible and hides the ListDetails user control. /// private void SearchOnlineButton_Click(object sender, System.EventArgs e) { this.ShowSearchOnlinePart(); } /// /// Restores window to the normal size and ensures that it is visible. /// private void RestoreWindow() { this.WindowState = FormWindowState.Normal; this.Visible = true; } /// /// Displays the ListDetails user control and hides the SearchOnline user control. /// /// Enables the swapping behavior of list and search modes. internal void ShowListDetailsPart() { //performance optimization - skip hiding this control if it has not been created yet if (this.SearchOnlinePart != null) { this.SearchOnlinePart.Visible = false; } this.ListDetailsPart.Visible = true; } /// /// Displays the SearchOnline user control and hides the ListDetails user control. /// /// Enables the swapping behavior of list and search modes. internal void ShowSearchOnlinePart() { //performance optimization - skip hiding this control if it has not been created yet if (this.ListDetailsPart != null) { this.ListDetailsPart.Visible = false; } //Show this control and hide all others this.SearchOnlinePart.Visible = true; } } }