Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@552 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
37 changed files with 600 additions and 152 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,32 +0,0 @@
@@ -1,32 +0,0 @@
|
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("")] |
||||
[assembly: AssemblyCopyright("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all values by your own or you can build default build and revision
|
||||
// numbers with the '*' character (the default):
|
||||
|
||||
[assembly: AssemblyVersion("2.0.0.1")] |
||||
|
||||
// The following attributes specify the key for the sign of your assembly. See the
|
||||
// .NET Framework documentation for more information about signing.
|
||||
// This is not required, if you don't want signing let these attributes like they're.
|
||||
[assembly: AssemblyDelaySign(false)] |
||||
[assembly: AssemblyKeyFile("")] |
@ -1,104 +0,0 @@
@@ -1,104 +0,0 @@
|
||||
using System; |
||||
using System.Resources; |
||||
using System.Text.RegularExpressions; |
||||
using System.IO; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace StringResourceSniffer |
||||
{ |
||||
class MainClass |
||||
{ |
||||
readonly static Regex pattern = new Regex(@"\$\{res:([^\}]*)\}"); |
||||
readonly static Regex resourceService = new Regex(@"ResourceService.GetString\(\""([^\""]*)\""\)"); |
||||
readonly static Dictionary<string, bool> resources = new Dictionary<string, bool>(); |
||||
static ResourceSet rs; |
||||
static string fileName; |
||||
|
||||
static void TryMatch(string resourceName) |
||||
{ |
||||
if (rs.GetString(resourceName) == null) { |
||||
Console.WriteLine("unknown: " + resourceName + " in " + fileName); |
||||
} |
||||
resources[resourceName] = true; |
||||
} |
||||
|
||||
static void SearchFiles(List<string> files) |
||||
{ |
||||
foreach (string file in files) { |
||||
fileName = file; |
||||
StreamReader sr = File.OpenText(file); |
||||
string content = sr.ReadToEnd(); |
||||
sr.Close(); |
||||
foreach (Match m in pattern.Matches(content)) { |
||||
TryMatch(m.Groups[1].Captures[0].Value); |
||||
} |
||||
foreach (Match m in resourceService.Matches(content)) { |
||||
TryMatch(m.Groups[1].Captures[0].Value); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
public static void Main(string[] args) |
||||
{ |
||||
rs = new ResourceSet(@"C:\Dokumente und Einstellungen\Omnibrain.DIABLO\Eigene Dateien\trunk\SharpDevelop\src\Main\StartUp\Resources\StringResources.resources"); |
||||
SearchFiles(SearchDirectory(@"C:\Dokumente und Einstellungen\Omnibrain.DIABLO\Eigene Dateien\trunk\SharpDevelop\src", |
||||
"*.cs")); |
||||
SearchFiles(SearchDirectory(@"C:\Dokumente und Einstellungen\Omnibrain.DIABLO\Eigene Dateien\trunk\SharpDevelop\AddIns", |
||||
"*.addin")); |
||||
|
||||
foreach (DictionaryEntry entry in rs) { |
||||
if (!resources.ContainsKey(entry.Key.ToString())) { |
||||
Console.WriteLine("Unused:" + entry.Key); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static List<string> SearchDirectory(string directory, string filemask, bool searchSubdirectories, bool ignoreHidden) |
||||
{ |
||||
List<string> collection = new List<string>(); |
||||
SearchDirectory(directory, filemask, collection, searchSubdirectories, ignoreHidden); |
||||
return collection; |
||||
} |
||||
|
||||
public static List<string> SearchDirectory(string directory, string filemask, bool searchSubdirectories) |
||||
{ |
||||
return SearchDirectory(directory, filemask, searchSubdirectories, false); |
||||
} |
||||
|
||||
public static List<string> SearchDirectory(string directory, string filemask) |
||||
{ |
||||
return SearchDirectory(directory, filemask, true, false); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds all files which are valid to the mask <paramref name="filemask"/> in the path
|
||||
/// <paramref name="directory"/> and all subdirectories
|
||||
/// (if <paramref name="searchSubdirectories"/> is true).
|
||||
/// The found files are added to the List<string>
|
||||
/// <paramref name="collection"/>.
|
||||
/// If <paramref name="ignoreHidden"/> is true, hidden files and folders are ignored.
|
||||
/// </summary>
|
||||
static void SearchDirectory(string directory, string filemask, List<string> collection, bool searchSubdirectories, bool ignoreHidden) |
||||
{ |
||||
string[] file = Directory.GetFiles(directory, filemask); |
||||
foreach (string f in file) { |
||||
if (ignoreHidden && (File.GetAttributes(f) & FileAttributes.Hidden) == FileAttributes.Hidden) { |
||||
continue; |
||||
} |
||||
collection.Add(f); |
||||
} |
||||
|
||||
if (searchSubdirectories) { |
||||
string[] dir = Directory.GetDirectories(directory); |
||||
foreach (string d in dir) { |
||||
if (ignoreHidden && (File.GetAttributes(d) & FileAttributes.Hidden) == FileAttributes.Hidden) { |
||||
continue; |
||||
} |
||||
SearchDirectory(d, filemask, collection, searchSubdirectories, ignoreHidden); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,381 @@
@@ -0,0 +1,381 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel Grunwald |
||||
* Date: 08.10.2005 |
||||
* Time: 19:47 |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Drawing; |
||||
using System.Resources; |
||||
using System.Text; |
||||
using System.Text.RegularExpressions; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace StringResourceTool |
||||
{ |
||||
public class MainForm : System.Windows.Forms.Form |
||||
{ |
||||
public MainForm() |
||||
{ |
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent(); |
||||
try { |
||||
using (StreamReader r = new StreamReader("password.txt")) { |
||||
userNameTextBox.Text = r.ReadLine(); |
||||
passwordTextBox.Text = r.ReadLine(); |
||||
} |
||||
savePasswordCheckBox.Checked = true; |
||||
} catch {} |
||||
} |
||||
|
||||
[STAThread] |
||||
public static void Main(string[] args) |
||||
{ |
||||
Application.EnableVisualStyles(); |
||||
Application.Run(new MainForm()); |
||||
} |
||||
|
||||
#region Windows Forms Designer generated code
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent() |
||||
{ |
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||
this.ClientSize = new System.Drawing.Size(621, 399); |
||||
groupBox1 = new System.Windows.Forms.GroupBox(); |
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
deleteStringsButton = new System.Windows.Forms.Button(); |
||||
//
|
||||
// deleteStringsButton
|
||||
//
|
||||
deleteStringsButton.Enabled = false; |
||||
deleteStringsButton.Location = new System.Drawing.Point(411, 20); |
||||
deleteStringsButton.Name = "deleteStringsButton"; |
||||
deleteStringsButton.Size = new System.Drawing.Size(144, 23); |
||||
deleteStringsButton.TabIndex = 7; |
||||
deleteStringsButton.Text = "Delete resource strings"; |
||||
deleteStringsButton.Click += new System.EventHandler(this.DeleteStringsButtonClick); |
||||
button4 = new System.Windows.Forms.Button(); |
||||
//
|
||||
// button4
|
||||
//
|
||||
button4.Enabled = false; |
||||
button4.Location = new System.Drawing.Point(292, 20); |
||||
button4.Name = "button4"; |
||||
button4.Size = new System.Drawing.Size(113, 23); |
||||
button4.TabIndex = 6; |
||||
button4.Text = "Download database"; |
||||
button4.Click += new System.EventHandler(this.Button4Click); |
||||
savePasswordCheckBox = new System.Windows.Forms.CheckBox(); |
||||
//
|
||||
// savePasswordCheckBox
|
||||
//
|
||||
savePasswordCheckBox.Location = new System.Drawing.Point(182, 44); |
||||
savePasswordCheckBox.Name = "savePasswordCheckBox"; |
||||
savePasswordCheckBox.Size = new System.Drawing.Size(104, 24); |
||||
savePasswordCheckBox.TabIndex = 5; |
||||
savePasswordCheckBox.Text = "Save password"; |
||||
button3 = new System.Windows.Forms.Button(); |
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new System.Drawing.Point(182, 20); |
||||
button3.Name = "button3"; |
||||
button3.Size = new System.Drawing.Size(75, 23); |
||||
button3.TabIndex = 4; |
||||
button3.Text = "Login"; |
||||
button3.Click += new System.EventHandler(this.Button3Click); |
||||
passwordTextBox = new System.Windows.Forms.TextBox(); |
||||
//
|
||||
// passwordTextBox
|
||||
//
|
||||
passwordTextBox.Location = new System.Drawing.Point(76, 42); |
||||
passwordTextBox.Name = "passwordTextBox"; |
||||
passwordTextBox.PasswordChar = '●'; |
||||
passwordTextBox.Size = new System.Drawing.Size(100, 21); |
||||
passwordTextBox.TabIndex = 3; |
||||
passwordTextBox.UseSystemPasswordChar = true; |
||||
userNameTextBox = new System.Windows.Forms.TextBox(); |
||||
//
|
||||
// userNameTextBox
|
||||
//
|
||||
userNameTextBox.Location = new System.Drawing.Point(76, 19); |
||||
userNameTextBox.Name = "userNameTextBox"; |
||||
userNameTextBox.Size = new System.Drawing.Size(100, 21); |
||||
userNameTextBox.TabIndex = 1; |
||||
label2 = new System.Windows.Forms.Label(); |
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Location = new System.Drawing.Point(6, 40); |
||||
label2.Name = "label2"; |
||||
label2.Size = new System.Drawing.Size(64, 23); |
||||
label2.TabIndex = 2; |
||||
label2.Text = "Password:"; |
||||
label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight; |
||||
label1 = new System.Windows.Forms.Label(); |
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Location = new System.Drawing.Point(6, 17); |
||||
label1.Name = "label1"; |
||||
label1.Size = new System.Drawing.Size(64, 23); |
||||
label1.TabIndex = 0; |
||||
label1.Text = "Username:"; |
||||
label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight; |
||||
groupBox1.Controls.Add(deleteStringsButton); |
||||
groupBox1.Controls.Add(button4); |
||||
groupBox1.Controls.Add(savePasswordCheckBox); |
||||
groupBox1.Controls.Add(button3); |
||||
groupBox1.Controls.Add(passwordTextBox); |
||||
groupBox1.Controls.Add(userNameTextBox); |
||||
groupBox1.Controls.Add(label2); |
||||
groupBox1.Controls.Add(label1); |
||||
groupBox1.Location = new System.Drawing.Point(12, 12); |
||||
groupBox1.Name = "groupBox1"; |
||||
groupBox1.Size = new System.Drawing.Size(597, 74); |
||||
groupBox1.TabIndex = 0; |
||||
groupBox1.TabStop = false; |
||||
groupBox1.Text = "Translation server"; |
||||
groupBox1.SuspendLayout(); |
||||
groupBox1.ResumeLayout(false); |
||||
groupBox1.PerformLayout(); |
||||
button2 = new System.Windows.Forms.Button(); |
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new System.Drawing.Point(142, 92); |
||||
button2.Name = "button2"; |
||||
button2.Size = new System.Drawing.Size(124, 23); |
||||
button2.TabIndex = 2; |
||||
button2.Text = "Find missing strings"; |
||||
button2.Click += new System.EventHandler(this.Button2Click); |
||||
button1 = new System.Windows.Forms.Button(); |
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new System.Drawing.Point(12, 91); |
||||
button1.Name = "button1"; |
||||
button1.Size = new System.Drawing.Size(124, 23); |
||||
button1.TabIndex = 1; |
||||
button1.Text = "Find unused strings"; |
||||
button1.Click += new System.EventHandler(this.Button1Click); |
||||
outputTextBox = new System.Windows.Forms.TextBox(); |
||||
//
|
||||
// outputTextBox
|
||||
//
|
||||
outputTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
||||
| System.Windows.Forms.AnchorStyles.Left) |
||||
| System.Windows.Forms.AnchorStyles.Right))); |
||||
outputTextBox.Location = new System.Drawing.Point(12, 120); |
||||
outputTextBox.Multiline = true; |
||||
outputTextBox.Name = "outputTextBox"; |
||||
outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; |
||||
outputTextBox.Size = new System.Drawing.Size(597, 267); |
||||
outputTextBox.TabIndex = 3; |
||||
this.Controls.Add(groupBox1); |
||||
this.Controls.Add(button2); |
||||
this.Controls.Add(button1); |
||||
this.Controls.Add(outputTextBox); |
||||
this.Name = "MainForm"; |
||||
this.Text = "StringResourceTool"; |
||||
this.SuspendLayout(); |
||||
this.ResumeLayout(false); |
||||
this.PerformLayout(); |
||||
} |
||||
private System.Windows.Forms.Button deleteStringsButton; |
||||
private System.Windows.Forms.Button button4; |
||||
private System.Windows.Forms.CheckBox savePasswordCheckBox; |
||||
private System.Windows.Forms.Button button3; |
||||
private System.Windows.Forms.TextBox passwordTextBox; |
||||
private System.Windows.Forms.TextBox userNameTextBox; |
||||
private System.Windows.Forms.Label label2; |
||||
private System.Windows.Forms.Label label1; |
||||
private System.Windows.Forms.GroupBox groupBox1; |
||||
private System.Windows.Forms.Button button2; |
||||
private System.Windows.Forms.Button button1; |
||||
private System.Windows.Forms.TextBox outputTextBox; |
||||
#endregion
|
||||
|
||||
void Button1Click(object sender, EventArgs e) |
||||
{ |
||||
button1.Enabled = false; |
||||
Display(FindMissing(FindResourceStrings(), FindUsedStrings())); |
||||
button1.Enabled = true; |
||||
} |
||||
|
||||
void Button2Click(object sender, EventArgs e) |
||||
{ |
||||
button2.Enabled = false; |
||||
Display(FindMissing(FindUsedStrings(), FindResourceStrings())); |
||||
button2.Enabled = true; |
||||
} |
||||
|
||||
void Display(List<string> list) |
||||
{ |
||||
StringBuilder b = new StringBuilder(); |
||||
foreach (string entry in list) { |
||||
b.AppendLine(entry); |
||||
} |
||||
outputTextBox.Text = b.ToString(); |
||||
} |
||||
|
||||
/// <summary>Gets entries in t1 that are missing from t2.</summary>
|
||||
List<string> FindMissing(Hashtable t1, Hashtable t2) |
||||
{ |
||||
List<string> result = new List<string>(); |
||||
foreach (DictionaryEntry e in t1) { |
||||
if (!t2.ContainsKey(e.Key)) { |
||||
result.Add(e.Key.ToString()); |
||||
} |
||||
} |
||||
result.Sort(); |
||||
return result; |
||||
} |
||||
|
||||
readonly static Regex pattern = new Regex(@"\$\{res:([^\}]*)\}"); |
||||
readonly static Regex resourceService = new Regex(@"ResourceService.GetString\(\""([^\""]*)\""\)"); |
||||
|
||||
Hashtable FindUsedStrings() |
||||
{ |
||||
Hashtable t = new Hashtable(); |
||||
FindUsedStrings(t, @"..\..\..\..\.."); |
||||
return t; |
||||
} |
||||
void FindUsedStrings(Hashtable t, string path) |
||||
{ |
||||
foreach (string subPath in Directory.GetDirectories(path)) { |
||||
if (subPath.EndsWith(".svn")) { |
||||
continue; |
||||
} |
||||
FindUsedStrings(t, subPath); |
||||
} |
||||
foreach (string fileName in Directory.GetFiles(path, "*.*")) { |
||||
switch (Path.GetExtension(fileName).ToLowerInvariant()) { |
||||
case ".cs": |
||||
FindUsedStrings(fileName, t, true); |
||||
break; |
||||
case ".resx": |
||||
case ".resources": |
||||
case ".dll": |
||||
case ".exe": |
||||
case ".pdb": |
||||
break; |
||||
default: |
||||
FindUsedStrings(fileName, t, false); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
void FindUsedStrings(string fileName, Hashtable t, bool resourceServicePattern) |
||||
{ |
||||
StreamReader sr = File.OpenText(fileName); |
||||
string content = sr.ReadToEnd(); |
||||
sr.Close(); |
||||
foreach (Match m in pattern.Matches(content)) { |
||||
t[m.Groups[1].Captures[0].Value] = null; |
||||
} |
||||
if (resourceServicePattern) { |
||||
foreach (Match m in resourceService.Matches(content)) { |
||||
t[m.Groups[1].Captures[0].Value] = null; |
||||
} |
||||
} |
||||
} |
||||
const string srcDir = @"..\..\..\..\"; |
||||
const string dataBaseDir = srcDir + @"..\..\SharpDevelopResources\LanguageResources\"; |
||||
Hashtable FindResourceStrings() |
||||
{ |
||||
ResourceSet rs = new ResourceSet(srcDir + @"Main\StartUp\Project\Resources\StringResources.resources"); |
||||
Hashtable t = new Hashtable(); |
||||
foreach (DictionaryEntry e in rs) { |
||||
t.Add(e.Key, null); |
||||
} |
||||
return t; |
||||
} |
||||
|
||||
TranslationServer server; |
||||
|
||||
void Button3Click(object sender, EventArgs e) |
||||
{ |
||||
server = new TranslationServer(outputTextBox); |
||||
if (savePasswordCheckBox.Checked) { |
||||
using (StreamWriter w = new StreamWriter("password.txt")) { |
||||
w.WriteLine(userNameTextBox.Text); |
||||
w.WriteLine(passwordTextBox.Text); |
||||
} |
||||
} else { |
||||
File.Delete("password.txt"); |
||||
} |
||||
if (server.Login(userNameTextBox.Text, passwordTextBox.Text)) { |
||||
button4.Enabled = true; |
||||
deleteStringsButton.Enabled = true; |
||||
} |
||||
} |
||||
|
||||
void Button4Click(object sender, EventArgs e) |
||||
{ |
||||
EventHandler onDownloadFinished = delegate { |
||||
outputTextBox.Text += "\nBuilding resource files..."; |
||||
RunBatch(dataBaseDir, "build.bat", delegate { |
||||
BeginInvoke(new MethodInvoker(delegate { |
||||
outputTextBox.Text += "\r\nBuilding SharpDevelop..."; |
||||
})); |
||||
RunBatch(srcDir, "debugbuild.bat", null); |
||||
}); |
||||
}; |
||||
server.DownloadDatabase(dataBaseDir + "LocalizeDb.mdb", onDownloadFinished); |
||||
} |
||||
|
||||
void RunBatch(string dir, string batchFile, MethodInvoker exitCallback) |
||||
{ |
||||
BeginInvoke(new MethodInvoker(delegate { |
||||
outputTextBox.Text += "\r\nRun " + dir + batchFile + "..."; |
||||
})); |
||||
ProcessStartInfo psi = new ProcessStartInfo("cmd", "/c " + batchFile); |
||||
psi.WorkingDirectory = dir; |
||||
Process p = Process.Start(psi); |
||||
if (exitCallback != null) { |
||||
p.EnableRaisingEvents = true; |
||||
p.Exited += delegate { |
||||
p.Dispose(); |
||||
exitCallback(); |
||||
}; |
||||
} |
||||
} |
||||
|
||||
void DeleteStringsButtonClick(object sender, EventArgs e) |
||||
{ |
||||
List<string> list = new List<string>(); |
||||
string preview = ""; |
||||
foreach (string line in outputTextBox.Lines) { |
||||
if (line.Length > 0) { |
||||
list.Add(line); |
||||
if (preview.Length == 0) { |
||||
preview = line; |
||||
} else if (preview.Length < 100) { |
||||
preview += ", " + line; |
||||
} |
||||
} |
||||
} |
||||
if (MessageBox.Show("Do you really want to delete the " + list.Count + " resource strings (" + preview + ")" |
||||
, "Delete resources", MessageBoxButtons.YesNo) == DialogResult.Yes) { |
||||
server.DeleteResourceStrings(list.ToArray()); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>WinExe</OutputType> |
||||
<RootNamespace>StringResourceTool</RootNamespace> |
||||
<AssemblyName>StringResourceTool</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{197537EA-78F4-4434-904C-C81B19459FE7}</ProjectGuid> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>bin\Debug\</OutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>True</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>bin\Release\</OutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="MainForm.cs" /> |
||||
<Compile Include="TranslationServer.cs" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||
# SharpDevelop 2.0.0.550 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringResourceTool", "StringResourceTool.csproj", "{197537EA-78F4-4434-904C-C81B19459FE7}" |
||||
EndProject |
||||
Global |
||||
EndGlobal |
@ -0,0 +1,123 @@
@@ -0,0 +1,123 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel Grunwald |
||||
* Date: 08.10.2005 |
||||
* Time: 20:24 |
||||
*/ |
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Net; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace StringResourceTool |
||||
{ |
||||
public class TranslationServer |
||||
{ |
||||
TextBox output; |
||||
string baseURL = "http://developer.sharpdevelop.net/corsavy/translation/"; |
||||
public TranslationServer(TextBox output) |
||||
{ |
||||
this.output = output; |
||||
} |
||||
CookieContainer cookieContainer = new CookieContainer(); |
||||
public bool Login(string user, string pwd) |
||||
{ |
||||
output.Text = "Contacting server..."; |
||||
Application.DoEvents(); |
||||
System.Threading.Thread.Sleep(50); |
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(baseURL + "logon.asp"); |
||||
request.ContentType = "application/x-www-form-urlencoded"; |
||||
string postString = "uname=" + user + "&upwd=" + pwd; |
||||
request.ContentLength = postString.Length; |
||||
request.CookieContainer = cookieContainer; |
||||
request.Method = "POST"; |
||||
request.AllowAutoRedirect = false; |
||||
Stream s = request.GetRequestStream(); |
||||
using (StreamWriter w = new StreamWriter(s)) { |
||||
w.Write(postString); |
||||
} |
||||
s.Close(); |
||||
string result; |
||||
using (StreamReader r = new StreamReader(request.GetResponse().GetResponseStream())) { |
||||
result = r.ReadToEnd(); |
||||
} |
||||
if (result.Contains("You couldn't be logged on")) { |
||||
output.Text += "\r\nInvalid username/password."; |
||||
return false; |
||||
} |
||||
output.Text += "\r\nLogin successful."; |
||||
return true; |
||||
} |
||||
public void DownloadDatabase(string targetFile, EventHandler successCallback) |
||||
{ |
||||
WebClient wc = new WebClient(); |
||||
wc.Headers.Set("Cookie", cookieContainer.GetCookieHeader(new Uri(baseURL))); |
||||
wc.DownloadProgressChanged += delegate(object sender, DownloadProgressChangedEventArgs e) { |
||||
output.BeginInvoke(new MethodInvoker(delegate { |
||||
output.Text = "Download: " + e.ProgressPercentage + "%"; |
||||
})); |
||||
}; |
||||
wc.DownloadDataCompleted += delegate(object sender, DownloadDataCompletedEventArgs e) { |
||||
output.BeginInvoke(new MethodInvoker(delegate { |
||||
if (e.Error != null) |
||||
output.Text = e.Error.ToString(); |
||||
else |
||||
output.Text = "Download complete."; |
||||
})); |
||||
if (e.Error == null) { |
||||
using (FileStream fs = new FileStream(targetFile, FileMode.Create, FileAccess.Write)) { |
||||
fs.Write(e.Result, 0, e.Result.Length); |
||||
} |
||||
successCallback(this, EventArgs.Empty); |
||||
} |
||||
wc.Dispose(); |
||||
}; |
||||
wc.DownloadDataAsync(new Uri(baseURL + "CompactNdownload.asp")); |
||||
} |
||||
|
||||
public void DeleteResourceStrings(string[] idx) |
||||
{ |
||||
const int threadCount = 3; // 3 parallel calls
|
||||
output.Text = "Deleting..."; |
||||
int index = 0; |
||||
int finishCount = 0; |
||||
EventHandler callback = null; |
||||
callback = delegate { |
||||
lock (idx) { |
||||
if (index < idx.Length) { |
||||
DeleteResourceString(idx[index++], callback); |
||||
} else { |
||||
finishCount += 1; |
||||
if (finishCount == threadCount) { |
||||
output.BeginInvoke(new MethodInvoker(delegate { |
||||
output.Text += "\r\nFinished."; |
||||
output.Text += "\r\nYou have to re-download the database to see the changes."; |
||||
})); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
for (int i = 0; i < threadCount; i++) { |
||||
callback(null, null); |
||||
} |
||||
} |
||||
|
||||
public void DeleteResourceString(string idx, EventHandler callback) |
||||
{ |
||||
WebClient wc = new WebClient(); |
||||
wc.Headers.Set("Cookie", cookieContainer.GetCookieHeader(new Uri(baseURL))); |
||||
wc.Headers.Set("Content-Type", "application/x-www-form-urlencoded"); |
||||
wc.UploadStringCompleted += delegate { |
||||
output.BeginInvoke(new MethodInvoker(delegate { |
||||
output.Text += "\r\nDeleted " + idx; |
||||
})); |
||||
wc.Dispose(); |
||||
if (callback != null) |
||||
callback(this, EventArgs.Empty); |
||||
}; |
||||
wc.UploadStringAsync(new Uri(baseURL + "owners_delete.asp"), |
||||
"Idx=" + Uri.EscapeDataString(idx) + "&ReallyDelete=on"); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue