当前位置: 首页>>代码示例>>C#>>正文


C# ToolStripMenuItem.?.Dispose方法代码示例

本文整理汇总了C#中System.Windows.Forms.ToolStripMenuItem.?.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripMenuItem.?.Dispose方法的具体用法?C# ToolStripMenuItem.?.Dispose怎么用?C# ToolStripMenuItem.?.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ToolStripMenuItem的用法示例。


在下文中一共展示了ToolStripMenuItem.?.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowCalendarContextMenu

        /// <summary>
        /// Show the context menu for the given day
        /// </summary>
        /// <param name="datetime"></param>
        /// <param name="location"></param>
        private void ShowCalendarContextMenu(DateTime datetime, Point location)
        {
            // Remove old submenus
            while (calContext.Items.Count > 2)
            {
                calContext.Items.RemoveAt(2);
            }

            // Set date Tag to new entry
            calContext.Items[0].Tag = datetime;

            // Add "Edit" menus for every schedule on this day
            foreach (ScheduleEntry entry in Scheduler.Entries.Where(x => x.IsToday(datetime)))
            {
                ToolStripItem tempItem = null;
                try
                {
                    tempItem = new ToolStripMenuItem();
                    tempItem.Click += editMenuItem_Click;
                    tempItem.Text = $"Edit \"{entry.Title}\"...";
                    tempItem.Tag = entry;

                    ToolStripItem item = tempItem;
                    tempItem = null;

                    calContext.Items.Add(item);
                }
                finally
                {
                    tempItem?.Dispose();
                }
            }

            // Show the toolstrip seperator if there are any entries
            toolStripSeperator.Visible = calContext.Items.Count > 2;

            // Display the menu
            calContext.Show(calControl, location);
        }
开发者ID:RapidFiring,项目名称:evemon,代码行数:44,代码来源:ScheduleEditorWindow.cs

示例2: BuildContextMenu

        /// <summary>
        /// Builds the context menu for the selected skill.
        /// </summary>
        /// <param name="skill">The skill.</param>
        private void BuildContextMenu(Skill skill)
        {
            tsmiAddSkill.DropDownItems.Clear();

            if (skill == null || skill.Level == 5)
            {
                tsmiAddSkill.Text = String.Empty;
                return;
            }
            
            // Reset the menu
            tsmiAddSkill.Text = $"Add {skill.Name}";

            // Build the level options
            for (Int64 level = skill.Level + 1; level <= 5; level++)
            {
                ToolStripMenuItem tempMenuLevel = null;
                try
                {
                    tempMenuLevel = new ToolStripMenuItem($"Level {Skill.GetRomanFromInt(level)} to");

                    Character.Plans.AddTo(tempMenuLevel.DropDownItems,
                        (menuPlanItem, plan) =>
                        {
                            menuPlanItem.Click += menuPlanItem_Click;
                            menuPlanItem.Tag = new KeyValuePair<Plan, SkillLevel>(plan, new SkillLevel(skill, level));
                        });

                    ToolStripMenuItem menuLevel = tempMenuLevel;
                    tempMenuLevel = null;

                    tsmiAddSkill.DropDownItems.Add(menuLevel);
                }
                finally
                {
                    tempMenuLevel?.Dispose();
                }
            }
        }
开发者ID:RapidFiring,项目名称:evemon,代码行数:43,代码来源:CharacterSkillsList.cs

示例3: CreateNewMonitorToolStripMenuItem

        /// <summary>
        /// Creates the new monitor toolstrip menu item.
        /// </summary>
        /// <param name="monitor">The monitor.</param>
        /// <returns>New menu item for a monitor.</returns>
        private static ToolStripMenuItem CreateNewMonitorToolStripMenuItem(IQueryMonitor monitor)
        {
            string menuText = $"Update {monitor} {GenerateTimeToNextUpdateText(monitor)}";

            ToolStripMenuItem menu;
            ToolStripMenuItem tempMenu = null;
            try
            {
                tempMenu = new ToolStripMenuItem(menuText)
                {
                    Tag = monitor.Method,
                    Enabled = monitor.Enabled && monitor.HasAccess && monitor.CanForceUpdate
                };

                menu = tempMenu;
                tempMenu = null;
            }
            finally
            {
                tempMenu?.Dispose();
            }
            return menu;
        }
开发者ID:RapidFiring,项目名称:evemon,代码行数:28,代码来源:CharacterMonitorHeader.cs


注:本文中的System.Windows.Forms.ToolStripMenuItem.?.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。