Browse Source

SD2-532: revamped html export; made progress bar access threadsafe

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@758 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Markus Palme 20 years ago
parent
commit
b401caf16a
  1. 16
      src/Main/Base/Project/Src/TextEditor/Commands/ProjectCommands.cs
  2. 970
      src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/ExportProjectToHtmlDialog.cs

16
src/Main/Base/Project/Src/TextEditor/Commands/ProjectCommands.cs

@ -21,6 +21,7 @@ using ICSharpCode.Core;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{ {
@ -34,14 +35,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
public override void Run() public override void Run()
{ {
// IProjectService projectService = (IProjectService)ICSharpCode.Core.ServiceManager.Services.GetService(typeof(IProjectService)); if (ProjectService.CurrentProject != null)
// if (projectService.CurrentSelectedProject != null) { {
// ExportProjectToHtmlDialog ephd = new ExportProjectToHtmlDialog(projectService.CurrentSelectedProject); ExportProjectToHtmlDialog ephd = new ExportProjectToHtmlDialog(ProjectService.CurrentProject);
// ephd.Owner = (Form)WorkbenchSingleton.Workbench; ephd.Owner = (Form)WorkbenchSingleton.Workbench;
// ephd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); ephd.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm);
// ephd.Dispose(); ephd.Dispose();
// } }
} }
} }
} }

970
src/Main/Base/Project/Src/TextEditor/Gui/Dialogs/ExportProjectToHtmlDialog.cs

