//コンテキストメニュー表示 public void ShowContextMenu(IPoderosaMenuGroup[] menus, ICommandTarget target, Point point_screen, ContextMenuFlags flags) { //まずソート ICollection sorted = PositionDesignationSorter.SortItems(menus); ContextMenuStrip cm = new ContextMenuStrip(); MenuUtil.BuildContextMenu(cm, new ConvertingEnumerable <IPoderosaMenuGroup>(sorted), target); if (cm.Items.Count == 0) { cm.Dispose(); return; } //キーボード操作をトリガにメニューを出すときは、選択があったほうが何かと操作しやすい。 if ((flags & ContextMenuFlags.SelectFirstItem) != ContextMenuFlags.None) { cm.Items[0].Select(); } // ContextMenuStrip is not disposed automatically and // its instance sits in memory till application end. // To release a document object related with some menu items, // we need to dispose ContextMenuStrip explicitly soon after it disappeared. cm.VisibleChanged += new EventHandler(ContextMenuStripVisibleChanged); try { cm.Show(this, this.PointToClient(point_screen)); } catch (Exception ex) { RuntimeUtil.ReportException(ex); } }
private void CreateInternal() { IToolBarComponent[] components = (IToolBarComponent[])WindowManagerPlugin.Instance.PoderosaWorld.PluginManager.FindExtensionPoint(WindowManagerConstants.TOOLBARCOMPONENT_ID).GetExtensions(); _toolStrips = new List <ToolStrip>(); string[] locations = _initialLocationInfo.Split(','); this.TopToolStripPanel.Size = new Size(TryParseInt(locations, 0), TryParseInt(locations, 1)); int index = 1; foreach (IToolBarComponent comp in PositionDesignationSorter.SortItems(components)) { //Locationの判定 Point pt = new Point(TryParseInt(locations, index * 2), TryParseInt(locations, index * 2 + 1)); CreateToolBarComponent(comp, pt); index++; } }
public void Create() { if (_created) { return; } _children.Clear(); IPoderosaMenuGroup[] me = (IPoderosaMenuGroup[])_extensionPoint.GetExtensions(); //ソートしてコレクションに追加 foreach (IPoderosaMenuGroup g in PositionDesignationSorter.SortItems(me)) { _children.Add(g); } _created = true; }
private void InitKeyConfigUI() { _keyConfigList.Items.Clear(); //列挙してソート TypedHashtable <ICommandCategory, List <IGeneralCommand> > category_list = new TypedHashtable <ICommandCategory, List <IGeneralCommand> >(); foreach (IGeneralCommand cmd in _keybinds.Commands) { ICommandCategory cat = cmd.CommandCategory; if (cat != null && cat.IsKeybindCustomizable) { if (category_list.Contains(cat)) { category_list[cat].Add(cmd); } else { List <IGeneralCommand> l = new List <IGeneralCommand>(); l.Add(cmd); category_list.Add(cat, l); } } } ICollection result = PositionDesignationSorter.SortItems(category_list.Keys); foreach (ICommandCategory cat in result) { foreach (IGeneralCommand cmd in category_list[cat]) { ListViewItem li = new ListViewItem(cat.Name); li = _keyConfigList.Items.Add(li); li.SubItems.Add(cmd.Description); li.SubItems.Add(FormatKey(_keybinds.GetKey(cmd))); li.Tag = cmd; } } }