Click here to Skip to main content
12,074,771 members (59,336 online)
Click here to Skip to main content

Stats

169.5K views
2.9K downloads
36 bookmarked
Posted

VS File Finder

, 8 May 2005
A Visual Studio add-in to help navigate around large projects.
vsfilefindersetup.zip
VSFileFinderSetup.msi
vsfilefindersource.zip
VSFileFinder
docs
back.gif
finder.gif
menu.gif
modified
back.gif
finder.gif
home.gif
menu.gif
monster.gif
next.gif
noback.gif
nonext.gif
solutionexplorer.gif
monster.gif
next.gif
noback.gif
nonext.gif
orig
back.png
finder.png
home.png
menu.png
monster.gif
next.png
noback.png
solutionexplorer.gif
solutionexplorer.gif
VSFileFinder
AddIn.def
AddIn.rgs
VSFileFinderCtrl
icon1.ico
Options.ico
VSFileFinderCtrl.def
VSFileFinderCtrl.rgs
VSFileFinderCtrlCtrl.bmp
VSFileFinderCtrlps.def
VSFileFinderCtrlps.mk
VSFileFinderSetup
Binary
bannrbmp.bmp
completi.ico
custicon.ico
dlgbmp.bmp
exclamic.ico
info.ico
insticon.ico
New.ico
removico.ico
repairic.ico
Up.ico
Product.wxs
Text.wxs
UI.wxs
// OptionsDlg.cpp : implementation file

#include "stdafx.h"
#include "VSFileFinderCtrl.h"
#include "OptionsDlg.h"
#include "ExcludeFilterDlg.h"
#include "HighlightFilterDlg.h"
#include "Resource.h"

IMPLEMENT_DYNAMIC(OptionsDlg, CDialog)

OptionsDlg::OptionsDlg(const Options& options, CWnd* pParent /*=NULL*/)
	: CDialog(IDD_OPTIONS, pParent)
	, m_Options(options)
{
}

OptionsDlg::~OptionsDlg()
{
}

BEGIN_MESSAGE_MAP(OptionsDlg, CDialog)
	// Excluded file list messages
	ON_BN_CLICKED(IDC_ADD_EXCLUDED_BUTTON, OnExcludeAddClicked)
	ON_BN_CLICKED(IDC_EDIT_EXCLUDED_BUTTON, OnExcludeEditClicked)
	ON_BN_CLICKED(IDC_REMOVE_EXCLUDED_BUTTON, OnExcludeRemoveClicked)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_EXCLUDED_FILES, OnExcludeSelChange)

	// Highlighted file list messages
	ON_BN_CLICKED(IDC_ADD_HIGHLIGHTED_BUTTON, OnHighlightedAddClicked)
	ON_BN_CLICKED(IDC_EDIT_HIGHLIGHTED_BUTTON, OnHighlightedEditClicked)
	ON_BN_CLICKED(IDC_REMOVE_HIGHLIGHTED_BUTTON, OnHighlightedRemoveClicked)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_HIGHLIGHTED_FILES, OnHighlightedSelChange)

	// About button
	ON_BN_CLICKED(IDC_ABOUT_BUTTON, OnAboutBtnClicked)
END_MESSAGE_MAP()

BOOL OptionsDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_ExcludedFileList.InsertColumn(0, _T("Description"), LVCFMT_LEFT, 167);
	m_ExcludedFileList.InsertColumn(1, _T("Filter"), LVCFMT_LEFT, 167);
	m_ExcludedFileList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	RefreshExcludedFilesList();
	UpdateExcludedFilesButtons();

	m_HighlightedFileList.InsertColumn(0, _T("Description"), LVCFMT_LEFT, 167);
	m_HighlightedFileList.InsertColumn(1, _T("Filter"), LVCFMT_LEFT, 167);
	m_HighlightedFileList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
	RefreshHighlightedFilesList();
	UpdateHighlightedFilesButtons();

	return FALSE;
}

void OptionsDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);

	// Excluded file list DDX
	DDX_Control(pDX, IDC_EXCLUDED_FILES, m_ExcludedFileList);
	DDX_Control(pDX, IDC_EDIT_EXCLUDED_BUTTON, m_EditExcludedFileButton);
	DDX_Control(pDX, IDC_REMOVE_EXCLUDED_BUTTON, m_RemoveExcludedFileButton);

	// Highlighted file list DDX
	DDX_Control(pDX, IDC_HIGHLIGHTED_FILES, m_HighlightedFileList);
	DDX_Control(pDX, IDC_EDIT_HIGHLIGHTED_BUTTON, m_EditHighlightedFileButton);
	DDX_Control(pDX, IDC_REMOVE_HIGHLIGHTED_BUTTON, m_RemoveHighlightedFileButton);
}

const Options& OptionsDlg::GetOptions() const
{
	return m_Options;
}

void OptionsDlg::RefreshExcludedFilesList()
{
	m_ExcludedFileList.DeleteAllItems();

	for (int i = 0; i < m_Options.GetExcludedFileCount(); ++i)
	{
		const Options::ExcludedFile& file = m_Options.GetExcludedFile(i);
		int nItem = m_ExcludedFileList.InsertItem(i, file.Description);
		ASSERT(nItem == i);
		m_ExcludedFileList.SetItemText(i, 1, file.Filter);
	}
}

