This commit is contained in:
140
Form1.cs
Normal file
140
Form1.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using System.IO;
|
||||
|
||||
namespace VSMRUManager
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
List<string> m_astrVSName = new List<string>();
|
||||
List<string> m_astrVSVersion = new List<string>();
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
GenerateVersion();
|
||||
|
||||
}
|
||||
|
||||
private void GenerateVersion()
|
||||
{
|
||||
string[] astrVSName = { "vs2013", "vs2012", "vs2010", "vs2008", "vs2005", "vs2003" };
|
||||
string[] astrVSVersion = { "12.0", "11.0", "10.0", "9.0", "8.0", "7.1" };
|
||||
|
||||
RegistryKey reg = null;
|
||||
string strKey;
|
||||
|
||||
for(int i=0; i<astrVSName.Length; i++)
|
||||
{
|
||||
strKey = "Software\\Microsoft\\VisualStudio\\"+astrVSVersion[i]+"\\ProjectMRUList";
|
||||
reg = Registry.CurrentUser.OpenSubKey(strKey);
|
||||
if(reg != null)
|
||||
{
|
||||
m_astrVSName.Add(astrVSName[i]);
|
||||
m_astrVSVersion.Add(astrVSVersion[i]);
|
||||
}
|
||||
}
|
||||
|
||||
cbVSVersion.Items.AddRange(m_astrVSName.ToArray());
|
||||
cbVSVersion.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void UpdateList()
|
||||
{
|
||||
if(cbVSVersion.SelectedIndex < 0)
|
||||
return;
|
||||
|
||||
lvList.Items.Clear();
|
||||
int iSelectedVersion = cbVSVersion.SelectedIndex;
|
||||
|
||||
string strKey = "Software\\Microsoft\\VisualStudio\\"+m_astrVSVersion[iSelectedVersion]+"\\ProjectMRUList";
|
||||
RegistryKey reg = Registry.CurrentUser.OpenSubKey(strKey);
|
||||
string[] astrSubValues = reg.GetValueNames();
|
||||
for(int i=0; i<astrSubValues.Length; i++)
|
||||
{
|
||||
ListViewItem item = new ListViewItem(new string[]{ (i+1).ToString(), astrSubValues[i], (string)reg.GetValue(astrSubValues[i]) });
|
||||
lvList.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void cbVSVersion_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateList();
|
||||
}
|
||||
|
||||
private void btDelAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(MessageBox.Show("Are you sure want to delete all list?", "confirm", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
|
||||
return;
|
||||
if(MessageBox.Show("Really?", "confirm", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
|
||||
return;
|
||||
|
||||
|
||||
int iSelectedVersion = cbVSVersion.SelectedIndex;
|
||||
string strKey = "Software\\Microsoft\\VisualStudio\\"+m_astrVSVersion[iSelectedVersion]+"\\ProjectMRUList";
|
||||
RegistryKey reg = Registry.CurrentUser.OpenSubKey(strKey, true);
|
||||
int iValueCnt = reg.ValueCount;
|
||||
for(int i=0; i<iValueCnt; i++)
|
||||
{
|
||||
int iRow = i;
|
||||
string strValueName = lvList.Items[iRow].SubItems[1].Text;
|
||||
string strValue = (string)reg.GetValue(strValueName);
|
||||
|
||||
reg.DeleteValue(strValueName);
|
||||
}
|
||||
|
||||
UpdateList();
|
||||
}
|
||||
|
||||
private void btDelSel_Click(object sender, EventArgs e)
|
||||
{
|
||||
int iSelectedVersion = cbVSVersion.SelectedIndex;
|
||||
string strKey = "Software\\Microsoft\\VisualStudio\\"+m_astrVSVersion[iSelectedVersion]+"\\ProjectMRUList";
|
||||
RegistryKey reg = Registry.CurrentUser.OpenSubKey(strKey, true);
|
||||
|
||||
ListView.SelectedIndexCollection selected = lvList.SelectedIndices;
|
||||
for(int i=0; i<selected.Count; i++)
|
||||
{
|
||||
int iRow = selected[i];
|
||||
string strValueName = lvList.Items[iRow].SubItems[1].Text;
|
||||
string strValue = (string)reg.GetValue(strValueName);
|
||||
|
||||
reg.DeleteValue(strValueName);
|
||||
}
|
||||
|
||||
UpdateList();
|
||||
}
|
||||
|
||||
private void btClear_Click(object sender, EventArgs e)
|
||||
{
|
||||
int iSelectedVersion = cbVSVersion.SelectedIndex;
|
||||
string strKey = "Software\\Microsoft\\VisualStudio\\"+m_astrVSVersion[iSelectedVersion]+"\\ProjectMRUList";
|
||||
RegistryKey reg = Registry.CurrentUser.OpenSubKey(strKey, true);
|
||||
int iValueCnt = reg.ValueCount;
|
||||
for(int i=0; i<iValueCnt; i++)
|
||||
{
|
||||
int iRow = i;
|
||||
string strValueName = lvList.Items[iRow].SubItems[1].Text;
|
||||
string strValue = (string)reg.GetValue(strValueName);
|
||||
|
||||
int iEnd = strValue.IndexOf('|');
|
||||
iEnd = (iEnd < 0) ? strValue.Length : iEnd;
|
||||
string strFilePath = strValue.Substring(0, iEnd);
|
||||
|
||||
FileInfo finfo = new FileInfo(strFilePath);
|
||||
if(finfo.Exists == false)
|
||||
reg.DeleteValue(strValueName);
|
||||
}
|
||||
|
||||
UpdateList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user