public override void CloseTabPage() { //this.Controls.Clear(); base.CloseTabPage(); //this.drawarea.CloseDrawArea(); //panelPageNavigation = null; //toolStripPageNavigation = null; //toolStripButtonAdd = null; //toolStripButtonDelete = null; //toolStripSeparator1 = null; //toolStripButtonFirst = null; //toolStripButtonPrevious = null; //toolStripLabelPageNumber = null; //toolStripButtonNext = null; //toolStripButtonLast = null; //drawarea = null; //panelTabPage = null; panelPageNavigation.Dispose(); toolStripPageNavigation.Dispose(); toolStripButtonAdd.Dispose(); toolStripButtonDelete.Dispose(); toolStripSeparator1.Dispose(); toolStripButtonFirst.Dispose(); toolStripButtonPrevious.Dispose(); toolStripLabelPageNumber.Dispose(); toolStripButtonNext.Dispose(); toolStripButtonLast.Dispose(); //drawarea = null; }
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"); }
public override void CloseTabPage() { //bool ret = true; //this.Controls.Clear(); base.CloseTabPage(); #if EWSAPP if (Dirty) { if (DialogResult.Yes == MessageBox.Show("Do you want to save?", "Save", MessageBoxButtons.YesNoCancel)) { SaveTabPage(); } } #endif //return ret; tblpou.Pages = null; panelPageNavigation.Dispose(); toolStripPageNavigation.Dispose(); toolStripButtonAdd.Dispose(); toolStripButtonDelete.Dispose(); toolStripSeparator1.Dispose(); toolStripButtonFirst.Dispose(); toolStripButtonPrevious.Dispose(); toolStripLabelPageNumber.Dispose(); toolStripButtonNext.Dispose(); toolStripButtonLast.Dispose(); //drawarea = null; }
/// <summary> /// Constructor using given PropertyGridView and mode flags</summary> /// <param name="mode">The flags specifying the PropertyGrid's features and appearance</param> /// <param name="propertyGridView">The customized PropertyGridView</param> public PropertyGrid(PropertyGridMode mode, PropertyGridView propertyGridView) { m_propertyGridView = propertyGridView; m_propertyGridView.BackColor = SystemColors.Window; m_propertyGridView.Dock = DockStyle.Fill; m_propertyGridView.EditingContextChanged += propertyGrid_EditingContextChanged; m_propertyGridView.MouseUp += propertyGrid_MouseUp; m_propertyGridView.DragOver += propertyGrid_DragOver; m_propertyGridView.DragDrop += propertyGrid_DragDrop; m_propertyGridView.MouseHover += propertyGrid_MouseHover; m_propertyGridView.MouseLeave += propertyGrid_MouseLeave; if (m_descriptionTextBox != null) { m_propertyGridView.DescriptionSetter = p => { if (p != null) m_descriptionTextBox.SetDescription(p.DisplayName, p.Description); else m_descriptionTextBox.ClearDescription(); }; } 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; var item1 = new ToolStripMenuItem("Unsorted".Localize()); item1.Tag = PropertySorting.None; var item2 = new ToolStripMenuItem("Alphabetical".Localize()); item2.Tag = PropertySorting.Alphabetical; var item3 = new ToolStripMenuItem("Categorized".Localize()); item3.Tag = PropertySorting.Categorized; var item4 = new ToolStripMenuItem("Categorized Alphabetical Properties".Localize()); item4.Tag = PropertySorting.Categorized | PropertySorting.Alphabetical; var item5 = new ToolStripMenuItem("Alphabetical Categories".Localize()); item5.Tag = PropertySorting.Categorized | PropertySorting.CategoryAlphabetical; var 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.DisableSearchControls) == 0) { var dropDownButton = new ToolStripDropDownButton(); dropDownButton.DisplayStyle = ToolStripItemDisplayStyle.Image; dropDownButton.Image = ResourceUtil.GetImage16(Resources.SearchImage); dropDownButton.ImageTransparentColor = System.Drawing.Color.Magenta; dropDownButton.Name = "PropertyGridSearchButton"; dropDownButton.Size = new System.Drawing.Size(29, 22); dropDownButton.Text = "Search".Localize("'Search' is a verb"); m_patternTextBox = new ToolStripAutoFitTextBox(); 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(); }
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"); }
/// <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")) { if (callback != null && !callback.isAroundFilterEnabled(moduleID)) callback.toggleAroundFilter(moduleID); continue; } // Leaves the ReverseLookup Modules hidden. if (moduleID.StartsWith("ReverseLookup")) { continue; } System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem(); newItem.AutoSize = true; if (callback != null && callback.isAroundFilterEnabled(moduleID) == true) { newItem.Image = global::BaseIMEUI.Properties.Resources.menuCheck; newItem.Checked = true; } else { newItem.Image = global::BaseIMEUI.Properties.Resources.menuUncheck; newItem.Checked = false; } 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.aroundFilterToolStripMenuItem_Click); this.u_configsDropDownMenu.Items.Add(newItem); } this.u_configsDropDownMenu.Items.Add(new ToolStripSeparator()); } // Load Output Filters. if (outputFilters.Count > 0) { foreach (KeyValuePair<string, string> outputFilter in outputFilters) { string ID = outputFilter.Key; string Name = outputFilter.Value; System.Windows.Forms.ToolStripMenuItem newItem = new System.Windows.Forms.ToolStripMenuItem(); newItem.AutoSize = true; if (callback != null && callback.isOutputFilterEnabled(ID) == true) { newItem.Image = global::BaseIMEUI.Properties.Resources.menuCheck; newItem.Checked = true; } else { newItem.Image = global::BaseIMEUI.Properties.Resources.menuUncheck; newItem.Checked = false; } newItem.Name = ID; newItem.Text = Name; newItem.ToolTipText = Name; newItem.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; newItem.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; newItem.Click += new System.EventHandler(this.outputFilterToolStripMenuItem_Click); u_configsDropDownMenu.Items.Add(newItem); } this.u_configsDropDownMenu.Items.Add(new ToolStripSeparator()); } this.u_configsDropDownMenu.Items.AddRange(this.m_defualtConfigItems); #region Init the default input method ToolStripMenuItem targetItem = null; bool found = false; foreach (object item in this.u_toggleInputMethodDropDownMenu.Items) { if (item is ToolStripMenuItem) { ToolStripMenuItem currentItem = (ToolStripMenuItem)item; if (currentItem.Name.Equals(currentInputMethod)) { found = true; targetItem = currentItem; break; } } } if (!found) targetItem = (ToolStripMenuItem)this.u_toggleInputMethodDropDownMenu.Items[0]; if (targetItem != null) { this.u_toggleInputMethod.Image = targetItem.Image; this.u_toggleInputMethod.Text = targetItem.Text; if (callback != null) callback.setPrimaryInputMethod(targetItem.Name, false); targetItem.CheckState = CheckState.Checked; } #endregion if (useEnglishKeyboard == true) this.u_toggleAlphanumericMode.Image = global::BaseIMEUI.Properties.Resources.english; else this.u_toggleAlphanumericMode.Image = global::BaseIMEUI.Properties.Resources.chinese; if (useFullWidth == true) this.u_toggleFullWidthCharacterMode.Image = global::BaseIMEUI.Properties.Resources.fullwidth; else this.u_toggleFullWidthCharacterMode.Image = global::BaseIMEUI.Properties.Resources.halfwidth; if (useSimplifiedChinese == true) this.u_toggleChineseCharacterConverter.Image = global::BaseIMEUI.Properties.Resources.zh_CN; else this.u_toggleChineseCharacterConverter.Image = global::BaseIMEUI.Properties.Resources.zh_TW; }
/// <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(); }