From 6315a5c5a1ddce5b545e6a71fe04930ea62a8b00 Mon Sep 17 00:00:00 2001 From: Roman Belkov Date: Wed, 14 Jan 2015 19:32:49 +0300 Subject: [PATCH] Added Russian localization Tweaked GUI Updated README --- .../DiskImager.Installer.vdproj | 50 +- DiskImager/DiskImager.csproj | 5 +- DiskImager/MainForm.Designer.cs | 151 ++-- DiskImager/MainForm.cs | 74 +- DiskImager/MainForm.resx | 600 ++++++++++++++ DiskImager/MainForm.ru.resx | 196 +++++ DiskImager/Properties/AssemblyInfo.cs | 4 +- DiskImager/Properties/Resources.Designer.cs | 84 +- DiskImager/Properties/Resources.resx | 28 +- DiskImager/Properties/Resources.ru.resx | 147 ++++ .../GZip/GzipInputStream.cs | 744 +++++++++--------- README.md | 13 +- 12 files changed, 1597 insertions(+), 499 deletions(-) create mode 100644 DiskImager/MainForm.ru.resx create mode 100644 DiskImager/Properties/Resources.ru.resx diff --git a/DiskImager.Installer/DiskImager.Installer.vdproj b/DiskImager.Installer/DiskImager.Installer.vdproj index 68178b8..a77562f 100644 --- a/DiskImager.Installer/DiskImager.Installer.vdproj +++ b/DiskImager.Installer/DiskImager.Installer.vdproj @@ -4,9 +4,9 @@ "ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}" "IsWebType" = "8:FALSE" "ProjectName" = "8:DiskImager.Installer" -"LanguageId" = "3:1033" +"LanguageId" = "3:0" "CodePage" = "3:1252" -"UILanguageId" = "3:1033" +"UILanguageId" = "3:0" "SccProjectName" = "8:" "SccLocalPath" = "8:" "SccAuxPath" = "8:" @@ -21,7 +21,7 @@ } "Entry" { - "MsmKey" = "8:_DB06497D6EA628F02D7A42761AF2DBAE" + "MsmKey" = "8:_B1090C5A5662721B31DE535DD9FE3833" "OwnerKey" = "8:_8FDF365DCE9B4F70A60EF2BB1651CCBF" "MsmSig" = "8:_UNDEFINED" } @@ -34,7 +34,7 @@ "Entry" { "MsmKey" = "8:_UNDEFINED" - "OwnerKey" = "8:_DB06497D6EA628F02D7A42761AF2DBAE" + "OwnerKey" = "8:_B1090C5A5662721B31DE535DD9FE3833" "MsmSig" = "8:_UNDEFINED" } } @@ -142,14 +142,14 @@ } "File" { - "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_DB06497D6EA628F02D7A42761AF2DBAE" + "{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_B1090C5A5662721B31DE535DD9FE3833" { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" "AssemblyAsmDisplayName" = "8:ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { - "_DB06497D6EA628F02D7A42761AF2DBAE" + "_B1090C5A5662721B31DE535DD9FE3833" { "Name" = "8:ICSharpCode.SharpZipLib.dll" "Attributes" = "3:512" @@ -222,22 +222,22 @@ } "MsiBootstrapper" { - "LangId" = "3:1033" + "LangId" = "3:0" "RequiresElevation" = "11:FALSE" } "Product" { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Disk Imager" - "ProductCode" = "8:{BEFE1D43-19A6-48F2-8340-92AD4513A108}" - "PackageCode" = "8:{1F1B2C34-933B-4AF1-8972-0CD044A9E172}" + "ProductCode" = "8:{51B52296-A8DC-4D25-9823-E85F0F7AADCF}" + "PackageCode" = "8:{43DD1045-2E31-4B8B-8299-C4C2D7BF62D1}" "UpgradeCode" = "8:{A2F957D8-23F6-44DB-A22C-CCA8275E1FCE}" "AspNetVersion" = "8:4.0.30319.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:FALSE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:1.1.0" + "ProductVersion" = "8:1.2.1" "Manufacturer" = "8:Dynamic Devices" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" @@ -779,7 +779,7 @@ { "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_8FDF365DCE9B4F70A60EF2BB1651CCBF" { - "SourcePath" = "8:..\\DiskImager\\obj\\x86\\Debug\\DiskImager.exe" + "SourcePath" = "8:..\\DiskImager\\obj\\x86\\Release\\DiskImager.exe" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_072AE4B10D3C471AA2B16D68E3691837" @@ -833,6 +833,34 @@ { } } + "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_D9008FB07D394DC88312BB67F0526092" + { + "SourcePath" = "8:" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_072AE4B10D3C471AA2B16D68E3691837" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + "ProjectOutputGroupRegister" = "3:1" + "OutputConfiguration" = "8:" + "OutputGroupCanonicalName" = "8:LocalizedResourceDlls" + "OutputProjectGuid" = "8:{4A73C63C-2BF2-4F85-AA55-A5CA581A33B4}" + "ShowKeyOutput" = "11:TRUE" + "ExcludeFilters" + { + } + } } } } diff --git a/DiskImager/DiskImager.csproj b/DiskImager/DiskImager.csproj index 195f36a..a16c1ef 100644 --- a/DiskImager/DiskImager.csproj +++ b/DiskImager/DiskImager.csproj @@ -106,6 +106,9 @@ MainForm.cs + + MainForm.cs + ResXFileCodeGenerator Resources.Designer.cs @@ -116,6 +119,7 @@ Resources.resx True + SettingsSingleFileGenerator @@ -158,6 +162,5 @@ ICSharpCode.SharpZLib - \ No newline at end of file diff --git a/DiskImager/MainForm.Designer.cs b/DiskImager/MainForm.Designer.cs index 9e81cfb..43474cd 100644 --- a/DiskImager/MainForm.Designer.cs +++ b/DiskImager/MainForm.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.textBoxFileName = new System.Windows.Forms.TextBox(); this.buttonRead = new System.Windows.Forms.Button(); this.buttonWrite = new System.Windows.Forms.Button(); @@ -47,6 +48,9 @@ this.menuStripMain = new System.Windows.Forms.MenuStrip(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.displayAllDrivesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.languageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.englishToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.russianToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.groupBoxTruncation = new System.Windows.Forms.GroupBox(); this.checkBoxUseMBR = new System.Windows.Forms.CheckBox(); this.checkedListBoxDrives = new System.Windows.Forms.CheckedListBox(); @@ -60,240 +64,191 @@ // // textBoxFileName // - this.textBoxFileName.Location = new System.Drawing.Point(10, 61); + resources.ApplyResources(this.textBoxFileName, "textBoxFileName"); this.textBoxFileName.Name = "textBoxFileName"; - this.textBoxFileName.Size = new System.Drawing.Size(420, 20); - this.textBoxFileName.TabIndex = 1; this.textBoxFileName.TextChanged += new System.EventHandler(this.TextBoxFileNameTextChanged); // // buttonRead // - this.buttonRead.Location = new System.Drawing.Point(10, 98); + resources.ApplyResources(this.buttonRead, "buttonRead"); this.buttonRead.Name = "buttonRead"; - this.buttonRead.Size = new System.Drawing.Size(75, 23); - this.buttonRead.TabIndex = 2; - this.buttonRead.Text = "Read"; this.buttonRead.UseVisualStyleBackColor = true; this.buttonRead.Click += new System.EventHandler(this.ButtonReadClick); // // buttonWrite // - this.buttonWrite.Location = new System.Drawing.Point(98, 98); + resources.ApplyResources(this.buttonWrite, "buttonWrite"); this.buttonWrite.Name = "buttonWrite"; - this.buttonWrite.Size = new System.Drawing.Size(75, 23); - this.buttonWrite.TabIndex = 3; - this.buttonWrite.Text = "Write"; this.buttonWrite.UseVisualStyleBackColor = true; this.buttonWrite.Click += new System.EventHandler(this.ButtonWriteClick); // // buttonExit // - this.buttonExit.Location = new System.Drawing.Point(275, 98); + resources.ApplyResources(this.buttonExit, "buttonExit"); this.buttonExit.Name = "buttonExit"; - this.buttonExit.Size = new System.Drawing.Size(75, 23); - this.buttonExit.TabIndex = 4; - this.buttonExit.Text = "Exit"; this.buttonExit.UseVisualStyleBackColor = true; this.buttonExit.Click += new System.EventHandler(this.ButtonExitClick); // // buttonChooseFile // - this.buttonChooseFile.Location = new System.Drawing.Point(436, 60); + resources.ApplyResources(this.buttonChooseFile, "buttonChooseFile"); this.buttonChooseFile.Name = "buttonChooseFile"; - this.buttonChooseFile.Size = new System.Drawing.Size(25, 20); - this.buttonChooseFile.TabIndex = 5; - this.buttonChooseFile.Text = "..."; this.buttonChooseFile.UseVisualStyleBackColor = true; this.buttonChooseFile.Click += new System.EventHandler(this.ButtonChooseFileClick); // // statusStrip1 // + resources.ApplyResources(this.statusStrip1, "statusStrip1"); this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1}); - this.statusStrip1.Location = new System.Drawing.Point(0, 335); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(620, 22); - this.statusStrip1.TabIndex = 6; - this.statusStrip1.Text = "statusStrip1"; // // toolStripStatusLabel1 // + resources.ApplyResources(this.toolStripStatusLabel1, "toolStripStatusLabel1"); this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(118, 17); - this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; // // saveFileDialog1 // this.saveFileDialog1.AddExtension = false; this.saveFileDialog1.DefaultExt = "img"; - this.saveFileDialog1.Filter = "Image Files (*.img)|*.img|Binary files (*.bin)|*.bin|All files (*.*)|*.*"; + resources.ApplyResources(this.saveFileDialog1, "saveFileDialog1"); // // labelFileName // - this.labelFileName.AutoSize = true; - this.labelFileName.Location = new System.Drawing.Point(12, 34); + resources.ApplyResources(this.labelFileName, "labelFileName"); this.labelFileName.Name = "labelFileName"; - this.labelFileName.Size = new System.Drawing.Size(54, 13); - this.labelFileName.TabIndex = 7; - this.labelFileName.Text = "File Name"; // // labelDriveTitle // - this.labelDriveTitle.AutoSize = true; - this.labelDriveTitle.Location = new System.Drawing.Point(466, 34); + resources.ApplyResources(this.labelDriveTitle, "labelDriveTitle"); this.labelDriveTitle.Name = "labelDriveTitle"; - this.labelDriveTitle.Size = new System.Drawing.Size(94, 13); - this.labelDriveTitle.TabIndex = 8; - this.labelDriveTitle.Text = "Removable Drives"; // // buttonCancel // - this.buttonCancel.Enabled = false; - this.buttonCancel.Location = new System.Drawing.Point(187, 98); + resources.ApplyResources(this.buttonCancel, "buttonCancel"); this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.Size = new System.Drawing.Size(75, 23); - this.buttonCancel.TabIndex = 10; - this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick); // // groupBoxCompression // + resources.ApplyResources(this.groupBoxCompression, "groupBoxCompression"); this.groupBoxCompression.Controls.Add(this.radioButtonCompNone); this.groupBoxCompression.Controls.Add(this.radioButtonCompTgz); this.groupBoxCompression.Controls.Add(this.radioButtonCompGz); this.groupBoxCompression.Controls.Add(this.radioButtonCompZip); - this.groupBoxCompression.Location = new System.Drawing.Point(33, 132); this.groupBoxCompression.Name = "groupBoxCompression"; - this.groupBoxCompression.Size = new System.Drawing.Size(252, 50); - this.groupBoxCompression.TabIndex = 11; this.groupBoxCompression.TabStop = false; - this.groupBoxCompression.Text = "Compression"; // // radioButtonCompNone // - this.radioButtonCompNone.AutoSize = true; + resources.ApplyResources(this.radioButtonCompNone, "radioButtonCompNone"); this.radioButtonCompNone.Checked = true; - this.radioButtonCompNone.Location = new System.Drawing.Point(170, 19); this.radioButtonCompNone.Name = "radioButtonCompNone"; - this.radioButtonCompNone.Size = new System.Drawing.Size(56, 17); - this.radioButtonCompNone.TabIndex = 3; this.radioButtonCompNone.TabStop = true; - this.radioButtonCompNone.Text = "NONE"; this.radioButtonCompNone.UseVisualStyleBackColor = true; this.radioButtonCompNone.CheckedChanged += new System.EventHandler(this.RadioButtonCompNoneCheckedChanged); // // radioButtonCompTgz // - this.radioButtonCompTgz.AutoSize = true; - this.radioButtonCompTgz.Location = new System.Drawing.Point(117, 19); + resources.ApplyResources(this.radioButtonCompTgz, "radioButtonCompTgz"); this.radioButtonCompTgz.Name = "radioButtonCompTgz"; - this.radioButtonCompTgz.Size = new System.Drawing.Size(47, 17); - this.radioButtonCompTgz.TabIndex = 2; - this.radioButtonCompTgz.Text = "TGZ"; this.radioButtonCompTgz.UseVisualStyleBackColor = true; this.radioButtonCompTgz.CheckedChanged += new System.EventHandler(this.RadioButtonCompTgzCheckedChanged); // // radioButtonCompGz // - this.radioButtonCompGz.AutoSize = true; - this.radioButtonCompGz.Location = new System.Drawing.Point(71, 19); + resources.ApplyResources(this.radioButtonCompGz, "radioButtonCompGz"); this.radioButtonCompGz.Name = "radioButtonCompGz"; - this.radioButtonCompGz.Size = new System.Drawing.Size(40, 17); - this.radioButtonCompGz.TabIndex = 1; - this.radioButtonCompGz.Text = "GZ"; this.radioButtonCompGz.UseVisualStyleBackColor = true; this.radioButtonCompGz.CheckedChanged += new System.EventHandler(this.RadioButtonCompGzCheckedChanged); // // radioButtonCompZip // - this.radioButtonCompZip.AutoSize = true; - this.radioButtonCompZip.Location = new System.Drawing.Point(23, 19); + resources.ApplyResources(this.radioButtonCompZip, "radioButtonCompZip"); this.radioButtonCompZip.Name = "radioButtonCompZip"; - this.radioButtonCompZip.Size = new System.Drawing.Size(42, 17); - this.radioButtonCompZip.TabIndex = 0; - this.radioButtonCompZip.Text = "ZIP"; this.radioButtonCompZip.UseVisualStyleBackColor = true; this.radioButtonCompZip.CheckedChanged += new System.EventHandler(this.RadioButtonCompZipCheckedChanged); // // menuStripMain // + resources.ApplyResources(this.menuStripMain, "menuStripMain"); this.menuStripMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.optionsToolStripMenuItem}); - this.menuStripMain.Location = new System.Drawing.Point(0, 0); this.menuStripMain.Name = "menuStripMain"; - this.menuStripMain.Size = new System.Drawing.Size(620, 24); - this.menuStripMain.TabIndex = 12; - this.menuStripMain.Text = "menuStrip1"; // // optionsToolStripMenuItem // + resources.ApplyResources(this.optionsToolStripMenuItem, "optionsToolStripMenuItem"); this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.displayAllDrivesToolStripMenuItem}); + this.displayAllDrivesToolStripMenuItem, + this.languageToolStripMenuItem}); this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; - this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); - this.optionsToolStripMenuItem.Text = "Options"; // // displayAllDrivesToolStripMenuItem // + resources.ApplyResources(this.displayAllDrivesToolStripMenuItem, "displayAllDrivesToolStripMenuItem"); this.displayAllDrivesToolStripMenuItem.CheckOnClick = true; this.displayAllDrivesToolStripMenuItem.Name = "displayAllDrivesToolStripMenuItem"; - this.displayAllDrivesToolStripMenuItem.Size = new System.Drawing.Size(275, 22); - this.displayAllDrivesToolStripMenuItem.Text = "Display All Drives *** DANGEROUS ***"; this.displayAllDrivesToolStripMenuItem.CheckedChanged += new System.EventHandler(this.DisplayAllDrivesToolStripMenuItemCheckedChanged); // + // languageToolStripMenuItem + // + resources.ApplyResources(this.languageToolStripMenuItem, "languageToolStripMenuItem"); + this.languageToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.englishToolStripMenuItem, + this.russianToolStripMenuItem}); + this.languageToolStripMenuItem.Name = "languageToolStripMenuItem"; + // + // englishToolStripMenuItem + // + resources.ApplyResources(this.englishToolStripMenuItem, "englishToolStripMenuItem"); + this.englishToolStripMenuItem.Name = "englishToolStripMenuItem"; + this.englishToolStripMenuItem.Click += new System.EventHandler(this.englishToolStripMenuItem_Click); + // + // russianToolStripMenuItem + // + resources.ApplyResources(this.russianToolStripMenuItem, "russianToolStripMenuItem"); + this.russianToolStripMenuItem.Name = "russianToolStripMenuItem"; + this.russianToolStripMenuItem.Click += new System.EventHandler(this.russianToolStripMenuItem_Click); + // // groupBoxTruncation // + resources.ApplyResources(this.groupBoxTruncation, "groupBoxTruncation"); this.groupBoxTruncation.Controls.Add(this.checkBoxUseMBR); - this.groupBoxTruncation.Location = new System.Drawing.Point(291, 132); this.groupBoxTruncation.Name = "groupBoxTruncation"; - this.groupBoxTruncation.Size = new System.Drawing.Size(172, 50); - this.groupBoxTruncation.TabIndex = 13; this.groupBoxTruncation.TabStop = false; - this.groupBoxTruncation.Text = "Image Truncation"; // // checkBoxUseMBR // - this.checkBoxUseMBR.AutoSize = true; - this.checkBoxUseMBR.Location = new System.Drawing.Point(23, 19); + resources.ApplyResources(this.checkBoxUseMBR, "checkBoxUseMBR"); this.checkBoxUseMBR.Name = "checkBoxUseMBR"; - this.checkBoxUseMBR.Size = new System.Drawing.Size(138, 17); - this.checkBoxUseMBR.TabIndex = 0; - this.checkBoxUseMBR.Text = "Use MBR partition sizes"; this.checkBoxUseMBR.UseVisualStyleBackColor = true; // // checkedListBoxDrives // + resources.ApplyResources(this.checkedListBoxDrives, "checkedListBoxDrives"); this.checkedListBoxDrives.FormattingEnabled = true; - this.checkedListBoxDrives.Location = new System.Drawing.Point(469, 58); this.checkedListBoxDrives.Name = "checkedListBoxDrives"; - this.checkedListBoxDrives.Size = new System.Drawing.Size(139, 124); this.checkedListBoxDrives.Sorted = true; - this.checkedListBoxDrives.TabIndex = 15; // // flowLayoutPanelProgressBars // + resources.ApplyResources(this.flowLayoutPanelProgressBars, "flowLayoutPanelProgressBars"); this.flowLayoutPanelProgressBars.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.flowLayoutPanelProgressBars.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flowLayoutPanelProgressBars.Location = new System.Drawing.Point(10, 194); this.flowLayoutPanelProgressBars.Name = "flowLayoutPanelProgressBars"; - this.flowLayoutPanelProgressBars.Size = new System.Drawing.Size(211, 137); - this.flowLayoutPanelProgressBars.TabIndex = 16; // // flowLayoutPanelProgressLabels // + resources.ApplyResources(this.flowLayoutPanelProgressLabels, "flowLayoutPanelProgressLabels"); this.flowLayoutPanelProgressLabels.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.flowLayoutPanelProgressLabels.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flowLayoutPanelProgressLabels.Location = new System.Drawing.Point(229, 194); this.flowLayoutPanelProgressLabels.Name = "flowLayoutPanelProgressLabels"; - this.flowLayoutPanelProgressLabels.Size = new System.Drawing.Size(379, 137); - this.flowLayoutPanelProgressLabels.TabIndex = 17; // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(620, 357); this.Controls.Add(this.flowLayoutPanelProgressLabels); this.Controls.Add(this.flowLayoutPanelProgressBars); this.Controls.Add(this.checkedListBoxDrives); @@ -314,7 +269,6 @@ this.MaximizeBox = false; this.Name = "MainForm"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "Disk Imager"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); @@ -355,6 +309,9 @@ private System.Windows.Forms.CheckedListBox checkedListBoxDrives; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelProgressBars; private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelProgressLabels; + private System.Windows.Forms.ToolStripMenuItem languageToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem englishToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem russianToolStripMenuItem; } } diff --git a/DiskImager/MainForm.cs b/DiskImager/MainForm.cs index c5cbf2a..38afbe0 100644 --- a/DiskImager/MainForm.cs +++ b/DiskImager/MainForm.cs @@ -14,13 +14,17 @@ using System; using System.IO; using System.Linq; using System.Collections.Generic; +using System.ComponentModel; using System.Drawing; +using System.Globalization; using System.Reflection; +using System.Threading; using System.Windows.Forms; using DynamicDevices.DiskWriter.Detection; using DynamicDevices.DiskWriter.Win32; using Microsoft.Win32; using System.Threading.Tasks; +using DynamicDevices.DiskWriter.Properties; namespace DynamicDevices.DiskWriter { @@ -34,11 +38,15 @@ namespace DynamicDevices.DiskWriter private DriveDetector _watcher = new DriveDetector(); private EnumCompressionType _eCompType; + + private CultureInfo CurrentLocale { get; set; } #endregion #region Constructor + //var LocRM = new ResourceManager("") + public MainForm() { InitializeComponent(); @@ -47,10 +55,10 @@ namespace DynamicDevices.DiskWriter MessageBoxEx.Owner = Handle; - toolStripStatusLabel1.Text = @"Initialised. Licensed under GPLv3. Use at own risk!"; + toolStripStatusLabel1.Text = Resources.MainForm_MainForm_Initialised__Licensed_under_GPLv3__Use_at_own_risk_; saveFileDialog1.OverwritePrompt = false; - saveFileDialog1.Filter = @"Image Files (*.img,*.bin,*.sdcard)|*.img;*.bin;*.sdcard|Compressed Files (*.zip,*.gz,*tgz)|*.zip;*.gz;*.tgz|All files (*.*)|*.*"; + saveFileDialog1.Filter = Resources.MainForm_MainForm_Image_Files__Choose; // Set version into title var version = Assembly.GetEntryAssembly().GetName().Version; @@ -128,8 +136,8 @@ namespace DynamicDevices.DiskWriter if (checkedListBoxDrives.CheckedItems.Count != 1) { MessageBox.Show( - @"You can read from only one drive at a time. Please select only one drive from drive list.", - @"*** WARNING ***", MessageBoxButtons.OK, MessageBoxIcon.Warning); + Resources.MainForm_ButtonReadClick_You_can_read_from_only_one_drive_at_a_time, + Resources.MainForm_ButtonReadClick_____WARNING____, MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } @@ -158,7 +166,7 @@ namespace DynamicDevices.DiskWriter } if (!res && !disk.IsCancelling) { - MessageBoxEx.Show("Problem with reading from disk.", "Read Error", + MessageBoxEx.Show(Resources.MainForm_ButtonReadClick_Problem_with_reading_from_disk_, Resources.MainForm_ButtonReadClick_Read_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -182,8 +190,8 @@ namespace DynamicDevices.DiskWriter { var dr = MessageBox.Show( - @"C: is almost certainly your main hard drive. Writing to this will likely destroy your data, and brick your PC. Are you absolutely sure you want to do this?", - @"*** WARNING ***", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + Resources.MainForm_ButtonWriteClick_C__is_almost_certainly_your_main_HDD, + Resources.MainForm_ButtonReadClick_____WARNING____, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr != DialogResult.Yes) return; } @@ -219,7 +227,7 @@ namespace DynamicDevices.DiskWriter } if (!res && !disk.IsCancelling) { - MessageBoxEx.Show("Problem writing to disk. Is it write-protected?", "Write Error", + MessageBoxEx.Show(Resources.MainForm_ButtonWriteClick_Problem_writing_to_disk__Is_it_write_protected_, Resources.MainForm_ButtonWriteClick_Write_Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } })).ToArray(); @@ -528,5 +536,55 @@ namespace DynamicDevices.DiskWriter } #endregion + + private void englishToolStripMenuItem_Click(object sender, EventArgs e) + { + Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); + ChangeLanguage("en-US"); + } + private void russianToolStripMenuItem_Click(object sender, EventArgs e) + { + Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU"); + ChangeLanguage("ru-RU"); + } + + //change the language in real time + private void ChangeLanguage(string lang) + { + CurrentLocale = new CultureInfo(lang); + var resources = new ComponentResourceManager(typeof (MainForm)); + foreach (Control c in Controls) + { + resources.ApplyResources(c, c.Name, CurrentLocale); + RefreshFormResources(c, resources); + } + + ChangeMenuStripLanguage(menuStripMain.Items, resources); + toolStripStatusLabel1.Text = Resources.MainForm_MainForm_Initialised__Licensed_under_GPLv3__Use_at_own_risk_; + saveFileDialog1.Filter = Resources.MainForm_MainForm_Image_Files__Choose; + } + + //refresh all menu strip controls recursively + private void ChangeMenuStripLanguage(ToolStripItemCollection collection, ComponentResourceManager resources) + { + foreach (ToolStripItem m in collection) + { + resources.ApplyResources(m, m.Name, CurrentLocale); + var item = m as ToolStripDropDownItem; + if (item != null) + ChangeMenuStripLanguage(item.DropDownItems, resources); + } + } + + //refresh all the sub-controls of the form recursively + private void RefreshFormResources(Control ctrl, ComponentResourceManager res) + { + ctrl.SuspendLayout(); + res.ApplyResources(ctrl, ctrl.Name, CurrentLocale); + foreach (Control c in ctrl.Controls) + RefreshFormResources(c, res); // recursion + ctrl.ResumeLayout(false); + } + } } diff --git a/DiskImager/MainForm.resx b/DiskImager/MainForm.resx index ec5200b..f2d3f97 100644 --- a/DiskImager/MainForm.resx +++ b/DiskImager/MainForm.resx @@ -117,13 +117,613 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 10, 61 + + + 420, 20 + + + + 1 + + + textBoxFileName + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 14 + + + 10, 98 + + + 75, 23 + + + 2 + + + Read + + + buttonRead + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 13 + + + 98, 98 + + + 75, 23 + + + 3 + + + Write + + + buttonWrite + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 12 + + + 275, 98 + + + 75, 23 + + + 4 + + + Exit + + + buttonExit + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 11 + + + 436, 60 + + + 25, 20 + + + 5 + + + ... + + + buttonChooseFile + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 10 + 17, 17 + + 118, 17 + + + toolStripStatusLabel1 + + + 0, 335 + + + 620, 22 + + + 6 + + + statusStrip1 + + + statusStrip1 + + + System.Windows.Forms.StatusStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 8 + 273, 17 + + Image Files (*.img)|*.img|Binary files (*.bin)|*.bin|All files (*.*)|*.* + + + True + + + 12, 34 + + + 54, 13 + + + 7 + + + File Name + + + labelFileName + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 7 + + + True + + + 466, 34 + + + 94, 13 + + + 8 + + + Removable Drives + + + labelDriveTitle + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 6 + + + False + + + 187, 98 + + + 75, 23 + + + 10 + + + Cancel + + + buttonCancel + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + True + + + 170, 19 + + + 56, 17 + + + 3 + + + NONE + + + radioButtonCompNone + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxCompression + + + 0 + + + True + + + 117, 19 + + + 47, 17 + + + 2 + + + TGZ + + + radioButtonCompTgz + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxCompression + + + 1 + + + True + + + 71, 19 + + + 40, 17 + + + 1 + + + GZ + + + radioButtonCompGz + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxCompression + + + 2 + + + True + + + 23, 19 + + + 42, 17 + + + 0 + + + ZIP + + + radioButtonCompZip + + + System.Windows.Forms.RadioButton, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxCompression + + + 3 + + + 33, 132 + + + 252, 50 + + + 11 + + + Compression + + + groupBoxCompression + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + 409, 17 + + 275, 22 + + + Display All Drives *** DANGEROUS *** + + + 114, 22 + + + English + + + 114, 22 + + + Russian + + + 275, 22 + + + Language + + + 61, 20 + + + Options + + + 0, 0 + + + 620, 24 + + + 12 + + + menuStrip1 + + + menuStripMain + + + System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 9 + + + True + + + 23, 19 + + + 138, 17 + + + 0 + + + Use MBR partition sizes + + + checkBoxUseMBR + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBoxTruncation + + + 0 + + + 291, 132 + + + 172, 50 + + + 13 + + + Image Truncation + + + groupBoxTruncation + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + 469, 58 + + + 139, 124 + + + 15 + + + checkedListBoxDrives + + + System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + + TopDown + + + 10, 194 + + + 211, 137 + + + 16 + + + flowLayoutPanelProgressBars + + + System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 + + + TopDown + + + 229, 194 + + + 379, 137 + + + 17 + + + flowLayoutPanelProgressLabels + + + System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + + + True + + + 6, 13 + + + 620, 357 + + + Disk Imager + + + toolStripStatusLabel1 + + + System.Windows.Forms.ToolStripStatusLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + saveFileDialog1 + + + System.Windows.Forms.SaveFileDialog, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + optionsToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + displayAllDrivesToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + languageToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + englishToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + russianToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + MainForm + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/DiskImager/MainForm.ru.resx b/DiskImager/MainForm.ru.resx new file mode 100644 index 0000000..e8b8102 --- /dev/null +++ b/DiskImager/MainForm.ru.resx @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Чтение + + + Запись + + + Выход + + + + 64, 13 + + + Имя файла + + + 40, 13 + + + Диски + + + Отмена + + + 10, 132 + + + Сжатие + + + 265, 22 + + + Показать все диски ***ОПАСНО*** + + + 141, 22 + + + Английский + + + 141, 22 + + + Русский + + + 265, 22 + + + Язык + + + 56, 20 + + + Опции + + + 126, 17 + + + Использовать MBR + + + 275, 132 + + + 188, 50 + + + Образ логических разделов + + \ No newline at end of file diff --git a/DiskImager/Properties/AssemblyInfo.cs b/DiskImager/Properties/AssemblyInfo.cs index b1a93b2..09f3d01 100644 --- a/DiskImager/Properties/AssemblyInfo.cs +++ b/DiskImager/Properties/AssemblyInfo.cs @@ -47,5 +47,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.*")] -[assembly: AssemblyFileVersion("1.2.0.0")] +[assembly: AssemblyVersion("1.2.1.*")] +[assembly: AssemblyFileVersion("1.2.1.0")] diff --git a/DiskImager/Properties/Resources.Designer.cs b/DiskImager/Properties/Resources.Designer.cs index dc847c2..c566350 100644 --- a/DiskImager/Properties/Resources.Designer.cs +++ b/DiskImager/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34003 +// Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -11,6 +11,7 @@ namespace DynamicDevices.DiskWriter.Properties { using System; + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -58,5 +59,86 @@ namespace DynamicDevices.DiskWriter.Properties { resourceCulture = value; } } + + /// + /// Looks up a localized string similar to *** WARNING ***. + /// + internal static string MainForm_ButtonReadClick_____WARNING____ { + get { + return ResourceManager.GetString("MainForm_ButtonReadClick_____WARNING____", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Problem with reading from disk.. + /// + internal static string MainForm_ButtonReadClick_Problem_with_reading_from_disk_ { + get { + return ResourceManager.GetString("MainForm_ButtonReadClick_Problem_with_reading_from_disk_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Read Error. + /// + internal static string MainForm_ButtonReadClick_Read_Error { + get { + return ResourceManager.GetString("MainForm_ButtonReadClick_Read_Error", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You can read from only one drive at a time. Please select only one drive from drive list.. + /// + internal static string MainForm_ButtonReadClick_You_can_read_from_only_one_drive_at_a_time { + get { + return ResourceManager.GetString("MainForm_ButtonReadClick_You_can_read_from_only_one_drive_at_a_time", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to C: is almost certainly your main hard drive. Writing to this will likely destroy your data, and brick your PC. Are you absolutely sure you want to do this?. + /// + internal static string MainForm_ButtonWriteClick_C__is_almost_certainly_your_main_HDD { + get { + return ResourceManager.GetString("MainForm_ButtonWriteClick_C__is_almost_certainly_your_main_HDD", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Problem writing to disk. Is it write-protected?. + /// + internal static string MainForm_ButtonWriteClick_Problem_writing_to_disk__Is_it_write_protected_ { + get { + return ResourceManager.GetString("MainForm_ButtonWriteClick_Problem_writing_to_disk__Is_it_write_protected_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Write Error. + /// + internal static string MainForm_ButtonWriteClick_Write_Error { + get { + return ResourceManager.GetString("MainForm_ButtonWriteClick_Write_Error", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Image Files (*.img,*.bin,*.sdcard)|*.img;*.bin;*.sdcard|Compressed Files (*.zip,*.gz,*tgz)|*.zip;*.gz;*.tgz|All files (*.*)|*.*. + /// + internal static string MainForm_MainForm_Image_Files__Choose { + get { + return ResourceManager.GetString("MainForm_MainForm_Image_Files__Choose", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Initialised. Licensed under GPLv3. Use at own risk!. + /// + internal static string MainForm_MainForm_Initialised__Licensed_under_GPLv3__Use_at_own_risk_ { + get { + return ResourceManager.GetString("MainForm_MainForm_Initialised__Licensed_under_GPLv3__Use_at_own_risk_", resourceCulture); + } + } } } diff --git a/DiskImager/Properties/Resources.resx b/DiskImager/Properties/Resources.resx index ffecec8..1508ea3 100644 --- a/DiskImager/Properties/Resources.resx +++ b/DiskImager/Properties/Resources.resx @@ -1,4 +1,3 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ***ВНИМАНИЕ*** + + + Проблема при чтении с диска + + + Ошибка чтения + + + Считывать можно только с одного диска одновременно. Пожалуйста, выберите только один диск. + + + Диск C: наверняка является основным жёстким диском Вашего компьютера. Запись на этот диск может повредить данные на Вашем компьютере. + + + Ошибка записи на диск. Пожалуйста, проверьте, не защищён ли диск от записи. + + + Ошибка записи + + + Образы файлов (*.img,*.bin,*.sdcard)|*.img;*.bin;*.sdcard|Сжатые файлы (*.zip,*.gz,*tgz)|*.zip;*.gz;*.tgz|Все файлы (*.*)|*.* + + + Программа лицензирована GNU GPL v3. Авторы не несут ответственность за ущерб! + + \ No newline at end of file diff --git a/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs b/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs index 2fed4d2..105f5c2 100644 --- a/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs +++ b/ICSharpCode.SharpZipLib/GZip/GzipInputStream.cs @@ -1,94 +1,94 @@ -// GzipInputStream.cs -// -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -// HISTORY -// 2009-08-11 T9121 Geoff Hart Added Multi-member gzip support -// 2012-06-03 Z-1802 Incorrect endianness and subfield in FEXTRA handling. - -using System; -using System.IO; - -using ICSharpCode.SharpZipLib.Checksums; -using ICSharpCode.SharpZipLib.Zip.Compression; -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -namespace ICSharpCode.SharpZipLib.GZip -{ - - /// - /// This filter stream is used to decompress a "GZIP" format stream. - /// The "GZIP" format is described baseInputStream RFC 1952. - /// - /// author of the original java version : John Leuner - /// - /// This sample shows how to unzip a gzipped file - /// - /// using System; - /// using System.IO; - /// - /// using ICSharpCode.SharpZipLib.Core; - /// using ICSharpCode.SharpZipLib.GZip; - /// - /// class MainClass - /// { - /// public static void Main(string[] args) - /// { - /// using (Stream inStream = new GZipInputStream(File.OpenRead(args[0]))) - /// using (FileStream outStream = File.Create(Path.GetFileNameWithoutExtension(args[0]))) { - /// byte[] buffer = new byte[4096]; - /// StreamUtils.Copy(inStream, outStream, buffer); - /// } - /// } - /// } - /// - /// - public class GZipInputStream : InflaterInputStream - { - #region Instance Fields - /// - /// CRC-32 value for uncompressed data - /// - protected Crc32 crc; - - /// - /// Flag to indicate if we've read the GZIP header yet for the current member (block of compressed data). - /// This is tracked per-block as the file is parsed. - /// +// GzipInputStream.cs +// +// Copyright (C) 2001 Mike Krueger +// +// This file was translated from java, it was part of the GNU Classpath +// Copyright (C) 2001 Free Software Foundation, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// Linking this library statically or dynamically with other modules is +// making a combined work based on this library. Thus, the terms and +// conditions of the GNU General Public License cover the whole +// combination. +// +// As a special exception, the copyright holders of this library give you +// permission to link this library with independent modules to produce an +// executable, regardless of the license terms of these independent +// modules, and to copy and distribute the resulting executable under +// terms of your choice, provided that you also meet, for each linked +// independent module, the terms and conditions of the license of that +// module. An independent module is a module which is not derived from +// or based on this library. If you modify this library, you may extend +// this exception to your version of the library, but you are not +// obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. + +// HISTORY +// 2009-08-11 T9121 Geoff Hart Added Multi-member gzip support +// 2012-06-03 Z-1802 Incorrect endianness and subfield in FEXTRA handling. + +using System; +using System.IO; + +using ICSharpCode.SharpZipLib.Checksums; +using ICSharpCode.SharpZipLib.Zip.Compression; +using ICSharpCode.SharpZipLib.Zip.Compression.Streams; + +namespace ICSharpCode.SharpZipLib.GZip +{ + + /// + /// This filter stream is used to decompress a "GZIP" format stream. + /// The "GZIP" format is described baseInputStream RFC 1952. + /// + /// author of the original java version : John Leuner + /// + /// This sample shows how to unzip a gzipped file + /// + /// using System; + /// using System.IO; + /// + /// using ICSharpCode.SharpZipLib.Core; + /// using ICSharpCode.SharpZipLib.GZip; + /// + /// class MainClass + /// { + /// public static void Main(string[] args) + /// { + /// using (Stream inStream = new GZipInputStream(File.OpenRead(args[0]))) + /// using (FileStream outStream = File.Create(Path.GetFileNameWithoutExtension(args[0]))) { + /// byte[] buffer = new byte[4096]; + /// StreamUtils.Copy(inStream, outStream, buffer); + /// } + /// } + /// } + /// + /// + public class GZipInputStream : InflaterInputStream + { + #region Instance Fields + /// + /// CRC-32 value for uncompressed data + /// + protected Crc32 crc; + + /// + /// Flag to indicate if we've read the GZIP header yet for the current member (block of compressed data). + /// This is tracked per-block as the file is parsed. + /// bool readGZIPHeader; /// @@ -101,288 +101,288 @@ namespace ICSharpCode.SharpZipLib.GZip /// private long _length; - private Stream _baseInputStream; - - #endregion - - #region Constructors - /// - /// Creates a GZipInputStream with the default buffer size - /// - /// - /// The stream to read compressed data from (baseInputStream GZIP format) - /// - public GZipInputStream(Stream baseInputStream) + private Stream _baseInputStream; + + #endregion + + #region Constructors + /// + /// Creates a GZipInputStream with the default buffer size + /// + /// + /// The stream to read compressed data from (baseInputStream GZIP format) + /// + public GZipInputStream(Stream baseInputStream) : this(baseInputStream, 4096) { _baseInputStream = baseInputStream; - } - - /// - /// Creates a GZIPInputStream with the specified buffer size - /// - /// - /// The stream to read compressed data from (baseInputStream GZIP format) - /// - /// - /// Size of the buffer to use - /// - public GZipInputStream(Stream baseInputStream, int size) - : base(baseInputStream, new Inflater(true), size) + } + + /// + /// Creates a GZIPInputStream with the specified buffer size + /// + /// + /// The stream to read compressed data from (baseInputStream GZIP format) + /// + /// + /// Size of the buffer to use + /// + public GZipInputStream(Stream baseInputStream, int size) + : base(baseInputStream, new Inflater(true), size) { _baseInputStream = baseInputStream; - } - #endregion - - #region Stream overrides - /// - /// Reads uncompressed data into an array of bytes - /// - /// - /// The buffer to read uncompressed data into - /// - /// - /// The offset indicating where the data should be placed - /// - /// - /// The number of uncompressed bytes to be read - /// - /// Returns the number of bytes actually read. - public override int Read(byte[] buffer, int offset, int count) - { - // A GZIP file can contain multiple blocks of compressed data, although this is quite rare. - // A compressed block could potentially be empty, so we need to loop until we reach EOF or - // we find data. - while (true) { - - // If we haven't read the header for this block, read it - if (! readGZIPHeader) { - - // Try to read header. If there is no header (0 bytes available), this is EOF. If there is - // an incomplete header, this will throw an exception. - if (! ReadHeader()) { - return 0; - } - } - - // Try to read compressed data - int bytesRead = base.Read(buffer, offset, count); - if (bytesRead > 0) { - crc.Update(buffer, offset, bytesRead); - } - - // If this is the end of stream, read the footer - if (inf.IsFinished) { - ReadFooter(); - } - - if (bytesRead > 0) { - return bytesRead; - } - } - } - #endregion - - #region Support routines - bool ReadHeader() - { - // Initialize CRC for this block - crc = new Crc32(); - - // Make sure there is data in file. We can't rely on ReadLeByte() to fill the buffer, as this could be EOF, - // which is fine, but ReadLeByte() throws an exception if it doesn't find data, so we do this part ourselves. - if (inputBuffer.Available <= 0) { - inputBuffer.Fill(); - if (inputBuffer.Available <= 0) { - // No header, EOF. - return false; - } - } - - // 1. Check the two magic bytes - Crc32 headCRC = new Crc32(); - int magic = inputBuffer.ReadLeByte(); - - if (magic < 0) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - - headCRC.Update(magic); - if (magic != (GZipConstants.GZIP_MAGIC >> 8)) { - throw new GZipException("Error GZIP header, first magic byte doesn't match"); - } - - //magic = baseInputStream.ReadByte(); - magic = inputBuffer.ReadLeByte(); - - if (magic < 0) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - - if (magic != (GZipConstants.GZIP_MAGIC & 0xFF)) { - throw new GZipException("Error GZIP header, second magic byte doesn't match"); - } - - headCRC.Update(magic); - - // 2. Check the compression type (must be 8) - int compressionType = inputBuffer.ReadLeByte(); - - if ( compressionType < 0 ) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - - if ( compressionType != 8 ) { - throw new GZipException("Error GZIP header, data not in deflate format"); - } - headCRC.Update(compressionType); - - // 3. Check the flags - int flags = inputBuffer.ReadLeByte(); - if (flags < 0) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - headCRC.Update(flags); - - /* This flag byte is divided into individual bits as follows: - - bit 0 FTEXT - bit 1 FHCRC - bit 2 FEXTRA - bit 3 FNAME - bit 4 FCOMMENT - bit 5 reserved - bit 6 reserved - bit 7 reserved - */ - - // 3.1 Check the reserved bits are zero - - if ((flags & 0xE0) != 0) { - throw new GZipException("Reserved flag bits in GZIP header != 0"); - } - - // 4.-6. Skip the modification time, extra flags, and OS type - for (int i=0; i< 6; i++) { - int readByte = inputBuffer.ReadLeByte(); - if (readByte < 0) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - headCRC.Update(readByte); - } - - // 7. Read extra field - if ((flags & GZipConstants.FEXTRA) != 0) { - - // XLEN is total length of extra subfields, we will skip them all - int len1, len2; - len1 = inputBuffer.ReadLeByte(); - len2 = inputBuffer.ReadLeByte(); - if ((len1 < 0) || (len2 < 0)) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - headCRC.Update(len1); - headCRC.Update(len2); - - int extraLen = (len2 << 8) | len1; // gzip is LSB first - for (int i = 0; i < extraLen;i++) { - int readByte = inputBuffer.ReadLeByte(); - if (readByte < 0) - { - throw new EndOfStreamException("EOS reading GZIP header"); - } - headCRC.Update(readByte); - } - } - - // 8. Read file name - if ((flags & GZipConstants.FNAME) != 0) { - int readByte; - while ( (readByte = inputBuffer.ReadLeByte()) > 0) { - headCRC.Update(readByte); - } - - if (readByte < 0) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - headCRC.Update(readByte); - } - - // 9. Read comment - if ((flags & GZipConstants.FCOMMENT) != 0) { - int readByte; - while ( (readByte = inputBuffer.ReadLeByte()) > 0) { - headCRC.Update(readByte); - } - - if (readByte < 0) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - - headCRC.Update(readByte); - } - - // 10. Read header CRC - if ((flags & GZipConstants.FHCRC) != 0) { - int tempByte; - int crcval = inputBuffer.ReadLeByte(); - if (crcval < 0) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - - tempByte = inputBuffer.ReadLeByte(); - if (tempByte < 0) { - throw new EndOfStreamException("EOS reading GZIP header"); - } - - crcval = (crcval << 8) | tempByte; - if (crcval != ((int) headCRC.Value & 0xffff)) { - throw new GZipException("Header CRC value mismatch"); - } - } - - readGZIPHeader = true; - return true; - } - - void ReadFooter() - { - byte[] footer = new byte[8]; - - // End of stream; reclaim all bytes from inf, read the final byte count, and reset the inflator - long bytesRead = inf.TotalOut & 0xffffffff; - inputBuffer.Available += inf.RemainingInput; - inf.Reset(); - - // Read footer from inputBuffer - int needed = 8; - while (needed > 0) { - int count = inputBuffer.ReadClearTextBuffer(footer, 8 - needed, needed); - if (count <= 0) { - throw new EndOfStreamException("EOS reading GZIP footer"); - } - needed -= count; // Jewel Jan 16 - } - - // Calculate CRC - int crcval = (footer[0] & 0xff) | ((footer[1] & 0xff) << 8) | ((footer[2] & 0xff) << 16) | (footer[3] << 24); - if (crcval != (int) crc.Value) { - throw new GZipException("GZIP crc sum mismatch, theirs \"" + crcval + "\" and ours \"" + (int) crc.Value); - } - - // NOTE The total here is the original total modulo 2 ^ 32. - uint total = - (uint)((uint)footer[4] & 0xff) | - (uint)(((uint)footer[5] & 0xff) << 8) | - (uint)(((uint)footer[6] & 0xff) << 16) | - (uint)((uint)footer[7] << 24); - - if (bytesRead != total) { - throw new GZipException("Number of bytes mismatch in footer"); - } - - // Mark header read as false so if another header exists, we'll continue reading through the file - readGZIPHeader = false; + } + #endregion + + #region Stream overrides + /// + /// Reads uncompressed data into an array of bytes + /// + /// + /// The buffer to read uncompressed data into + /// + /// + /// The offset indicating where the data should be placed + /// + /// + /// The number of uncompressed bytes to be read + /// + /// Returns the number of bytes actually read. + public override int Read(byte[] buffer, int offset, int count) + { + // A GZIP file can contain multiple blocks of compressed data, although this is quite rare. + // A compressed block could potentially be empty, so we need to loop until we reach EOF or + // we find data. + while (true) { + + // If we haven't read the header for this block, read it + if (! readGZIPHeader) { + + // Try to read header. If there is no header (0 bytes available), this is EOF. If there is + // an incomplete header, this will throw an exception. + if (! ReadHeader()) { + return 0; + } + } + + // Try to read compressed data + int bytesRead = base.Read(buffer, offset, count); + if (bytesRead > 0) { + crc.Update(buffer, offset, bytesRead); + } + + // If this is the end of stream, read the footer + if (inf.IsFinished) { + ReadFooter(); + } + + if (bytesRead > 0) { + return bytesRead; + } + } + } + #endregion + + #region Support routines + bool ReadHeader() + { + // Initialize CRC for this block + crc = new Crc32(); + + // Make sure there is data in file. We can't rely on ReadLeByte() to fill the buffer, as this could be EOF, + // which is fine, but ReadLeByte() throws an exception if it doesn't find data, so we do this part ourselves. + if (inputBuffer.Available <= 0) { + inputBuffer.Fill(); + if (inputBuffer.Available <= 0) { + // No header, EOF. + return false; + } + } + + // 1. Check the two magic bytes + Crc32 headCRC = new Crc32(); + int magic = inputBuffer.ReadLeByte(); + + if (magic < 0) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + + headCRC.Update(magic); + if (magic != (GZipConstants.GZIP_MAGIC >> 8)) { + throw new GZipException("Error GZIP header, first magic byte doesn't match"); + } + + //magic = baseInputStream.ReadByte(); + magic = inputBuffer.ReadLeByte(); + + if (magic < 0) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + + if (magic != (GZipConstants.GZIP_MAGIC & 0xFF)) { + throw new GZipException("Error GZIP header, second magic byte doesn't match"); + } + + headCRC.Update(magic); + + // 2. Check the compression type (must be 8) + int compressionType = inputBuffer.ReadLeByte(); + + if ( compressionType < 0 ) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + + if ( compressionType != 8 ) { + throw new GZipException("Error GZIP header, data not in deflate format"); + } + headCRC.Update(compressionType); + + // 3. Check the flags + int flags = inputBuffer.ReadLeByte(); + if (flags < 0) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + headCRC.Update(flags); + + /* This flag byte is divided into individual bits as follows: + + bit 0 FTEXT + bit 1 FHCRC + bit 2 FEXTRA + bit 3 FNAME + bit 4 FCOMMENT + bit 5 reserved + bit 6 reserved + bit 7 reserved + */ + + // 3.1 Check the reserved bits are zero + + if ((flags & 0xE0) != 0) { + throw new GZipException("Reserved flag bits in GZIP header != 0"); + } + + // 4.-6. Skip the modification time, extra flags, and OS type + for (int i=0; i< 6; i++) { + int readByte = inputBuffer.ReadLeByte(); + if (readByte < 0) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + headCRC.Update(readByte); + } + + // 7. Read extra field + if ((flags & GZipConstants.FEXTRA) != 0) { + + // XLEN is total length of extra subfields, we will skip them all + int len1, len2; + len1 = inputBuffer.ReadLeByte(); + len2 = inputBuffer.ReadLeByte(); + if ((len1 < 0) || (len2 < 0)) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + headCRC.Update(len1); + headCRC.Update(len2); + + int extraLen = (len2 << 8) | len1; // gzip is LSB first + for (int i = 0; i < extraLen;i++) { + int readByte = inputBuffer.ReadLeByte(); + if (readByte < 0) + { + throw new EndOfStreamException("EOS reading GZIP header"); + } + headCRC.Update(readByte); + } + } + + // 8. Read file name + if ((flags & GZipConstants.FNAME) != 0) { + int readByte; + while ( (readByte = inputBuffer.ReadLeByte()) > 0) { + headCRC.Update(readByte); + } + + if (readByte < 0) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + headCRC.Update(readByte); + } + + // 9. Read comment + if ((flags & GZipConstants.FCOMMENT) != 0) { + int readByte; + while ( (readByte = inputBuffer.ReadLeByte()) > 0) { + headCRC.Update(readByte); + } + + if (readByte < 0) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + + headCRC.Update(readByte); + } + + // 10. Read header CRC + if ((flags & GZipConstants.FHCRC) != 0) { + int tempByte; + int crcval = inputBuffer.ReadLeByte(); + if (crcval < 0) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + + tempByte = inputBuffer.ReadLeByte(); + if (tempByte < 0) { + throw new EndOfStreamException("EOS reading GZIP header"); + } + + crcval = (crcval << 8) | tempByte; + if (crcval != ((int) headCRC.Value & 0xffff)) { + throw new GZipException("Header CRC value mismatch"); + } + } + + readGZIPHeader = true; + return true; + } + + void ReadFooter() + { + byte[] footer = new byte[8]; + + // End of stream; reclaim all bytes from inf, read the final byte count, and reset the inflator + long bytesRead = inf.TotalOut & 0xffffffff; + inputBuffer.Available += inf.RemainingInput; + inf.Reset(); + + // Read footer from inputBuffer + int needed = 8; + while (needed > 0) { + int count = inputBuffer.ReadClearTextBuffer(footer, 8 - needed, needed); + if (count <= 0) { + throw new EndOfStreamException("EOS reading GZIP footer"); + } + needed -= count; // Jewel Jan 16 + } + + // Calculate CRC + int crcval = (footer[0] & 0xff) | ((footer[1] & 0xff) << 8) | ((footer[2] & 0xff) << 16) | (footer[3] << 24); + if (crcval != (int) crc.Value) { + throw new GZipException("GZIP crc sum mismatch, theirs \"" + crcval + "\" and ours \"" + (int) crc.Value); + } + + // NOTE The total here is the original total modulo 2 ^ 32. + uint total = + (uint)((uint)footer[4] & 0xff) | + (uint)(((uint)footer[5] & 0xff) << 8) | + (uint)(((uint)footer[6] & 0xff) << 16) | + (uint)((uint)footer[7] << 24); + + if (bytesRead != total) { + throw new GZipException("Number of bytes mismatch in footer"); + } + + // Mark header read as false so if another header exists, we'll continue reading through the file + readGZIPHeader = false; } /// @@ -432,7 +432,7 @@ namespace ICSharpCode.SharpZipLib.GZip } return _length; } - } - #endregion - } -} + } + #endregion + } +} diff --git a/README.md b/README.md index 0b959ad..af47b4e 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,12 @@ A Windows Disk Imager. A C#.NET utility for reading / writing SD cards and USB d Licensed under GNU General Public License 3.0 or later. Some rights reserved. See LICENSE, AUTHORS. -The current release can be downloaded here - -http://www.dynamicdevices.co.uk/downloads/DiskImager.Installer.msi +The current release can be downloaded [here](https://github.com/RomanBelkov/DiskImager/releases) +or [here (old link)](http://www.dynamicdevices.co.uk/downloads/DiskImager.Installer.msi) (Please feed back any platform testing you do, or any issues you encounter. Thanks.) +## Description ## This utility is a C#.NET implementation of Win32DiskImager with a couple of features authors wanted to use: - writing images to a number of SD cards at once @@ -24,12 +24,13 @@ This utility is a C#.NET implementation of Win32DiskImager with a couple of feat - it also *might* be slightly faster when dealing with uncompressed read/write -*NOTE This application is under development and could possibly cause damage to your computer drive(s). We cannot take responsibility for any damage caused or losses incurred through use of this utility. Use at own risk!* +*NOTE: This application is under development and could possibly cause damage to your computer drive(s). We cannot take responsibility for any damage caused or losses incurred through use of this utility. Use at own risk!* Credits: Inspired by the excellent Win32DiskImager. -ChangeLog -========= +## ChangeLog ## + +1.2.1 14/01/15 RB Added Russian localization and tweaked GUI a bit. 1.2.0 06/01/15 RB Added ability to write the same image to many SD simultaneously. Changed the look of GUI.