示例#1
0
        /// <summary>
        /// Event handler invoked when any project is clicked in the menu.
        /// Alternate the checkboxes, and make the Punch In menu item
        /// enabled.  If the user was already punched in, then the
        /// existing project is first punched out.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void projectSelectMenuItem_Click(object sender, EventArgs e)
        {
            if (currentProjectMenuItem != null)
            {
                currentProjectMenuItem.Checked = false;
            }

            ProjectToolStripMenuItem currentItem = (ProjectToolStripMenuItem)sender;

            currentItem.Checked = true;

            // With a project selected, the user can check in or out
            punchInOutToolStripMenuItem.Enabled = true;

            currentProjectMenuItem = currentItem;

            // Remember the selected project
            string projectName = currentItem.ProjectRow.ProjectName;

            Properties.Settings.Default.LastSelectedProject = projectName;

            Properties.Settings.Default.Save();

            dt.CurrentProjectRow = currentItem.ProjectRow;

            // Update punch out status for new selected project
            UpdatePunchInOutOptions();
        }
示例#2
0
        void dt_ProjectDeleted(object sender, TimeTrackerEvent e)
        {
            TimeTrackerDataSet.ProjectsRow row = e.ProjectEntry;
            ToolStripMenuItem menuItem         = null;

            // Modify the project menu list accordingly
            foreach (ToolStripMenuItem mi in projectMenuItems)
            {
                if (mi.Tag == row)
                {
                    menuItem = mi;
                    break;
                }
            }

            if (menuItem != null)
            {
                menuItem.Visible = false;
                projectMenuItems.Remove(menuItem);

                // If the deleted project is the current project
                if (currentProjectMenuItem == menuItem)
                {
                    // Now there is no current project
                    currentProjectMenuItem = null;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Adds a new project menu item given a ProjectsRow object.
        /// </summary>
        /// <param name="newProjectRow"></param>
        private ToolStripMenuItem AddProjectMenuItem(TimeTracker.TimeTrackerDataSet.ProjectsRow newProjectRow)
        {
            ProjectToolStripMenuItem newMenuItem = new ProjectToolStripMenuItem(newProjectRow);

            newMenuItem.Click += projectSelectEventHandler;

            this.changeProjectToolStripMenuItem.DropDownItems.AddRange(
                new System.Windows.Forms.ToolStripItem[] {
                newMenuItem
            });

            projectMenuItems.Add(newMenuItem);

            return(newMenuItem);
        }