@ -1,478 +1,492 @@
// TODO: New Projectfile system. // <file>
//// <file> // <copyright see="prj:///doc/copyright.txt"/>
//// <copyright see="prj:///doc/copyright.txt"/> // <license see="prj:///doc/license.txt"/>
//// <license see="prj:///doc/license.txt"/> // <owner name="Markus Palme" email="markuspalme@gmx.de"/>
//// <owner name="Mike Krüger" email="mike@icsharpcode.net"/> // <version value="$version"/>
//// <version value="$version"/> // </file>
//// </file>
// using System;
//using System; using System.Drawing;
//using System.Drawing; using System.Collections;
//using System.Collections; using System.Collections.Specialized;
//using System.Collections.Specialized; using System.ComponentModel;
//using System.ComponentModel; using System.Windows.Forms;
//using System.Windows.Forms; using System.Threading;
//using System.Threading; using System.IO;
//using System.IO; using ICSharpCode.TextEditor.Document;
//using ICSharpCode.TextEditor.Document; using ICSharpCode.Core;
//using ICSharpCode.Core; using ICSharpCode.TextEditor.Util;
//using ICSharpCode.TextEditor.Util;
// using ICSharpCode.SharpDevelop.Project;
//using ICSharpCode.SharpDevelop.Project;
// namespace ICSharpCode.SharpDevelop.Gui
//namespace ICSharpCode.SharpDevelop.Gui {
//{ public class ExportProjectToHtmlDialog : Form
// public class ExportProjectToHtmlDialog : Form {
// { TextBox pathTextBox = new TextBox();
// TextBox pathTextBox = new TextBox(); Label pathLabel = new Label();
// Label pathLabel = new Label(); Button okButton = new Button();
// Button okButton = new Button(); Button cancelButton = new Button();
// Button cancelButton = new Button(); Button browseButton = new Button();
// Button browseButton = new Button();
// ProgressBar progressBar = new ProgressBar();
// ProgressBar progressBar = new ProgressBar();
// IProject project;
// int filesExported = 0;
//
// delegate void ProgressBarDelegate();
//
// IProject project; int FilesExported
// int filesExported = 0; {
// get {
// int FilesExported { return filesExported;
// get { }
// return filesExported; set
// } {
// set { filesExported = value;
// progressBar.Value = filesExported = value;
// } if(this.InvokeRequired)
// } {
// this.Invoke(new ProgressBarDelegate(setProgressBar), new object[] {});
// void StartExporting() }
// { else
// Controls.Clear(); {
// progressBar.Value = filesExported = value;
// progressBar.Location = new Point(8, 8); }
// progressBar.Size = new Size(Width - 16, 16); }
// progressBar.Minimum = 0; }
// progressBar.Maximum = project.ProjectFiles.Count;
// void setProgressBar()
// Controls.Add(progressBar); {
// FilesExported = FilesExported;
// cancelButton = new Button(); }
// cancelButton.Location = new Point(188 + 80, 36);
// cancelButton.Size = new Size(74, 23); void StartExporting()
// cancelButton.Text = ResourceService.GetString("Global.CancelButtonText"); {
// cancelButton.Click += new EventHandler(StopThread); Controls.Clear();
// Controls.Add(cancelButton);
// } progressBar.Location = new Point(8, 8);
// public ExportProjectToHtmlDialog(IProject project) progressBar.Size = new Size(Width - 16, 16);
// { progressBar.Minimum = 0;
//
// int max = 0;
// this.project = project; foreach(ProjectItem item in project.Items)
// {
// pathLabel.Location = new Point(8, 8); if(item is FileProjectItem) {
// pathLabel.Size = new Size(60,16); max++;
// pathLabel.Text = ResourceService.GetString("Dialog.ExportProjectToHtml.FolderLabel"); }
// Controls.Add(pathLabel); }
// progressBar.Maximum = max;
// pathTextBox.Location = new Point(70, 8);
// pathTextBox.Size = new Size(230,16); Controls.Add(progressBar);
// Controls.Add(pathTextBox);
// cancelButton = new Button();
// browseButton.Location = new Point(310, 8); cancelButton.Location = new Point(188 + 80, 36);
// browseButton.Size = new Size(32,23); cancelButton.Size = new Size(74, 23);
// browseButton.Text = "..."; cancelButton.Text = ResourceService.GetString("Global.CancelButtonText");
// browseButton.Click += new EventHandler(BrowseDirectories); cancelButton.Click += new EventHandler(StopThread);
// browseButton.FlatStyle = FlatStyle.System; Controls.Add(cancelButton);
// Controls.Add(browseButton); }
//
// okButton.Location = new Point(188, 36); public ExportProjectToHtmlDialog(IProject project)
// okButton.Size = new Size(74, 23); {
// okButton.Text = ResourceService.GetString("Global.OKButtonText"); this.project = project;
// okButton.Click += new EventHandler(ExportProject);
// okButton.FlatStyle = FlatStyle.System; pathLabel.Location = new Point(8, 8);
// Controls.Add(okButton); pathLabel.Size = new Size(60,16);
// pathLabel.Text = ResourceService.GetString("Dialog.ExportProjectToHtml.FolderLabel");
// cancelButton.Location = new Point(188 + 80, 36); Controls.Add(pathLabel);
// cancelButton.Size = new Size(74, 23);
// cancelButton.Text = ResourceService.GetString("Global.CancelButtonText"); pathTextBox.Location = new Point(70, 8);
// cancelButton.DialogResult = DialogResult.Cancel; pathTextBox.Size = new Size(230,16);
// cancelButton.FlatStyle = FlatStyle.System; Controls.Add(pathTextBox);
// Controls.Add(cancelButton);
// browseButton.Location = new Point(310, 8);
// Icon = null; browseButton.Size = new Size(32,23);
// FormBorderStyle = FormBorderStyle.FixedDialog; browseButton.Text = "...";
// Size = new Size(350, 88 + 6); browseButton.Click += new EventHandler(BrowseDirectories);
// StartPosition = FormStartPosition.CenterParent; browseButton.FlatStyle = FlatStyle.System;
// ShowInTaskbar = false; Controls.Add(browseButton);
// MinimizeBox = MaximizeBox = false;
// okButton.Location = new Point(188, 36);
// Text = ResourceService.GetString("Dialog.ExportProjectToHtml.DialogName"); okButton.Size = new Size(74, 23);
// } okButton.Text = ResourceService.GetString("Global.OKButtonText");
// okButton.Click += new EventHandler(ExportProject);
// void BrowseDirectories(object sender, EventArgs e) okButton.FlatStyle = FlatStyle.System;
// { Controls.Add(okButton);
// FolderDialog fd = new FolderDialog();
// cancelButton.Location = new Point(188 + 80, 36);
// if(fd.DisplayDialog(ResourceService.GetString("Dialog.ExportProjectToHtml.SelectTargetDirInfo")) == DialogResult.OK) { cancelButton.Size = new Size(74, 23);
// pathTextBox.Text = fd.Path; cancelButton.Text = ResourceService.GetString("Global.CancelButtonText");
// } cancelButton.DialogResult = DialogResult.Cancel;
// } cancelButton.FlatStyle = FlatStyle.System;
// Controls.Add(cancelButton);
// Hashtable projectTable = new Hashtable();
// Hashtable bitmapTable = new Hashtable(); Icon = null;
// int bitmapIconIndex = 0; FormBorderStyle = FormBorderStyle.FixedDialog;
// int indexFileIndex = 0; Size = new Size(350, 88 + 6);
// StartPosition = FormStartPosition.CenterParent;
// public Hashtable GetPath(string filename, Hashtable table, bool create) ShowInTaskbar = false;
// { MinimizeBox = MaximizeBox = false;
// string directory = Path.GetDirectoryName(filename);
// string[] treepath = directory.Split(new char[] { Path.DirectorySeparatorChar }); Text = ResourceService.GetString("Dialog.ExportProjectToHtml.DialogName");
// Hashtable curTable = table; }
//
// foreach (string path in treepath) { void BrowseDirectories(object sender, EventArgs e)
// if (path.Length == 0 || path[0] == '.') {
// continue; FolderDialog fd = new FolderDialog();
//
// object node = curTable[path]; if(fd.DisplayDialog(ResourceService.GetString("Dialog.ExportProjectToHtml.SelectTargetDirInfo")) == DialogResult.OK) {
// pathTextBox.Text = fd.Path;
// if (node == null) { }
// if (create) { }
// Hashtable newTable = new Hashtable();
// curTable[path] = newTable; Hashtable projectTable = new Hashtable();
// curTable = newTable; Hashtable bitmapTable = new Hashtable();
// continue; int bitmapIconIndex = 0;
// } else { int indexFileIndex = 0;
// return null;
// } public Hashtable GetPath(string filename, Hashtable table, bool create)
// } {
// curTable = (Hashtable)node; string directory = Path.GetDirectoryName(filename);
// } string[] treepath = directory.Split(new char[] { Path.DirectorySeparatorChar });
// return curTable; Hashtable curTable = table;
// }
// int GetImageIndex(string filename) foreach (string path in treepath) {
// { if (path.Length == 0 || path[0] == '.')
// if (filename != null) { continue;
// return IconService.GetImageIndexForFile(filename);
// } object node = curTable[path];
// return -1;
// } if (node == null) {
// if (create) {
// class Descriptor Hashtable newTable = new Hashtable();
// { curTable[path] = newTable;
// public string title; curTable = newTable;
// public string url; continue;
// public Descriptor(string title, string url) } else {
// { return null;
// this.title = title; }
// this.url = url; }
// } curTable = (Hashtable)node;
// } }
// return curTable;
// StreamWriter curFileStream = null; }
// Stack curIndexStreamStack = new Stack();
// int curSpanNumber = 0; class Descriptor
// Hashtable Spans = new Hashtable(); {
// public string title;
// string ExportFile(string fileName, string targetPath) public string url;
// { public Descriptor(string title, string url)
// string targetFile; {
// if (fileName.EndsWith(".txt")) this.title = title;
// { this.url = url;
// targetFile = fileUtilityService.AbsoluteToRelativePath(project.BaseDirectory, fileName).Substring(2); }
// File.Copy(fileName, targetPath + Path.DirectorySeparatorChar + targetFile); }
// return targetFile;
// } StreamWriter curFileStream = null;
// targetFile = FileUtility.AbsoluteToRelativePath(project.BaseDirectory, fileName).Substring(2).Replace(Path.DirectorySeparatorChar.ToString(), "") + ".html"; Stack curIndexStreamStack = new Stack();
// int curSpanNumber = 0;
// IDocument document = new DocumentFactory().CreateDocument(); Hashtable Spans = new Hashtable();
// document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(fileName);
// StreamReader stream = File.OpenText(fileName); string ExportFile(string fileName, string targetPath)
// document.TextContent = stream.ReadToEnd(); {
// stream.Close(); string targetFile;
// if (fileName.EndsWith(".txt"))
// curFileStream = File.CreateText(targetPath + Path.DirectorySeparatorChar + targetFile); {
// curFileStream.Write("<html>\r\n"); targetFile = FileUtility.GetRelativePath(project.Directory, fileName).Substring(2);
// curFileStream.Write("<head>\r\n"); File.Copy(fileName, targetPath + Path.DirectorySeparatorChar + targetFile);
// curFileStream.Write("<link rel=\"stylesheet\" type=\"text/css\" href=\"sdcss.css\">\r\n"); return targetFile;
// curFileStream.Write("<title>" + Path.GetFileName(fileName) + "</title>\r\n"); }
// curFileStream.Write("</head>\r\n"); targetFile = FileUtility.GetRelativePath(project.Directory, fileName).Substring(2).Replace(Path.DirectorySeparatorChar.ToString(), "") + ".html";
// curFileStream.Write("<body>\r\n");
// IDocument document = new DocumentFactory().CreateDocument();
// curFileStream.Write("<div class=\"code\"><TABLE SUMMARY=\"SourceCode\" BORDER=0 CELLSPACING=0 CELLPADDING=2 WIDTH=\"100%\">\r\n"); document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(fileName);
// curFileStream.Write(" <TR BGCOLOR=\"#FFFFFF\">\r\n"); StreamReader stream = File.OpenText(fileName);
// curFileStream.Write(" <TH WIDTH=\"50\" NOWRAP ALIGN=LEFT></TH>\r\n"); document.TextContent = stream.ReadToEnd();
// curFileStream.Write(" <TH WIDTH=\"1%\" NOWRAP ALIGN=LEFT></TH>\r\n"); stream.Close();
// curFileStream.Write(" <TH VALIGN=TOP ALIGN=LEFT>&nbsp; \r\n");
// curFileStream.Write(" </TH>\r\n"); curFileStream = File.CreateText(targetPath + Path.DirectorySeparatorChar + targetFile);
// curFileStream.Write("<html>\r\n");
// curFileStream.Write(" </TR>\r\n"); curFileStream.Write("<head>\r\n");
// int i = 0; curFileStream.Write("<link rel=\"stylesheet\" type=\"text/css\" href=\"sdcss.css\">\r\n");
// foreach (LineSegment line in document.LineSegmentCollection) { curFileStream.Write("<title>" + Path.GetFileName(fileName) + "</title>\r\n");
// curFileStream.Write(" <TR BGCOLOR=\"#FFFFFF\" VALIGN=TOP>\r\n"); curFileStream.Write("</head>\r\n");
// curFileStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>" + ++i + ":</TD>\r\n"); curFileStream.Write("<body>\r\n");
// curFileStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=LEFT>&nbsp;\r\n");
// bool spanOpen = false; curFileStream.Write("<div class=\"code\"><TABLE SUMMARY=\"SourceCode\" BORDER=0 CELLSPACING=0 CELLPADDING=2 WIDTH=\"100%\">\r\n");
// Color curColor = Color.Black; curFileStream.Write(" <TR BGCOLOR=\"#FFFFFF\">\r\n");
// bool oldItalic = false; curFileStream.Write(" <TH WIDTH=\"50\" NOWRAP ALIGN=LEFT></TH>\r\n");
// bool oldBold = false; curFileStream.Write(" <TH WIDTH=\"1%\" NOWRAP ALIGN=LEFT></TH>\r\n");
// bool firstSpan = true; curFileStream.Write(" <TH VALIGN=TOP ALIGN=LEFT>&nbsp; \r\n");
// foreach (TextWord word in line.Words) { curFileStream.Write(" </TH>\r\n");
// switch (word.Type) {
// case TextWordType.Space: curFileStream.Write(" </TR>\r\n");
// curFileStream.Write("&nbsp;"); int i = 0;
// break; foreach (LineSegment line in document.LineSegmentCollection) {
// curFileStream.Write(" <TR BGCOLOR=\"#FFFFFF\" VALIGN=TOP>\r\n");
// case TextWordType.Tab: curFileStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>" + ++i + ":</TD>\r\n");
// for (int k = 0; k < document.TextEditorProperties.TabIndent; ++k) { curFileStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=LEFT>&nbsp;\r\n");
// curFileStream.Write("&nbsp;"); bool spanOpen = false;
// } Color curColor = Color.Black;
// break; bool oldItalic = false;
// bool oldBold = false;
// case TextWordType.Word: bool firstSpan = true;
// Color c = word.Color; foreach (TextWord word in line.Words) {
// string colorstr = c.R + ", " + c.G + ", " + c.B; switch (word.Type) {
// case TextWordType.Space:
// if (word.Font.Italic) { curFileStream.Write("&nbsp;");
// colorstr = "i" + colorstr; break;
// }
// if (word.Font.Bold) { case TextWordType.Tab:
// colorstr = "b" + colorstr; for (int k = 0; k < document.TextEditorProperties.TabIndent; ++k) {
// } curFileStream.Write("&nbsp;");
// if (Spans[colorstr] == null) { }
// Spans[colorstr] = "span" + ++curSpanNumber; break;
// }
// bool newColor = c != curColor || oldItalic != word.Font.Italic || oldBold != word.Font.Bold; case TextWordType.Word:
// if (newColor) { Color c = word.Color;
// if (!firstSpan) { string colorstr = c.R + ", " + c.G + ", " + c.B;
// curFileStream.Write("</span>" );
// } if (word.Font.Italic) {
// colorstr = "i" + colorstr;
// curFileStream.Write("<span class=\"" + Spans[colorstr].ToString() + "\">" ); }
// spanOpen = true; if (word.Font.Bold) {
// firstSpan = false; colorstr = "b" + colorstr;
// } }
// curFileStream.Write(HtmlLize(word.Word)); if (Spans[colorstr] == null) {
// Spans[colorstr] = "span" + ++curSpanNumber;
// if (newColor) { }
// curColor = c; bool newColor = c != curColor || oldItalic != word.Font.Italic || oldBold != word.Font.Bold;
// oldItalic = word.Font.Italic; if (newColor) {
// oldBold = word.Font.Bold; if (!firstSpan) {
// } curFileStream.Write("</span>" );
// break; }
// }
// } curFileStream.Write("<span class=\"" + Spans[colorstr].ToString() + "\">" );
// if (spanOpen) { spanOpen = true;
// curFileStream.Write("</span>" ); firstSpan = false;
// } }
// curFileStream.Write("</TD>\r\n"); curFileStream.Write(HtmlLize(word.Word));
// curFileStream.Write("</TR>\r\n");
// } if (newColor) {
// curFileStream.Write("</TABLE></div>\r\n"); curColor = c;
// oldItalic = word.Font.Italic;
// curFileStream.Write("<P>\r\n"); oldBold = word.Font.Bold;
// curFileStream.Write("This page was automatically generated by \r\n"); }
// curFileStream.Write("<A TARGET=\"_blank\" HREF=\"http://www.icsharpcode.net/OpenSource/SD\">SharpDevelop</A>.\r\n"); break;
// curFileStream.Write("</p>\r\n"); }
// curFileStream.Write("</body>\r\n"); }
// curFileStream.Write("</html>\r\n"); if (spanOpen) {
// curFileStream.Close(); curFileStream.Write("</span>" );
// return targetFile; }
// } curFileStream.Write("</TD>\r\n");
// curFileStream.Write("</TR>\r\n");
// string HtmlLize(string str) }
// { curFileStream.Write("</TABLE></div>\r\n");
// return str.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;");
// } curFileStream.Write("<P>\r\n");
// curFileStream.Write("This page was automatically generated by \r\n");
// void WriteIndexTable(string fileName, string name, ArrayList nameList, Hashtable table) curFileStream.Write("<A TARGET=\"_blank\" HREF=\"http://www.icsharpcode.net/OpenSource/SD\">SharpDevelop</A>.\r\n");
// { curFileStream.Write("</p>\r\n");
//// TODO: New Projectfile system. curFileStream.Write("</body>\r\n");
//// curIndexStreamStack.Push(File.CreateText(fileName)); curFileStream.Write("</html>\r\n");
//// StreamWriter curIndexStream = (StreamWriter)curIndexStreamStack.Peek(); curFileStream.Close();
//// return targetFile;
//// curIndexStream.Write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\r\n"); }
//// curIndexStream.Write("<html>\r\n");
//// curIndexStream.Write("<head>\r\n"); string HtmlLize(string str)
//// curIndexStream.Write("<title>" + project.Name + "</title>\r\n"); {
//// curIndexStream.Write("</head>\r\n"); return str.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;");
//// }
//// curIndexStream.Write("<body>\r\n");
//// curIndexStream.Write("<p>Location : "); void WriteIndexTable(string fileName, string name, ArrayList nameList, Hashtable table)
//// foreach (Descriptor d in nameList) { {
//// curIndexStream.Write("<a href=\""+ d.url + "\">" + d.title + "</a>/"); curIndexStreamStack.Push(File.CreateText(fileName));
//// } StreamWriter curIndexStream = (StreamWriter)curIndexStreamStack.Peek();
//// curIndexStream.Write(name);
//// curIndexStream.Write("</p>\r\n"); curIndexStream.Write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\r\n");
//// curIndexStream.Write("<html>\r\n");
//// nameList.Add(new Descriptor(name, Path.GetFileName(fileName))); curIndexStream.Write("<head>\r\n");
//// curIndexStream.Write("<title>" + project.Name + "</title>\r\n");
//// curIndexStream.Write("<TABLE SUMMARY=\"Directory\" BORDER=0 CELLSPACING=0 CELLPADDING=2 WIDTH=\"100%\">\r\n"); curIndexStream.Write("</head>\r\n");
//// curIndexStream.Write(" <TR BGCOLOR=\"#F38C00\">\r\n");
//// curIndexStream.Write(" <TH WIDTH=\"1%\">&nbsp;</TH>\r\n"); curIndexStream.Write("<body>\r\n");
//// curIndexStream.Write(" <TH WIDTH=\"1%\" NOWRAP ALIGN=LEFT>Name</TH>\r\n"); curIndexStream.Write("<p>Location : ");
//// curIndexStream.Write(" <TH WIDTH=\"1%\" NOWRAP ALIGN=RIGHT>Size</TH>\r\n"); foreach (Descriptor d in nameList) {
//// curIndexStream.Write(" <TH WIDTH=\"1%\" NOWRAP ALIGN=LEFT>Date</TH>\r\n"); curIndexStream.Write("<a href=\""+ d.url + "\">" + d.title + "</a>/");
//// curIndexStream.Write(" <TH VALIGN=TOP ALIGN=LEFT>&nbsp; \r\n"); }
//// curIndexStream.Write(" </TH>\r\n"); curIndexStream.Write(name);
//// curIndexStream.Write(" </TR>\r\n"); curIndexStream.Write("</p>\r\n");
////
//// bool coloring = false; nameList.Add(new Descriptor(name, Path.GetFileName(fileName)));
//// foreach (DictionaryEntry entry in table) {
//// if (entry.Value is Hashtable) { curIndexStream.Write("<TABLE SUMMARY=\"Directory\" BORDER=0 CELLSPACING=0 CELLPADDING=2 WIDTH=\"100%\">\r\n");
//// string filename = "index" + ++indexFileIndex + ".html"; curIndexStream.Write(" <TR BGCOLOR=\"#F38C00\">\r\n");
//// WriteIndexTable(Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar + filename, entry.Key.ToString(), nameList, (Hashtable)entry.Value); curIndexStream.Write(" <TH WIDTH=\"1%\">&nbsp;</TH>\r\n");
//// nameList.RemoveAt(nameList.Count - 1); curIndexStream.Write(" <TH WIDTH=\"1%\" NOWRAP ALIGN=LEFT>Name</TH>\r\n");
//// curIndexStream.Write(" <TR BGCOLOR=\"" + (coloring ? "#FFFFFF" : "#EEEEEE") + "\" VALIGN=TOP>\r\n"); curIndexStream.Write(" <TH WIDTH=\"1%\" NOWRAP ALIGN=RIGHT>Size</TH>\r\n");
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT><a href=\"" + filename + "\"><IMG ALIGN=ABSBOTTOM BORDER=0 WIDTH=16 HEIGHT=16 SRC=\"folderbitmap.png\"></a></TD>\r\n"); curIndexStream.Write(" <TH WIDTH=\"1%\" NOWRAP ALIGN=LEFT>Date</TH>\r\n");
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=LEFT><a href=\""+ filename + "\">" + entry.Key.ToString() + "</a> </TD>\r\n"); curIndexStream.Write(" <TH VALIGN=TOP ALIGN=LEFT>&nbsp; \r\n");
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>-</TD>\r\n"); curIndexStream.Write(" </TH>\r\n");
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>-</TD>\r\n"); curIndexStream.Write(" </TR>\r\n");
//// curIndexStream.Write(" <TD VALIGN=TOP ALIGN=LEFT>&nbsp; \r\n");
//// curIndexStream.Write(" </TD>\r\n"); bool coloring = false;
//// curIndexStream.Write(" </TR>\r\n"); foreach (DictionaryEntry entry in table) {
//// } else if (entry.Value is ProjectFile) { if (entry.Value is Hashtable) {
//// ProjectFile fInfo = (ProjectFile)entry.Value; string filename = "index" + ++indexFileIndex + ".html";
//// DateTime time = Directory.GetLastAccessTime(fInfo.Name); WriteIndexTable(Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar + filename, entry.Key.ToString(), nameList, (Hashtable)entry.Value);
//// FileStream reader = File.OpenRead(fInfo.Name); nameList.RemoveAt(nameList.Count - 1);
//// long size = reader.Length; curIndexStream.Write(" <TR BGCOLOR=\"" + (coloring ? "#FFFFFF" : "#EEEEEE") + "\" VALIGN=TOP>\r\n");
//// reader.Close(); curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT><a href=\"" + filename + "\"><IMG ALIGN=ABSBOTTOM BORDER=0 WIDTH=16 HEIGHT=16 SRC=\"folderbitmap.png\"></a></TD>\r\n");
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=LEFT><a href=\""+ filename + "\">" + entry.Key.ToString() + "</a> </TD>\r\n");
//// int idx = GetImageIndex(fInfo.Name); curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>-</TD>\r\n");
//// if (bitmapTable[idx] == null) { curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>-</TD>\r\n");
//// string filename = "fileicon" + ++bitmapIconIndex + ".png"; curIndexStream.Write(" <TD VALIGN=TOP ALIGN=LEFT>&nbsp; \r\n");
//// curIndexStream.Write(" </TD>\r\n");
//// Bitmap bmp = (Bitmap)IconService.ImageList.Images[idx]; curIndexStream.Write(" </TR>\r\n");
//// bmp.Save(Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar + filename); } else if (entry.Value is FileProjectItem) {
//// bitmapTable[idx] = filename; FileProjectItem fInfo = entry.Value as FileProjectItem;
//// } DateTime time = Directory.GetLastAccessTime(fInfo.FileName);
//// string outFile = ExportFile(fInfo.Name, Path.GetDirectoryName(fileName)); FileStream reader = File.OpenRead(fInfo.FileName);
//// ++FilesExported; long size = reader.Length;
//// curIndexStream.Write(" <TR BGCOLOR=\"" + (coloring ? "#FFFFFF" : "#EEEEEE") + "\" VALIGN=TOP>\r\n"); reader.Close();
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT><a href=\"" + outFile + "\"><IMG ALIGN=ABSBOTTOM BORDER=0 WIDTH=16 HEIGHT=16 SRC=\"" + bitmapTable[idx].ToString() +"\"></a></TD>\r\n");
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=LEFT><a href=\"" + outFile + "\">" + Path.GetFileName(fInfo.Name) + "</a> </TD>\r\n"); string filename = "fileicon" + ++bitmapIconIndex + ".png";
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>" + size + "</TD>\r\n"); string outputFileName = Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar + filename;
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>" + time.ToString("d") + "</TD>\r\n"); Bitmap bmp = IconService.GetBitmap(IconService.GetImageForFile(fInfo.FileName));
//// curIndexStream.Write(" <TD VALIGN=TOP ALIGN=LEFT>&nbsp; \r\n");
//// curIndexStream.Write(" </TD>\r\n"); if(! File.Exists(outputFileName)) {
//// curIndexStream.Write(" </TR>\r\n"); bmp.Save(outputFileName);
//// }
//// }
//// coloring = !coloring; string outFile = ExportFile(fInfo.FileName, Path.GetDirectoryName(fileName));
//// } ++FilesExported;
//// curIndexStream.Write(" <TR BGCOLOR=\"" + (coloring ? "#FFFFFF" : "#EEEEEE") + "\" VALIGN=TOP>\r\n");
//// curIndexStream.Write("</TABLE>\r\n"); curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT><a href=\"" + outFile + "\"><IMG ALIGN=ABSBOTTOM BORDER=0 WIDTH=16 HEIGHT=16 SRC=\"" + filename +"\"></a></TD>\r\n");
//// curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=LEFT><a href=\"" + outFile + "\">" + Path.GetFileName(fInfo.FileName) + "</a> </TD>\r\n");
//// curIndexStream.Write("<p>\r\n"); curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>" + size + "</TD>\r\n");
//// curIndexStream.Write("This page was automatically generated by \r\n"); curIndexStream.Write(" <TD NOWRAP VALIGN=TOP ALIGN=RIGHT>" + time.ToString("d") + "</TD>\r\n");
//// curIndexStream.Write("<A TARGET=\"_blank\" HREF=\"http://www.icsharpcode.net/OpenSource/SD\">SharpDevelop</A>.\r\n"); curIndexStream.Write(" <TD VALIGN=TOP ALIGN=LEFT>&nbsp; \r\n");
//// curIndexStream.Write("</p>\r\n"); curIndexStream.Write(" </TD>\r\n");
//// curIndexStream.Write("</body>\r\n"); curIndexStream.Write(" </TR>\r\n");
//// curIndexStream.Write("</html>\r\n");
//// }
//// lock (this) { coloring = !coloring;
//// curIndexStream.Close(); }
//// curIndexStreamStack.Pop();
//// } curIndexStream.Write("</TABLE>\r\n");
// }
// curIndexStream.Write("<p>\r\n");
// delegate void MyD(); curIndexStream.Write("This page was automatically generated by \r\n");
// curIndexStream.Write("<A TARGET=\"_blank\" HREF=\"http://www.icsharpcode.net/OpenSource/SD\">SharpDevelop</A>.\r\n");
// void QuitDialog() curIndexStream.Write("</p>\r\n");
// { curIndexStream.Write("</body>\r\n");
// DialogResult = DialogResult.OK; curIndexStream.Write("</html>\r\n");
// }
// lock (this) {
// Thread exportFilesThread; curIndexStream.Close();
// void ExportFilesThread() curIndexStreamStack.Pop();
// { }
// ResourceService.GetBitmap("Icons.16x16.ClosedFolderBitmap").Save(FileUtility.GetDirectoryNameWithSeparator(pathTextBox.Text) + "folderbitmap.png"); }
// WriteIndexTable(FileUtility.GetDirectoryNameWithSeparator(pathTextBox.Text) + "index.html", "[ROOT]", new ArrayList(), projectTable);
// CreateCSS(pathTextBox.Text); delegate void MyD();
// Invoke(new MyD(QuitDialog));
// } void QuitDialog()
// {
// void StopThread(object sender, EventArgs e) DialogResult = DialogResult.OK;
// { }
// lock (this) {
// exportFilesThread.Abort(); Thread exportFilesThread;
// curFileStream.Close(); void ExportFilesThread()
// while (curIndexStreamStack.Count > 0) { {
// ((StreamWriter)curIndexStreamStack.Pop()).Close(); ResourceService.GetBitmap("Icons.16x16.ClosedFolderBitmap").Save(Path.Combine(pathTextBox.Text, "folderbitmap.png"));
// } WriteIndexTable(Path.Combine(pathTextBox.Text, "index.html"), "[ROOT]", new ArrayList(), projectTable);
// QuitDialog(); CreateCSS(pathTextBox.Text);
// } Invoke(new MyD(QuitDialog));
// } }
//
// void CreateCSS(string targetPath) void StopThread(object sender, EventArgs e)
// { {
// lock (this) { lock (this) {
// StreamWriter sw = File.CreateText(targetPath + Path.DirectorySeparatorChar + "sdcss.css"); exportFilesThread.Abort();
// sw.Write("div.code\r\n"); curFileStream.Close();
// sw.Write("{\r\n"); while (curIndexStreamStack.Count > 0) {
// sw.Write(" background-color: rgb(255,255,255);\r\n"); ((StreamWriter)curIndexStreamStack.Pop()).Close();
// sw.Write(" font-family: \"Lucida Console\", \"courier new\", courier;\r\n"); }
// sw.Write(" color: rgb(0,0,0);\r\n"); QuitDialog();
// sw.Write(" font-size: x-small;\r\n"); }
// sw.Write(" padding: 1em;\r\n"); }
// sw.Write(" margin: 1em;\r\n");
// sw.Write("}\r\n"); void CreateCSS(string targetPath)
// {
// foreach (DictionaryEntry entry in Spans) { lock (this) {
// string color = entry.Key.ToString(); StreamWriter sw = File.CreateText(targetPath + Path.DirectorySeparatorChar + "sdcss.css");
// string name = entry.Value.ToString(); sw.Write("div.code\r\n");
// bool bold = color.StartsWith("b"); sw.Write("{\r\n");
// if (bold) { sw.Write(" background-color: rgb(255,255,255);\r\n");
// color = color.Substring(1); sw.Write(" font-family: \"Lucida Console\", \"courier new\", courier;\r\n");
// } sw.Write(" color: rgb(0,0,0);\r\n");
// bool italic = color.StartsWith("i"); sw.Write(" font-size: x-small;\r\n");
// if (italic) { sw.Write(" padding: 1em;\r\n");
// color = color.Substring(1); sw.Write(" margin: 1em;\r\n");
// } sw.Write("}\r\n");
//
// sw.Write("div.code span." + name +"\r\n"); foreach (DictionaryEntry entry in Spans) {
// sw.Write("{\r\n"); string color = entry.Key.ToString();
// sw.Write(" color: rgb("+ color + ");\r\n"); string name = entry.Value.ToString();
// if (bold) { bool bold = color.StartsWith("b");
// sw.Write(" font-weight: bold;\r\n"); if (bold) {
// } else color = color.Substring(1);
// if (italic) { }
// sw.Write(" font-weight: italic;\r\n"); bool italic = color.StartsWith("i");
// } else { if (italic) {
// sw.Write(" font-weight: normal;\r\n"); color = color.Substring(1);
// } }
//
// sw.Write("}\r\n"); sw.Write("div.code span." + name +"\r\n");
// } sw.Write("{\r\n");
// sw.Close(); sw.Write(" color: rgb("+ color + ");\r\n");
// } if (bold) {
// sw.Write(" font-weight: bold;\r\n");
// } } else
// if (italic) {
// void ExportProject(object sender, EventArgs e) sw.Write(" font-weight: italic;\r\n");
// { } else {
// if (!Directory.Exists(pathTextBox.Text)) { sw.Write(" font-weight: normal;\r\n");
// MessageBox.Show("Directory doesn't exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
// return;
// } sw.Write("}\r\n");
// }
// foreach (ProjectFile fInfo in project.ProjectFiles) { sw.Close();
// if (fInfo.Subtype != Subtype.Directory) { }
// if (fInfo.BuildAction == BuildAction.Compile ||
// fInfo.BuildAction == BuildAction.Nothing) { }
// string relativefile = FileUtility.AbsoluteToRelativePath(project.BaseDirectory, fInfo.Name);
// Hashtable table = GetPath(relativefile, projectTable, true); void ExportProject(object sender, EventArgs e)
// table[Path.GetFileName(fInfo.Name)] = fInfo; {
// } if (!Directory.Exists(pathTextBox.Text)) {
// } MessageBox.Show("Directory doesn't exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// } return;
// }
// StartExporting();
// exportFilesThread = new Thread(new ThreadStart(ExportFilesThread)); foreach (ProjectItem item in project.Items) {
// exportFilesThread.IsBackground = true; if(item is FileProjectItem)
// exportFilesThread.Start(); {
// } FileProjectItem fItem = item as FileProjectItem;
// } if(fItem.BuildAction == FileProjectItem.FileBuildAction.Compile || fItem.BuildAction == FileProjectItem.FileBuildAction.None)
//} {
string relativefile = FileUtility.GetRelativePath(project.Directory, fItem.FileName);
Hashtable table = GetPath(relativefile, projectTable, true);
table[Path.GetFileName(fItem.FileName)] = fItem;
}
}
}
StartExporting();
exportFilesThread = new Thread(new ThreadStart(ExportFilesThread));
exportFilesThread.IsBackground = true;
exportFilesThread.Start();
}
}
}

Loading…
Cancel
Save