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


C# ToolStripButton.Dispose方法代码示例

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


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

示例1: RegisterToolBoxButton

        ///<summary>
        ///  Registers new Tool Box button in main tool-set
        ///</summary>
        ///<param name="ownControl">Control owns button will be created</param>
        ///<param name="item">Instance of <see cref="ToolStripMenuItem"/> which provides information to create button</param>
        ///<param name="action">Action should be call when created button clicked</param>
        ///<returns>Action delegate to notify main form when created button should be enabled/disabled</returns>
        ///<exception cref="FireFlyException"></exception>
        public Action<bool> RegisterToolBoxButton([NotNull]Control ownControl, [NotNull]ToolStripMenuItem item, [CanBeNull]EventHandler action)
        {
            var nb = new ToolStripButton(item.Text, item.Image) { Name = item.Name, ToolTipText = item.ToolTipText, Tag = ownControl, Visible = false};
            if (item.ShortcutKeys != Keys.None)
            {
#if CHECKERS
                if (nb.ToolTipText.IsNull())
                {
                    throw new FireFlyException("{0} has empty ToolTipText property", nb.Name);
                }
#endif
                nb.ToolTipText += " (" + new KeysConverter().ConvertToString(item.ShortcutKeys) + ")";
            }
            nb.DisplayStyle = item.Image != null ? ToolStripItemDisplayStyle.Image : ToolStripItemDisplayStyle.Text;
            nb.Click += action ?? ((s, e) => item.PerformClick());
            nb.Enabled = item.Visible && item.Enabled;
            tsMain.Items.Add(nb);

            ownControl.GotFocus += (s, e) => nb.Visible = true;
            ownControl.LostFocus += (s, e) =>
            {
                nb.Visible = false;
            };
            ownControl.Disposed += (s, e) => nb.Dispose();

            return isActive =>
            {
                nb.Enabled = isActive;
                item.Visible = isActive;
            };
        }
开发者ID:supermuk,项目名称:iudico,代码行数:39,代码来源:MainForm.cs

示例2: MasterToolStrip

        public static void MasterToolStrip(ToolStrip SourceToolbar)
        {
            ToolStripButton btn = null;
            //This procedure assumes an Image List has been already attached to the
            //supplied Toolbar with the required images in the required order
            try
            {
                ToolStrip with_1 = SourceToolbar;
                with_1.Items.Add(new ToolStripSeparator()); //Add a Separator

                btn = new ToolStripButton();
                ToolStripButton with_2 = btn;
                with_2.AutoToolTip = true;
                with_2.ToolTipText = CultureSupport.TextDictionary("TT_NEW", TextReturnTypeEnum.PureString);
                with_2.Tag = "New";
                with_2.ImageIndex = 0;
                with_1.Items.Add(btn);

                btn = new ToolStripButton();
                ToolStripButton with_3 = btn;
                with_3.AutoToolTip = true;
                with_3.ToolTipText = CultureSupport.TextDictionary("TT_DELETE", TextReturnTypeEnum.PureString);
                with_3.Tag = "Delete";
                with_3.ImageIndex = 1;
                with_1.Items.Add(btn);

                btn = new ToolStripButton();
                ToolStripButton with_4 = btn;
                with_4.AutoToolTip = true;
                with_4.ToolTipText = CultureSupport.TextDictionary("TT_SAVECHANGES", TextReturnTypeEnum.PureString);
                with_4.Tag = "Save";
                with_4.ImageIndex = 2;
                with_1.Items.Add(btn);

                btn = new ToolStripButton();
                ToolStripButton with_5 = btn;
                with_5.AutoToolTip = true;
                with_5.ToolTipText = CultureSupport.TextDictionary("TT_UNDOCHANGES", TextReturnTypeEnum.PureString);
                with_5.Tag = "Undo";
                with_5.ImageIndex = 3;
                with_1.Items.Add(btn);

                with_1.Items.Add(new ToolStripSeparator());

                btn = new ToolStripButton();
                ToolStripButton with_6 = btn;
                with_6.AutoToolTip = true;
                with_6.ToolTipText = CultureSupport.TextDictionary("TT_FIND", TextReturnTypeEnum.PureString);
                with_6.Tag = "Find";
                with_6.ImageIndex = 4;
                with_1.Items.Add(btn);

                with_1.Items.Add(new ToolStripSeparator());

                btn = new ToolStripButton();
                ToolStripButton with_7 = btn;
                with_7.AutoToolTip = true;
                with_7.ToolTipText = CultureSupport.TextDictionary("TT_CLOSE", TextReturnTypeEnum.PureString);
                with_7.Tag = "Exit";
                with_7.ImageIndex = 5;
                with_1.Items.Add(btn);

            }
            catch (Exception)
            {
            }
            finally
            {
                btn.Dispose();
            }
        }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:71,代码来源:ToolbarSupport.cs

示例3: TransactionToolStrip

        public static void TransactionToolStrip(ToolStrip SourceToolbar)
        {
            ToolStripItem btn = null;

            try
            {
                ToolStrip with_1 = SourceToolbar;
                with_1.Items.Add(new ToolStripSeparator()); //Add a Separator

                btn = new ToolStripButton();
                ToolStripButton with_2 = ((ToolStripButton) btn);
                with_2.AutoToolTip = true;
                with_2.ToolTipText = CultureSupport.TextDictionary("TT_SAVECHANGES", TextReturnTypeEnum.PureString);
                with_2.Tag = "Save";
                with_1.Items.Add(btn);

                btn = new ToolStripButton();
                ToolStripButton with_3 = ((ToolStripButton) btn);
                with_3.AutoToolTip = true;
                with_3.ToolTipText = CultureSupport.TextDictionary("TT_UNDOCHANGES", TextReturnTypeEnum.PureString);
                with_3.Tag = "Undo";
                with_1.Items.Add(btn);

                with_1.Items.Add(new ToolStripSeparator());

                btn = new ToolStripButton();
                ToolStripButton with_4 = ((ToolStripButton) btn);
                with_4.AutoToolTip = true;
                with_4.ToolTipText = CultureSupport.TextDictionary("TT_CLOSE", TextReturnTypeEnum.PureString);
                with_4.Tag = "Exit";
                with_1.Items.Add(btn);
            }
            catch (Exception)
            {
            }
            finally
            {
                btn.Dispose();
            }
        }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:40,代码来源:ToolbarSupport.cs


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