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


C# ListViewItem.Select方法代码示例

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


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

示例1: AddTrackTypesMenuItems

        private void AddTrackTypesMenuItems(ContextMenuStrip menu, ListViewItem[] selectedListViewItems)
        {
            var tracks = selectedListViewItems.Select(item => item.Tag as Track).ToArray();
            var allTrackTypes = Enum.GetValues(typeof(TrackType)).OfType<TrackType>().ToArray();

            var selectedTrackTypes = new HashSet<TrackType>();
            foreach (var track in tracks)
            {
                selectedTrackTypes.Add(track.Type);
            }
            var selectedTrackType = selectedTrackTypes.Count == 1 ? new TrackType?(selectedTrackTypes.First()) : null;

            foreach (var trackType in allTrackTypes)
            {
                var type = trackType;
                var menuItem = new ToolStripMenuItem(trackType.ToString());
                if (selectedTrackType.HasValue && selectedTrackType == trackType)
                {
                    menuItem.Checked = true;
                    menuItem.Enabled = false;
                }
                menuItem.Click += (s, e) => TrackTypeMenuItemOnClick(selectedListViewItems, type);
                menu.Items.Add(menuItem);
            }
        }
开发者ID:JGTM2016,项目名称:bdhero,代码行数:25,代码来源:TrackListViewHelper.cs

