/// <summary> /// Handles the Load event of the form. /// </summary> /// <param name="sender">Instance of the form that raises the event.</param> /// <param name="e">Instance of <see cref="EventArgs"/> which holds the data for managing the event.</param> private void MyAnalogClockForm_Load(object sender, EventArgs e) { //Removes title bar and border //from the form. Text = string.Empty; FormBorderStyle = FormBorderStyle.None; ControlBox = false; //Creates the instance of the context menu _contextMenu = new ContextMenuStrip(); //Builds the context menu using the items dictionary. //Subscribes the Click event for every item to the MenuItem_Click method. _contextMenu.BuildContextMenu(_contextMenuItems, MenuItem_Click); // Attach the context menu to the form. ContextMenuStrip = _contextMenu; // Set the size to a square of 300x300. SetSize(300, 300); //Use double buffering to avoid flickering. DoubleBuffered = true; //The form will not be shown in the task bar. ShowInTaskbar = false; // Set focus to the form. You should do this // in order to make Alt+F4 close the clock properly. Focus(); //Creates an instance of a timer //and adjusts the time for firing the //Tick event (1000 milliseconds == 1 second) _clockTimer = new Timer { Interval = 1000 }; //Subscribes the Tick event for the timer instance _clockTimer.Tick += _clockTimer_Tick; _clockTimer.Enabled = true; }