public ToolStripDropDownItemProvider (ToolStripDropDownItem dropDrownItem) : base (dropDrownItem) { this.dropDrownItem = dropDrownItem; itemProviders = new Dictionary<ToolStripItem, FragmentControlProvider> (); }
// Constructor required by plugins public DynamicMenu(ToolStripDropDownItem tsmiHost) { Debug.Assert(tsmiHost != null); if(tsmiHost == null) throw new ArgumentNullException("tsmiHost"); m_tsicHost = tsmiHost.DropDownItems; }
public static List<ToolStripItem> CreateGroupItems(ToolStripDropDownItem dropDownItem) { List<ToolStripItem> ret = new List<ToolStripItem>(); DropDownMenuReorderable dropDown = null; if(dropDownItem != null) { dropDown = (DropDownMenuReorderable)dropDownItem.DropDown; while(dropDown.Items.Count > 0) { dropDown.Items[0].Dispose(); } dropDown.ItemsClear(); } const string key = "groups"; foreach(Group group in GroupsManager.Groups) { if(group.Paths.Count == 0 || !QTUtility2.PathExists(group.Paths[0])) continue; QMenuItem item = new QMenuItem(group.Name, MenuGenre.Group); item.SetImageReservationKey(group.Paths[0], null); if(dropDown != null) { dropDown.AddItem(item, key); } ret.Add(item); if(!group.Startup) continue; if(StartUpTabFont == null) { StartUpTabFont = new Font(item.Font, FontStyle.Underline); } item.Font = StartUpTabFont; } if(dropDownItem != null) { dropDownItem.Enabled = dropDown.Items.Count > 0; } return ret; }
private void maakHelpMenu() { ToolStripDropDownItem menu; menu = new ToolStripMenuItem("Help"); menu.DropDownItems.Add("Over \"Schets\"", null, this.about); menuStrip.Items.Add(menu); }
private void AddSubMenuNodes(IEnumerable<ConnectionInfo> nodes, ToolStripDropDownItem toolStripMenuItem) { foreach (var connectionInfo in nodes) { var newItem = CreateMenuItem(connectionInfo); toolStripMenuItem.DropDownItems.Add(newItem); } }
private void attachToolStripMenuItem_DropDownOpening(object sender, EventArgs e) { System.Windows.Forms.ToolStripDropDownItem parentMenuItem = ((System.Windows.Forms.ToolStripDropDownItem)(sender)); parentMenuItem.DropDownItems.Clear(); String[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\"); var pipeNames = ( from n in listOfPipes where n.StartsWith("\\\\.\\pipe\\SSE_") && n.Contains("_IDE_") == false select n.Substring(18)).Distinct().ToList(); int addedCount = 0; if (pipeNames.Count() > 0) { foreach (string pipeName in pipeNames) { int processId = 0; if (int.TryParse(pipeName, out processId)) { Process sseProcess = Process.GetProcessById(processId); string userName = ""; string userDomain = ""; userDomain = sseProcess.StartInfo.EnvironmentVariables["userdomain"]; userName = sseProcess.StartInfo.EnvironmentVariables["username"]; if (userDomain != "") { userDomain += "\\"; } //foreach (System.Collections.DictionaryEntry ss in sseProcess.StartInfo.EnvironmentVariables) //{ // MessageBox.Show(ss.Key + " = " + ss.Value); //} string caption = sseProcess.ProcessName + " (PID:" + processId + ", User:"******")"; ToolStripItem menuItem = parentMenuItem.DropDownItems.Add(caption); menuItem.Click += new EventHandler(Debug_Attach_MenuItem_Click); menuItem.Tag = processId; menuItem.Enabled = !_RunningApplication.IsRunning; addedCount++; } } } if (addedCount == 0) { parentMenuItem.DropDownItems.Add("(no processes found)").Enabled = false; } }
private static void Endisable(ToolStripDropDownItem tsddi, bool enable, PropagationMode mode) { if((mode & PropagationMode.CHILDREN) == PropagationMode.CHILDREN) { foreach(ToolStripItem tsi in tsddi.DropDownItems) { Endisable(tsi, enable, PropagationMode.CHILDREN); } } tsddi.Enabled = enable; }
private void HookItem(ToolStripDropDownItem t) { t.Click += SubHook; t.Tag = this; if (!t.HasDropDownItems) return; foreach (ToolStripMenuItem item in t.DropDownItems) { HookItem(item); } }
private void AddBodyGlyphs(ToolStripDropDownItem item) { if ((item != null) && (((ToolStripMenuItemDesigner) this.designerHost.GetDesigner(item)) != null)) { foreach (ToolStripItem item2 in item.DropDownItems) { this.AddItemBodyGlyph(item2); } } }
private void maakFileMenu() { menu = new ToolStripMenuItem("File"); menu.DropDownItems.Add("Nieuw", null, this.nieuw); menu.DropDownItems.Add("Opslaan", null, this.opslaan); menu.DropDownItems[1].Enabled = false; menu.DropDownItems.Add("Open", null, this.open); menu.DropDownItems.Add("Exit", null, this.afsluiten); menuStrip.Items.Add(menu); }
public OpenWithMenu(ToolStripDropDownItem tsmiHost) { if(tsmiHost == null) { Debug.Assert(false); return; } m_tsmiHost = tsmiHost; m_dynMenu = new DynamicMenu(m_tsmiHost); m_dynMenu.MenuClick += this.OnOpenUrl; m_tsmiHost.DropDownOpening += this.OnMenuOpening; }
protected static void PerformDropDownClick(ToolStripDropDownItem dropDownItem, object ItemTag) { foreach (ToolStripItem item in dropDownItem.DropDownItems) { if (ItemTag.Equals(item.Tag)) { item.PerformClick(); break; } } }
protected void UpdateDropDownText(ToolStripDropDownItem dropDownItem, object ItemTag) { foreach (ToolStripItem item in dropDownItem.DropDownItems) { if (ItemTag.Equals(item.Tag)) { dropDownItem.Text = item.Text; break; } } }
public MruController(string subKeyName, ToolStripDropDownItem recentMenu, EventHandler onItemClick) { if (string.IsNullOrWhiteSpace(subKeyName)) throw new ArgumentNullException("subKeyName"); if (recentMenu == null) throw new ArgumentNullException("parentMenuItem"); if (onItemClick == null) throw new ArgumentNullException("onItemClick"); SubKeyName = string.Concat(@"Software\", subKeyName); RecentMenu = recentMenu; OnItemClick = onItemClick; RefreshRecentMenu(); }
private bool CheckDropDownBounds(ToolStripDropDownItem dropDownItem, Glyph childGlyph, GlyphCollection glyphs) { if (dropDownItem == null) { return false; } Rectangle bounds = childGlyph.Bounds; Rectangle rect = base.BehaviorService.ControlRectInAdornerWindow(dropDownItem.DropDown); if (!bounds.IntersectsWith(rect)) { glyphs.Insert(0, childGlyph); } return true; }
private void RecursiveMenuItems(ToolStripDropDownItem item) { if (item.HasDropDownItems) { foreach (var cItem in item.DropDownItems) { if (cItem is ToolStripMenuItem) { RecursiveMenuItems((ToolStripMenuItem)cItem); } } } SetColorsOnMenuItem((ToolStripMenuItem)item); }
public void Destroy() { if(m_dynMenu != null) { m_dynMenu.Clear(); m_dynMenu.MenuClick -= this.OnOpenUrl; m_dynMenu = null; m_tsmiHost.DropDownOpening -= this.OnMenuOpening; m_tsmiHost = null; // After the menu has been destroyed: ReleaseOpenWithList(); // Release icons, ... } }
internal static void GetAllDbData(ToolStripDropDownItem toolStripMenu) { using (UPdatabase ctx = new UPdatabase()) { var allRows = ctx.UpData.ToList(); if (toolStripMenu.DropDownItems.Count != 0) { toolStripMenu.DropDownItems.Clear(); } foreach (var name in allRows) { toolStripMenu.DropDownItems.Add(name.ID + "-" + name.UserName, null, myClickHandler); item = ctx.UpData.FirstOrDefault(s => s.UserName == name.UserName); } } }
void LoadConfigNodes(ConfigEntitySection configs, ToolStripDropDownItem root) { foreach (ConfigEntitySection section in configs.Sections) { SectionMenu node = new SectionMenu(section); LoadConfigNodes(section, node); root.DropDownItems.Add(node); } foreach (ConfigFileEntity config in configs.List) { ConfigMenu node = new ConfigMenu(config); root.DropDownItems.Add(node); } }
public MediaController(Model model, StatusController statusController, ToolStripDropDownItem recentMenu, EventHandler onItemClick) { Model = model; StatusController = statusController; var filter = Properties.Settings.Default.MediaFilter; OpenFileDialog = new OpenFileDialog { Filter = filter, Multiselect = true, Title = "Select the media file(s) to add" }; FolderBrowserDialog = new FolderBrowserDialog { Description = "Select the media folder to add" }; MruController = new MruController(Application.ProductName + @"\MediaMRU", recentMenu, onItemClick); }
public PersistenceController(Model model, Control view, ToolStripDropDownItem recentMenu, EventHandler onItemClick) { Model = model; View = view; var filter = Properties.Settings.Default.LibraryFilter; OpenFileDialog = new OpenFileDialog { Filter = filter, Title = "Select the library file to open" }; SaveFileDialog = new SaveFileDialog { Filter = filter, Title = "Save library file" }; MruController = new MruController(Application.ProductName + @"\LibraryMRU", recentMenu, onItemClick); }
protected override void OnVisibleChanged(EventArgs e) { base.OnVisibleChanged(e); if (owner_item != null && owner_item is ToolStripDropDownItem) { ToolStripDropDownItem dropdown_owner = (ToolStripDropDownItem)owner_item; if (Visible) { dropdown_owner.OnDropDownOpened(EventArgs.Empty); } else { dropdown_owner.OnDropDownClosed(EventArgs.Empty); } } }
/// <summary> /// Applies resources to the specified <see cref="ToolStripDropDownItem"/> /// and its child drop down items. /// </summary> /// <param name="resources">The <see cref="ComponentResourceManager"/> used to apply the resources.</param> /// <param name="dropDownItem">The <see cref="ToolStripDropDownItem"/> to apply the resources to.</param> /// <exception cref="ArgumentNullException"><paramref name="resources"/> is <c>null</c> -or- <paramref name="dropDownItem"/> is <c>null</c>.</exception> public static void ApplyResources(ComponentResourceManager resources, ToolStripDropDownItem dropDownItem) { if (resources == null) { throw new ArgumentNullException("resources"); } if (dropDownItem == null) { throw new ArgumentNullException("dropDownItem"); } for (int i = 0; i < dropDownItem.DropDownItems.Count; i++) { LocalizationHelper.ApplyResources(resources, dropDownItem.DropDownItems[i]); } resources.ApplyResources(dropDownItem, dropDownItem.Name); }
/// <summary> /// Populates the list box with the list of undo/redo actions, and displays the form /// directly below the tool strip button. /// </summary> /// <param name="dropDownButton">Tool strip button under which this form should be displayed</param> /// <param name="undo">true if this is "undo", false for "redo"</param> /// <param name="undoManager">the UndoManager</param> public void ShowList(ToolStripDropDownItem dropDownButton, bool undo, UndoManager undoManager) { Point location = dropDownButton.Owner.PointToScreen(new Point(dropDownButton.Bounds.Left, dropDownButton.Bounds.Bottom)); Left = location.X; Top = location.Y; _undo = undo; _undoManager = undoManager; listBox.Items.Clear(); IEnumerable<String> descriptions = undo ? undoManager.UndoDescriptions : undoManager.RedoDescriptions; foreach (String description in descriptions) { listBox.Items.Add(description); } UpdateSelectedIndex(0); Height = listBox.ItemHeight * Math.Min(MAX_DISPLAY_ITEMS, listBox.Items.Count) + label.Height + TOTAL_BORDER_WIDTH; Show(dropDownButton.Owner); listBox.Focus(); }
private ArrayList FindInternal(string key, bool searchAllChildren, ToolStripItemCollection itemsToLookIn, ArrayList foundItems) { if ((itemsToLookIn == null) || (foundItems == null)) { return(null); } try { for (int i = 0; i < itemsToLookIn.Count; i++) { if ((itemsToLookIn[i] != null) && WindowsFormsUtils.SafeCompareStrings(itemsToLookIn[i].Name, key, true)) { foundItems.Add(itemsToLookIn[i]); } } if (!searchAllChildren) { return(foundItems); } for (int j = 0; j < itemsToLookIn.Count; j++) { ToolStripDropDownItem item = itemsToLookIn[j] as ToolStripDropDownItem; if ((item != null) && item.HasDropDownItems) { foundItems = this.FindInternal(key, searchAllChildren, item.DropDownItems, foundItems); } } } catch (Exception exception) { if (System.Windows.Forms.ClientUtils.IsCriticalException(exception)) { throw; } } return(foundItems); }
public override void MenuWillOpen(NSMenu menu) { if (owner.currentMenu != menu) { var cancelEventArgs = new CancelEventArgs(); if (owner.owner_item != null && owner.owner_item is ToolStripDropDownItem) { ToolStripDropDownItem dropdown_owner = (ToolStripDropDownItem)owner.owner_item; dropdown_owner.OnDropDownShow(cancelEventArgs); } if (!cancelEventArgs.Cancel) { owner.OnOpening(cancelEventArgs); } if (cancelEventArgs.Cancel) { menu.CancelTrackingWithoutAnimation(); return; } } owner.is_visible = true; owner.currentMenu = menu; owner.OnVisibleChanged(EventArgs.Empty); // Send WM_CANCELMODE to cancel any grabs owner.CancelGrab(); // Convert all the menu items to NSMenuItems (w/ embedded views if necessary) if (!beforePopupCalled) { BeforePopup(); } owner.OnOpened(EventArgs.Empty); }
private void SetupTrackLineMenu(ToolStripDropDownItem menu, Action<int> clickHandler, EventHandler disableHandler) { while (menu.DropDownItems.Count > 0) { // The item will be removed from its container as it is disposed menu.DropDownItems[0].Dispose(); } // Select every linear expression and create a menu item from it var items = from expr in graph.GraphedExpressions where expr is StandardExpression && expr.Type == ExpressionType.Linear let stdExpr = expr as StandardExpression select new { Menu = new ToolStripMenuItem(stdExpr.Expression.OriginalExpression), stdExpr.Slot }; foreach (var item in items) { // Required to do this because of the way foreach closures work // Asked and answered here: "http://stackoverflow.com/questions/3465115" var localItem = item; localItem.Menu.Click += (s, e) => clickHandler(localItem.Slot); menu.DropDownItems.Add(localItem.Menu); } // If no expressions were found, disable the menu item menu.Enabled = menu.DropDownItems.Count > 0; if (menu.Enabled) { ToolStripMenuItem disableMenu = new ToolStripMenuItem("Disable"); disableMenu.Click += disableHandler; menu.DropDownItems.Insert(0, disableMenu); } }
private void AddHistoryItems(ToolStripDropDownItem button) { QTTabBarClass tabBar = QTUtility.instanceManager.GetTabBar(ExplorerHandle); if(tabBar != null) { button.DropDownItems.Clear(); List<QMenuItem> list = tabBar.CreateNavBtnMenuItems(true); if(list.Count != 0) { button.DropDownItems.AddRange(list.ToArray()); button.DropDownItems.AddRange(tabBar.CreateBranchMenu(true, components, navBranchRoot_DropDownItemClicked).ToArray()); } else { ToolStripMenuItem item = new ToolStripMenuItem("none"); item.Enabled = false; button.DropDownItems.Add(item); } } }
private void AddRecentFileToMenu(string FileName, ToolStripDropDownItem oToolStripItem, EventHandler menu_Click) { oToolStripItem.Enabled = true; ToolStripMenuItem RecentFileMenu = new ToolStripMenuItem(FileName); RecentFileMenu.Click += menu_Click; oToolStripItem.DropDownItems.Add (RecentFileMenu); }
/// <summary> /// Generates a group of drop <c>ToolStipItem(s)</c> /// under the given <c>ToolStripDropDownItem</c> /// The <c>EventHandler</c> menu_Click is assign /// to each <c>ToolStripDropDownItem.Click</c> event. /// </summary> /// <remarks> /// <example> /// The developer can assume that <c>ToolStripDropDownItem.Text</c> /// is the name of the file. It is assumed that the developer would do /// something similar to the code below. /// <code> /// ToolStripDropDownItem menuItem = (ToolStripDropDownItem) sender; /// string FileName = menuItem.Text; /// /// //Open the file /// </code> /// </example> /// This function will be marked <c>[Obsolete]</c> in the event that /// changes to it are made. I might assign the file name to /// <c>ToolStripDropDownItem.Tag</c> /// </remarks> /// <param name="menuParent"> /// Parent <c>ToolStripDropDownItem</c> /// </param> /// <param name="menu_Click"> /// <c>EventHandler</c> for Click Events /// </param> public void GenerateOpenRecentMenu(ToolStripDropDownItem menuParent, EventHandler menu_Click) { menuParent.DropDownItems.Clear(); foreach (RecentFileElement RecentFile in this) { AddRecentFileToMenu (RecentFile.Name, menuParent, menu_Click); } }
/// <summary> /// Returns an observable sequence wrapping the DropDownOpening event on the ToolStripDropDownItem instance. /// </summary> /// <param name="instance">The ToolStripDropDownItem instance to observe.</param> /// <returns>An observable sequence wrapping the DropDownOpening event on the ToolStripDropDownItem instance.</returns> public static IObservable <EventPattern <EventArgs> > DropDownOpeningObservable(this ToolStripDropDownItem instance) { return(Observable.FromEventPattern <EventHandler, EventArgs>( handler => instance.DropDownOpening += handler, handler => instance.DropDownOpening -= handler)); }
/// <include file='doc\ToolStripDropDownItem.uex' path='docs/doc[@for="ToolStripDropDownItemAccessibleObject.ToolStripDropDownItemAccessibleObject"]/*' /> public ToolStripDropDownItemAccessibleObject(ToolStripDropDownItem item) : base(item) { owner = item; }
/// <include file='doc\ToolStripDropDownItem.uex' path='docs/doc[@for="ToolStripDropDownItemAccessibleObject.ToolStripDropDownItemAccessibleObject"]/*' /> public ToolStripDropDownItemAccessibleObject(ToolStripDropDownItem item) : base(item) { owner = item; }
private void PopulateQuickSwitchMenu(ToolStripDropDownItem parent) { quickCoinMenu.Items.Clear(); foreach (CoinConfiguration coinConfiguration in engineConfiguration.CoinConfigurations.Where(c => c.Enabled)) { ToolStripMenuItem coinSwitchItem = new ToolStripMenuItem() { Text = coinConfiguration.Coin.Name, Tag = coinConfiguration.Coin.Symbol }; coinSwitchItem.Click += HandleQuickSwitchClick; quickCoinMenu.Items.Add(coinSwitchItem); } //Mono under Linux absolutely doesn't like having one context menu assigned to multiple //toolstrip items' DropDown property at once, so we have to target a single one here parent.DropDown = quickCoinMenu; }
public static void UpdateControlTheme(ToolStripDropDownItem menuItem) { if (menuItem.Font != SystemFonts.MessageBoxFont) menuItem.Font = new Font(SystemFonts.MessageBoxFont, menuItem.Font.Style); UpdateControlTheme(menuItem.DropDown); }
/// <summary> /// Returns an observable sequence wrapping the DropDownItemClicked event on the ToolStripDropDownItem instance. /// </summary> /// <param name="instance">The ToolStripDropDownItem instance to observe.</param> /// <returns>An observable sequence wrapping the DropDownItemClicked event on the ToolStripDropDownItem instance.</returns> public static IObservable <EventPattern <ToolStripItemClickedEventArgs> > DropDownItemClickedObservable(this ToolStripDropDownItem instance) { return(Observable.FromEventPattern <ToolStripItemClickedEventHandler, ToolStripItemClickedEventArgs>( handler => instance.DropDownItemClicked += handler, handler => instance.DropDownItemClicked -= handler)); }
/// <summary> /// Adds a range of controls to the Command list at once /// </summary> /// <param name="Items">Array of Commands to add to the list.</param> public void AddRange(params object[] Items) { foreach (object instance in Items) { Type ObjType = instance.GetType(); string sObjType = ObjType.ToString(); switch (sObjType) { case "System.Windows.Forms.ToolBarButton": System.Windows.Forms.ToolBarButton ItmToolBarButton = (System.Windows.Forms.ToolBarButton)instance; this.Add(ItmToolBarButton); break; case "System.Windows.Forms.MenuItem": System.Windows.Forms.MenuItem ItmMenuItem = (System.Windows.Forms.MenuItem)instance; this.Add(ItmMenuItem); break; case "System.Windows.Forms.Button": System.Windows.Forms.Button ItmButton = (System.Windows.Forms.Button)instance; this.Add(ItmButton); break; case "System.Windows.Forms.ListView": System.Windows.Forms.ListView ItmListView = (System.Windows.Forms.ListView)instance; this.Add(ItmListView); break; case "System.Windows.Forms.ToolStripDropDownItem": System.Windows.Forms.ToolStripDropDownItem ItmToolStripDropDownItem = (System.Windows.Forms.ToolStripDropDownItem)instance; this.Add(ItmToolStripDropDownItem); break; case "System.Windows.Forms.ToolStripMenuItem": System.Windows.Forms.ToolStripMenuItem ItmToolStripMenuItem = (System.Windows.Forms.ToolStripMenuItem)instance; this.Add(ItmToolStripMenuItem); break; case "System.Windows.Forms.ToolStripButton": System.Windows.Forms.ToolStripButton ItmToolStripButton = (System.Windows.Forms.ToolStripButton)instance; this.Add(ItmToolStripButton); break; case "System.Windows.Forms.TextBox": System.Windows.Forms.TextBox itmTextBox = (System.Windows.Forms.TextBox)instance; this.Add(itmTextBox); break; case "System.Windows.Forms.Label": System.Windows.Forms.Label itmLabel = (System.Windows.Forms.Label)instance; this.Add(itmLabel); break; case "System.Windows.Forms.ComboBox": System.Windows.Forms.ComboBox itmComboBox = (System.Windows.Forms.ComboBox)instance; this.Add(itmComboBox); break; case "System.Windows.Forms.CheckBox": System.Windows.Forms.CheckBox itmCheckBox = (System.Windows.Forms.CheckBox)instance; this.Add(itmCheckBox); break; case "System.Windows.Forms.NumericUpDown": System.Windows.Forms.NumericUpDown itmNumericUpDown = (System.Windows.Forms.NumericUpDown)instance; this.Add(itmNumericUpDown); break; default: // use late binding // This would only come into play when command manager is extended // to handle a new type outside the library MethodInfo generic = this.AddMethodInfo.MakeGenericMethod(ObjType); generic.Invoke(this, new object[] { instance }); break; } } }
/// <summary> /// Sets the enabled state of the ToolStripDropDownItem /// </summary> /// <param name="item">A ToolStripDropDownItem</param> /// <param name="bEnable">If true then the <paramref name="item"/> will be Enabled; Otherwise Disabled.</param> public override void Enable(ToolStripDropDownItem item, bool bEnable) { System.Windows.Forms.ToolStripDropDownItem tItem = (System.Windows.Forms.ToolStripDropDownItem)item; tItem.Enabled = bEnable; }
/// <summary> /// Sets the Visible state of the ToolStripDropDownItem /// </summary> /// <param name="item">A ToolStripDropDownItem</param> /// <param name="bVisible">If true then the <paramref name="item"/> will be Visible; Otherwise Invisible.</param> public override void Visible(System.Windows.Forms.ToolStripDropDownItem item, bool bVisible) { item.Visible = bVisible; }
internal void FillTextModules( ToolStripDropDownItem textModulesToolStripItem) { checkGetTextModules(); textModulesToolStripItem.DropDownItems.Clear(); foreach (var textModule in _textModules) { var mi = new ToolStripMenuItem(textModule.Name) { Tag = textModule }; mi.Click += delegate { var tm = (TextModuleInfo)mi.Tag; insertHtmlFragmentAtCurrentPosition(tm.Html); }; textModulesToolStripItem.DropDownItems.Add(mi); } }
/// <summary> /// Рекурсивно перевести элементы управления Windows-формы /// </summary> private static void TranslateWinControls(ICollection controls, WinForms.ToolTip toolTip, Dictionary <string, ControlInfo> controlInfoDict) { if (controls == null) { return; } foreach (object elem in controls) { ControlInfo controlInfo; if (elem is WinForms.Control) { // обработка обычного элемента управления WinForms.Control control = (WinForms.Control)elem; if (!string.IsNullOrEmpty(control.Name) /*например, поле ввода и кнопки NumericUpDown*/ && controlInfoDict.TryGetValue(control.Name, out controlInfo)) { if (controlInfo.Text != null) { control.Text = controlInfo.Text; } if (controlInfo.ToolTip != null && toolTip != null) { toolTip.SetToolTip(control, controlInfo.ToolTip); } if (controlInfo.Items != null) { if (elem is WinForms.ComboBox) { WinForms.ComboBox comboBox = (WinForms.ComboBox)elem; int cnt = Math.Min(comboBox.Items.Count, controlInfo.Items.Count); for (int i = 0; i < cnt; i++) { string itemText = controlInfo.Items[i]; if (itemText != null) { comboBox.Items[i] = itemText; } } } else if (elem is WinForms.ListView) { WinForms.ListView listView = (WinForms.ListView)elem; int cnt = Math.Min(listView.Items.Count, controlInfo.Items.Count); for (int i = 0; i < cnt; i++) { string itemText = controlInfo.Items[i]; if (itemText != null) { listView.Items[i].Text = itemText; } } } } } // запуск обработки вложенных элементов if (elem is WinForms.MenuStrip) { // запуск обработки элементов меню WinForms.MenuStrip menuStrip = (WinForms.MenuStrip)elem; TranslateWinControls(menuStrip.Items, toolTip, controlInfoDict); } else if (elem is WinForms.ToolStrip) { // запуск обработки элементов панели инструментов WinForms.ToolStrip toolStrip = (WinForms.ToolStrip)elem; TranslateWinControls(toolStrip.Items, toolTip, controlInfoDict); } else if (elem is WinForms.DataGridView) { // запуск обработки столбцов таблицы WinForms.DataGridView dataGridView = (WinForms.DataGridView)elem; TranslateWinControls(dataGridView.Columns, toolTip, controlInfoDict); } else if (elem is WinForms.ListView) { // запуск обработки столбцов и групп списка WinForms.ListView listView = (WinForms.ListView)elem; TranslateWinControls(listView.Columns, toolTip, controlInfoDict); TranslateWinControls(listView.Groups, toolTip, controlInfoDict); } // запуск обработки дочерних элементов if (control.HasChildren) { TranslateWinControls(control.Controls, toolTip, controlInfoDict); } } else if (elem is WinForms.ToolStripItem) { // обработка элемента меню или элемента панели инструментов WinForms.ToolStripItem item = (WinForms.ToolStripItem)elem; if (controlInfoDict.TryGetValue(item.Name, out controlInfo)) { if (controlInfo.Text != null) { item.Text = controlInfo.Text; } if (controlInfo.ToolTip != null) { item.ToolTipText = controlInfo.ToolTip; } } if (elem is WinForms.ToolStripDropDownItem) { // запуск обработки элементов подменю WinForms.ToolStripDropDownItem dropDownItem = (WinForms.ToolStripDropDownItem)elem; if (dropDownItem.HasDropDownItems) { TranslateWinControls(dropDownItem.DropDownItems, toolTip, controlInfoDict); } } } else if (elem is WinForms.DataGridViewColumn) { // обработка столбца таблицы WinForms.DataGridViewColumn column = (WinForms.DataGridViewColumn)elem; if (controlInfoDict.TryGetValue(column.Name, out controlInfo) && controlInfo.Text != null) { column.HeaderText = controlInfo.Text; } } else if (elem is WinForms.ColumnHeader) { // обработка столбца списка WinForms.ColumnHeader columnHeader = (WinForms.ColumnHeader)elem; if (controlInfoDict.TryGetValue(columnHeader.Name, out controlInfo) && controlInfo.Text != null) { columnHeader.Text = controlInfo.Text; } } else if (elem is WinForms.ListViewGroup) { // обработка группы списка WinForms.ListViewGroup listViewGroup = (WinForms.ListViewGroup)elem; if (controlInfoDict.TryGetValue(listViewGroup.Name, out controlInfo) && controlInfo.Text != null) { listViewGroup.Header = controlInfo.Text; } } } }