示例2: UIEventHandlers

        private void UIEventHandlers()
        {
            // Drag Drop Files
            lvPreview.DragEnter += (@s, a) =>
                {
                    if (a.Data.GetDataPresent(DataFormats.FileDrop))
                        a.Effect = DragDropEffects.Link;
                };
            lvPreview.DragDrop += (@s, e) =>
                {
                    String[] files = (String[]) e.Data.GetData(DataFormats.FileDrop);
                    Session.AddFile(files);
                    UpdatePreview();
                };

            // Resize
            lvPreview.Resize += (@s, a) =>
            {
                Int32 width = (lvPreview.Width - 48) / 2;
                lvPreview.Columns[0].Width = width;
                lvPreview.Columns[1].Width = width;
            };
            lvPreview.KeyDown += (@s, e) =>
                {
                    if (e.KeyCode == Keys.A && e.Modifiers == Keys.Control)
                    {
                        foreach (ListViewItem i in lvPreview.Items)
                            i.Selected = true;
                    }
                    else if (e.KeyCode == Keys.Delete)
                    {
                        ListViewItem[] items = new ListViewItem[lvPreview.SelectedItems.Count];
                        lvPreview.SelectedItems.CopyTo(items, 0);

                        Session.RemoveFiles(from i in items select (String)i.Tag);
                        UpdatePreview();
                    }
                };

            // Context Menus
            lvPreview.ItemSelectionChanged += (@s, e) =>
                {
                    Int32 count = lvPreview.SelectedItems.Count;

                    tsmiPvRemSelection.Enabled = count > 0;
                    tsmiPvExtractRule.Enabled = count == 1;
                };
            lvRules.ItemSelectionChanged += (@s, e) =>
                {
                    Int32 count = lvRules.SelectedItems.Count;

                    tsmiRemoveRules.Enabled = count > 0;
                    tsmiAddToTemplates.Enabled = count == 1;
                };
            tsmiAddRule.Click += (@s, e) =>
                {
                    RuleEditorDialog dlg = new RuleEditorDialog(this);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        RenamingRule rule = dlg.Rule;
                        Session.Rules.AddRule(rule);
                    }
                };
            tsmiRemoveRules.Click += (@s, e) =>
                {
                    ListViewItem[] selection = new ListViewItem[lvRules.SelectedItems.Count];
                    lvRules.SelectedItems.CopyTo(selection, 0);

                    foreach (RenamingRule rule in selection.Select(v => v.Tag).OfType<RenamingRule>())
                        Session.Rules.RemoveRule(rule);

                    UpdateUI();
                };
            tsmiAddToTemplates.Click += (@s, e) =>
                {
                    RenamingRule rule = lvRules.SelectedItems[0].Tag as RenamingRule;
                    if (rule == null) throw new Exception();

                    OptionsDialog dlg = new OptionsDialog(1, rule);
                    dlg.ShowDialog();
                    UpdateUI();
                };
            tsmiPvAddFiles.Click += (@s, e) =>
                {
                    OpenFileDialog dlg = new OpenFileDialog() { Multiselect = true };
                    if (dlg.ShowDialog() == DialogResult.OK)
                        Session.AddFile(dlg.FileNames);
                };
            tsmiPvRemSelection.Click += (@s, e) =>
                {
                    ListViewItem[] items = new ListViewItem[lvPreview.SelectedItems.Count];
                    lvPreview.SelectedItems.CopyTo(items, 0);

                    Session.RemoveFiles(from i in items select (String)i.Tag);
                    UpdatePreview();
                };
            tsmiPvExtractRule.Click += (@s, e) =>
                {
                    String fname = lvPreview.SelectedItems[0].Tag as String;
                    if (fname == null) return;
//.........这里部分代码省略.........
开发者ID:jluchiji,项目名称:RenEx,代码行数:101,代码来源:MainForm.cs

示例3: AddLanguagesMenuItem

        private void AddLanguagesMenuItem(ContextMenuStrip menu, ListViewItem[] listViewItems)
        {
            // Only allow users to change the language on video tracks
            var tracks = listViewItems.Select(item => item.Tag as Track).ToArray();
            var isVideo = tracks.All(track => track.IsVideo);
            if (!isVideo)
                return;

            var selectedLanguages = new HashSet<Language>();
            foreach (var track2 in tracks)
            {
                selectedLanguages.Add(track2.Language);
            }
            var selectedLanguage = selectedLanguages.Count == 1 ? selectedLanguages.FirstOrDefault() : null;

            var languagesMenuItem = new ToolStripMenuItem("Language");
            foreach (var language in _allLanguages.OrderBy(language => language.Name))
            {
                var lang = language;
                var langMenuItem = new ToolStripMenuItem(language.Name);

                langMenuItem.Click += (s, e) => LanguageMenuItemOnClick(listViewItems, lang);

                if (language.Equals(selectedLanguage))
                {
                    langMenuItem.Checked = true;
                    langMenuItem.Enabled = false;
                }

                languagesMenuItem.DropDownItems.Add(langMenuItem);
            }

            menu.Items.Add(languagesMenuItem);
            menu.Items.Add("-");
        }
开发者ID:JGTM2016,项目名称:bdhero,代码行数:35,代码来源:TrackListViewHelper.cs

示例4: RenamingTabAttachEventHandlers

        private void RenamingTabAttachEventHandlers()
        {
            renBtnAddRule.Click += (@s, e) =>
                {
                    RuleEditorDialog dlg = new RuleEditorDialog(this);
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        RenamingRule rule = dlg.Rule;
                        rule.Active = true;

                        switch (rule.Type)
                        {
                            case RenamingRule.RuleType.Name:
                                {
                                    Session.Rules.NameRules.Add(rule);
                                }
                                break;
                            case RenamingRule.RuleType.Extension:
                                {
                                    Session.Rules.ExtensionRules.Add(rule);
                                }
                                break;
                            case RenamingRule.RuleType.Directory:
                                {
                                    Session.Rules.DirectoryRules.Add(rule);
                                }
                                break;
                        }
                        UpdateUI();
                    }
                };
            renBtnRemoveRule.Click += (@s, e) =>
                {
                    ListViewItem[] selection = new ListViewItem[lvRules.SelectedItems.Count];
                    lvRules.SelectedItems.CopyTo(selection, 0);

                    foreach (RenamingRule rule in selection.Select(v => v.Tag).OfType<RenamingRule>())
                    {
                        if (rule.Type == RenamingRule.RuleType.Name)
                            Session.Rules.NameRules.Remove(rule);
                        else if (rule.Type == RenamingRule.RuleType.Extension)
                            Session.Rules.ExtensionRules.Remove(rule);
                        else
                            Session.Rules.DirectoryRules.Remove(rule);
                    }
                    UpdateUI();
                };
            lvRules.ItemChecked += (@s, a) =>
                {
                    RenamingRule rule = a.Item.Tag as RenamingRule;
                    if (rule == null) return;

                    if (rule.Active != a.Item.Checked)
                    {
                        rule.Active = a.Item.Checked;
                        UpdatePreview();
                    }
                };
        }
开发者ID:jluchiji,项目名称:RenEx,代码行数:59,代码来源:MainForm.cs


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