Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QuickFileNav"/> class.
        /// </summary>
        /// <param name="gatherer">The gatherer.</param>
        public FileNav(FileGatherer fileGatherer)
        {
            InitializeComponent();

            if (lastSize.HasValue)
            {
                this.Size = lastSize.Value;
            }
            if (lastLocation.HasValue)
            {
                this.WindowState   = FormWindowState.Normal;
                this.StartPosition = FormStartPosition.Manual;
                this.BringToFront();
                this.Location = lastLocation.Value;
            }

            this.fileGatherer = fileGatherer;
            this.allFiles     = fileGatherer.Files;
            this.dataGrid.SetupColumns(false);
            SetStyles();

            this.dataGrid.CellDoubleClick += new DataGridViewCellEventHandler(BtnOkClick);
            this.filter.btnOk.Click       += new EventHandler(BtnOkClick);
            this.filter.btnCancel.Click   += new EventHandler(btnCancel_Click);
            this.filter.btnExplore.Click  += new EventHandler(btnExplore_Click);

            // Handle all the KeyDown events. Note that we need to
            // pipe messages from the grid through to the textbox control.
            this.dataGrid.KeyPress += (o, e) =>
            {
                this.filter.txtFilter.Focus();
                SendKeys.Send(e.KeyChar.ToString());
                e.Handled = true;
            };
            this.filter.txtFilter.TextChanged += (o, e) => { UpdateFilter(); };
            this.filter.txtFilter.KeyDown     += new KeyEventHandler(OnKeyDown);
            this.dataGrid.KeyDown             += new KeyEventHandler(OnKeyDown);
            this.KeyDown += new KeyEventHandler(OnKeyDown);
            this.filter.txtFilter.MouseWheel += (o, e) => { this.dataGrid.Scroll(-e.Delta / 40); };

            // Set the initial filter and update the dialog
            this.filter.txtFilter.Text = fileGatherer.LastSearchString;
            UpdateFilter();

            // Select the first row
            if (this.dataGrid.Rows.Count > 0)
            {
                this.dataGrid.Rows[0].Selected = true;
            }
        }
Beispiel #2
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // Create the command for the menu item.
                CommandID   menuCommandID = new CommandID(GuidList.guidVSNavCmdSet, (int)PkgCmdIDList.quickFindFile);
                MenuCommand menuItem      = new MenuCommand(MenuItemCallback, menuCommandID);
                mcs.AddCommand(menuItem);
            }

            this.manager = new EventManager();
            Version.Initialize(this);
            this.fileGatherer = new FileGatherer(manager);
        }