예제 #1
0
        private void label_start_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            ContextMenu contextMenu = new ContextMenu();
            MenuItem    menuItem    = null;

            List <string> years = GetRecentYear();

            for (int i = 0; i < years.Count; i++)
            {
                string strYear = years[i];
                //
                menuItem = new MenuItem(strYear);
                contextMenu.MenuItems.Add(menuItem);

                //
                string strPart = "全年";

                QuickSetParam param = new QuickSetParam();
                param.Year = strYear;
                param.Part = strPart;

                MenuItem subMenuItem = new MenuItem(strPart);
                subMenuItem.Click += new System.EventHandler(this.menu_quickSet_Click);
                subMenuItem.Tag    = param;
                menuItem.MenuItems.Add(subMenuItem);

                //
                strPart    = "上半年";
                param      = new QuickSetParam();
                param.Year = strYear;
                param.Part = strPart;

                subMenuItem        = new MenuItem(strPart);
                subMenuItem.Click += new System.EventHandler(this.menu_quickSet_Click);
                subMenuItem.Tag    = param;
                menuItem.MenuItems.Add(subMenuItem);

                //
                strPart    = "下半年";
                param      = new QuickSetParam();
                param.Year = strYear;
                param.Part = strPart;

                subMenuItem        = new MenuItem(strPart);
                subMenuItem.Click += new System.EventHandler(this.menu_quickSet_Click);
                subMenuItem.Tag    = param;
                menuItem.MenuItems.Add(subMenuItem);
            }

            menuItem        = new MenuItem("清空");
            menuItem.Click += menu_clear_Click;
            contextMenu.MenuItems.Add(menuItem);

            contextMenu.Show(this.label_start, new Point(e.X, e.Y));
        }
예제 #2
0
        void menu_quickSet_Click(object sender, EventArgs e)
        {
            MenuItem menu = (MenuItem)sender;

            QuickSetParam param = (QuickSetParam)menu.Tag;

            if (param.Part == "全年")
            {
                this.Text = param.Year + "0101-" + param.Year + "1231";
                return;
            }
            if (param.Part == "上半年")
            {
                this.Text = param.Year + "0101-" + param.Year + "0630";
                return;
            }
            if (param.Part == "下半年")
            {
                this.Text = param.Year + "0701-" + param.Year + "1231";
                return;
            }
            throw new Exception("未知的part参数值 '" + param.Part + "'");
        }
예제 #3
0
        private void label_start_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
                return;

            ContextMenu contextMenu = new ContextMenu();
            MenuItem menuItem = null;

            List<string> years = GetRecentYear();

            for (int i = 0; i < years.Count; i++)
            {
                string strYear = years[i];
                //
                menuItem = new MenuItem(strYear);
                contextMenu.MenuItems.Add(menuItem);

                // 
                string strPart = "全年";

                QuickSetParam param = new QuickSetParam();
                param.Year = strYear;
                param.Part = strPart;

                MenuItem subMenuItem = new MenuItem(strPart);
                subMenuItem.Click += new System.EventHandler(this.menu_quickSet_Click);
                subMenuItem.Tag = param;
                menuItem.MenuItems.Add(subMenuItem);

                // 
                strPart = "上半年";
                param = new QuickSetParam();
                param.Year = strYear;
                param.Part = strPart;

                subMenuItem = new MenuItem(strPart);
                subMenuItem.Click += new System.EventHandler(this.menu_quickSet_Click);
                subMenuItem.Tag = param;
                menuItem.MenuItems.Add(subMenuItem);

                // 
                strPart = "下半年";
                param = new QuickSetParam();
                param.Year = strYear;
                param.Part = strPart;

                subMenuItem = new MenuItem(strPart);
                subMenuItem.Click += new System.EventHandler(this.menu_quickSet_Click);
                subMenuItem.Tag = param;
                menuItem.MenuItems.Add(subMenuItem);
            }


            contextMenu.Show(this.label_start, new Point(e.X, e.Y));
        }