本文整理汇总了C#中System.Windows.Forms.ToolStrip.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStrip.Dispose方法的具体用法?C# ToolStrip.Dispose怎么用?C# ToolStrip.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStrip
的用法示例。
在下文中一共展示了ToolStrip.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BehaviorFindToolStrip
public void BehaviorFindToolStrip ()
{
// Default stuff
Assert.AreEqual (null, ToolStripManager.FindToolStrip (string.Empty), "A1");
Assert.AreEqual (null, ToolStripManager.FindToolStrip ("MyStrip"), "A2");
ToolStrip ts = new ToolStrip ();
ts.Name = "MyStrip";
// Basic operation
Assert.AreSame (ts, ToolStripManager.FindToolStrip ("MyStrip"), "A3");
// Dispose removes them
ts.Dispose ();
Assert.AreEqual (null, ToolStripManager.FindToolStrip ("MyStrip"), "A4");
ts = new ToolStrip ();
ts.Name = "MyStrip1";
MenuStrip ms = new MenuStrip ();
ms.Name = "MyStrip2";
// Basic operation
Assert.AreSame (ts, ToolStripManager.FindToolStrip ("MyStrip1"), "A5");
Assert.AreSame (ms, ToolStripManager.FindToolStrip ("MyStrip2"), "A6");
// Find unnamed strip
StatusStrip ss = new StatusStrip ();
Assert.AreEqual (ss, ToolStripManager.FindToolStrip (string.Empty), "A7");
// Always return first unnamed strip
ContextMenuStrip cms = new ContextMenuStrip ();
Assert.AreEqual (ss, ToolStripManager.FindToolStrip (string.Empty), "A8");
// Remove first unnamed strip, returns second one
ss.Dispose ();
Assert.AreEqual (cms, ToolStripManager.FindToolStrip (string.Empty), "A9");
// ContextMenuStrips are included
cms.Name = "Context";
Assert.AreEqual (cms, ToolStripManager.FindToolStrip ("Context"), "A10");
}
示例2: PropertyGrid
//.........这里部分代码省略.........
m_patternTextBox.Name = "patternTextBox";
m_patternTextBox.MaximumWidth = 1080;
m_patternTextBox.KeyUp += patternTextBox_KeyUp;
m_patternTextBox.TextBox.PreviewKeyDown += patternTextBox_PreviewKeyDown;
var clearSearchButton = new ToolStripButton();
clearSearchButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
clearSearchButton.Image = ResourceUtil.GetImage16(Resources.DeleteImage);
dropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta;
clearSearchButton.Name = "PropertyGridClearSearchButton";
clearSearchButton.Size = new System.Drawing.Size(29, 22);
clearSearchButton.Text = "Clear Search".Localize("'Clear' is a verb");
clearSearchButton.Click += clearSearchButton_Click;
m_toolStrip.Items.AddRange(
new ToolStripItem[] {
dropDownButton,
m_patternTextBox,
clearSearchButton
});
}
if ((mode & PropertyGridMode.HideResetAllButton) == 0)
{
// Reset all button.
var resetAllButton = new ToolStripButton();
resetAllButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
resetAllButton.Image = ResourceUtil.GetImage16(Resources.ResetImage);
resetAllButton.ImageTransparentColor = System.Drawing.Color.Magenta;
resetAllButton.Name = "PropertyGridResetAllButton";
resetAllButton.Size = new Size(29, 22);
resetAllButton.ToolTipText = "Reset all properties".Localize();
resetAllButton.Click += (sender, e) =>
{
ITransactionContext transaction = m_propertyGridView.EditingContext.As<ITransactionContext>();
transaction.DoTransaction(delegate
{
ResetAll();
},
"Reset All Properties".Localize("'Reset' is a verb and this is the name of a command"));
};
m_toolStrip.Items.Add(resetAllButton);
}
if ((mode & PropertyGridMode.AllowEditingComposites) != 0)
{
m_navigateOut = new ToolStripButton(null, s_navigateOutImage, navigateOut_Click);
m_navigateOut.Enabled = true;
m_navigateOut.ToolTipText = "Navigate back to parent of selected object".Localize();
m_toolStrip.Items.Add(m_navigateOut);
m_propertyGridView.AllowEditingComposites = true;
}
SuspendLayout();
if ((mode & PropertyGridMode.DisplayTooltips) != 0)
m_propertyGridView.AllowTooltips = true;
if ((mode & PropertyGridMode.DisplayDescriptions) == 0)
Controls.Add(m_propertyGridView);
else
{
m_splitContainer.Orientation = Orientation.Horizontal;
m_splitContainer.BackColor = SystemColors.InactiveBorder;
m_splitContainer.FixedPanel = FixedPanel.Panel2;
m_splitContainer.SplitterWidth = 8;
m_splitContainer.Dock = DockStyle.Fill;
m_splitContainer.Panel1.Controls.Add(m_propertyGridView);
m_descriptionTextBox = new DescriptionControl(this);
m_descriptionTextBox.BackColor = SystemColors.Window;
m_descriptionTextBox.Dock = DockStyle.Fill;
m_splitContainer.Panel2.Controls.Add(m_descriptionTextBox);
Controls.Add(m_splitContainer);
m_propertyGridView.SelectedPropertyChanged += propertyGrid_SelectedRowChanged;
m_descriptionTextBox.ClearDescription();
}
if (m_toolStrip.Items.Count > 0)
{
UpdateToolstripItems();
Controls.Add(m_toolStrip);
}
else
{
m_toolStrip.Dispose();
m_toolStrip = null;
}
Name = "PropertyGrid";
Font = m_propertyGridView.Font;
FontChanged += (sender, e) => m_propertyGridView.Font = Font;
ResumeLayout(false);
PerformLayout();
}
示例3: MethodDipose
public void MethodDipose()
{
ToolStrip ts = new ToolStrip ();
ToolStripItem item_a = ts.Items.Add ("A");
ToolStripItem item_b = ts.Items.Add ("B");
ToolStripItem item_c = ts.Items.Add ("C");
Assert.AreEqual (3, ts.Items.Count, "A1");
ts.Dispose ();
Assert.AreEqual (0, ts.Items.Count, "A2");
Assert.IsTrue (item_a.IsDisposed, "A3");
Assert.IsTrue (item_b.IsDisposed, "A4");
Assert.IsTrue (item_c.IsDisposed, "A5");
}
示例4: InitUI
/// <summary>
/// Initialize User Interface
/// </summary>
private void InitUI()
{
BIServerConnector callback = BIServerConnector.SharedInstance;
Dictionary<string, string> extraInputMethods = new Dictionary<string, string>();
Dictionary<string, string> outputFilters = new Dictionary<string, string>();
Dictionary<string, string> aroundFilters = new Dictionary<string, string>();
List<string> modulesSuppressedFromUI = new List<string>();
string currentInputMethod = "";
bool useFullWidth = true;
bool useSimplifiedChinese = false;
bool useEnglishKeyboard = false;
if (callback != null)
{
currentInputMethod = callback.stringValueForLoaderConfigKey("PrimaryInputMethod");
if (currentInputMethod.Length == 0)
currentInputMethod = callback.primaryInputMethod();
useSimplifiedChinese = callback.isOutputFilterEnabled("ChineseCharacterConvertor-TC2SC");
useFullWidth = callback.isFullWidthCharacterMode();
extraInputMethods = callback.allInputMethodIdentifiersAndNames();
outputFilters = callback.allOutputFilterIdentifiersAndNames();
aroundFilters = callback.allAroundFilterIdentifiersAndNames();
modulesSuppressedFromUI = callback.arrayValueForLoaderConfigKey("ModulesSuppressedFromUI");
if (callback.isLoaderConfigKeyTrue("EnablesCapsLockAsAlphanumericModeToggle"))
this.u_toolStrip.Items.Remove(u_toggleAlphanumericMode);
}
// Load extra Input Method modules.
this.u_toggleInputMethodDropDownMenu.Items.Clear();
this.u_toggleInputMethodDropDownMenu.Items.AddRange(this.m_defualtInputMethodMenuItems);
if (modulesSuppressedFromUI.Contains("SmartMandarin"))
this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_smartPhoneticToolStripMenuItem);
if (modulesSuppressedFromUI.Contains("TraditionalMandarins"))
this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_traditionalPhoneticToolStripMenuItem);
if (modulesSuppressedFromUI.Contains("Generic-cj-cin"))
this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_cangjieToolStripMenuItem);
if (modulesSuppressedFromUI.Contains("Generic-simplex-cin"))
this.u_toggleInputMethodDropDownMenu.Items.Remove(this.u_simplexToolStripMenuItem);
if (extraInputMethods.Count > 0)
{
ToolStrip tempStrip = new ToolStrip();
ToolStripItem[] tempItems = new ToolStripItem[] { };
ToolStripItemCollection genericInputMethodMenuItems = new ToolStripItemCollection(tempStrip, tempItems);
foreach (KeyValuePair<string, string> genericInputMethod in extraInputMethods)
{
string moduleID = genericInputMethod.Key;
string moduleName = genericInputMethod.Value;
if (modulesSuppressedFromUI.Contains(moduleID))
continue;
System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem();
if (moduleID.Equals(currentInputMethod))
newItem.CheckState = CheckState.Checked;
newItem.AutoSize = true;
newItem.Image = global::BaseIMEUI.Properties.Resources.generic;
newItem.Name = moduleID;
newItem.Text = moduleName;
newItem.ToolTipText = moduleName;
newItem.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
newItem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
newItem.Click += new System.EventHandler(this.SelectInputMethod);
genericInputMethodMenuItems.Add(newItem);
}
if (u_toggleInputMethodDropDownMenu.Items.Count > 0 && genericInputMethodMenuItems.Count > 0)
this.u_toggleInputMethodDropDownMenu.Items.Add(new ToolStripSeparator());
if (genericInputMethodMenuItems.Count > 0)
this.u_toggleInputMethodDropDownMenu.Items.AddRange(genericInputMethodMenuItems);
tempStrip.Dispose();
}
// Avoids that there is no input method in the menu.
if (this.u_toggleInputMethodDropDownMenu.Items.Count == 0)
this.u_toggleInputMethodDropDownMenu.Items.Add(this.u_smartPhoneticToolStripMenuItem);
this.u_configsDropDownMenu.Items.Clear();
// Loads Around Filters.
if (aroundFilters.Count > 0)
{
foreach (KeyValuePair<string, string> aroundFilter in aroundFilters)
{
string moduleID = aroundFilter.Key;
string moduleName = aroundFilter.Value;
// Makes the search and evanuator module always enabled.
if (moduleID.Equals("OneKey") || moduleID.Equals("Evaluator"))
//.........这里部分代码省略.........
示例5: GridControl
/// <summary>
/// Constructor</summary>
/// <param name="mode">Flags specifiying the GridControl's features and appearance</param>
/// <param name="gridView">The GridView to be used. Can be sub-classed to customize its behavior.</param>
public GridControl(PropertyGridMode mode, GridView gridView)
{
m_gridView = gridView;
m_gridView.BackColor = SystemColors.Window;
m_gridView.Dock = DockStyle.Fill;
m_gridView.EditingContextChanged += gridView_BindingChanged;
m_gridView.MouseUp += gridView_MouseUp;
m_gridView.DragOver += gridView_DragOver;
m_gridView.DragDrop += gridView_DragDrop;
m_gridView.MouseHover += gridView_MouseHover;
m_gridView.MouseLeave += gridView_MouseLeave;
m_gridView.SelectedPropertyChanged += gridView_SelectedPropertyChanged;
m_toolStrip = new ToolStrip();
m_toolStrip.GripStyle = ToolStripGripStyle.Hidden;
m_toolStrip.Dock = DockStyle.Top;
if ((mode & PropertyGridMode.PropertySorting) != 0)
{
m_propertyOrganization = new ToolStripDropDownButton(null, s_categoryImage);
m_propertyOrganization.ToolTipText = "Property Organization".Localize(
"Could be rephrased as 'How do you want these properties to be organized?'");
//m_propertyOrganization.ImageTransparentColor = Color.Magenta;
m_propertyOrganization.DropDownItemClicked += organization_DropDownItemClicked;
ToolStripMenuItem item1 = new ToolStripMenuItem("Unsorted".Localize());
item1.Tag = PropertySorting.None;
ToolStripMenuItem item2 = new ToolStripMenuItem("Alphabetical".Localize());
item2.Tag = PropertySorting.Alphabetical;
ToolStripMenuItem item3 = new ToolStripMenuItem("Categorized".Localize());
item3.Tag = PropertySorting.Categorized;
ToolStripMenuItem item4 = new ToolStripMenuItem("Categorized Alphabetical Properties".Localize());
item4.Tag = PropertySorting.Categorized | PropertySorting.Alphabetical;
ToolStripMenuItem item5 = new ToolStripMenuItem("Alphabetical Categories".Localize());
item5.Tag = PropertySorting.Categorized | PropertySorting.CategoryAlphabetical;
ToolStripMenuItem item6 = new ToolStripMenuItem("Alphabetical Categories And Properties".Localize());
item6.Tag = PropertySorting.ByCategory;
m_propertyOrganization.DropDownItems.Add(item1);
m_propertyOrganization.DropDownItems.Add(item2);
m_propertyOrganization.DropDownItems.Add(item3);
m_propertyOrganization.DropDownItems.Add(item4);
m_propertyOrganization.DropDownItems.Add(item5);
m_propertyOrganization.DropDownItems.Add(item6);
m_toolStrip.Items.Add(m_propertyOrganization);
m_toolStrip.Items.Add(new ToolStripSeparator());
}
if ((mode & PropertyGridMode.ShowHideProperties) != 0)
{
m_propertyShowHideButton = new ToolStripButton(null, s_showHidePropertiesImage);
m_propertyShowHideButton.ToolTipText = "Property Show / Hide".Localize();
m_propertyShowHideButton.Click += propertyShowHide_Click;
m_toolStrip.Items.Add(m_propertyShowHideButton);
m_toolStrip.Items.Add(new ToolStripSeparator());
}
if ((mode & PropertyGridMode.DisableDragDropColumnHeaders) != 0)
{
m_gridView.DragDropColumnsEnabed = false;
}
m_descriptionLabel = new ToolStripAutoFitLabel();
m_descriptionLabel.TextAlign = ContentAlignment.TopLeft;
m_descriptionLabel.MaximumWidth = 5000;
m_toolStrip.Items.Add(m_descriptionLabel);
SuspendLayout();
Controls.Add(m_gridView);
if (m_toolStrip.Items.Count > 0)
{
UpdateToolstripItems();
Controls.Add(m_toolStrip);
}
else
{
m_toolStrip.Dispose();
m_toolStrip = null;
}
Font = new Font("Segoe UI", 9.0f);
ResumeLayout(false);
PerformLayout();
}