Skip to content

Commit

Permalink
删除垃圾注释
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Jan 17, 2017
1 parent bcb38d6 commit bafe80b
Show file tree
Hide file tree
Showing 28 changed files with 445 additions and 564 deletions.
1 change: 0 additions & 1 deletion EncodingNormalior/Model/InspectFileWhiteListSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public void Add(List<string> whiteList)

private void Parse(string whiteList)
{
//"\\w+[\\\\|/]"
_folderRegex = new Regex("\\w+[\\\\|/]$");
if (_folderRegex.IsMatch(whiteList))
{
Expand Down
154 changes: 63 additions & 91 deletions EncodingNormalizerVsx/EncodingNormalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,74 +7,103 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Globalization;
using System.IO;
using System.Windows;
using System.Windows.Forms;
using EncodingNormalizerVsx.View;
using EnvDTE;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using MessageBox=System.Windows.MessageBox;
using Window = System.Windows.Window;

namespace EncodingNormalizerVsx
{
/// <summary>
/// Command handler
/// Command handler
/// </summary>
internal sealed class EncodingNormalizer
{
/// <summary>
/// Command ID.
/// Command ID.
/// </summary>
public const int CommandId = 0x0100;

/// <summary>
/// Command menu group (command set GUID).
/// Command menu group (command set GUID).
/// </summary>
public static readonly Guid CommandSet = new Guid("0640f5ce-e6bc-43ba-b45e-497d70819a20");

/// <summary>
/// VS Package that provides this command, not null.
/// VS Package that provides this command, not null.
/// </summary>
private readonly Package package;

private Window _conformWindow;
private Window _definitionWindow;

/// <summary>
/// Initializes a new instance of the <see cref="EncodingNormalizer"/> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// Initializes a new instance of the <see cref="EncodingNormalizer" /> class.
/// Adds our command handlers for menu (commands must exist in the command table file)
/// </summary>
/// <param name="package">Owner package, not null.</param>
private EncodingNormalizer(Package package)
{
if (package == null)
{
throw new ArgumentNullException("package");
}

this.package = package;

OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
var commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if (commandService != null)
{
var menuCommandID = new CommandID(CommandSet, CommandId);
var menuItem = new MenuCommand(this.EncodingNormalizerCallback, menuCommandID);
var menuItem = new MenuCommand(EncodingNormalizerCallback, menuCommandID);
commandService.AddCommand(menuItem);

menuCommandID = new CommandID(CommandSet, 0x0101);
menuItem = new MenuCommand(this.MenuItemCallback, menuCommandID);
menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
commandService.AddCommand(menuItem);
}
}

private System.Windows.Window _conformWindow;
private System.Windows.Window _definitionWindow;
//private void ReadAccount()
//{
// var folder = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
// "\\EncodingNormalizer\\";
// var file = folder+ "Account.json";
// if (!Directory.Exists(folder))
// {
// Directory.CreateDirectory(folder);
// }

// using (StreamWriter stream = File.CreateText(file))
// {
// stream.Write("EncodingNormalizer");
// }

// using (StreamReader stream=File.OpenText(file))
// {
// string str = stream.ReadToEnd();
// }
//}

/// <summary>
/// Gets the instance of the command.
/// </summary>
public static EncodingNormalizer Instance { get; private set; }

/// <summary>
/// Gets the service provider from the owner package.
/// </summary>
private IServiceProvider ServiceProvider
{
get { return package; }
}

private void EncodingNormalizerCallback(object sender, EventArgs e)
{
DTE dte = (DTE)ServiceProvider.GetService(typeof(DTE));
var dte = (DTE) ServiceProvider.GetService(typeof(DTE));
var file = dte.Solution.FullName;
List<string> project = new List<string>();
int noLoadProjectCount = 0;
var project = new List<string>();
var noLoadProjectCount = 0;
//if (string.IsNullOrEmpty(file))
{
if (dte.Solution.Projects.Count > 0)
Expand All @@ -84,30 +113,25 @@ private void EncodingNormalizerCallback(object sender, EventArgs e)
try
{
foreach (var temp in dte.Solution.Projects)
{
try
{
file = ((Project)temp).FileName;
file = ((Project) temp).FileName;
if (file.EndsWith(".csproj"))
{

}
file = ((Project)temp).FullName;
file = ((Project) temp).FullName;

if (!string.IsNullOrEmpty(file))
{
project.Add(new FileInfo(file).Directory?.FullName);
}
}
catch (NotImplementedException)
{
noLoadProjectCount++;
}
}
}
catch (NotImplementedException)
{
System.Windows.MessageBox.Show("The project not loaded.", "项目还没有加载完成");
MessageBox.Show("The project not loaded.", "项目还没有加载完成");
return;
}
if (noLoadProjectCount > 0)
Expand Down Expand Up @@ -140,9 +164,6 @@ private void EncodingNormalizerCallback(object sender, EventArgs e)
//MessageBox.Show(AppDomain.CurrentDomain.BaseDirectory, "路径");
//string str = EncodingNormalizerPackage.DefinitionPage().CriterionEncoding.ToString();
// MessageBox.Show(str, "路径");



}

private void ConformWindow(string file, List<string> project)
Expand All @@ -156,72 +177,26 @@ private void ConformWindow(string file, List<string> project)

var folder = "";
if (!string.IsNullOrEmpty(file))
{
folder = new FileInfo(file).Directory?.FullName;
}
System.Windows.Window window = new System.Windows.Window();
ConformPage conformPage = new ConformPage();
var window = new Window();
var conformPage = new ConformPage();
window.Content = conformPage;
window.Title = "编码规范工具";
conformPage.Closing += (_s, _e) =>
{
window.Close();
_conformWindow = null;
};
window.Closed += (_s, _e) =>
{
_conformWindow = null;
};
window.Closed += (_s, _e) => { _conformWindow = null; };
conformPage.SolutionFolder = folder;
conformPage.Project = project;
window.Show();
conformPage.InspectFolderEncoding();
_conformWindow = window;
}

//private void ReadAccount()
//{
// var folder = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
// "\\EncodingNormalizer\\";
// var file = folder+ "Account.json";
// if (!Directory.Exists(folder))
// {
// Directory.CreateDirectory(folder);
// }

// using (StreamWriter stream = File.CreateText(file))
// {
// stream.Write("EncodingNormalizer");
// }

// using (StreamReader stream=File.OpenText(file))
// {
// string str = stream.ReadToEnd();
// }
//}

/// <summary>
/// Gets the instance of the command.
/// </summary>
public static EncodingNormalizer Instance
{
get;
private set;
}

/// <summary>
/// Gets the service provider from the owner package.
/// </summary>
private IServiceProvider ServiceProvider
{
get
{
return this.package;
}
}

/// <summary>
/// Initializes the singleton instance of the command.
/// Initializes the singleton instance of the command.
/// </summary>
/// <param name="package">Owner package, not null.</param>
public static void Initialize(Package package)
Expand All @@ -230,9 +205,9 @@ public static void Initialize(Package package)
}

/// <summary>
/// This function is the callback used to execute the command when the menu item is clicked.
/// See the constructor to see how the menu item is associated with this function using
/// OleMenuCommandService service and MenuCommand class.
/// This function is the callback used to execute the command when the menu item is clicked.
/// See the constructor to see how the menu item is associated with this function using
/// OleMenuCommandService service and MenuCommand class.
/// </summary>
/// <param name="sender">Event sender.</param>
/// <param name="e">Event args.</param>
Expand All @@ -244,17 +219,14 @@ private void MenuItemCallback(object sender, EventArgs e)
_definitionWindow.Show();
return;
}
System.Windows.Window window = new System.Windows.Window();
View.DefinitionPage definitionPage = new DefinitionPage();
var window = new Window();
var definitionPage = new DefinitionPage();
definitionPage.Closing += (_s, _e) =>
{
window.Close();
_definitionWindow = null;
};
window.Closed += (_s, _e) =>
{
_definitionWindow = null;
};
window.Closed += (_s, _e) => { _definitionWindow = null; };
window.Title = "编码规范工具设置";
window.Content = definitionPage;
window.Show();
Expand All @@ -273,4 +245,4 @@ private void MenuItemCallback(object sender, EventArgs e)
// OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
}
}
}
Loading

0 comments on commit bafe80b

Please sign in to comment.