void OptionsDlg::UpdateExcludedFilesButtons()
{
	int nSelection = m_ExcludedFileList.GetNextItem(-1, LVNI_SELECTED);
	bool bEnable = (nSelection >= 0 && nSelection < m_Options.GetExcludedFileCount());

	m_EditExcludedFileButton.EnableWindow(bEnable);
	m_RemoveExcludedFileButton.EnableWindow(bEnable);
}

void OptionsDlg::RefreshHighlightedFilesList()
{
	m_HighlightedFileList.DeleteAllItems();

	for (int i = 0; i < m_Options.GetHighlightedFileCount(); ++i)
	{
		const Options::HighlightedFile& file = m_Options.GetHighlightedFile(i);
		int nItem = m_HighlightedFileList.InsertItem(i, file.Description);
		ASSERT(nItem == i);
		m_HighlightedFileList.SetItemText(i, 1, file.Filter);
		m_HighlightedFileList.SetItemData(i, file.Colour);
	}
}

void OptionsDlg::UpdateHighlightedFilesButtons()
{
	int nSelection = m_HighlightedFileList.GetNextItem(-1, LVNI_SELECTED);
	bool bEnable = (nSelection >= 0 && nSelection < m_Options.GetHighlightedFileCount());

	m_EditHighlightedFileButton.EnableWindow(bEnable);
	m_RemoveHighlightedFileButton.EnableWindow(bEnable);
}

void OptionsDlg::OnExcludeAddClicked()
{
	ExcludeFilterDlg dlg(this, _T("Add Exclude Filter"));
	if (dlg.DoModal() == IDOK)
	{
		Options::ExcludedFile file;
		file.Description = dlg.GetDescription();
		file.Filter = dlg.GetFilter();
		m_Options.AddExcludedFile(file);
		RefreshExcludedFilesList();
		UpdateExcludedFilesButtons();
	}
}

void OptionsDlg::OnExcludeEditClicked()
{
	int nSelection = m_ExcludedFileList.GetNextItem(-1, LVNI_SELECTED);
	if (nSelection < 0 || nSelection >= m_Options.GetExcludedFileCount())
		return;
	Options::ExcludedFile file(m_Options.GetExcludedFile(nSelection));
	ExcludeFilterDlg dlg(this, _T("Edit Exclude Filter"), file.Description, file.Filter);
	if (dlg.DoModal() == IDOK)
	{
		file.Description = dlg.GetDescription();
		file.Filter = dlg.GetFilter();
		m_Options.RemoveExcludedFile(nSelection);
		m_Options.AddExcludedFile(file);
		RefreshExcludedFilesList();
		UpdateExcludedFilesButtons();
	}
}

void OptionsDlg::OnExcludeRemoveClicked()
{
	int nSelection = m_ExcludedFileList.GetNextItem(-1, LVNI_SELECTED);
	if (nSelection < 0 || nSelection >= m_Options.GetExcludedFileCount())
		return;
	m_Options.RemoveExcludedFile(nSelection);
	RefreshExcludedFilesList();
	UpdateExcludedFilesButtons();
}

void OptionsDlg::OnExcludeSelChange(NMHDR*, LRESULT* pResult)
{
	UpdateExcludedFilesButtons();
	*pResult = 0;
}

void OptionsDlg::OnHighlightedAddClicked()
{
	HighlightFilterDlg dlg(this, _T("Add Highlight Filter"));
	if (dlg.DoModal() == IDOK)
	{
		Options::HighlightedFile file;
		file.Description = dlg.GetDescription();
		file.Filter = dlg.GetFilter();
		file.Colour = dlg.GetColour();
		m_Options.AddHighlightedFile(file);
		RefreshHighlightedFilesList();
		UpdateHighlightedFilesButtons();
	}
}

void OptionsDlg::OnHighlightedEditClicked()
{
	int nSelection = m_HighlightedFileList.GetNextItem(-1, LVNI_SELECTED);
	if (nSelection < 0 || nSelection >= m_Options.GetHighlightedFileCount())
		return;
	Options::HighlightedFile file(m_Options.GetHighlightedFile(nSelection));
	HighlightFilterDlg dlg(this, _T("Edit Highlight Filter"), file.Description, file.Filter, file.Colour);
	if (dlg.DoModal() == IDOK)
	{
		file.Description = dlg.GetDescription();
		file.Filter = dlg.GetFilter();
		file.Colour = dlg.GetColour();
		m_Options.RemoveHighlightedFile(nSelection);
		m_Options.AddHighlightedFile(file);
		RefreshHighlightedFilesList();
		UpdateHighlightedFilesButtons();
	}
}

void OptionsDlg::OnHighlightedRemoveClicked()
{
	int nSelection = m_HighlightedFileList.GetNextItem(-1, LVNI_SELECTED);
	if (nSelection < 0 || nSelection >= m_Options.GetHighlightedFileCount())
		return;
	m_Options.RemoveHighlightedFile(nSelection);
	RefreshHighlightedFilesList();
	UpdateHighlightedFilesButtons();
}

void OptionsDlg::OnHighlightedSelChange(NMHDR*, LRESULT* pResult)
{
	UpdateHighlightedFilesButtons();
	*pResult = 0;
}

void OptionsDlg::OnAboutBtnClicked()
{
	CDialog dlg(IDD_ABOUT, this);
	dlg.DoModal();
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

J W Payne
Web Developer
United Kingdom United Kingdom
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.160208.1 | Last Updated 8 May 2005
Article Copyright 2004 by J W Payne
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid